<?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('candidates', function (Blueprint $table) {
            $table->id();
            $table->foreignId('political_party_id')->constrained()->cascadeOnDelete();
            $table->foreignId('department_id')->nullable()->constrained()->nullOnDelete();
            $table->enum('type', [
                'presidential',
                'national_senator',
                'regional_senator',
                'regional_deputy',
                'andean_parliament',
            ]);
            $table->unsignedSmallInteger('number')->nullable();
            $table->string('first_name');
            $table->string('last_name');
            $table->string('photo')->nullable();
            $table->timestamps();
            $table->softDeletes();

            $table->index('type');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('candidates');
    }
};
