migrations/Version20221017130631.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 Version20221017130631 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Adding federation table and link it to health_mutual table';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->hasTable('federation'),
  17.             'The site and federation tables were already created!'
  18.         );
  19.         $table $schema->createTable('federation');
  20.         $table->addColumn('id'Types::GUID)->setNotnull(true);
  21.         $table->addColumn('name'Types::STRING, ['length' => 255]);
  22.         $table->setPrimaryKey(['id']);
  23.         $table $schema->createTable('federation_health_mutual');
  24.         $table->addColumn('federation_id'Types::GUID)->setNotnull(true);
  25.         $table->addColumn('health_mutual_id'Types::GUID)->setNotnull(true);
  26.         $table->addForeignKeyConstraint(
  27.             'federation',
  28.             ['federation_id'],
  29.             ['id'],
  30.             [],
  31.             'fk_federation_federation_health_mutual'
  32.         );
  33.         $table->addForeignKeyConstraint(
  34.             'health_mutual',
  35.             ['health_mutual_id'],
  36.             ['id'],
  37.             [],
  38.             'fk_health_mutual_federation_health_mutual'
  39.         );
  40.     }
  41.     public function down(Schema $schema): void
  42.     {
  43.         $this->skipIf(
  44.             false === $schema->hasTable('federation'),
  45.             'The site and federation tables were already removed!'
  46.         );
  47.         $schema->dropTable('federation_health_mutual');
  48.         $schema->dropTable('federation');
  49.     }
  50. }