diff options
Diffstat (limited to 'database/migrations/99999_pivots.php')
| -rw-r--r-- | database/migrations/99999_pivots.php | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/database/migrations/99999_pivots.php b/database/migrations/99999_pivots.php index edd497f..e0649ff 100644 --- a/database/migrations/99999_pivots.php +++ b/database/migrations/99999_pivots.php @@ -12,42 +12,46 @@ return new class extends Migration */ public function up(): void { - Schema::create('link_tag', function (Blueprint $table) { - $table->integer('link_id')->unsigned()->index(); - $table->foreign('link_id')->references('id')->on('links')->onDelete('cascade'); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); - }); - Schema::create('file_tag', function (Blueprint $table) { - $table->integer('file_id')->unsigned()->index(); - $table->foreign('file_id')->references('id')->on('files')->onDelete('cascade'); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); - }); - Schema::create('quest_tag', function (Blueprint $table) { - $table->integer('quest_id')->unsigned()->index(); - $table->foreign('quest_id')->references('id')->on('quests')->onDelete('cascade'); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); - }); - Schema::create('tag_writing', function (Blueprint $table){ - $table->integer('writing_id')->unsigned()->index(); - $table->foreign('writing_id')->references('id')->on('writings')->onDelete('cascade'); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); - }); - Schema::create('role_user', function (Blueprint $table) { - $table->integer('user_id')->unsigned()->index(); - $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); - $table->integer('role_id')->unsigned()->index(); - $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); - }); - Schema::create('tag_quote', function (Blueprint $table) { - $table->integer('quote_id')->unsigned()->index(); - $table->foreign('quote_id')->references('id')->on('quotes')->onDelete('cascade'); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); - }); + if (!Schema::hasTable('link_tag')) { + Schema::create('link_tag', function (Blueprint $table) { + $table->unsignedBigInteger('link_id')->index(); + $table->foreign('link_id')->references('id')->on('links')->onDelete('cascade'); + $table->unsignedBigInteger('tag_id')->index(); + $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); + }); + } + if (!Schema::hasTable('file_tag')) { + Schema::create('file_tag', function (Blueprint $table) { + $table->unsignedBigInteger('file_id')->index(); + $table->foreign('file_id')->references('id')->on('files')->onDelete('cascade'); + $table->unsignedBigInteger('tag_id')->index(); + $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); + }); + } + if (!Schema::hasTable('tag_writing')) { + Schema::create('tag_writing', function (Blueprint $table) { + $table->unsignedBigInteger('writing_id')->index(); + $table->foreign('writing_id')->references('id')->on('writings')->onDelete('cascade'); + $table->unsignedBigInteger('tag_id')->index(); + $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); + }); + } + if (!Schema::hasTable('role_user')) { + Schema::create('role_user', function (Blueprint $table) { + $table->unsignedBigInteger('user_id')->index(); + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $table->unsignedBigInteger('role_id')->index(); + $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); + }); + } + if (!Schema::hasTable('tag_quote')) { + Schema::create('tag_quote', function (Blueprint $table) { + $table->unsignedBigInteger('quote_id')->index(); + $table->foreign('quote_id')->references('id')->on('quotes')->onDelete('cascade'); + $table->unsignedBigInteger('tag_id')->index(); + $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); + }); + } } /** @@ -57,9 +61,8 @@ return new class extends Migration { Schema::dropIfExists('link_tag'); Schema::dropIfExists('file_tag'); - Schema::dropIfExists('quest_tag'); Schema::dropIfExists('tag_writing'); + Schema::dropIfExists('role_user'); Schema::dropIfExists('tag_quote'); - //Schema::dropIfExists('role_user'); } }; |
