migrations/Version20250512164500.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 Version20250512164500 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Drop tariff table as it is no longer needed';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             false === $schema->hasTable('tariff'),
  17.             'The tariff table is already removed!'
  18.         );
  19.         $schema->dropTable('tariff');
  20.     }
  21.     public function down(Schema $schema): void
  22.     {
  23.         $this->skipIf(
  24.             true === $schema->hasTable('tariff'),
  25.             'The tariff table already exists!'
  26.         );
  27.         $table $schema->createTable('tariff');
  28.         $table->addColumn('id'Types::STRING)
  29.             ->setNotnull(true);
  30.         $table->addColumn('cns_code'Types::STRING)
  31.             ->setLength(40)
  32.             ->setNotnull(true);
  33.         $table->addColumn('cns_tariff'Types::FLOAT)
  34.             ->setNotnull(true);
  35.         $table->addColumn('available_from'Types::DATETIME_IMMUTABLE)
  36.             ->setNotnull(false);
  37.         $table->addColumn('available_to'Types::DATETIME_IMMUTABLE)
  38.             ->setNotnull(false);
  39.         $table->addColumn('created_at'Types::DATETIME_IMMUTABLE)
  40.             ->setNotnull(true);
  41.         $table->addColumn('last_updated_at'Types::DATETIME_IMMUTABLE)
  42.             ->setNotnull(true);
  43.         $table->addColumn('cns_id'Types::INTEGER)
  44.             ->setNotnull(true);
  45.         $table->addColumn('label'Types::STRING)
  46.             ->setLength(255)
  47.             ->setNotnull(true);
  48.         $table->setPrimaryKey(['id']);
  49.     }
  50. }