<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20230217152301 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add message document generator info table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('message_document_generator_info'),
'The message_document_generator_info table already exists!'
);
$table = $schema->createTable('message_document_generator_info');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('created_at', Types::DATETIME_IMMUTABLE)->setNotnull(true);
$table->addColumn('status', Types::STRING, ['length' => 30])->setNotnull(true);
$table->addColumn('status_message', Types::TEXT)->setNotnull(false);
$table->addColumn('callback_at', Types::DATETIME_IMMUTABLE)->setNotnull(false);
$table->addColumn('callback_message', Types::TEXT)->setNotnull(false);
$table->addColumn('document_name', Types::STRING, ['length' => 255])->setNotnull(false);
$table->addColumn('document_url', Types::STRING, ['length' => 255])->setNotnull(false);
$table->addColumn('message_id', Types::GUID)->setNotnull(true);
$table->setPrimaryKey(['id']);
$messageTable = $schema->getTable('message');
$table->addForeignKeyConstraint(
$messageTable,
['message_id'],
['id'],
[],
'fk_message_document_generator_info_message'
);
$table->addIndex(['message_id'], 'idx_message_document_generator_info_message_id');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('message_document_generator_info'),
'The message_document_generator_info table is already removed !'
);
$schema->dropTable('message_document_generator_info');
}
}