mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 08:04:19 +02:00
39 lines
1.2 KiB
PHP
39 lines
1.2 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('tags', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('uuid')->unique();
|
|
$table->string('name')->unique();
|
|
$table->foreignId('team_id')->nullable()->constrained()->onDelete('cascade');
|
|
$table->timestamps();
|
|
});
|
|
Schema::create('taggables', function (Blueprint $table) {
|
|
$table->unsignedBigInteger('tag_id');
|
|
$table->unsignedBigInteger('taggable_id');
|
|
$table->string('taggable_type');
|
|
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
|
|
$table->unique(['tag_id', 'taggable_id', 'taggable_type'], 'taggable_unique'); // Composite unique index
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('taggables');
|
|
Schema::dropIfExists('tags');
|
|
}
|
|
};
|