Skip to content
FunnelGuard

Fix guide by FunnelsGuard

DB migration failed silently: how to find and fix it

OPS-302High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A database migration is a script that changes your database structure: adding a column, creating a table, changing a data type. It usually runs during a deploy, just before or after the new code goes live.

A migration fails silently when it errors, times out or only half-runs, and nobody is told. The deploy still shows green. Common causes: the migration step was skipped in the pipeline, the error was swallowed by a script that returns exit code 0, a lock or timeout stopped it midway, or it ran against the wrong database.

Why it costs you leads or sales

Pages may still load, so the site looks fine. But the parts that touch the database break: saving a lead, creating an order, applying a coupon, logging in. Visitors see a generic error, a spinner that never ends, or a thank-you page for a lead that was never stored.

How a failed migration loses a lead
  1. Ad clickVisitor lands on page
  2. Form submittedNew code sends the data
  3. Database writeColumn missing, query fails
  4. Lead in CRMNever created
  5. Follow-upNobody knows to call

The migration breaks the save step; everything after it is lost.

Leads saved per day around a deployExample numbers
Leads saved per day around a deploy (example)Day before deploy: 24 leads; Deploy day: 11 leads; Day after: 0 leads; Two days after: 0 leads0918241100Day before deployDeploy dayDay afterTwo days afterleads

Example: illustrative numbers showing leads dropping to zero after a deploy with a failed migration.

How to check if your site has it

Check whether the migration really ran
  1. Read the deploy log

    Find the migration step in your CI/CD or host log. Look for errors, timeouts, 'skipped' or a missing step altogether.

  2. Check migration status

    Run your framework's status command (for example php artisan migrate:status, rails db:migrate:status, python manage.py showmigrations, npx prisma migrate status). Look for pending or failed entries.

  3. Compare the schema

    Connect to the production database and confirm the new column, table or index exists and has the right type.

  4. Check application error logs

    Search for messages such as 'column does not exist', 'unknown column', 'no such table' or 'relation does not exist' since the deploy time.

  5. Submit a test lead and order

    Fill in your real form, then check the database and CRM for the record. Do not rely on the thank-you page alone.

Search logs for schema errors (adjust the path)bash
grep -iE "unknown column|does not exist|no such table|undefined column" /var/log/app/*.log | tail -n 50

How to fix it

Back up the database first. Then apply the fix that matches the cause. The exact commands depend on your framework or platform.

Fix by platform
  1. Back up the database

    Export it from your host panel or a backup plugin before touching anything.

  2. Re-run the plugin or theme update

    Many plugins run their table changes on update or activation. Deactivate and reactivate the plugin, or open its settings page, and check for a 'database update' notice.

  3. Verify the tables

    In phpMyAdmin or Adminer, confirm the expected tables and columns exist. Enable WP_DEBUG_LOG in wp-config.php to see database errors in wp-content/debug.log.

Deploy step that stops on migration failurebash
#!/usr/bin/env bash
set -euo pipefail

# Any failing command below stops the deploy
npx prisma migrate deploy
./restart-app.sh
Deploy pipeline

Silent failure

  • Migration errors are swallowed
  • Deploy shows green
  • Forms fail until someone notices

Fails loudly

  • Pipeline stops on a migration error
  • Team is alerted at once
  • A test lead confirms the save works

How to confirm it's fixed

Confirmation checks
  • Migration status shows no pending or failed entries
  • The new column or table exists in production with the right type
  • No new schema errors in the application log
  • A test form submission appears in the database, inbox and CRM
  • A test order or booking is created end to end (use test mode for payments)
  • Old leads lost during the gap are recovered from logs, backups or ad platform lead exports where possible

How to prevent it happening again

Prevention
  • Run migrations as a required pipeline step that blocks the release on failure
  • Test migrations on a staging copy of production data first
  • Keep migrations small, reversible and backwards compatible
  • Add a post-deploy smoke test that saves a record
  • Alert on spikes of database errors in your logs
  • Avoid deploying during peak ad hours so problems cost less
  • Record every deploy in a changelog
Example: how a silent failure unfolds
  1. 14:00

    Deploy finishes and shows green. Migration timed out unseen.

  2. 14:05

    New form code writes to a column that does not exist.

  3. Next morning

    Sales notices no new leads.

  4. Next morning +1h

    Migration re-run, test lead saved.

How FunnelGuard handles this

FunnelGuard detects this only partly. It cannot see your migration tool, deploy log or database schema. What it does is run your real customer journeys on a schedule, such as a lead form or checkout, and check each step. It also checks whether the test lead reaches your inbox and CRM. If a failed migration breaks the form or stops the lead arriving, the journey fails. A failure is re-checked from a second region, then you get one alert with a screenshot and a likely cause.

What it does not check: whether a migration ran, pending or half-applied migrations, schema differences, or database errors on parts of your site that no monitored journey touches. It also cannot tell you that a migration problem is the cause, only that a journey broke.

To cover the rest by hand: add a migration status check and a non-zero exit on failure to your pipeline, watch your logs for schema errors, and run a manual test lead after every deploy that includes a migration. Test traffic from FunnelGuard is marked (utm_source=funnelguard, fg_test=1), so you can filter those test records out of your data. The Free plan covers 1 site and 2 journeys with daily checks, and paid plans have a 3-day free trial.

Questions people ask

How do I know if a database migration failed?

Check your deploy log for errors, then run your framework's migration status command to look for pending or failed migrations. Confirm in the production database that the new column or table exists. Also search application logs for 'column does not exist' or 'no such table' errors.

Why did my deploy succeed but the form stopped saving leads?

The code likely expects a database change that never applied. The deploy only checks that the new code started, not that the migration completed. The form then fails on the missing column, or an error handler hides the failure.

Why is my migration only partly applied?

A timeout, table lock, crash or error midway can leave some changes applied and others not. This is more likely on large tables and on databases that cannot roll back schema changes inside a transaction. Inspect the schema and fix it with a corrective migration.

How do I stop migrations failing silently in CI/CD?

Make the migration a required step that returns a non-zero exit code on error, and stop the deploy when it does. Remove any commands that ignore failures, such as '|| true'. Add a post-deploy test that saves a real record.

Can I roll back a failed database migration?

Sometimes. If you wrote a down or reverse migration, you can run it, but only after checking what was actually applied. Restoring a backup is the safe fallback, though it may lose data written since the backup.

Can FunnelGuard detect a failed database migration?

Only partly. It does not read your migrations or schema, but it runs your lead form or checkout on a schedule and alerts you if the journey fails or the test lead does not reach your inbox or CRM. That catches the visible effect, not the cause.

Do I need a backup before fixing a migration?

Yes. Take a full backup before re-running or repairing any migration, because changes to a live database can be hard to undo. Test the fix on a staging copy if you can.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.