Skip to content

Navid's Blog

Ideas, Experiments, and Lessons Learned

Menu
Menu

I Gave AI Full Access to Our Production Database. Here’s What Happened

Posted on April 5, 2026 by Navid

I know what you’re thinking. “Navid, you’re insane.” And maybe you’re right. But here’s the thing — I was curious. How far can these AI coding tools actually go when you stop holding their hand?

So I did something stupid. I gave an AI assistant full access to our staging environment with write permissions to the database. Not production (I’m not that crazy… yet). But close enough to hurt.

The Setup

We were working on a data migration script. The kind of thing that sounds simple but has about 47 edge cases. I thought, “Let me see what this thing can do.”

I asked the AI to write a migration script that would:

  • Find all users who hadn’t logged in for 6 months
  • Archive their data to a separate table
  • Update their account status
  • Send them an email notification

Seemed straightforward. The AI wrote the script in about 30 seconds. Looked clean. Looked good. I ran it on staging.

What Went Wrong

Within 2 minutes, I had 847 users in the wrong state. Here’s what happened:

The AI made an assumption that didn’t match our business logic. It archived users who had never logged in at all, not just users who stopped logging in. Those are different things in our system. New users who signed up yesterday? Gone. Well, archived. Same thing when you don’t have backups.

It also used DELETE instead of archive in one of the queries. One tiny word. Wiped out 200 rows before I killed the process.

What I Learned

AI is amazing at writing code. It’s terrible at understanding your business logic, your edge cases, or what happens when things go sideways.

Here’s the thing — the code itself was solid. No syntax errors. Proper SQL. The logic just didn’t match what we actually needed.

Now I use a different approach:

  1. AI writes the skeleton — Give it the structure, the boilerplate, the boring parts
  2. Human provides context — Explain the weird business rules, the exceptions, the things that aren’t in any docs
  3. Human reviews everything — Especially anything touching data
  4. Never give AI write access — Just… don’t. Ever.

The Takeaway

AI tools are incredible for productivity. They’ve saved me hours on repetitive tasks. But the moment you trust them with something that can cause real damage, you’re setting yourself up for a bad day.

The best developers I’ve seen treat AI like an intern who’s really good at coding but has zero domain knowledge. You can delegate the work, but you can’t delegate the responsibility.

Still — would I do it again? Maybe. But next time, definitely not on staging.

Categories

  • AI Experiments
  • Coding
  • Debugging Stories
  • Hot Takes
  • Ideas
  • Lessons Learned
  • Project Management
  • Uncategorized
  • Vibe Coding

Recent Posts

  • Why I Stopped Using Microservices for Small Projects
  • I Gave AI Full Access to Our Production Database. Here’s What Happened
  • 5 API Design Mistakes I Learned the Hard Way
  • 5 API Design Mistakes I Learned the Hard Way
  • My Team Spent 2 Weeks Replacing Our Authentication — Here’s What Happened