<?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 Version20251123150400 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('DROP SEQUENCE main_id_seq CASCADE');
        $this->addSql('CREATE TABLE ag_main (id SERIAL NOT NULL, president_id INT DEFAULT NULL, secretaire_id INT DEFAULT NULL, ag_date_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, locate VARCHAR(255) NOT NULL, locate_zipcode VARCHAR(255) NOT NULL, locate_city VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_8173EDAFB40A33C7 ON ag_main (president_id)');
        $this->addSql('CREATE INDEX IDX_8173EDAFA90F02B2 ON ag_main (secretaire_id)');
        $this->addSql('COMMENT ON COLUMN ag_main.ag_date_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE ag_main_member (id SERIAL NOT NULL, member_id INT DEFAULT NULL, main_id INT DEFAULT NULL, is_voted_allow BOOLEAN NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_7979FD617597D3FE ON ag_main_member (member_id)');
        $this->addSql('CREATE INDEX IDX_7979FD61627EA78A ON ag_main_member (main_id)');
        $this->addSql('ALTER TABLE ag_main ADD CONSTRAINT FK_8173EDAFB40A33C7 FOREIGN KEY (president_id) REFERENCES members (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE ag_main ADD CONSTRAINT FK_8173EDAFA90F02B2 FOREIGN KEY (secretaire_id) REFERENCES members (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE ag_main_member ADD CONSTRAINT FK_7979FD617597D3FE FOREIGN KEY (member_id) REFERENCES members (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE ag_main_member ADD CONSTRAINT FK_7979FD61627EA78A FOREIGN KEY (main_id) REFERENCES ag_main (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE main DROP CONSTRAINT fk_bf28cd64a90f02b2');
        $this->addSql('ALTER TABLE main DROP CONSTRAINT fk_bf28cd64b40a33c7');
        $this->addSql('DROP TABLE main');
    }

    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 main_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE main (id SERIAL NOT NULL, president_id INT DEFAULT NULL, secretaire_id INT DEFAULT NULL, ag_date_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, locate VARCHAR(255) NOT NULL, locate_zipcode VARCHAR(255) NOT NULL, locate_city VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX idx_bf28cd64a90f02b2 ON main (secretaire_id)');
        $this->addSql('CREATE INDEX idx_bf28cd64b40a33c7 ON main (president_id)');
        $this->addSql('COMMENT ON COLUMN main.ag_date_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('ALTER TABLE main ADD CONSTRAINT fk_bf28cd64a90f02b2 FOREIGN KEY (secretaire_id) REFERENCES members (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE main ADD CONSTRAINT fk_bf28cd64b40a33c7 FOREIGN KEY (president_id) REFERENCES members (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE ag_main DROP CONSTRAINT FK_8173EDAFB40A33C7');
        $this->addSql('ALTER TABLE ag_main DROP CONSTRAINT FK_8173EDAFA90F02B2');
        $this->addSql('ALTER TABLE ag_main_member DROP CONSTRAINT FK_7979FD617597D3FE');
        $this->addSql('ALTER TABLE ag_main_member DROP CONSTRAINT FK_7979FD61627EA78A');
        $this->addSql('DROP TABLE ag_main');
        $this->addSql('DROP TABLE ag_main_member');
    }
}
