mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 23:23:52 +08: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:
parent
d6632c061d
commit
c23b7f33eb
|
@ -47,10 +47,11 @@ return [
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('discussions', function (Blueprint $table) use ($schema) {
|
$schema->table('discussions', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign([
|
$table->dropForeign(['user_id']);
|
||||||
'user_id', 'last_posted_user_id', 'hidden_user_id',
|
$table->dropForeign(['last_posted_user_id']);
|
||||||
'first_post_id', 'last_post_id'
|
$table->dropForeign(['hidden_user_id']);
|
||||||
]);
|
$table->dropForeign(['first_post_id']);
|
||||||
|
$table->dropForeign(['last_post_id']);
|
||||||
|
|
||||||
Migration::fixIndexNames($schema, $table);
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,7 +37,8 @@ return [
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('discussion_user', function (Blueprint $table) use ($schema) {
|
$schema->table('discussion_user', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign(['user_id', 'discussion_id']);
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropForeign(['discussion_id']);
|
||||||
|
|
||||||
Migration::fixIndexNames($schema, $table);
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,7 +37,8 @@ return [
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('group_user', function (Blueprint $table) use ($schema) {
|
$schema->table('group_user', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign(['user_id', 'group_id']);
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropForeign(['group_id']);
|
||||||
|
|
||||||
Migration::fixIndexNames($schema, $table);
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,7 +41,8 @@ return [
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('notifications', function (Blueprint $table) use ($schema) {
|
$schema->table('notifications', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign(['user_id', 'from_user_id']);
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropForeign(['from_user_id']);
|
||||||
|
|
||||||
Migration::fixIndexNames($schema, $table);
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,10 +43,10 @@ return [
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('posts', function (Blueprint $table) use ($schema) {
|
$schema->table('posts', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign([
|
$table->dropForeign(['user_id']);
|
||||||
'user_id', 'discussion_id',
|
$table->dropForeign(['discussion_id']);
|
||||||
'edited_user_id', 'hidden_user_id'
|
$table->dropForeign(['edited_user_id']);
|
||||||
]);
|
$table->dropForeign(['hidden_user_id']);
|
||||||
|
|
||||||
Migration::fixIndexNames($schema, $table);
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user