Conditions | 2 |
Paths | 8 |
Total Lines | 75 |
Code Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
12 | public function up(): void |
||
13 | { |
||
14 | try { |
||
15 | Schema::create($this->prefix . 'shipping_query', function (Blueprint $table) { |
||
16 | $table->bigInteger('id')->unsigned()->primary()->comment('Unique query identifier'); |
||
17 | $table->bigInteger('user_id')->index('user_id')->comment('User who sent the query'); |
||
18 | $table->char('invoice_payload', 255)->default('')->comment('Bot specified invoice payload'); |
||
19 | $table->char('shipping_address', 255)->default('')->comment('User specified shipping address'); |
||
20 | $table->timestamp('created_at')->nullable()->comment('Entry date creation'); |
||
21 | $table->foreign('user_id', 'shipping_query_ibfk_1')->references('id')->on($this->prefix . 'user')->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
22 | }); |
||
23 | |||
24 | Schema::create($this->prefix . 'pre_checkout_query', function (Blueprint $table) { |
||
25 | $table->bigInteger('id')->unsigned()->primary()->comment('Unique query identifier'); |
||
26 | $table->bigInteger('user_id')->index('user_id')->comment('User who sent the query'); |
||
27 | $table->char('currency', 3)->comment('Three-letter ISO 4217 currency code'); |
||
28 | $table->bigInteger('total_amount')->comment('Total price in the smallest units of the currency'); |
||
29 | $table->char('invoice_payload', 255)->default('')->comment('Bot specified invoice payload'); |
||
30 | $table->char('shipping_option_id', 255)->nullable()->comment('Identifier of the shipping option chosen by the user'); |
||
31 | $table->text('order_info')->nullable()->comment('Order info provided by the user'); |
||
32 | $table->timestamp('created_at')->nullable()->comment('Entry date creation'); |
||
33 | $table->foreign('user_id', 'pre_checkout_query_ibfk_1')->references('id')->on($this->prefix . 'user')->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
34 | }); |
||
35 | |||
36 | Schema::create($this->prefix . 'poll', static function (Blueprint $table) { |
||
37 | $table->bigInteger('id')->unsigned()->primary()->comment('Unique poll identifier'); |
||
38 | $table->char('question', 255)->comment('Poll question'); |
||
39 | $table->text('options')->comment('List of poll options'); |
||
40 | $table->boolean('is_closed')->default(0)->comment('True, if the poll is closed'); |
||
41 | $table->timestamp('created_at')->nullable()->comment('Entry date creation'); |
||
42 | }); |
||
43 | |||
44 | Schema::table($this->prefix . 'callback_query', static function (Blueprint $table) { |
||
45 | $table->char('chat_instance', 255)->default('')->comment('Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent')->after('inline_message_id'); |
||
46 | $table->char('game_short_name', 255)->default('')->comment('Short name of a Game to be returned, serves as the unique identifier for the game')->after('data'); |
||
47 | }); |
||
48 | |||
49 | Schema::table($this->prefix . 'chat', static function (Blueprint $table) { |
||
50 | $table->char('first_name', 255)->nullable()->comment('First name of the other party in a private chat')->after('username'); |
||
51 | $table->char('last_name', 255)->nullable()->comment('Last name of the other party in a private chat')->after('first_name'); |
||
52 | }); |
||
53 | |||
54 | Schema::table($this->prefix . 'message', static function (Blueprint $table) { |
||
55 | $table->text('forward_signature')->nullable()->default(null)->comment('For messages forwarded from channels, signature of the post author if present')->after('forward_from_message_id'); |
||
56 | $table->text('forward_sender_name')->nullable()->default(null)->comment('Sender\'s name for messages forwarded from users who disallow adding a link to their account in forwarded messages')->after('forward_signature'); |
||
57 | $table->unsignedBigInteger('edit_date')->nullable()->comment('Date the message was last edited in Unix time')->after('reply_to_message'); |
||
58 | $table->text('author_signature')->nullable()->comment('Signature of the post author for messages in channels')->after('media_group_id'); |
||
59 | $table->text('caption_entities')->nullable()->comment('For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption')->after('entities'); |
||
60 | $table->text('poll')->nullable()->comment('Poll object. Message is a native poll, information about the poll')->after('venue'); |
||
61 | $table->text('invoice')->nullable()->comment('Message is an invoice for a payment, information about the invoice')->after('pinned_message'); |
||
62 | $table->text('successful_payment')->nullable()->comment('Message is a service message about a successful payment, information about the payment')->after('invoice'); |
||
63 | }); |
||
64 | |||
65 | Schema::table($this->prefix . 'telegram_update', function (Blueprint $table) { |
||
66 | $table->bigInteger('channel_post_id')->unsigned()->nullable()->comment('New incoming channel post of any kind - text, photo, sticker, etc.'); |
||
67 | $table->bigInteger('edited_channel_post_id')->unsigned()->nullable()->comment('New version of a channel post that is known to the bot and was edited'); |
||
68 | $table->bigInteger('shipping_query_id')->unsigned()->nullable()->comment('New incoming shipping query. Only for invoices with flexible price'); |
||
69 | $table->bigInteger('pre_checkout_query_id')->unsigned()->nullable()->comment('New incoming pre-checkout query. Contains full information about checkout'); |
||
70 | $table->bigInteger('poll_id')->unsigned()->nullable()->comment('New poll state. Bots receive only updates about polls, which are sent or stopped by the bot'); |
||
71 | |||
72 | $table->index('channel_post_id', 'channel_post_id'); |
||
73 | $table->index('edited_channel_post_id', 'edited_channel_post_id'); |
||
74 | $table->index('shipping_query_id', 'shipping_query_id'); |
||
75 | $table->index('pre_checkout_query_id', 'pre_checkout_query_id'); |
||
76 | $table->index('poll_id', 'poll_id'); |
||
77 | |||
78 | $table->foreign(['chat_id', 'channel_post_id'], 'telegram_update_ibfk_6')->references(['chat_id', 'id'])->on($this->prefix . 'message'); |
||
79 | $table->foreign('edited_channel_post_id', 'telegram_update_ibfk_7')->references('id')->on($this->prefix . 'edited_message'); |
||
80 | $table->foreign('shipping_query_id', 'telegram_update_ibfk_8')->references('id')->on($this->prefix . 'shipping_query'); |
||
81 | $table->foreign('pre_checkout_query_id', 'telegram_update_ibfk_9')->references('id')->on($this->prefix . 'pre_checkout_query'); |
||
82 | $table->foreign('poll_id', 'telegram_update_ibfk_10')->references('id')->on($this->prefix . 'poll'); |
||
83 | }); |
||
84 | } catch (Throwable $e) { |
||
85 | Log::error($e->getMessage()); |
||
86 | return; // Migration may be partly done already... |
||
87 | } |
||
143 |