<?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 Version20190706075437 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\'.');
// migrate values into temp column
$this->addSql('ALTER TABLE product ADD tax_value DOUBLE PRECISION NOT NULL');
$this->addSql('UPDATE product LEFT JOIN iva_aliquot ON iva_aliquot.id=product.tax SET product.tax_value=iva_aliquot.value');
// drop the old tax column
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_DB3A4D938E81BA76');
$this->addSql('DROP INDEX IDX_D34A04AD8E81BA76 ON product');
$this->addSql('ALTER TABLE product DROP tax');
// rename the column
$this->addSql('ALTER TABLE product CHANGE tax_value tax DOUBLE PRECISION');
}
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\'.');
// NO DOWNGRADE...
}
}