<?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 Version20240118103519 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update TaxProduct to OrderSlip and add fields OrderSlip';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE order_slip ADD product_count INT NOT NULL AFTER total_tax_excl, ADD total_products_tax_excl DOUBLE PRECISION NOT NULL AFTER product_count, ADD total_products_tax_incl DOUBLE PRECISION NOT NULL AFTER total_products_tax_excl, ADD total_shipping_tax_excl DOUBLE PRECISION DEFAULT NULL AFTER total_products_tax_incl, ADD total_shipping_amount DOUBLE PRECISION DEFAULT NULL AFTER total_shipping_tax_excl, ADD shipping_rate VARCHAR(255) DEFAULT NULL AFTER total_shipping_amount, ADD total_ecotax_tax_excl DOUBLE PRECISION DEFAULT NULL AFTER shipping_rate, ADD total_ecotax_tax_incl DOUBLE PRECISION DEFAULT NULL AFTER total_ecotax_tax_excl, ADD ecotax_rate VARCHAR(255) DEFAULT NULL AFTER total_ecotax_tax_incl');
$this->addSql('UPDATE order_slip SET total_products_tax_excl = total_tax_excl');
$this->addSql('ALTER TABLE order_slip DROP total_tax_excl');
$this->addSql('ALTER TABLE tax_product ADD order_slip_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE tax_product ADD CONSTRAINT FK_9202A4A7AFBDDA20 FOREIGN KEY (order_slip_id) REFERENCES order_slip (id)');
$this->addSql('CREATE INDEX IDX_9202A4A7AFBDDA20 ON tax_product (order_slip_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE order_slip ADD total_tax_excl DOUBLE PRECISION NOT NULL AFTER number');
$this->addSql('UPDATE order_slip SET total_tax_excl = total_products_tax_excl');
$this->addSql('ALTER TABLE order_slip DROP product_count, DROP total_products_tax_excl, DROP total_products_tax_incl, DROP total_shipping_tax_excl, DROP total_shipping_amount, DROP shipping_rate, DROP total_ecotax_tax_excl, DROP total_ecotax_tax_incl, DROP ecotax_rate');
$this->addSql('ALTER TABLE tax_product DROP FOREIGN KEY FK_9202A4A7AFBDDA20');
$this->addSql('DROP INDEX IDX_9202A4A7AFBDDA20 ON tax_product');
$this->addSql('ALTER TABLE tax_product DROP order_slip_id');
}
}