migrations/Version20221103101348.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\Migrations\AbstractMigration;
  7. final class Version20221103101348 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return '';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('tariff')->hasColumn('cns_id'),
  17.             'The cns_id field already exists in the tariff table!'
  18.         );
  19.         $schema->getTable('tariff')
  20.             ->addColumn('cns_id'Types::INTEGER)->setNotnull(false);
  21.         $schema->getTable('tariff')
  22.             ->addColumn('label'Types::STRING)->setNotnull(false);
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         $this->skipIf(
  27.             false === $schema->getTable('tariff')->hasColumn('cns_id'),
  28.             'The cns_id is already removed from the tariff table!'
  29.         );
  30.         $schema->getTable('tariff')
  31.             ->dropColumn('cns_id');
  32.         $schema->getTable('tariff')
  33.             ->dropColumn('label');
  34.     }
  35. }