I Let AI Handle My Database and Lost Everything
I messed up.
I was letting AI (Claude) handle implementation, and I didn’t take backups. My work just vanished.
The worst part? The “partially correct fixes” I’d made along the way were all gone too.
What Happened
Things got confusing midway through, so I decided to start over.
AI rolled back to a much older backup.
That was it. Everything I’d correctly fixed after that point — gone.
The Real Problem
Code was fine. I use Git, so I could trace the history and recover code changes quickly.
The problem was data.
I’d been letting AI modify the database directly. There was no record of what changed or how.
That’s the kind of thing that quietly kills you.
Why I Didn’t Set Up Backups
Sure, you could say “just sync DB backups with every Git commit.”
But here’s why I didn’t:
- AI-driven development generates a lot of commits (constant trial and error)
- Backing up on every commit makes history untrackable
- You can’t tell which backup is the correct one
- It wastes disk space
And fundamentally — backups preserve state, but not history.
That’s the real weakness.
What I Realized
When you let AI handle things:
- Speed goes up
- But state management gets sloppy
A human would feel “this seems risky” and pause. AI has no fear. It just acts.
And situations like this — where AI deletes its own correct changes — happen naturally.
The Fix
One rule: manage all DB changes via SQL scripts.
- No direct database modifications
- All changes written as explicit SQL scripts
- Committed to Git
Why This Works
- Reproducible anytime
- Easy to find where things broke
- Diffs are visible
- Can be enforced as a rule for AI too
The key insight: manage procedures, not state.
What I Did
I added rules to CLAUDE.md:
- All DB changes must be output as SQL scripts
- Direct modifications are prohibited
- SQL scripts must be committed to Git
Make AI follow the rules too.
Takeaway
AI is capable, but it won’t manage your history for you.
Skip this, and you’ll silently lose hours.
The lesson: Always codify your data changes.