20260428120013_create_audit_log.php 1.0 KB

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare(strict_types=1);
  3. use App\Infrastructure\Db\Migrations\BaseMigration;
  4. final class CreateAuditLog extends BaseMigration
  5. {
  6. public function change(): void
  7. {
  8. $table = $this->table('audit_log');
  9. $table
  10. ->addColumn('actor_kind', 'string', ['limit' => 16, 'null' => false])
  11. ->addColumn('actor_id', 'string', ['limit' => 64, 'null' => true])
  12. ->addColumn('action', 'string', ['limit' => 64, 'null' => false])
  13. ->addColumn('target_type', 'string', ['limit' => 64, 'null' => true])
  14. ->addColumn('target_id', 'string', ['limit' => 64, 'null' => true])
  15. ->addColumn('details_json', 'text', ['null' => true])
  16. ->addColumn('ip_address', 'string', ['limit' => 45, 'null' => true]);
  17. $this->addTimestampColumn($table, 'created_at');
  18. $table
  19. ->addIndex(['created_at'])
  20. ->addIndex(['actor_kind', 'actor_id'])
  21. ->addIndex(['target_type', 'target_id'])
  22. ->create();
  23. }
  24. }