<?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 Version20260610110921 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add city_id and province_id to doctor_addresses';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE doctor_addresses ADD city_id INT DEFAULT NULL, ADD province_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE doctor_addresses ADD CONSTRAINT FK_doctor_addresses_city FOREIGN KEY (city_id) REFERENCES cities (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE doctor_addresses ADD CONSTRAINT FK_doctor_addresses_province FOREIGN KEY (province_id) REFERENCES provinces (id) ON DELETE SET NULL');
        $this->addSql('CREATE INDEX IDX_doctor_addresses_city ON doctor_addresses (city_id)');
        $this->addSql('CREATE INDEX IDX_doctor_addresses_province ON doctor_addresses (province_id)');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE doctor_addresses DROP FOREIGN KEY FK_doctor_addresses_city');
        $this->addSql('ALTER TABLE doctor_addresses DROP FOREIGN KEY FK_doctor_addresses_province');
        $this->addSql('DROP INDEX IDX_doctor_addresses_city ON doctor_addresses');
        $this->addSql('DROP INDEX IDX_doctor_addresses_province ON doctor_addresses');
        $this->addSql('ALTER TABLE doctor_addresses DROP city_id, DROP province_id');
    }
}
