<?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 Version20250907100913 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE review DROP CONSTRAINT fk_794381c67b100c1a');
        $this->addSql('ALTER TABLE price DROP CONSTRAINT fk_cac822d97b100c1a');
        $this->addSql('DROP SEQUENCE idoctor_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE location_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE specialist_id_seq CASCADE');
        $this->addSql('ALTER TABLE location DROP CONSTRAINT fk_5e9e89cb299b2577');
        $this->addSql('ALTER TABLE location DROP CONSTRAINT fk_5e9e89cb7b100c1a');
        $this->addSql('ALTER TABLE location DROP CONSTRAINT fk_5e9e89cbae80f5df');
        $this->addSql('DROP TABLE specialist');
        $this->addSql('DROP TABLE idoctor');
        $this->addSql('DROP TABLE location');
        $this->addSql('ALTER TABLE department ALTER did TYPE INT');
        $this->addSql('DROP INDEX idx_cac822d97b100c1a');
        $this->addSql('ALTER TABLE price DROP specialist_id');
        $this->addSql('DROP INDEX idx_794381c67b100c1a');
        $this->addSql('ALTER TABLE review DROP specialist_id');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('CREATE SEQUENCE idoctor_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE SEQUENCE location_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE SEQUENCE specialist_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE specialist (id INT NOT NULL, name VARCHAR(255) NOT NULL, nearest_date DATE DEFAULT NULL, kinder INT DEFAULT NULL, speciality VARCHAR(255) DEFAULT NULL, category VARCHAR(255) DEFAULT NULL, expirience VARCHAR(255) DEFAULT NULL, description TEXT DEFAULT NULL, img VARCHAR(255) DEFAULT NULL, infoclinica BOOLEAN NOT NULL, alias VARCHAR(255) NOT NULL, dcode VARCHAR(255) NOT NULL, updated TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE idoctor (id INT NOT NULL, dcode INT NOT NULL, name VARCHAR(255) NOT NULL, department_id INT NOT NULL, department_name VARCHAR(255) NOT NULL, filial_id INT NOT NULL, filial_name VARCHAR(255) NOT NULL, comment VARCHAR(255) DEFAULT NULL, nearest_date VARCHAR(255) NOT NULL, view_in_web INT NOT NULL, online_mode INT NOT NULL, updated TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE location (id INT NOT NULL, department_id INT NOT NULL, filial_id INT NOT NULL, specialist_id INT DEFAULT NULL, dcode INT NOT NULL, online_mode BOOLEAN NOT NULL, active BOOLEAN NOT NULL, updated TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX idx_5e9e89cb299b2577 ON location (filial_id)');
        $this->addSql('CREATE INDEX idx_5e9e89cb7b100c1a ON location (specialist_id)');
        $this->addSql('CREATE INDEX idx_5e9e89cbae80f5df ON location (department_id)');
        $this->addSql('ALTER TABLE location ADD CONSTRAINT fk_5e9e89cb299b2577 FOREIGN KEY (filial_id) REFERENCES filial (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE location ADD CONSTRAINT fk_5e9e89cb7b100c1a FOREIGN KEY (specialist_id) REFERENCES specialist (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE location ADD CONSTRAINT fk_5e9e89cbae80f5df FOREIGN KEY (department_id) REFERENCES department (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE review ADD specialist_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE review ADD CONSTRAINT fk_794381c67b100c1a FOREIGN KEY (specialist_id) REFERENCES specialist (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX idx_794381c67b100c1a ON review (specialist_id)');
        $this->addSql('ALTER TABLE price ADD specialist_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE price ADD CONSTRAINT fk_cac822d97b100c1a FOREIGN KEY (specialist_id) REFERENCES specialist (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX idx_cac822d97b100c1a ON price (specialist_id)');
        $this->addSql('ALTER TABLE department ALTER did TYPE BIGINT');
    }
}
