migrations/Version20220913123615.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 Version20220913123615 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('ticket')->hasColumn('member_application_id'),
  17.             'The member_application_id field was already added in the ticket table!'
  18.         );
  19.         $schema->getTable('ticket')->addColumn(
  20.             'member_application_id',
  21.             Types::STRING,
  22.             [
  23.                 'length' => 255,
  24.                 'notnull' => false,
  25.                 'default' => 'null',
  26.             ]
  27.         );
  28.         $schema->getTable('ticket')->addForeignKeyConstraint(
  29.             'member_application',
  30.             ['member_application_id'],
  31.             ['id'],
  32.             [],
  33.             'fk_ticket_member_application'
  34.         );
  35.     }
  36.     public function down(Schema $schema): void
  37.     {
  38.         $this->skipIf(
  39.             false === $schema->getTable('ticket')->hasColumn('member_application_id'),
  40.             'The member_application_id field was already removed from the ticket table!'
  41.         );
  42.         $schema->getTable('ticket')->dropIndex('fk_ticket_member_application');
  43.         $schema->getTable('ticket')->dropColumn('member_application_id');
  44.     }
  45. }