<?php

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

return new class extends Migration
{
    /**
     * Jalankan migrasi untuk membuat tabel kelompok tani.
     */
    public function up(): void
    {
        Schema::create('kelompok_tani', function (Blueprint $table) {
            $table->id();
            $table->string('nomor_induk', 50)->unique(); // ID Kelompok Tani unik untuk validasi excel
            $table->string('nama_kelompok', 150);
            $table->string('nama_ketua', 150);
            $table->char('nik_ketua', 16);
            $table->string('no_hp_ketua', 20)->nullable();
            
            // Relasi wilayah administratif Jawa Tengah
            $table->foreignId('regency_id')->constrained('regencies');
            $table->foreignId('district_id')->constrained('districts');
            $table->foreignId('village_id')->constrained('villages');
            
            $table->text('alamat_spesifik')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Batalkan migrasi.
     */
    public function down(): void
    {
        Schema::dropIfExists('kelompok_tani');
    }
};