<?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('desa', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('kecamatan_id')->constrained('kecamatan')->cascadeOnDelete();
            $table->string('nama');
            $table->string('slug');
            $table->string('logo')->nullable();
            $table->enum('status', ['draft', 'published', 'suspended'])->default('draft');
            $table->date('tanggal_pilkades')->nullable();
            $table->boolean('is_active')->default(true);
            $table->timestamps();
            $table->softDeletes();

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

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