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

Fix index names in migrations

This can be reverted when we upgrade to Laravel 5.7.
This commit is contained in:
Toby Zerner
2018-11-27 22:33:21 +10:30
parent 60e80d45ca
commit 2722a0f2c5
2 changed files with 14 additions and 4 deletions

View File

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

View File

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