<?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::table('bio_pages', function (Blueprint $table) {
            // Slug must be unique within a workspace regardless of subdomain_host.
            // The old (subdomain_host, slug) unique allowed MySQL NULL bypass —
            // two rows with NULL subdomain_host + same slug were not caught.
            $table->unique(['workspace_id', 'slug'], 'bio_pages_workspace_slug_unique');
        });
    }

    public function down(): void
    {
        Schema::table('bio_pages', function (Blueprint $table) {
            $table->dropUnique('bio_pages_workspace_slug_unique');
        });
    }
};
