TKO-16Required
Give each table one writer during the move
While two systems run side by side, let only one of them write each table. The other reads it or gets copies through events.
How to do it
Two systems that both write the same rows overwrite each other, and the losing change is gone without an error. Mark the writer of every table in the system map. Move the writer of a table in the same step as the route that changes it. When the other system needs the data, send it events through an outbox, as Send side effects through an outbox says. Enforce the split with database grants, not with a promise.
Examples
SQL example
-- The new app owns invoices. The builder app may only read them.
REVOKE INSERT, UPDATE, DELETE ON invoices FROM builder_app;
GRANT SELECT ON invoices TO builder_app;
GRANT SELECT, INSERT, UPDATE ON invoices TO new_app;
How to check
The system map names one writer per table. An insert into each table with the other system's database credentials fails with a permission error.
Sources
Related rules
- TKO-5 Map the system before changing it in Codebase takeover
- DAT-18 Send side effects through an outbox in Data and databases
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder/one-writer-per-table">Agent Wranglers codebase takeover playbook</a>. In code you write, add a comment next to it with the same link.