1
0

20260501120000_add_audit_target_label.php 899 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. declare(strict_types=1);
  3. use App\Infrastructure\Db\Migrations\BaseMigration;
  4. /**
  5. * The numeric `target_id` is rarely meaningful to a human reader of the
  6. * audit log. Add a sibling `target_label` column carrying the most
  7. * descriptive identifier for the entity at the moment the event was
  8. * recorded (reporter/consumer/policy name, category slug, IP/CIDR text,
  9. * job name, token prefix). Frozen at write time — renaming the entity
  10. * later does not rewrite history.
  11. */
  12. final class AddAuditTargetLabel extends BaseMigration
  13. {
  14. public function up(): void
  15. {
  16. $this->table('audit_log')
  17. ->addColumn('target_label', 'string', ['limit' => 255, 'null' => true, 'after' => 'target_id'])
  18. ->update();
  19. }
  20. public function down(): void
  21. {
  22. $this->table('audit_log')
  23. ->removeColumn('target_label')
  24. ->update();
  25. }
  26. }