migrations/Version20250515124926.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8.  * Auto-generated Migration:
  9.  */
  10. final class Version20250515124926 extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return 'Create activity_log table';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         $this->skipIf(true === $schema->hasTable('activity_log'), 'The activity_log table already exists!');
  19.         $table $schema->createTable('activity_log');
  20.         $table->addColumn('id'Types::GUID)->setNotnull(true);
  21.         $table->addColumn('performed_by'Types::GUID)->setNotnull(false);
  22.         $table->addColumn('created_at'Types::DATETIME_IMMUTABLE)->setNotnull(true);
  23.         $table->addColumn('content'Types::TEXT)->setNotnull(false);
  24.         $table->addColumn('entity_type'Types::STRING, ['length' => 255])->setNotnull(true);
  25.         $table->addColumn('entity_id'Types::STRING, ['length' => 255])->setNotnull(true);
  26.         $table->addColumn('context_type'Types::STRING, ['length' => 255])->setNotnull(true);
  27.         $table->setPrimaryKey(['id']);
  28.         $table->addForeignKeyConstraint('employee', ['performed_by'], ['id'], [], 'fk_activity_log_employee');
  29.         $table->addIndex(['entity_type'], 'idx_activity_log_entity_type');
  30.         $table->addIndex(['entity_id'], 'idx_activity_log_entity_id');
  31.     }
  32.     public function down(Schema $schema): void
  33.     {
  34.         $this->skipIf(true !== $schema->hasTable('activity_log'), 'The activity_log table already removed!');
  35.         $schema->dropTable('activity_log');
  36.     }
  37. }