Skip to content
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 . We checked the SQL syntax, required event fields, sample results, and limits on using the query. Who reviews this page

Question answered

Which releases contain failed or rolled-back database migrations?

A deploy can appear healthy even when a migration stopped halfway through. Record the final migration status so you can check whether the database is ready for the release.

Event schema

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. We review the synthetic sample output separately. Check field types, thresholds, and counting rules 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
Download this SVG chart of the sample results for an article, runbook, or design review. Please credit Telemetry.

Reproduce the example

Download the sample data

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

How the SQL works

  1. 1One final 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. 3Use release, service, and database fields to find which deployment needs review.

Edge cases to check

  • Some migration tools retry automatically. Preserve attempt count separately while emitting one final 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 final outcome.

Read alert setup

Set up the events this query needs

Related instrumentation and guides

Continue the analysis

Run it on your 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