add unique constraints

This commit is contained in:
shibafu 2020-02-22 16:46:15 +09:00
parent 77d3ebd452
commit 631ae820f3

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUniqueConstraintToTagRelations extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ejaculation_tag', function (Blueprint $table) {
$table->unique(['ejaculation_id', 'tag_id']);
});
Schema::table('metadata_tag', function (Blueprint $table) {
$table->unique(['metadata_url', 'tag_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('ejaculation_tag', function (Blueprint $table) {
$table->dropUnique(['ejaculation_id', 'tag_id']);
});
Schema::table('metadata_tag', function (Blueprint $table) {
$table->dropUnique(['metadata_url', 'tag_id']);
});
}
}