<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20221102132633 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('tariff')->hasColumn('cns_tariff'),
'The cns_tariff field already exists in the tariff table!'
);
$this->addSql('ALTER TABLE tariff ADD cns_tariff DOUBLE PRECISION NOT NULL;');
$this->addSql('UPDATE tariff SET cns_tariff = tariff');
$this->addSql('ALTER TABLE tariff DROP COLUMN tariff');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('tariff')->hasColumn('tariff'),
'The tariff field already exists in the tariff table!'
);
$this->addSql('ALTER TABLE tariff ADD tariff DOUBLE PRECISION NOT NULL;');
$this->addSql('UPDATE tariff SET tariff = cns_tariff');
$this->addSql('ALTER TABLE tariff DROP COLUMN cns_tariff');
}
}