<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('m_districts', function (Blueprint $table) {
            $table->id();
            // Foreign Key ke m_cities
            $table->foreignId('city_id')
                  ->constrained('m_cities')
                  ->cascadeOnDelete();
    
            $table->string('region_code', 50)->index();
            $table->string('name', 100);
            
            $table->foreignId('created_by')->nullable()->constrained('users');
            $table->foreignId('updated_by')->nullable()->constrained('users');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('districts');
    }
};
