<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

final class Version20260212120000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Link users to employees (one-to-one)';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE users ADD employee_id INT DEFAULT NULL');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_USERS_EMPLOYEE ON users (employee_id)');
        $this->addSql('ALTER TABLE users ADD CONSTRAINT FK_USERS_EMPLOYEE FOREIGN KEY (employee_id) REFERENCES employees (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE users DROP CONSTRAINT FK_USERS_EMPLOYEE');
        $this->addSql('DROP INDEX UNIQ_USERS_EMPLOYEE');
        $this->addSql('ALTER TABLE users DROP COLUMN employee_id');
    }
}
