clrghouz/database/migrations/2024_06_03_072631_msg_attributes.php
Deon George 8fb3a21fcd
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 39s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m51s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Normalise tagline/tearline/origin
2024-06-03 19:09:09 +10:00

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');
}
};