<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20230127101914 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add subject to ticket';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('ticket_topic'),
'The ticket_topic table already exists!'
);
$table = $schema->createTable('ticket_topic');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('name', Types::STRING, ['length' => 255])->setNotnull(true);
$table->setPrimaryKey(['id']);
$translationTable = $schema->createTable('ticket_topic_translation');
$translationTable->addColumn('id', Types::GUID)->setNotnull(true);
$translationTable->addColumn('translatable_id', Types::STRING, ['length' => 255])->setNotnull(true);
$translationTable->addColumn('title', Types::STRING, ['length' => 255])->setNotnull(true);
$translationTable->addColumn('description', Types::STRING, ['length' => 255])->setNotnull(true);
$translationTable->addColumn('language', Types::STRING, ['length' => 10])->setNotnull(true);
$translationTable->setPrimaryKey(['id']);
$translationTable->addForeignKeyConstraint(
$table,
['translatable_id'],
['id'],
[],
'fk_ticket_topic_ticket_topic_translation'
);
$translationTable->addIndex(['translatable_id'], 'idx_page_translation_translatable_id');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('ticket_topic'),
'The ticket_topic table is already removed !'
);
$schema->dropTable('ticket_topic');
$schema->dropTable('ticket_topic_translation');
}
}