<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260616010000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Extend operation log for audit timeline';
}
public function up(Schema $schema): void
{
$this->addSql("ALTER TABLE operation_log ADD type VARCHAR(30) DEFAULT 'operation' NOT NULL, ADD username VARCHAR(180) DEFAULT NULL, ADD operator_type VARCHAR(30) DEFAULT NULL, ADD user_agent LONGTEXT DEFAULT NULL, ADD result VARCHAR(20) DEFAULT 'success' NOT NULL, ADD failure_reason LONGTEXT DEFAULT NULL");
$this->addSql('CREATE INDEX idx_operation_log_created_at ON operation_log (created_at)');
$this->addSql('CREATE INDEX idx_operation_log_type_created_at ON operation_log (type, created_at)');
$this->addSql('CREATE INDEX idx_operation_log_action_created_at ON operation_log (action, created_at)');
$this->addSql('CREATE INDEX idx_operation_log_result_created_at ON operation_log (result, created_at)');
$this->addSql('CREATE INDEX idx_operation_log_username_created_at ON operation_log (username, created_at)');
$this->addSql('CREATE INDEX idx_operation_log_ip_created_at ON operation_log (ip, created_at)');
$this->addSql('CREATE INDEX idx_operation_log_operator_created_at ON operation_log (operator_id, created_at)');
$this->addSql('CREATE INDEX idx_operation_log_resource ON operation_log (resource_type, resource_id)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX idx_operation_log_created_at ON operation_log');
$this->addSql('DROP INDEX idx_operation_log_type_created_at ON operation_log');
$this->addSql('DROP INDEX idx_operation_log_action_created_at ON operation_log');
$this->addSql('DROP INDEX idx_operation_log_result_created_at ON operation_log');
$this->addSql('DROP INDEX idx_operation_log_username_created_at ON operation_log');
$this->addSql('DROP INDEX idx_operation_log_ip_created_at ON operation_log');
$this->addSql('DROP INDEX idx_operation_log_operator_created_at ON operation_log');
$this->addSql('DROP INDEX idx_operation_log_resource ON operation_log');
$this->addSql('ALTER TABLE operation_log DROP type, DROP username, DROP operator_type, DROP user_agent, DROP result, DROP failure_reason');
}
}