<?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 Version20260407065007 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 advert_line (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, pos INT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, price_ht NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL, advert_id INT NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX IDX_9834F5BBD07ECCB6 ON advert_line (advert_id)');
        $this->addSql('ALTER TABLE advert_line ADD CONSTRAINT FK_9834F5BBD07ECCB6 FOREIGN KEY (advert_id) REFERENCES advert (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('DROP INDEX idx_54f1f40b41defada');
        $this->addSql('ALTER TABLE advert ADD state VARCHAR(20) DEFAULT \'created\' NOT NULL');
        $this->addSql('ALTER TABLE advert ADD raison_message TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE advert ADD total_ht NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL');
        $this->addSql('ALTER TABLE advert ADD total_tva NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL');
        $this->addSql('ALTER TABLE advert ADD total_ttc NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL');
        $this->addSql('ALTER TABLE advert ADD submission_id VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE advert ADD advert_file VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE advert ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
        $this->addSql('ALTER TABLE advert ADD customer_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE advert ADD CONSTRAINT FK_54F1F40B9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE SET NULL NOT DEFERRABLE');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_54F1F40B41DEFADA ON advert (devis_id)');
        $this->addSql('CREATE INDEX IDX_54F1F40B9395C3F3 ON advert (customer_id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE advert_line DROP CONSTRAINT FK_9834F5BBD07ECCB6');
        $this->addSql('DROP TABLE advert_line');
        $this->addSql('ALTER TABLE advert DROP CONSTRAINT FK_54F1F40B9395C3F3');
        $this->addSql('DROP INDEX UNIQ_54F1F40B41DEFADA');
        $this->addSql('DROP INDEX IDX_54F1F40B9395C3F3');
        $this->addSql('ALTER TABLE advert DROP state');
        $this->addSql('ALTER TABLE advert DROP raison_message');
        $this->addSql('ALTER TABLE advert DROP total_ht');
        $this->addSql('ALTER TABLE advert DROP total_tva');
        $this->addSql('ALTER TABLE advert DROP total_ttc');
        $this->addSql('ALTER TABLE advert DROP submission_id');
        $this->addSql('ALTER TABLE advert DROP advert_file');
        $this->addSql('ALTER TABLE advert DROP updated_at');
        $this->addSql('ALTER TABLE advert DROP customer_id');
        $this->addSql('CREATE INDEX idx_54f1f40b41defada ON advert (devis_id)');
    }
}
