<?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 Version20210127222522 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE orders DROP tax');
// normalize shipping discounts
$this->addSql('UPDATE orders SET shippingCost=0,systemDiscount=0 WHERE shippingCost=systemDiscount');
$this->addSql('UPDATE orders SET shippingCost=0,discount=0 WHERE shippingCost=discount');
$this->addSql('UPDATE orders SET discount=(COALESCE(systemDiscount, 0) + COALESCE(discount, 0))');
$this->addSql('ALTER TABLE orders DROP systemDiscount');
// normalize orders that had a total discount, they should be support orders
$this->addSql('UPDATE orders SET order_type="support" WHERE orders.subtotal=orders.discount');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE orders ADD tax NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE orders ADD systemDiscount NUMERIC(10, 2) DEFAULT NULL');
}
}