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.             && Type::getType(Types::DATETIME_IMMUTABLE) === $schema->getTable('member_application')->getColumn('exported_to_v9_at')->getType(),
  19.             'The exported_to_v9_at field already is datetime'
  20.         );
  21.         $schema->getTable('member_application')
  22.             ->getColumn('exported_to_v9_at')
  23.             ->setType(Type::getType(Types::DATETIME_IMMUTABLE))
  24.         ;
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         $this->skipIf(
  29.             true === $schema->getTable('member_application')->hasColumn('exported_to_v9_at')
  30.             && Type::getType(Types::DATE_IMMUTABLE) === $schema->getTable('member_application')->getColumn('exported_to_v9_at')->getType(),
  31.             'The exported_to_v9_at field already is date'
  32.         );
  33.         $schema->getTable('member_application')
  34.             ->getColumn('exported_to_v9_at')
  35.             ->setType(Type::getType(Types::DATE_IMMUTABLE))
  36.         ;
  37.     }
  38. }