|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
6
|
|
|
use Illuminate\Support\Facades\Log; |
|
7
|
|
|
use Illuminate\Support\Facades\Schema; |
|
8
|
|
|
use PhpTelegramBot\Laravel\Migration; |
|
9
|
|
|
|
|
10
|
|
|
class UpdateSchema0560To0570 extends Migration |
|
11
|
|
|
{ |
|
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
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function down(): void |
|
91
|
|
|
{ |
|
92
|
|
|
try { |
|
93
|
|
|
Schema::table($this->prefix . 'telegram_update', static function (Blueprint $table) { |
|
94
|
|
|
$table->dropForeign('telegram_update_ibfk_10'); |
|
95
|
|
|
$table->dropForeign('telegram_update_ibfk_9'); |
|
96
|
|
|
$table->dropForeign('telegram_update_ibfk_8'); |
|
97
|
|
|
$table->dropForeign('telegram_update_ibfk_7'); |
|
98
|
|
|
$table->dropForeign('telegram_update_ibfk_6'); |
|
99
|
|
|
|
|
100
|
|
|
$table->dropIndex('poll_id'); |
|
101
|
|
|
$table->dropIndex('pre_checkout_query_id'); |
|
102
|
|
|
$table->dropIndex('shipping_query_id'); |
|
103
|
|
|
$table->dropIndex('edited_channel_post_id'); |
|
104
|
|
|
$table->dropIndex('channel_post_id'); |
|
105
|
|
|
|
|
106
|
|
|
$table->dropColumn('poll_id'); |
|
107
|
|
|
$table->dropColumn('pre_checkout_query_id'); |
|
108
|
|
|
$table->dropColumn('shipping_query_id'); |
|
109
|
|
|
$table->dropColumn('edited_channel_post_id'); |
|
110
|
|
|
$table->dropColumn('channel_post_id'); |
|
111
|
|
|
}); |
|
112
|
|
|
|
|
113
|
|
|
Schema::table($this->prefix . 'message', static function (Blueprint $table) { |
|
114
|
|
|
$table->dropColumn('successful_payment'); |
|
115
|
|
|
$table->dropColumn('invoice'); |
|
116
|
|
|
$table->dropColumn('poll'); |
|
117
|
|
|
$table->dropColumn('caption_entities'); |
|
118
|
|
|
$table->dropColumn('author_signature'); |
|
119
|
|
|
$table->dropColumn('edit_date'); |
|
120
|
|
|
$table->dropColumn('forward_sender_name'); |
|
121
|
|
|
$table->dropColumn('forward_signature'); |
|
122
|
|
|
}); |
|
123
|
|
|
|
|
124
|
|
|
Schema::table($this->prefix . 'chat', static function (Blueprint $table) { |
|
125
|
|
|
$table->dropColumn('last_name'); |
|
126
|
|
|
$table->dropColumn('first_name'); |
|
127
|
|
|
}); |
|
128
|
|
|
|
|
129
|
|
|
Schema::table($this->prefix . 'callback_query', static function (Blueprint $table) { |
|
130
|
|
|
$table->dropColumn('game_short_name'); |
|
131
|
|
|
$table->dropColumn('chat_instance'); |
|
132
|
|
|
}); |
|
133
|
|
|
|
|
134
|
|
|
Schema::dropIfExists($this->prefix . 'poll'); |
|
135
|
|
|
Schema::dropIfExists($this->prefix . 'pre_checkout_query'); |
|
136
|
|
|
Schema::dropIfExists($this->prefix . 'shipping_query'); |
|
137
|
|
|
} catch (Throwable $e) { |
|
138
|
|
|
Log::error($e->getMessage()); |
|
139
|
|
|
return; // Migration may be partly done already... |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|