From 147fc1a65ea54dfe43c724e8e84135365bceecf4 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 27 Nov 2018 22:33:45 +1030 Subject: [PATCH] Fix index names in migrations This can be reverted when we upgrade to Laravel 5.7. --- ...102300_change_post_mentions_post_add_foreign_keys.php | 9 +++++++-- ...102500_change_post_mentions_user_add_foreign_keys.php | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/extensions/mentions/migrations/2018_06_27_102300_change_post_mentions_post_add_foreign_keys.php b/extensions/mentions/migrations/2018_06_27_102300_change_post_mentions_post_add_foreign_keys.php index 1482d1501..09d729079 100644 --- a/extensions/mentions/migrations/2018_06_27_102300_change_post_mentions_post_add_foreign_keys.php +++ b/extensions/mentions/migrations/2018_06_27_102300_change_post_mentions_post_add_foreign_keys.php @@ -9,6 +9,7 @@ * file that was distributed with this source code. */ +use Flarum\Database\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Builder; @@ -26,15 +27,19 @@ return [ }) ->delete(); - $schema->table('post_mentions_post', function (Blueprint $table) { + $schema->table('post_mentions_post', function (Blueprint $table) use ($schema) { $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade'); $table->foreign('mentions_post_id')->references('id')->on('posts')->onDelete('cascade'); + + Migration::fixIndexNames($schema, $table); }); }, 'down' => function (Builder $schema) { - $schema->table('posts_mentions_posts', function (Blueprint $table) { + $schema->table('posts_mentions_posts', function (Blueprint $table) use ($schema) { $table->dropForeign(['post_id', 'mentions_post_id']); + + Migration::fixIndexNames($schema, $table); }); } ]; diff --git a/extensions/mentions/migrations/2018_06_27_102500_change_post_mentions_user_add_foreign_keys.php b/extensions/mentions/migrations/2018_06_27_102500_change_post_mentions_user_add_foreign_keys.php index 76b584c33..0f0491867 100644 --- a/extensions/mentions/migrations/2018_06_27_102500_change_post_mentions_user_add_foreign_keys.php +++ b/extensions/mentions/migrations/2018_06_27_102500_change_post_mentions_user_add_foreign_keys.php @@ -9,6 +9,7 @@ * file that was distributed with this source code. */ +use Flarum\Database\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Builder; @@ -26,15 +27,19 @@ return [ }) ->delete(); - $schema->table('post_mentions_user', function (Blueprint $table) { + $schema->table('post_mentions_user', function (Blueprint $table) use ($schema) { $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade'); $table->foreign('mentions_user_id')->references('id')->on('users')->onDelete('cascade'); + + Migration::fixIndexNames($schema, $table); }); }, 'down' => function (Builder $schema) { - $schema->table('post_mentions_user', function (Blueprint $table) { + $schema->table('post_mentions_user', function (Blueprint $table) use ($schema) { $table->dropForeign(['post_id', 'mentions_user_id']); + + Migration::fixIndexNames($schema, $table); }); } ];