<?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 Version20231213150523 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add TaxDiscount, TaxProduct & update fields Order, OrderInvoice and OrderProduct';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE tax_discount (id INT AUTO_INCREMENT NOT NULL, order_id INT DEFAULT NULL, rate VARCHAR(50) NOT NULL, amount DOUBLE PRECISION NOT NULL, INDEX IDX_17415B08D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tax_product (id INT AUTO_INCREMENT NOT NULL, order_invoice_id INT DEFAULT NULL, total_price_tax_excl DOUBLE PRECISION NOT NULL, total_amount DOUBLE PRECISION NOT NULL, rate VARCHAR(255) NOT NULL, INDEX IDX_9202A4A79A530CA8 (order_invoice_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE tax_discount ADD CONSTRAINT FK_17415B08D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)');
$this->addSql('ALTER TABLE tax_product ADD CONSTRAINT FK_9202A4A79A530CA8 FOREIGN KEY (order_invoice_id) REFERENCES order_invoice (id)');
$this->addSql('ALTER TABLE `order` ADD payment VARCHAR(255) NOT NULL, ADD total_discount_tax_incl DOUBLE PRECISION DEFAULT NULL, ADD total_discount_tax DOUBLE PRECISION DEFAULT NULL');
$this->addSql('ALTER TABLE order_invoice ADD total_shipping_tax_excl DOUBLE PRECISION DEFAULT NULL, ADD total_shipping_amount DOUBLE PRECISION DEFAULT NULL, ADD shipping_rate VARCHAR(255) DEFAULT NULL, ADD total_ecotax_tax_excl DOUBLE PRECISION DEFAULT NULL, ADD total_ecotax_tax_incl DOUBLE PRECISION DEFAULT NULL, ADD ecotax_rate VARCHAR(255) DEFAULT NULL, ADD total_wrapping_tax_excl DOUBLE PRECISION DEFAULT NULL, ADD total_wrapping_amount DOUBLE PRECISION DEFAULT NULL, ADD wrapping_rate VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE order_product ADD reduction_amount_tax_excl DOUBLE PRECISION DEFAULT NULL, ADD reduction_amount_tax_incl DOUBLE PRECISION DEFAULT NULL, ADD ecotax_tax_rate VARCHAR(255) DEFAULT NULL, ADD ecotax_name VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE tax_discount DROP FOREIGN KEY FK_17415B08D9F6D38');
$this->addSql('ALTER TABLE tax_product DROP FOREIGN KEY FK_9202A4A79A530CA8');
$this->addSql('DROP TABLE tax_discount');
$this->addSql('DROP TABLE tax_product');
$this->addSql('ALTER TABLE `order` DROP payment, DROP total_discount_tax_incl, DROP total_discount_tax');
$this->addSql('ALTER TABLE order_invoice 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, DROP total_wrapping_tax_excl, DROP total_wrapping_amount, DROP wrapping_rate');
$this->addSql('ALTER TABLE order_product DROP reduction_amount_tax_excl, DROP reduction_amount_tax_incl, DROP ecotax_tax_rate, DROP ecotax_name');
}
}