<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20221107144633 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds inquiry_category and inquiry_category_translation tables.';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('inquiry_category'),
'The inquiry_category table was already created!'
);
$table = $schema->createTable('inquiry_category');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('upload_type', Types::STRING, ['length' => 80])->setNotnull(true);
$table->addColumn('icon', Types::STRING, ['length' => 80])->setNotnull(true);
$table->setPrimaryKey(['id']);
$table = $schema->createTable('inquiry_category_translation');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('translatable_id', Types::GUID)->setNotnull(true);
$table->addColumn('title', Types::STRING, ['length' => 80])->setNotnull(true);
$table->addColumn('language', Types::STRING, ['length' => 10])->setNotnull(true);
$table->setPrimaryKey(['id']);
$table->addForeignKeyConstraint('inquiry_category', ['translatable_id'], ['id'], [], 'fk_inquiry_category_inquiry_category_translation');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('inquiry_category'),
'The inquiry_category table was already removed!'
);
$schema->dropTable('inquiry_category_translation');
$schema->dropTable('inquiry_category');
}
}