<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20250127102900 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add inquiry table';
}
public function up(Schema $schema): void
{
$this->skipIf($schema->hasTable('inquiry'), 'Table inquiry already exists');
$table = $schema->createTable('inquiry');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('ged_id', Types::STRING)->setLength(15)->setNotnull(true);
$table->addColumn('added_at', Types::DATETIME_IMMUTABLE)->setNotnull(true);
$table->addColumn('source_channel', Types::STRING)->setLength(20)->setNotnull(true);
$table->addColumn('total_page_count', Types::INTEGER)->setNotnull(true);
$table->addColumn('status', Types::STRING)->setLength(20)->setNotnull(true);
$table->addColumn('assigned_department_id', Types::STRING)->setLength(255)->setNotnull(true);
$table->addColumn('assigned_employee_id', Types::STRING)->setLength(255)->setNotnull(false)->setDefault(null);
$table->addColumn('health_insurance_pages', Types::JSON)->setNotnull(false);
$table->addColumn('ignored_pages', Types::JSON)->setNotnull(false);
$table->addColumn('ocr_data', Types::JSON)->setNotnull(false);
$table->setPrimaryKey(['id']);
$table->addIndex(['ged_id'], 'idx_ged_id');
$table->addForeignKeyConstraint('department', ['assigned_department_id'], ['id'], [], 'fk_inquiry_department');
$table->addForeignKeyConstraint('employee', ['assigned_employee_id'], ['id'], [], 'fk_inquiry_employee');
}
public function down(Schema $schema): void
{
$this->skipIf(!$schema->hasTable('inquiry'), 'Table inquiry does not exist');
$schema->dropTable('inquiry');
}
}