| @@ 11-26 (lines=16) @@ | ||
| 8 | ||
| 9 | class UpdateSchema0600To0610 extends Migration |
|
| 10 | { |
|
| 11 | public function up(): void |
|
| 12 | { |
|
| 13 | Schema::disableForeignKeyConstraints(); |
|
| 14 | ||
| 15 | try { |
|
| 16 | Schema::table('telegram_update', static function (Blueprint $table) { |
|
| 17 | $table->dropIndex('message_id'); |
|
| 18 | $table->index('message_id', 'message_id'); |
|
| 19 | $table->index(['chat_id', 'message_id'], 'chat_message_id'); |
|
| 20 | }); |
|
| 21 | } catch (Exception $e) { |
|
| 22 | // Migration may be partly done already... |
|
| 23 | } |
|
| 24 | ||
| 25 | Schema::enableForeignKeyConstraints(); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function down(): void |
|
| 29 | { |
|
| @@ 28-43 (lines=16) @@ | ||
| 25 | Schema::enableForeignKeyConstraints(); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function down(): void |
|
| 29 | { |
|
| 30 | Schema::disableForeignKeyConstraints(); |
|
| 31 | ||
| 32 | try { |
|
| 33 | Schema::table('telegram_update', static function (Blueprint $table) { |
|
| 34 | $table->dropIndex('chat_message_id'); |
|
| 35 | $table->dropIndex('message_id'); |
|
| 36 | $table->index('message_id', 'message_id'); |
|
| 37 | }); |
|
| 38 | } catch (Exception $e) { |
|
| 39 | // Migration may be partly done already... |
|
| 40 | } |
|
| 41 | ||
| 42 | Schema::enableForeignKeyConstraints(); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||