From e2004c2dcb152bd92f723dd259b5364c13c084f3 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 30 Nov 2018 14:05:04 +0100 Subject: [PATCH] Migrations: Fix dropping foreign keys Passing an array to dropForeign does not mean dropping multiple indices, but rather dropping a key on multiple tables. Passing a string means that this string will be interpreted as index name, not as name of the indexed column. Passing an array with one string is therefore correct, in order to benefit from automatic index name generation. --- .../2018_06_27_085300_change_tags_add_foreign_keys.php | 4 +++- .../2018_06_27_100200_change_tag_user_add_foreign_keys.php | 3 ++- .../2018_06_27_103100_add_discussion_tag_foreign_keys.php | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions/tags/migrations/2018_06_27_085300_change_tags_add_foreign_keys.php b/extensions/tags/migrations/2018_06_27_085300_change_tags_add_foreign_keys.php index c79429045..75a4ba28f 100644 --- a/extensions/tags/migrations/2018_06_27_085300_change_tags_add_foreign_keys.php +++ b/extensions/tags/migrations/2018_06_27_085300_change_tags_add_foreign_keys.php @@ -42,7 +42,9 @@ return [ 'down' => function (Builder $schema) { $schema->table('tags', function (Blueprint $table) use ($schema) { - $table->dropForeign(['parent_id', 'last_posted_discussion_id', 'last_posted_user_id']); + $table->dropForeign(['parent_id']); + $table->dropForeign(['last_posted_discussion_id']); + $table->dropForeign(['last_posted_user_id']); Migration::fixIndexNames($schema, $table); }); diff --git a/extensions/tags/migrations/2018_06_27_100200_change_tag_user_add_foreign_keys.php b/extensions/tags/migrations/2018_06_27_100200_change_tag_user_add_foreign_keys.php index ce2d3b225..fd0275fb8 100644 --- a/extensions/tags/migrations/2018_06_27_100200_change_tag_user_add_foreign_keys.php +++ b/extensions/tags/migrations/2018_06_27_100200_change_tag_user_add_foreign_keys.php @@ -37,7 +37,8 @@ return [ 'down' => function (Builder $schema) { $schema->table('tag_user', function (Blueprint $table) use ($schema) { - $table->dropForeign(['tag_id', 'user_id']); + $table->dropForeign(['tag_id']); + $table->dropForeign(['user_id']); Migration::fixIndexNames($schema, $table); }); diff --git a/extensions/tags/migrations/2018_06_27_103100_add_discussion_tag_foreign_keys.php b/extensions/tags/migrations/2018_06_27_103100_add_discussion_tag_foreign_keys.php index 58687c5e7..fdd727a01 100644 --- a/extensions/tags/migrations/2018_06_27_103100_add_discussion_tag_foreign_keys.php +++ b/extensions/tags/migrations/2018_06_27_103100_add_discussion_tag_foreign_keys.php @@ -37,7 +37,8 @@ return [ 'down' => function (Builder $schema) { $schema->table('discussion_tag', function (Blueprint $table) use ($schema) { - $table->dropForeign(['discussion_id', 'tag_id']); + $table->dropForeign(['discussion_id']); + $table->dropForeign(['tag_id']); Migration::fixIndexNames($schema, $table); });