<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20260312140000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Create contract_suspensions table';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('CREATE TABLE contract_suspensions (
            id SERIAL PRIMARY KEY,
            contract_period_id INT NOT NULL REFERENCES employee_contract_periods(id) ON DELETE CASCADE,
            start_date DATE NOT NULL,
            end_date DATE DEFAULT NULL,
            comment TEXT DEFAULT NULL,
            created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL
        )');
        $this->addSql('CREATE INDEX idx_suspension_period_start ON contract_suspensions (contract_period_id, start_date)');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('DROP TABLE contract_suspensions');
    }
}
