mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 13:05:50 +08:00
Fix index names in migrations
This can be reverted when we upgrade to Laravel 5.7.
This commit is contained in:
parent
4483b7fee7
commit
d08bb264b4
|
@ -9,21 +9,26 @@
|
||||||
* 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('tags', function (Blueprint $table) {
|
$schema->table('tags', function (Blueprint $table) use ($schema) {
|
||||||
$table->string('slug', 100)->change();
|
$table->string('slug', 100)->change();
|
||||||
$table->unique('slug');
|
$table->unique('slug');
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('tags', function (Blueprint $table) {
|
$schema->table('tags', function (Blueprint $table) use ($schema) {
|
||||||
$table->string('slug', 255)->change();
|
$table->string('slug', 255)->change();
|
||||||
$table->dropUnique('tags_slug_unique');
|
$table->dropUnique(['slug']);
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -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\Query\Expression;
|
use Illuminate\Database\Query\Expression;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Schema\Builder;
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
@ -30,16 +31,20 @@ return [
|
||||||
'last_posted_discussion_id' => $select('id', 'discussions', 'last_posted_discussion_id'),
|
'last_posted_discussion_id' => $select('id', 'discussions', 'last_posted_discussion_id'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema->table('tags', function (Blueprint $table) {
|
$schema->table('tags', function (Blueprint $table) use ($schema) {
|
||||||
$table->foreign('parent_id')->references('id')->on('tags')->onDelete('set null');
|
$table->foreign('parent_id')->references('id')->on('tags')->onDelete('set null');
|
||||||
$table->foreign('last_posted_user_id')->references('id')->on('users')->onDelete('set null');
|
$table->foreign('last_posted_user_id')->references('id')->on('users')->onDelete('set null');
|
||||||
$table->foreign('last_posted_discussion_id')->references('id')->on('discussions')->onDelete('set null');
|
$table->foreign('last_posted_discussion_id')->references('id')->on('discussions')->onDelete('set null');
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('tags', function (Blueprint $table) {
|
$schema->table('tags', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign(['parent_id', 'last_posted_discussion_id', 'last_posted_user_id']);
|
$table->dropForeign(['parent_id', 'last_posted_discussion_id', 'last_posted_user_id']);
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -26,15 +27,19 @@ return [
|
||||||
})
|
})
|
||||||
->delete();
|
->delete();
|
||||||
|
|
||||||
$schema->table('tag_user', function (Blueprint $table) {
|
$schema->table('tag_user', function (Blueprint $table) use ($schema) {
|
||||||
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
|
$table->foreign('tag_id')->references('id')->on('tags')->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('tag_user', function (Blueprint $table) {
|
$schema->table('tag_user', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign(['tag_id', 'user_id']);
|
$table->dropForeign(['tag_id', 'user_id']);
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -26,15 +27,19 @@ return [
|
||||||
})
|
})
|
||||||
->delete();
|
->delete();
|
||||||
|
|
||||||
$schema->table('discussion_tag', function (Blueprint $table) {
|
$schema->table('discussion_tag', function (Blueprint $table) use ($schema) {
|
||||||
$table->foreign('discussion_id')->references('id')->on('discussions')->onDelete('cascade');
|
$table->foreign('discussion_id')->references('id')->on('discussions')->onDelete('cascade');
|
||||||
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
|
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'down' => function (Builder $schema) {
|
'down' => function (Builder $schema) {
|
||||||
$schema->table('discussion_tag', function (Blueprint $table) {
|
$schema->table('discussion_tag', function (Blueprint $table) use ($schema) {
|
||||||
$table->dropForeign(['discussion_id', 'tag_id']);
|
$table->dropForeign(['discussion_id', 'tag_id']);
|
||||||
|
|
||||||
|
Migration::fixIndexNames($schema, $table);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user