migrations/Version20230215181001.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 Version20230215181001 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add dossier type table';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->hasTable('dossier_type'),
  17.             'The dossier_type table already exists!'
  18.         );
  19.         $table $schema->createTable('dossier_type');
  20.         $table->addColumn('id'Types::GUID)->setNotnull(true);
  21.         $table->addColumn('name'Types::STRING, ['length' => 255])->setNotnull(true);
  22.         $table->addColumn('internal_id'Types::STRING, ['length' => 40])->setNotnull(true);
  23.         $table->addColumn('category'Types::STRING, ['length' => 40])->setNotnull(true);
  24.         $table->setPrimaryKey(['id']);
  25.         $table->addIndex(
  26.             ['internal_id'],
  27.             'uniq_dossier_type_internal_id'
  28.         );
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         $this->skipIf(
  33.             false === $schema->hasTable('dossier_type'),
  34.             'The dossier_type table is already removed !'
  35.         );
  36.         $schema->dropTable('dossier_type');
  37.     }
  38. }