<?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('kecamatan', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('kabupaten_id')->constrained('kabupaten')->cascadeOnDelete();
            $table->string('nama');
            $table->string('slug');
            $table->string('kode_wilayah')->nullable();
            $table->boolean('is_active')->default(true);
            $table->timestamps();
            $table->softDeletes();

            $table->unique(['kabupaten_id', 'slug']);
        });
    }

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