1
0
mirror of https://github.com/flarum/core.git synced 2025-08-18 14:22:02 +02:00

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.
This commit is contained in:
Franz Liedke
2018-11-30 14:05:04 +01:00
parent d08bb264b4
commit e2004c2dcb
3 changed files with 7 additions and 3 deletions

View File

@@ -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);
});

View File

@@ -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);
});

View File

@@ -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);
});