<?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('bd_divisions', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('bn_name')->nullable();
            $table->timestamps();
        });

        Schema::create('bd_districts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('division_id')->constrained('bd_divisions')->cascadeOnDelete();
            $table->string('name');
            $table->string('bn_name')->nullable();
            $table->string('lat')->nullable();
            $table->string('lon')->nullable();
            $table->timestamps();
        });

        Schema::create('bd_upazilas', function (Blueprint $table) {
            $table->id();
            $table->foreignId('district_id')->constrained('bd_districts')->cascadeOnDelete();
            $table->string('name');
            $table->string('bn_name')->nullable();
            $table->timestamps();
        });
    }

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