<?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('alamat_users', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained('users')->onDelete('cascade');
            $table->string('label')->default('Rumah')->comment('Misal: Rumah, Kantor, Kost');
            $table->string('nama_penerima');
            $table->string('no_telp');
            $table->char('provinsi_id', 2)->nullable();
            $table->char('kota_id', 4)->nullable();
            $table->char('kecamatan_id', 7)->nullable();
            $table->char('desa_id', 10)->nullable();
            $table->string('kode_pos')->nullable();
            $table->text('alamat_lengkap');
            $table->boolean('is_utama')->default(false);
            $table->timestamps();
        });
    }

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