<?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 Version20260609133121 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('CREATE TABLE clinics (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, name VARCHAR(255) DEFAULT NULL, info LONGTEXT DEFAULT NULL, address LONGTEXT DEFAULT NULL, telephone VARCHAR(50) DEFAULT NULL, is_24_7 TINYINT NOT NULL, working_days VARCHAR(255) DEFAULT NULL, latitude DOUBLE PRECISION DEFAULT NULL, longitude DOUBLE PRECISION DEFAULT NULL, city_id INT DEFAULT NULL, state_id INT DEFAULT NULL, representation_id INT DEFAULT NULL, images_clinic JSON DEFAULT NULL, clinic_logo JSON DEFAULT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, user_id INT NOT NULL, UNIQUE INDEX UNIQ_D7053B66D17F50A6 (uuid), INDEX idx_clinics_owner (user_id), INDEX idx_clinics_city (city_id), INDEX idx_clinics_state (state_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('CREATE TABLE clinic_doctors (clinic_id INT NOT NULL, doctor_id INT NOT NULL, INDEX IDX_ED177046CC22AD4 (clinic_id), INDEX IDX_ED17704687F4FB17 (doctor_id), PRIMARY KEY (clinic_id, doctor_id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('CREATE TABLE clinic_specialties (clinic_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_3201DD37CC22AD4 (clinic_id), INDEX IDX_3201DD3712469DE2 (category_id), PRIMARY KEY (clinic_id, category_id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('CREATE TABLE clinic_services (clinic_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_C00FFAB0CC22AD4 (clinic_id), INDEX IDX_C00FFAB012469DE2 (category_id), PRIMARY KEY (clinic_id, category_id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('CREATE TABLE clinic_insurances (clinic_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_BE9FC898CC22AD4 (clinic_id), INDEX IDX_BE9FC89812469DE2 (category_id), PRIMARY KEY (clinic_id, category_id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('ALTER TABLE clinics ADD CONSTRAINT FK_D7053B66A76ED395 FOREIGN KEY (user_id) REFERENCES users (id)');
        $this->addSql('ALTER TABLE clinic_doctors ADD CONSTRAINT FK_ED177046CC22AD4 FOREIGN KEY (clinic_id) REFERENCES clinics (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE clinic_doctors ADD CONSTRAINT FK_ED17704687F4FB17 FOREIGN KEY (doctor_id) REFERENCES doctors (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE clinic_specialties ADD CONSTRAINT FK_3201DD37CC22AD4 FOREIGN KEY (clinic_id) REFERENCES clinics (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE clinic_specialties ADD CONSTRAINT FK_3201DD3712469DE2 FOREIGN KEY (category_id) REFERENCES categories (id)');
        $this->addSql('ALTER TABLE clinic_services ADD CONSTRAINT FK_C00FFAB0CC22AD4 FOREIGN KEY (clinic_id) REFERENCES clinics (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE clinic_services ADD CONSTRAINT FK_C00FFAB012469DE2 FOREIGN KEY (category_id) REFERENCES categories (id)');
        $this->addSql('ALTER TABLE clinic_insurances ADD CONSTRAINT FK_BE9FC898CC22AD4 FOREIGN KEY (clinic_id) REFERENCES clinics (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE clinic_insurances ADD CONSTRAINT FK_BE9FC89812469DE2 FOREIGN KEY (category_id) REFERENCES categories (id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE clinics DROP FOREIGN KEY FK_D7053B66A76ED395');
        $this->addSql('ALTER TABLE clinic_doctors DROP FOREIGN KEY FK_ED177046CC22AD4');
        $this->addSql('ALTER TABLE clinic_doctors DROP FOREIGN KEY FK_ED17704687F4FB17');
        $this->addSql('ALTER TABLE clinic_specialties DROP FOREIGN KEY FK_3201DD37CC22AD4');
        $this->addSql('ALTER TABLE clinic_specialties DROP FOREIGN KEY FK_3201DD3712469DE2');
        $this->addSql('ALTER TABLE clinic_services DROP FOREIGN KEY FK_C00FFAB0CC22AD4');
        $this->addSql('ALTER TABLE clinic_services DROP FOREIGN KEY FK_C00FFAB012469DE2');
        $this->addSql('ALTER TABLE clinic_insurances DROP FOREIGN KEY FK_BE9FC898CC22AD4');
        $this->addSql('ALTER TABLE clinic_insurances DROP FOREIGN KEY FK_BE9FC89812469DE2');
        $this->addSql('DROP TABLE clinics');
        $this->addSql('DROP TABLE clinic_doctors');
        $this->addSql('DROP TABLE clinic_specialties');
        $this->addSql('DROP TABLE clinic_services');
        $this->addSql('DROP TABLE clinic_insurances');
    }
}
