<?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 Version20260402202809 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 facture (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, split_index SMALLINT DEFAULT 0 NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, order_number_id INT NOT NULL, advert_id INT DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX IDX_FE8664108C26A5E8 ON facture (order_number_id)');
        $this->addSql('CREATE INDEX IDX_FE866410D07ECCB6 ON facture (advert_id)');
        $this->addSql('ALTER TABLE facture ADD CONSTRAINT FK_FE8664108C26A5E8 FOREIGN KEY (order_number_id) REFERENCES order_number (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE facture ADD CONSTRAINT FK_FE866410D07ECCB6 FOREIGN KEY (advert_id) REFERENCES advert (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE "order" DROP CONSTRAINT fk_f5299398d07eccb6');
        $this->addSql('ALTER TABLE "order" DROP CONSTRAINT fk_f52993988c26a5e8');
        $this->addSql('DROP TABLE "order"');
        $this->addSql('DROP INDEX uniq_54f1f40b8c26a5e8');
        $this->addSql('CREATE INDEX IDX_54F1F40B8C26A5E8 ON advert (order_number_id)');
        $this->addSql('DROP INDEX uniq_8b27c52b8c26a5e8');
        $this->addSql('CREATE INDEX IDX_8B27C52B8C26A5E8 ON devis (order_number_id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE "order" (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, split_index SMALLINT DEFAULT 0 NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, order_number_id INT NOT NULL, advert_id INT DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX idx_f5299398d07eccb6 ON "order" (advert_id)');
        $this->addSql('CREATE UNIQUE INDEX uniq_f52993988c26a5e8 ON "order" (order_number_id)');
        $this->addSql('ALTER TABLE "order" ADD CONSTRAINT fk_f5299398d07eccb6 FOREIGN KEY (advert_id) REFERENCES advert (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE "order" ADD CONSTRAINT fk_f52993988c26a5e8 FOREIGN KEY (order_number_id) REFERENCES order_number (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE facture DROP CONSTRAINT FK_FE8664108C26A5E8');
        $this->addSql('ALTER TABLE facture DROP CONSTRAINT FK_FE866410D07ECCB6');
        $this->addSql('DROP TABLE facture');
        $this->addSql('DROP INDEX IDX_54F1F40B8C26A5E8');
        $this->addSql('CREATE UNIQUE INDEX uniq_54f1f40b8c26a5e8 ON advert (order_number_id)');
        $this->addSql('DROP INDEX IDX_8B27C52B8C26A5E8');
        $this->addSql('CREATE UNIQUE INDEX uniq_8b27c52b8c26a5e8 ON devis (order_number_id)');
    }
}
