Skip to content

Phase 1.1 — Foundation: AuditEvent enum + JSON snapshot migration#90

Draft
sjelfull wants to merge 1 commit into
v3from
foundation-enum-json
Draft

Phase 1.1 — Foundation: AuditEvent enum + JSON snapshot migration#90
sjelfull wants to merge 1 commit into
v3from
foundation-enum-json

Conversation

@sjelfull
Copy link
Copy Markdown
Owner

@sjelfull sjelfull commented Apr 26, 2026

Part of the v3 refactor stack for FRE-56. Closes FRE-124.

Diff: 7 files changed, 317 insertions(+), 11 deletions(-)
Tests: 49 → 69 (+20)
Verified on fresh DB: DROP DATABASE; pest green

Stack navigation

↑ Bottom of the stack — branches off v3
↓ Followed by #91 core-services-recorder (P1.2)

Review notes

  • Single-commit branch — review the commit, not just the diff
  • BC preserved — old AuditService API still works via @deprecated delegators
  • This is a draft — not a request to merge yet. Marked ready when the stack is approved end-to-end.

- Add src/enums/AuditEvent.php — backed enum with 45 cases mirroring
  existing AuditModel::EVENT_* string constants (same backing values
  for DB backward compat). Provides label() and tryFromString().
- Deprecate AuditModel::EVENT_* constants via docblock; kept for BC.
- Refactor AuditModel::createFromRecord() to decode snapshot as JSON
  (Json::decode with try/catch) instead of legacy base64(serialize()).
  Populate new $eventEnum property via AuditEvent::tryFromString().
- Update AuditService::saveRecord to write snapshot as Json::encode()
  instead of base64(serialize()) — matches the reader.
- Install.php: snapshot + location now $this->json(); add changedFields
  (JSON) and request (string(10)) columns; add composite indexes on
  (dateCreated, event) and (userId, dateCreated).
- New migration m260421_000000_snapshot_to_json.php: converts legacy
  base64(serialize()) / serialize() / JSON rows into a shadow JSON
  column, renames, same for location, adds composite indexes. Failed
  rows preserved with _migrationError marker.
- AuditRecord.php: docblock notes snapshot is JSON on disk.
- Test fixture updated to use plain JSON snapshot string.

Tests: 49 passed, 1 skipped (unchanged from baseline).
@sjelfull
Copy link
Copy Markdown
Owner Author

📚 Stack navigation

Part of the FRE-56 v3 refactor — 12-branch stack via git-spice. Merge in order: bottom-up, each PR rebases the next.

# Stage Title
#90 P1.1 Foundation — enum + JSON migration
#91 P1.2 Core services — recorder, diff, registry
#92 P1.3 15 field handlers
#93 P1.4 Project config tracking
#94 P1.5 UI — diff renderer + 20 templates
#95 P1.6 Tests — +19 coverage
#96 P2.1 Decompose — Element/User/UserGroup handlers
#97 P2.2 Decompose — 5 more handlers
#98 P2.3 Repoint event wiring
#99 P2.4 Tests — migrate to enum
#111 P2.5 CI — PHP 8.2/8.3/8.4 matrix
#110 P3.0 Docs — escape hatch (filter-records, getting-started, events)

Quick jump

(bottom of stack — branches off v3)#91 P1.2


📌 Reviewing: focus on the single commit. BC preserved via @deprecated delegators. Tests: 49 → 131 across the full stack, fresh-DB-verified per branch. CI: ECS + PHPStan green per branch.

@sjelfull
Copy link
Copy Markdown
Owner Author

sjelfull commented Apr 28, 2026

This change is part of the following stack:

Change managed by git-spice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant