<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('server_groups', function (Blueprint $table) {
            $table->id();
            $table->uuid('uuid')->unique();
            $table->string('name')->unique();
            $table->string('color')->default('accent'); // a @theme token key (validated in the model)
            $table->timestamps();
        });

        Schema::create('server_server_group', function (Blueprint $table) {
            $table->foreignId('server_id')->constrained()->cascadeOnDelete();
            $table->foreignId('server_group_id')->constrained()->cascadeOnDelete();
            $table->primary(['server_id', 'server_group_id']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('server_server_group');
        Schema::dropIfExists('server_groups');
    }
};
