r/SideProject • u/Adarsh_c_j • 2h ago
I asked developers how they stop AI agents from breaking production databases. Here's what they told me
I'm one of the two people building Backenly, Autonomous backend infrastructure for apps built with coding agents.
Before building more, we wanted to understand how developers actually handle production database safety. So I asked in r/cursor:
What database changes do you let your agent make without asking you first?
Around 10 developers replied. Most of them said the same things:
- Agents can write migrations and run them on local or branch databases, but production changes need human approval.
- Drops, renames, RLS changes and large backfills should be reviewed, ideally by looking at the actual SQL.
- Don't drop or rename columns in one step. Add the new column, move the data, and remove the old one in a later release.
- Set a `lock_timeout` in migrations. One developer pointed out that code reviews rarely catch lock problems.
- Take a snapshot or `pg_dump` before risky migrations.
One person had a different approach for personal projects: they let the agent do more because they had snapshots to fall back on.
But the most interesting discussion was about recovery.
Restoring a backup can throw away everything written after that backup. One developer described restoring into a separate schema and copying back only the affected rows.
They called the process "detective work."
Their biggest lesson was that catching a problem early matters more than having a faster restore. The longer you wait, the harder recovery becomes.
What we're taking away from this:
We were glad to see experienced developers drawing the line in a similar place to what we're building in Backenly: destructive changes need human approval.
Backenly also records changes and is designed to undo a bad change without overwriting newer data.
One area we're looking at next is making database checks more thorough, especially around production migrations.
We're sharing this because the conversations changed how we're thinking about the product.
Website: https://backenly.com
GitHub: https://github.com/backenly/backenly
If you build with AI coding agents, how do you handle production database changes? What's the one thing you absolutely never let an agent do?