<?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 Version20230601202702 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 sub_devis (id INT AUTO_INCREMENT NOT NULL, parent_id INT NOT NULL, montant_ht NUMERIC(50, 3) NOT NULL, percentage DOUBLE PRECISION NOT NULL, INDEX IDX_6763A192727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE sub_devis ADD CONSTRAINT FK_6763A192727ACA70 FOREIGN KEY (parent_id) REFERENCES devis (id)');
$this->addSql('ALTER TABLE devis DROP montant_ht, DROP montant_tva');
$this->addSql('ALTER TABLE facture DROP FOREIGN KEY FK_FE866410F4445056');
$this->addSql('DROP INDEX IDX_FE866410F4445056 ON facture');
$this->addSql('ALTER TABLE facture CHANGE devise_id sub_devis_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE facture ADD CONSTRAINT FK_FE866410FB711483 FOREIGN KEY (sub_devis_id) REFERENCES sub_devis (id)');
$this->addSql('CREATE INDEX IDX_FE866410FB711483 ON facture (sub_devis_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facture DROP FOREIGN KEY FK_FE866410FB711483');
$this->addSql('ALTER TABLE sub_devis DROP FOREIGN KEY FK_6763A192727ACA70');
$this->addSql('DROP TABLE sub_devis');
$this->addSql('DROP INDEX IDX_FE866410FB711483 ON facture');
$this->addSql('ALTER TABLE facture CHANGE sub_devis_id devise_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE facture ADD CONSTRAINT FK_FE866410F4445056 FOREIGN KEY (devise_id) REFERENCES devise (id)');
$this->addSql('CREATE INDEX IDX_FE866410F4445056 ON facture (devise_id)');
$this->addSql('ALTER TABLE devis ADD montant_ht NUMERIC(50, 3) NOT NULL, ADD montant_tva NUMERIC(50, 3) NOT NULL');
}
}