<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20221017130631 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adding federation table and link it to health_mutual table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('federation'),
'The site and federation tables were already created!'
);
$table = $schema->createTable('federation');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('name', Types::STRING, ['length' => 255]);
$table->setPrimaryKey(['id']);
$table = $schema->createTable('federation_health_mutual');
$table->addColumn('federation_id', Types::GUID)->setNotnull(true);
$table->addColumn('health_mutual_id', Types::GUID)->setNotnull(true);
$table->addForeignKeyConstraint(
'federation',
['federation_id'],
['id'],
[],
'fk_federation_federation_health_mutual'
);
$table->addForeignKeyConstraint(
'health_mutual',
['health_mutual_id'],
['id'],
[],
'fk_health_mutual_federation_health_mutual'
);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('federation'),
'The site and federation tables were already removed!'
);
$schema->dropTable('federation_health_mutual');
$schema->dropTable('federation');
}
}