<?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('bio_pages', function (Blueprint $table) {
            $table->id();
            $table->string('ulid', 26)->unique();
            $table->foreignId('workspace_id')->constrained()->cascadeOnDelete();
            $table->foreignId('domain_id')->nullable()->constrained()->nullOnDelete();
            $table->string('slug', 64);
            $table->json('title');
            $table->json('description')->nullable();
            $table->string('og_image')->nullable();
            $table->json('theme')->nullable();
            $table->boolean('is_published')->default(false);
            $table->softDeletes();
            $table->timestamps();
            $table->unique(['workspace_id', 'domain_id', 'slug'], 'bio_pages_workspace_domain_slug_unique');
            $table->index('workspace_id');
        });
    }

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