<?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 Version20210929062629 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('ALTER TABLE invoice ADD quotation_id INT DEFAULT NULL, ADD invoice_date DATE NOT NULL');
$this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_90651744B4EA4E60 FOREIGN KEY (quotation_id) REFERENCES customer_quotations (id)');
$this->addSql('UPDATE invoice set invoice_date = date_created WHERE invoice_date IS NULL');
$this->addSql('CREATE INDEX IDX_90651744B4EA4E60 ON invoice (quotation_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE invoice DROP FOREIGN KEY FK_90651744B4EA4E60');
$this->addSql('DROP INDEX IDX_90651744B4EA4E60 ON invoice');
$this->addSql('ALTER TABLE invoice DROP quotation_id, DROP invoice_date');
}
}