migrations/Version20230502155501.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\Type;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\Migrations\AbstractMigration;
  8. final class Version20230502155501 extends AbstractMigration
  9. {
  10.     public function getDescription(): string
  11.     {
  12.         return 'Fix exported_to_v9_at to member_application';
  13.     }
  14.     public function up(Schema $schema): void
  15.     {
  16.         $this->skipIf(
  17.             true === $schema->getTable('member_application')->hasColumn('exported_to_v9_at')
  18.             &&
  19.             Type::getType(Types::DATETIME_IMMUTABLE) === $schema->getTable('member_application')->getColumn('exported_to_v9_at')->getType(),
  20.             'The exported_to_v9_at field already is datetime'
  21.         );
  22.         $schema->getTable('member_application')
  23.             ->getColumn('exported_to_v9_at')
  24.             ->setType(Type::getType(Types::DATETIME_IMMUTABLE))
  25.         ;
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         $this->skipIf(
  30.             true === $schema->getTable('member_application')->hasColumn('exported_to_v9_at')
  31.             &&
  32.             Type::getType(Types::DATE_IMMUTABLE) === $schema->getTable('member_application')->getColumn('exported_to_v9_at')->getType(),
  33.             'The exported_to_v9_at field already is date'
  34.         );
  35.         $schema->getTable('member_application')
  36.             ->getColumn('exported_to_v9_at')
  37.             ->setType(Type::getType(Types::DATE_IMMUTABLE))
  38.         ;
  39.     }
  40. }