<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20230215181001 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add dossier type table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('dossier_type'),
'The dossier_type table already exists!'
);
$table = $schema->createTable('dossier_type');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('name', Types::STRING, ['length' => 255])->setNotnull(true);
$table->addColumn('internal_id', Types::STRING, ['length' => 40])->setNotnull(true);
$table->addColumn('category', Types::STRING, ['length' => 40])->setNotnull(true);
$table->setPrimaryKey(['id']);
$table->addIndex(
['internal_id'],
'uniq_dossier_type_internal_id'
);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('dossier_type'),
'The dossier_type table is already removed !'
);
$schema->dropTable('dossier_type');
}
}