---
title: "Give each table one writer during the move · Agent Wranglers"
url: https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder/one-writer-per-table
id: TKO-16
level: Required
risk: data
updated: 2026-10-22
tokens: 796
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Give each table one writer during the move

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Leaving an AI builder](https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: TKO-16
- Level: Required
- Chapter: [Leaving an AI builder](https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder.md)
- Rule: While two systems run side by side, let only one of them write each table. The other reads it or gets copies through events.
- 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.
- Risk: Data leaked or lost
- How: 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](https://agentwranglers.se/playbook/codebase-takeover/triage/system-map.md). 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](https://agentwranglers.se/playbook/data/transactions-and-concurrency/outbox.md) says. Enforce the split with database grants, not with a promise.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### SQL example

```sql
-- 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;
```

## Sources

- [AWS Prescriptive Guidance on strangler fig data synchronization](https://docs.aws.amazon.com/prescriptive-guidance/latest/cloud-design-patterns/strangler-fig.html)

## Related rules

- TKO-5 [Map the system before changing it](https://agentwranglers.se/playbook/codebase-takeover/triage/system-map.md) in Codebase takeover
- DAT-18 [Send side effects through an outbox](https://agentwranglers.se/playbook/data/transactions-and-concurrency/outbox.md) in Data and databases

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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.

- Previous: [Put a router in front and move one route at a time](https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder/strangler-router.md)
- Next: [Compare old and new answers before switching a route](https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder/shadow-compare.md)
- [Leaving an AI builder](https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder.md)
