82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
||
|
return new class extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*/
|
||
|
public function up(): void
|
||
|
{
|
||
|
Schema::create('taglines', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
$table->timestamp('created_at');
|
||
|
$table->softDeletes();
|
||
|
$table->string('value')->unique();
|
||
|
});
|
||
|
|
||
|
Schema::create('tearlines', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
$table->timestamp('created_at');
|
||
|
$table->softDeletes();
|
||
|
$table->string('value')->unique();
|
||
|
});
|
||
|
|
||
|
Schema::create('origins', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
$table->timestamp('created_at');
|
||
|
$table->softDeletes();
|
||
|
$table->string('value')->unique();
|
||
|
});
|
||
|
|
||
|
Schema::table('echomails', function (Blueprint $table) {
|
||
|
$table->bigInteger('tagline_id')->nullable();
|
||
|
$table->foreign('tagline_id')->references('id')->on('taglines');
|
||
|
|
||
|
$table->bigInteger('tearline_id')->nullable();
|
||
|
$table->foreign('tearline_id')->references('id')->on('tearlines');
|
||
|
|
||
|
$table->bigInteger('origin_id')->nullable();
|
||
|
$table->foreign('origin_id')->references('id')->on('origins');
|
||
|
});
|
||
|
|
||
|
Schema::table('netmails', function (Blueprint $table) {
|
||
|
$table->bigInteger('tagline_id')->nullable();
|
||
|
$table->foreign('tagline_id')->references('id')->on('taglines');
|
||
|
|
||
|
$table->bigInteger('tearline_id')->nullable();
|
||
|
$table->foreign('tearline_id')->references('id')->on('tearlines');
|
||
|
|
||
|
$table->bigInteger('origin_id')->nullable();
|
||
|
$table->foreign('origin_id')->references('id')->on('origins');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*/
|
||
|
public function down(): void
|
||
|
{
|
||
|
Schema::table('netmails', function (Blueprint $table) {
|
||
|
$table->dropForeign(['tagline_id']);
|
||
|
$table->dropForeign(['tearline_id']);
|
||
|
$table->dropForeign(['origin_id']);
|
||
|
$table->dropColumn(['tagline_id','tearline_id','origin_id']);
|
||
|
});
|
||
|
|
||
|
Schema::table('echomails', function (Blueprint $table) {
|
||
|
$table->dropForeign(['tagline_id']);
|
||
|
$table->dropForeign(['tearline_id']);
|
||
|
$table->dropForeign(['origin_id']);
|
||
|
$table->dropColumn(['tagline_id','tearline_id','origin_id']);
|
||
|
});
|
||
|
|
||
|
Schema::dropIfExists('origins');
|
||
|
Schema::dropIfExists('tearlines');
|
||
|
Schema::dropIfExists('taglines');
|
||
|
}
|
||
|
};
|