Recovering from DROP TABLE in Neon
Whether you typed it yourself or your AI agent did, here's exactly what to do after a DROP TABLE hit your Neon (Postgres) — best options first, honest about the rest.
First, in the next 60 seconds
- 1. Stop all writes. Quit the app, pause the agent, and don't run another query — every write reduces what you can recover.
- 2. Don't restart, vacuum, or checkpoint the database. Those steps can permanently overwrite recoverable data.
- 3. Make a copy of the current state now (a dump, a snapshot, or the raw file) before you attempt anything.
What just happened
A DROP TABLE removes the table definition and every row in it in one shot. The structure and the data are both gone, and on most engines it auto-commits immediately, so there is no transaction left to roll back.
Your recovery options in Neon, best first
- 1
Branch from a point in time
Neon keeps a history of your data. In the console, create a new branch from a timestamp just before the destructive query, then point your app at that branch or copy the affected table back. This is Neon's single best recovery feature for exactly this situation.
- 2
Restore to a timestamp (time travel)
Neon's restore lets you reset a branch to an earlier moment inside your history-retention window. Restore to just before the bad statement — only data written after that point is lost.
- 3
Roll back if the transaction is still open
Neon is plain Postgres: if the destructive statement has not been committed yet,
ROLLBACK;undoes it instantly. - 4
Restore your own pg_dump
If you (or OopsDB) took a
pg_dump, restore it into a fresh Neon branch or database and copy the table back.
If you have no backup
Neon's history retention depends on your plan (e.g. 24 hours on free, longer on paid). If the destructive query is older than your retention window and you kept no dump, it is past Neon's reach. Check your retention setting now — and widen it.
Make sure this never happens again
The honest truth: your coding agent will eventually run DROP TABLE again. The fix isn't to trust it more — it's to keep an automatic, recent snapshot so a bad query is a 30-second rollback instead of a lost weekend.
OopsDB takes an encrypted snapshot of your Neon (Postgres) every few minutes and restores it with one command. It's free, open-source, and runs entirely on your machine — set it up in two minutes and the next DROP TABLE won't cost you anything.
Free & open-source for local backups · optional €8/mo cloud vault keeps a copy off your machine · cancel anytime.