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:32 +10:30
parent aa00a2d51b
commit a54f1e2bc5

View File

@ -9,6 +9,7 @@
* file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
@ -26,15 +27,19 @@ return [
})
->delete();
$schema->table('post_likes', function (Blueprint $table) {
$schema->table('post_likes', function (Blueprint $table) use ($schema) {
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
Migration::fixIndexNames($schema, $table);
});
},
'down' => function (Builder $schema) {
$schema->table('post_likes', function (Blueprint $table) {
$schema->table('post_likes', function (Blueprint $table) use ($schema) {
$table->dropForeign(['post_id', 'user_id']);
Migration::fixIndexNames($schema, $table);
});
}
];