<?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 Version20260407121419 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_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, type VARCHAR(30) DEFAULT NULL, service_id INT DEFAULT NULL, facture_id INT NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX IDX_3712983A7F2DEE08 ON facture_line (facture_id)');
        $this->addSql('ALTER TABLE facture_line ADD CONSTRAINT FK_3712983A7F2DEE08 FOREIGN KEY (facture_id) REFERENCES facture (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE facture ADD state VARCHAR(20) DEFAULT \'created\' NOT NULL');
        $this->addSql('ALTER TABLE facture ADD total_ht NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL');
        $this->addSql('ALTER TABLE facture ADD total_tva NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL');
        $this->addSql('ALTER TABLE facture ADD total_ttc NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL');
        $this->addSql('ALTER TABLE facture ADD is_paid BOOLEAN NOT NULL');
        $this->addSql('ALTER TABLE facture ADD paid_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
        $this->addSql('ALTER TABLE facture ADD paid_method VARCHAR(30) DEFAULT NULL');
        $this->addSql('ALTER TABLE facture ADD facture_pdf VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE facture ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
        $this->addSql('ALTER TABLE facture ADD customer_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE facture ADD CONSTRAINT FK_FE8664109395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE SET NULL NOT DEFERRABLE');
        $this->addSql('CREATE INDEX IDX_FE8664109395C3F3 ON facture (customer_id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE facture_line DROP CONSTRAINT FK_3712983A7F2DEE08');
        $this->addSql('DROP TABLE facture_line');
        $this->addSql('ALTER TABLE facture DROP CONSTRAINT FK_FE8664109395C3F3');
        $this->addSql('DROP INDEX IDX_FE8664109395C3F3');
        $this->addSql('ALTER TABLE facture DROP state');
        $this->addSql('ALTER TABLE facture DROP total_ht');
        $this->addSql('ALTER TABLE facture DROP total_tva');
        $this->addSql('ALTER TABLE facture DROP total_ttc');
        $this->addSql('ALTER TABLE facture DROP is_paid');
        $this->addSql('ALTER TABLE facture DROP paid_at');
        $this->addSql('ALTER TABLE facture DROP paid_method');
        $this->addSql('ALTER TABLE facture DROP facture_pdf');
        $this->addSql('ALTER TABLE facture DROP updated_at');
        $this->addSql('ALTER TABLE facture DROP customer_id');
    }
}
