<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration:
*/
final class Version20250515124926 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create activity_log table';
}
public function up(Schema $schema): void
{
$this->skipIf(true === $schema->hasTable('activity_log'), 'The activity_log table already exists!');
$table = $schema->createTable('activity_log');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('performed_by', Types::GUID)->setNotnull(false);
$table->addColumn('created_at', Types::DATETIME_IMMUTABLE)->setNotnull(true);
$table->addColumn('content', Types::TEXT)->setNotnull(false);
$table->addColumn('entity_type', Types::STRING, ['length' => 255])->setNotnull(true);
$table->addColumn('entity_id', Types::STRING, ['length' => 255])->setNotnull(true);
$table->addColumn('context_type', Types::STRING, ['length' => 255])->setNotnull(true);
$table->setPrimaryKey(['id']);
$table->addForeignKeyConstraint('employee', ['performed_by'], ['id'], [], 'fk_activity_log_employee');
$table->addIndex(['entity_type'], 'idx_activity_log_entity_type');
$table->addIndex(['entity_id'], 'idx_activity_log_entity_id');
}
public function down(Schema $schema): void
{
$this->skipIf(true !== $schema->hasTable('activity_log'), 'The activity_log table already removed!');
$schema->dropTable('activity_log');
}
}