migrations/Version20221107144633.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 Version20221107144633 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Adds inquiry_category and inquiry_category_translation tables.';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->hasTable('inquiry_category'),
  17.             'The inquiry_category table was already created!'
  18.         );
  19.         $table $schema->createTable('inquiry_category');
  20.         $table->addColumn('id'Types::GUID)->setNotnull(true);
  21.         $table->addColumn('upload_type'Types::STRING, ['length' => 80])->setNotnull(true);
  22.         $table->addColumn('icon'Types::STRING, ['length' => 80])->setNotnull(true);
  23.         $table->setPrimaryKey(['id']);
  24.         $table $schema->createTable('inquiry_category_translation');
  25.         $table->addColumn('id'Types::GUID)->setNotnull(true);
  26.         $table->addColumn('translatable_id'Types::GUID)->setNotnull(true);
  27.         $table->addColumn('title'Types::STRING, ['length' => 80])->setNotnull(true);
  28.         $table->addColumn('language'Types::STRING, ['length' => 10])->setNotnull(true);
  29.         $table->setPrimaryKey(['id']);
  30.         $table->addForeignKeyConstraint('inquiry_category', ['translatable_id'], ['id'], [], 'fk_inquiry_category_inquiry_category_translation');
  31.     }
  32.     public function down(Schema $schema): void
  33.     {
  34.         $this->skipIf(
  35.             false === $schema->hasTable('inquiry_category'),
  36.             'The inquiry_category table was already removed!'
  37.         );
  38.         $schema->dropTable('inquiry_category_translation');
  39.         $schema->dropTable('inquiry_category');
  40.     }
  41. }