Telemetry
Database reliability SQL recipe

Track Database Migration Failures by Release

Compare database migration success, failure, rollback, and duration by application release before completing a rollout.

Beginnerdatabase_migration_eventsReviewed 2026-07-28Tested with Apache DataFusion 45.2.0

Reviewed by the Telemetry product team on . SQL compatibility, event contract, synthetic output, and operational caveats. Editorial ownership

Question answered

Which releases contain failed or rolled-back database migrations?

A deploy can appear healthy while a partially applied migration leaves later application requests at risk. Recording one terminal migration outcome makes release readiness inspectable.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampTerminal migration time in UTC.
migration_idUtf8Stable migration identifier from source control.
serviceUtf8Service or deploy job that ran the migration.
database_nameUtf8Approved logical database name.
releaseUtf8Application or infrastructure release.
statusUtf8success, failed, or rolled_back.
duration_msFloat64Migration execution duration.
error_typeUtf8Controlled failure category without raw database output.
environmentUtf8Deployment environment.
DataFusion SQL

Copy the query

sql
SELECT
  release,
  service,
  database_name,
  COUNT(*) AS migrations,
  SUM(CASE WHEN status = 'success' THEN 1 ELSE 0 END) AS successful,
  SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) AS failed,
  SUM(CASE WHEN status = 'rolled_back' THEN 1 ELSE 0 END) AS rolled_back,
  100.0 * SUM(CASE WHEN status = 'success' THEN 1 ELSE 0 END)
    / NULLIF(COUNT(*), 0) AS success_rate_pct,
  AVG(duration_ms) AS average_duration_ms
FROM database_migration_events
WHERE timestamp_utc >= now() - INTERVAL '30 days'
  AND environment = 'production'
GROUP BY release, service, database_name
ORDER BY release DESC;

This read-only query is planned and executed against an empty typed table with Apache DataFusion 45.2.0. The deterministic sample output is synthetic and reviewed separately; validate field types, thresholds, and business definitions against your own data. Read the testing methodology.

Query result

Migration success rate by release

The newer release contains both a failed and a rolled-back migration and should not be treated as complete.

releaseservicedatabase_namemigrationssuccessfulfailedrolled_backsuccess_rate_pctaverage_duration_ms
2026.07.2application-apiapp_production5311601,470
2026.07.1application-apiapp_production5500100890

Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.

Migration success rate by release: static chart of synthetic success_rate_pct values from the Track Database Migration Failures by Release example result
Indexable SVG of the deterministic example output. Download it for an article, runbook, or design review with attribution.

Reproduce the example

Download the public fixture

The JSON bundle includes the typed event contract, reproducible input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.

How the SQL works

  1. 1One terminal row per migration prevents start and retry events from inflating the denominator.
  2. 2Failed and rolled-back outcomes remain separate because a successful rollback still means the migration did not ship.
  3. 3Release, service, and database identify the exact rollout boundary that needs review.

Edge cases to decide

  • Some migration tools retry automatically. Preserve attempt count separately while emitting one terminal outcome.
  • A successful migration can still be logically wrong; pair this view with application health and post-deploy validation.
  • Do not log raw DDL, connection strings, or unrestricted database error text.

Recommended dashboard

  • Bars: success_rate_pct by release
  • Table: failed and rolled-back migration IDs
  • Trend: migration duration and count by deploy

Alert guidance

Block rollout completion when any production migration has a failed or rolled-back terminal outcome.

Read alert setup

Put the recipe to work

Related instrumentation and guides

Continue the analysis

Run it on real events

Create a table, adapt the fields, and save the result

Start free, send structured events, and use the query result as a chart, shared dashboard widget, or alert input.

Get an API key