<?php

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

return new class extends Migration {
    public function up(): void {
        Schema::create('formularios', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('nit', 20);
            $table->string('municipio', 10);
            $table->unsignedSmallInteger('anio')->nullable();
            $table->unsignedTinyInteger('periodo')->nullable();
            $table->string('estado', 30)->default('borrador');
            $table->string('creado_por', 100)->nullable();
            $table->timestamps();

            $table->unique(['nit','municipio','anio','periodo'], 'uk_form_nit_mpio_periodo');
            $table->index(['nit','municipio']);
        });
    }
    public function down(): void { Schema::dropIfExists('formularios'); }
};
