LogicTrail
  • Trails
  • Check my app
  • Pricing
  • Sign in
  1. Trails
  2. /
  3. Data you can lose
  4. · 5 minutes · Free

The agent that reset production

You asked your to fix a failing . It says it 'reset the database to resolve drift'. Your live customers are gone.

This answers: How do I stop an AI agent deleting my database? No coding needed. 3 quick decisions.

  • Keeping data safe
  • Supervising your AI
  • Keys and secrets

Step 1 of 3

The agent ran the reset against the database in this file. Which database was it?

.env
# copied from the dashboard so the app "just works" locallyDATABASE_URL=postgres://postgres:••••@db.prod-eu.example.co:5432/postgres
Choose an answer

Pick one. You will see what really happens, and why.

How do I stop an AI agent deleting my database?

Do not keep production database credentials where the agent runs. Use a separate development database locally, give production a role that cannot drop tables, and keep backups the agent cannot reach. Instructions like 'never touch production' are not enough; only permissions reliably stop a destructive command.

Trail of the bug
  1. AI agent
  2. Your laptop
  3. Database

Breaks at Your laptop: .env holds the production URL

How it works

What you get back after a 4pm mistakePoint-in-time recovery
Backup 00:00Mistake 16:0024:00

Data lost: 16 hours

A daily backup restores midnight. Everything written between midnight and 4pm, sixteen hours of orders, is gone.

Why AI tools write this bug

Agents that hit a error often reach for a reset or drop command because it makes the error go away, and they use whatever connection string they find in .

How to fix it

  1. Use a local or branch database for development; never copy the production URL into .
  2. Give production a database role without drop or truncate rights for day-to-day use.
  3. Keep backups and outside the agent's reach.
  4. Review destructive commands before approving them, and never use auto-approve near production.

Check your own app

Paste this into Lovable, Cursor or Claude Code:

Without running any command, tell me: which database does each environment variable in this project point at (local, staging, production)? Which of those credentials could drop tables or delete data? Which scripts or commands in package.json or the migrations folder can reset or drop the database? Do not run anything.

Common questions

The agent says the data cannot be recovered. Is that true?
Not necessarily. Agents describe what they believe. Check your host's backups and point-in-time recovery yourself before accepting it.

Related scenarios

  • Approve this command?Free · 4 min
  • The key you deletedPro · 4 min
  • The key you pasted into chatPro · 4 min

More on this trail

Data you can lose: Agents that reset production, backups that are a day old, rollbacks that break.

Want someone to look?

We check AI-built apps for this and three other common leaks, in plain English.

Check my app
Sign in