How to Roll Back a Bad Deploy in Five Minutes

· 7 min read ·
vibe-coding launch deployment rollback

A man in a green sweater turns a rewind dial while a small white robot waves a green flag, and a monitor shows a wobbly block house standing straight again

To roll back a bad deploy, tell your host to serve the last build that worked. On Vercel, Netlify, Cloudflare Pages and Railway that is a button, and the old version is live in seconds. Do that first, check the live site, and only then work out what went wrong.

The usual mistake is the opposite order: you push a quick fix to a broken production app, the fix is also wrong, and now two deploys are in the way. A rollback is not an admission of failure. It buys you time to fix things calmly.

Here is the five-minute version, then the traps that make it take an hour.

The five minutes

  1. Stop pushing. Every new deploy is another variable.
  2. Find the last good deploy in your host’s deployment list. It is the one before the deploy that broke things.
  3. Roll back with the host’s button (below).
  4. Load the live site yourself. Log in, do the one thing that was broken, and confirm it works.
  5. Check your data. Did the bad version write anything wrong or run a database change? This is the step with the real trap, and it has its own section below.

Only after that do you fix forward, on staging, as in staging vs production.

How to roll back on each host, and what bites

HostWhereThe gotcha
VercelProject, Production Deployment tile, Instant RollbackAfter a rollback, Vercel turns off auto-assignment of production domains. New pushes will not go live until you promote a deployment. Hobby plans can only roll back to the previous deployment.
NetlifyDeploys list, open a good deploy, Publish deployWith auto publishing on, the next Git push overwrites your rollback. Use Lock to stop auto publishing first.
Cloudflare PagesDeployments, roll back to a previous production deploymentDeployments older than 30 days are deleted, except your 100 most recent and the current one.
RailwayService, Deployments, three dots, RollbackNeeds the old image to still exist: 24 hours on Free, 72 on Hobby, 120 on Pro. After that you can only Redeploy, which rebuilds.
LovableVersion history, Revert, then publish againRevert restores code only, not your database.

Sources: Vercel, Netlify, Cloudflare Pages, Railway, Lovable.

The two gotchas that are the exact opposite of each other deserve a closer look. On Vercel, you roll back, fix the bug, push, and nothing changes, because Vercel stopped auto-assigning production domains. You undo the rollback by promoting a deployment, from the dashboard or with vercel promote (docs). On Netlify the danger is the reverse: you roll back, a teammate or your own tool pushes to main, and the broken code goes live again, because auto publishing was still on. Same button, opposite trap.

Two smaller ones. Vercel does not change environment variables when you roll back, so if the bad deploy came from an env var you edited, the rollback will not fix it. Railway restores the previous deployment’s variables along with its image, so there the rollback does revert a bad variable change. And in Lovable, the live site shows the version you last published, so after you revert, publish again, then load the live URL to confirm.

What about the database?

Rolling back code does not roll back data. If the new release changed your database before it went bad, the old code now runs against a database it does not recognize.

Say the new release renames the users.name column to full_name. The migration runs, the release breaks for a different reason, you roll back, and now the old code asks for a column that no longer exists. Here is a scratch version you can run with node --test on Node 22.13 or newer (older 22.x needs the --experimental-sqlite flag), with package.json set to {"type":"module"}. The old code:

// app.js (the code you would roll back to)
export function greeting(db, id) {
const row = db.prepare("SELECT name FROM users WHERE id = ?").get(id);
return "Hi " + row.name;
}

The new release’s migration, written the tempting way:

migrations.js
export function migrate(db) {
db.exec("ALTER TABLE users RENAME COLUMN name TO full_name");
}

And a test of what a user sees after rolling back:

app.test.mjs
import { test } from "node:test";
import assert from "node:assert";
import { DatabaseSync } from "node:sqlite";
import { greeting } from "./app.js";
import { migrate } from "./migrations.js";
function liveDb() {
const db = new DatabaseSync(":memory:");
db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
db.exec("INSERT INTO users VALUES (1, 'Asha')");
return db;
}
test("after rolling back, a user still sees their name", () => {
const db = liveDb();
migrate(db); // the new release ran its migration before it went bad
assert.equal(greeting(db, 1), "Hi Asha");
});

Run it and it fails with no such column: name. That is your rollback failing in production. Now write the migration so the old code survives, by adding the new column and copying the data instead of renaming:

export function migrate(db) {
db.exec("ALTER TABLE users ADD COLUMN full_name TEXT");
db.exec("UPDATE users SET full_name = name");
}

The test passes. One catch, checked in the scratch run: while the old code is live after a rollback, it writes only name. Rename a user or add one during that window and full_name goes stale or stays null, so rolling forward shows blank names. A trigger that copies name into full_name on every insert and update closes the gap (in SQLite it is two small CREATE TRIGGER statements, in Postgres a function plus a trigger). After the old code is gone, run the copy once more, then drop name. Engineers call this an additive migration: add first, switch the code over, and drop the old column in a later release once you are sure you will not roll back. The test checks what a user experiences, not how the migration is written, so any future change that makes rollback unsafe fails it.

What if the bad release dropped or rewrote data? Rolling code back cannot bring rows back. That takes a database backup. On Supabase, Pro projects keep the last 7 days of daily backups, and Point-in-Time Recovery is a paid add-on for Pro and above (backups docs). Find where restore lives and what plan you have before the first outage, and include it in your drill below.

This is also why Lovable’s default matters. Its built-in backend setting for backward incompatible database migrations, such as dropping or renaming a column, is “Never allow” by default (Lovable docs). Leave it that way. Lovable’s own docs add that reverting a version does not undo database changes (version history).

Rolling back in Git too

A host rollback fixes what users see. Your repository still contains the bad commit, and the next push will redeploy it. Undo it in Git with git revert, which adds a new commit that cancels the bad one and leaves history intact:

Terminal window
git log --oneline
# e4a3937 v3 bad deploy
# 8af53f1 v2: additive migration
git revert --no-edit HEAD
git log --oneline
# 743e9b6 Revert "v3 bad deploy"
# e4a3937 v3 bad deploy

That reverts exactly one commit. If the bad release was two commits, revert the range, oldest first: git revert --no-edit <first>^..<last>. If it came in as a merged pull request, git revert HEAD stops with “is a merge but no -m option was given”, so use git revert -m 1 <merge commit> to keep the main line. Both cases were run in a scratch repo. Avoid git reset --hard plus a force push on a shared branch. It rewrites history for everyone, and it is exactly the kind of command to keep your AI tool from running unasked (more in git for vibe coders).

A prompt to start with

Write a rollback plan for this app. Name the host and the exact steps to roll back to the previous deploy. Say what happens to environment variables and to the database on rollback. Review every database migration in this repo and list any that would break the previous version of the code, such as dropped or renamed columns. Do not change anything yet.

The one check an engineer does by hand

Do a rollback drill while nothing is wrong. Roll back to the previous deploy, load the live site, then roll forward again. Note how long it took, because that is your real rollback time. It takes five minutes and tells you whether the button exists on your plan (Vercel Hobby only offers the previous deployment), whether you can find the last good deploy, and whether pushing again actually goes live afterwards. Nobody wants to learn those answers during an outage.

A rollback also belongs next to the other safety nets on the launch checklist. If a quick patch tends to break something else, read why an AI fix breaks two things.

The Get AI Native ebook goes deeper on this. It is free, and the expected launch is around Christmas. Join the waitlist on the homepage.

Comments