<?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('voting_tables', function (Blueprint $table) {
            $table->id();
            $table->foreignId('voting_location_id')->constrained()->cascadeOnDelete();
            $table->unsignedSmallInteger('table_number');
            $table->unsignedInteger('voter_count')->nullable();
            $table->timestamps();
            $table->softDeletes();

            $table->unique(['voting_location_id', 'table_number']);
        });
    }

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