<?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 Version20210907005143 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 payment DROP FOREIGN KEY FK_B97A80369C8502E8');
$this->addSql('ALTER TABLE payment DROP FOREIGN KEY FK_9B522D462B5CA896');
$this->addSql('DROP INDEX UNIQ_6D28840D2B5CA896 ON payment');
$this->addSql('DROP INDEX IDX_6D28840D9C8502E8 ON payment');
$this->addSql('ALTER TABLE payment ADD order_id INT DEFAULT NULL, DROP receipt_id, DROP idAccountingEntry');
$this->addSql('UPDATE payment LEFT JOIN order_payment ON order_payment.payment_id=payment.id SET payment.order_id=order_payment.order_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE payment ADD receipt_id INT DEFAULT NULL, ADD idAccountingEntry INT DEFAULT NULL, DROP order_id');
$this->addSql('ALTER TABLE payment ADD CONSTRAINT FK_9B522D462B5CA896 FOREIGN KEY (receipt_id) REFERENCES receipt (id)');
$this->addSql('ALTER TABLE payment ADD CONSTRAINT FK_B97A80369C8502E8 FOREIGN KEY (idAccountingEntry) REFERENCES accounting_entry (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_6D28840D2B5CA896 ON payment (receipt_id)');
$this->addSql('CREATE INDEX IDX_6D28840D9C8502E8 ON payment (idAccountingEntry)');
}
public function isTransactional(): bool
{
return false;
}
}