<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20221104131512 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('faq_entry'),
'The faq_entry table was already created!'
);
$faqTable = $schema->createTable('faq_entry');
$faqTable->addColumn('id', Types::GUID)->setNotnull(true);
$faqTable->addColumn('name', Types::STRING, ['length' => 255])->setNotnull(true);
$faqTable->setPrimaryKey(['id']);
$faqTranslationTable = $schema->createTable('faq_entry_translation');
$faqTranslationTable->addColumn('id', Types::GUID)->setNotnull(true);
$faqTranslationTable->addColumn('translatable_id', Types::STRING, ['length' => 255])->setNotnull(true);
$faqTranslationTable->addColumn('question', Types::STRING, ['length' => 255])->setNotnull(true);
$faqTranslationTable->addColumn('answer', Types::TEXT)->setNotnull(true);
$faqTranslationTable->addColumn('language', Types::STRING, ['length' => 10])->setNotnull(true);
$faqTranslationTable->setPrimaryKey(['id']);
$faqTranslationTable->addForeignKeyConstraint(
$faqTable,
['translatable_id'],
['id'],
[],
'fk_faq_entry_faq_entry_translation'
);
$faqTranslationTable->addIndex(['translatable_id'], 'idx_faq_entry_translation_translatable_id');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('faq_entry'),
'The faq_entry tables was already removed!'
);
$schema->dropTable('faq_entry');
$schema->dropTable('faq_entry_translation');
}
}