Trigger remediation
Led the deprecation of brittle DB triggers and stored procedures by translating their behavior into testable, domain-shaped services in the application layer.
47
triggers retired
3 teams
coordinated across
0
behavior regressions
- Role
- Tech lead
- Timeline
- Jan 2024 - ongoing
- Stack
- PostgreSQL, PHP, PHPUnit
- Tags
- Postgres, Refactor
§Context
A decade of business rules had quietly migrated into Postgres triggers and stored procedures. They were correct, mostly, but invisible to the application, untestable, and a constant source of surprise during incidents.
§What I did
- Built a small framework for capturing existing trigger behavior as characterization tests, so we could refactor without trusting our memory of the spec.
- Translated each trigger into a domain-shaped service in PHP, leaving the trigger in place as a verifier until the new path matched 1:1.
- Coordinated three teams' rollouts on a shared cutover plan, so no two teams were moving the same surface at once.
§Outcome
47 triggers retired so far, zero observable behavior changes, and a small library of patterns the next team picked up without asking.