<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
 * Absence management: create the absence_policy table.
 */
final class Version20260521123520 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Create absence_policy table';
    }

    public function up(Schema $schema): void
    {
        $this->addSql(<<<'SQL'
                CREATE TABLE absence_policy (
                  id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
                  type VARCHAR(32) NOT NULL,
                  days_per_year DOUBLE PRECISION DEFAULT NULL,
                  days_per_event DOUBLE PRECISION DEFAULT NULL,
                  justification_required BOOLEAN NOT NULL,
                  notice_days INT NOT NULL,
                  count_working_days_only BOOLEAN NOT NULL,
                  active BOOLEAN NOT NULL,
                  PRIMARY KEY (id)
                )
            SQL);
        $this->addSql('CREATE UNIQUE INDEX uniq_absence_policy_type ON absence_policy (type)');
    }

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