<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20221108083829 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('slider_item'),
'The slider_item table was already created!'
);
$sliderItemTable = $schema->createTable('slider_item');
$sliderItemTable->addColumn('id', Types::GUID)->setNotnull(true);
$sliderItemTable->addColumn('overlay_color', Types::STRING, ['length' => 9])->setNotnull(true);
$sliderItemTable->addColumn('background_image_file_name', Types::STRING, ['length' => 255])->setNotnull(false);
$sliderItemTable->setPrimaryKey(['id']);
$sliderItemTranslationTable = $schema->createTable('slider_item_translation');
$sliderItemTranslationTable->addColumn('id', Types::GUID)->setNotnull(true);
$sliderItemTranslationTable->addColumn('translatable_id', Types::STRING, ['length' => 255])->setNotnull(true);
$sliderItemTranslationTable->addColumn('title', Types::STRING, ['length' => 255])->setNotnull(true);
$sliderItemTranslationTable->addColumn('content', Types::TEXT)->setNotnull(true);
$sliderItemTranslationTable->addColumn('link_text', Types::STRING, ['length' => 255])->setNotnull(false);
$sliderItemTranslationTable->addColumn('link_url', Types::STRING, ['length' => 255])->setNotnull(false);
$sliderItemTranslationTable->addColumn('language', Types::STRING, ['length' => 10])->setNotnull(true);
$sliderItemTranslationTable->setPrimaryKey(['id']);
$sliderItemTranslationTable->addForeignKeyConstraint(
$sliderItemTable,
['translatable_id'],
['id'],
[],
'fk_slider_item_slider_item_translation'
);
$sliderItemTranslationTable->addIndex(['translatable_id'], 'idx_slider_item_translation_translatable_id');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('slider_item'),
'The slider_item tables was already removed!'
);
$schema->dropTable('slider_item_translation');
$schema->dropTable('slider_item');
}
}