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