migrations/Version20231219105400.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 Version20231219105400 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('member_application_company_comment')->hasColumn('member_application_id'),
  17.             'The member_application_id column was already added to member_application_company_comment table!'
  18.         );
  19.         $commentTable $schema->getTable('member_application_company_comment');
  20.         $commentTable->addColumn('member_application_id'Types::STRING, ['length' => 255])->setNotnull(true);
  21.         $commentTable->addForeignKeyConstraint(
  22.             $schema->getTable('member_application'),
  23.             ['member_application_id'],
  24.             ['id'],
  25.             [],
  26.             'fk_ma_company_comment_member_application'
  27.         );
  28.         $commentTable->addIndex(['member_application_id'], 'idx_ma_company_comment_member_application_id');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         $this->skipIf(
  33.             false === $schema->getTable('member_application_company_comment')->hasColumn('member_application_id'),
  34.             'The member_application_id column was already removed to member_application_company_comment table!'
  35.         );
  36.         $commentTable $schema->getTable('member_application_company_comment');
  37.         $commentTable->dropIndex('idx_ma_company_comment_member_application_id');
  38.         $commentTable->dropColumn('member_application_id');
  39.     }
  40. }