revert the fix index names logic, preparing for illuminate 5.7

This commit is contained in:
Daniël Klabbers 2019-01-15 21:00:38 +01:00
parent d4783f4ac5
commit c18731953d
4 changed files with 8 additions and 28 deletions

View File

@ -9,26 +9,21 @@
* file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$schema->table('tags', function (Blueprint $table) use ($schema) {
$schema->table('tags', function (Blueprint $table) {
$table->string('slug', 100)->change();
$table->unique('slug');
Migration::fixIndexNames($schema, $table);
});
},
'down' => function (Builder $schema) {
$schema->table('tags', function (Blueprint $table) use ($schema) {
$schema->table('tags', function (Blueprint $table) {
$table->string('slug', 255)->change();
$table->dropUnique(['slug']);
Migration::fixIndexNames($schema, $table);
});
}
];

View File

@ -9,7 +9,6 @@
* file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
@ -31,22 +30,18 @@ return [
'last_posted_discussion_id' => $select('id', 'discussions', 'last_posted_discussion_id'),
]);
$schema->table('tags', function (Blueprint $table) use ($schema) {
$schema->table('tags', function (Blueprint $table) {
$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_discussion_id')->references('id')->on('discussions')->onDelete('set null');
Migration::fixIndexNames($schema, $table);
});
},
'down' => function (Builder $schema) {
$schema->table('tags', function (Blueprint $table) use ($schema) {
$schema->table('tags', function (Blueprint $table) {
$table->dropForeign(['parent_id']);
$table->dropForeign(['last_posted_discussion_id']);
$table->dropForeign(['last_posted_user_id']);
Migration::fixIndexNames($schema, $table);
});
}
];

View File

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

View File

@ -9,7 +9,6 @@
* file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
@ -27,20 +26,16 @@ return [
})
->delete();
$schema->table('discussion_tag', function (Blueprint $table) use ($schema) {
$schema->table('discussion_tag', function (Blueprint $table) {
$table->foreign('discussion_id')->references('id')->on('discussions')->onDelete('cascade');
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
Migration::fixIndexNames($schema, $table);
});
},
'down' => function (Builder $schema) {
$schema->table('discussion_tag', function (Blueprint $table) use ($schema) {
$schema->table('discussion_tag', function (Blueprint $table) {
$table->dropForeign(['discussion_id']);
$table->dropForeign(['tag_id']);
Migration::fixIndexNames($schema, $table);
});
}
];