<?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('ms_kelurahan', function (Blueprint $table) {
            $table->id('MsKelurahanId');
            $table->integer('ms_provinsi_id');
            $table->integer('ms_kabupaten_id');
            $table->integer('ms_kecamatan_id');
            $table->string('name');
            $table->string('kode_wilayah');
            $table->timestampsTz();

            $table->foreign('ms_provinsi_id')->references('MsProvinsiId')->on('ms_provinsi')->onDelete('cascade');
            $table->foreign('ms_kabupaten_id')->references('MsKabupatenId')->on('ms_kabupaten')->onDelete('cascade');
            $table->foreign('ms_kecamatan_id')->references('MsKecamatanId')->on('ms_kecamatan')->onDelete('cascade');
        });
    }

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