<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20260730060615 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Link clinic_staff rows to a login account (users.id) for the ROLE_STAFF panel access.';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE clinic_staff ADD user_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE clinic_staff ADD CONSTRAINT FK_CBEA5AA1A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL');
        $this->addSql('CREATE INDEX IDX_CBEA5AA1A76ED395 ON clinic_staff (user_id)');
        $this->addSql('CREATE INDEX idx_staff_user_active ON clinic_staff (user_id, active)');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE clinic_staff DROP FOREIGN KEY FK_CBEA5AA1A76ED395');
        $this->addSql('DROP INDEX IDX_CBEA5AA1A76ED395 ON clinic_staff');
        $this->addSql('DROP INDEX idx_staff_user_active ON clinic_staff');
        $this->addSql('ALTER TABLE clinic_staff DROP user_id');
    }
}
