mirror of
https://github.com/flarum/framework.git
synced 2025-04-16 16:18:46 +08:00
Fix index names in migrations
This can be reverted when we upgrade to Laravel 5.7.
This commit is contained in:
parent
60e80d45ca
commit
2722a0f2c5
extensions/flags/migrations
@ -9,6 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Flarum\Database\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Schema\Builder;
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
|
||||||
@ -30,15 +31,19 @@ return [
|
|||||||
})
|
})
|
||||||
->update(['user_id' => null]);
|
->update(['user_id' => null]);
|
||||||
|
|
||||||
$schema->table('flags', function (Blueprint $table) {
|
$schema->table('flags', function (Blueprint $table) use ($schema) {
|
||||||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
|
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
|
||||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('flags', function (Blueprint $table) {
|
$schema->table('flags', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign(['post_id', 'user_id']);
|
$table->dropForeign(['post_id', 'user_id']);
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -9,19 +9,24 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Flarum\Database\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Schema\Builder;
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'up' => function (Builder $schema) {
|
'up' => function (Builder $schema) {
|
||||||
$schema->table('flags', function (Blueprint $table) {
|
$schema->table('flags', function (Blueprint $table) use ($schema) {
|
||||||
$table->index('created_at');
|
$table->index('created_at');
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('flags', function (Blueprint $table) {
|
$schema->table('flags', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropIndex(['created_at']);
|
$table->dropIndex(['created_at']);
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user