<?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('towns', function (Blueprint $table) {
            $table->id();
            $table->string('town_pid', 15)->unique();
            $table->string('town_name', 50);
            $table->unsignedTinyInteger('state');
            $table->unsignedInteger('population')->nullable();
            $table->unsignedTinyInteger('town_class')->nullable();
            $table->timestamp('date_retired')->nullable();
            $table->timestamps();

            $table->index(['town_name', 'state']);
        });
    }

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