Skip to main content

Schema Drift Detection (Database Drift)

What is Schema Drift?

Schema migrations on production databases should ideally be automated using CI/CD pipelines, preventing developers from needing root access. However, not every team follows this setup, allowing developers to make direct changes to production databases. This leads to Schema Drift, or database drift, where the live database schema deviates from its intended, version-controlled state.

Schema drift is dangerous because it can lead to unexpected behavior in applications, data corruption, and even system outages. When the actual database schema deviates from the expected schema, queries may fail, data integrity constraints may be violated, and application logic may break. Additionally, schema migrations are planned based on the assumption the target database is in a specific state and may fail and cause unknown side effects. This can result in hard-to-debug issues and degraded system performance, ultimately affecting the reliability and stability of your application.

Atlas Schema Monitoring detects schema drift and ensures your database schemas are always in sync with their intended states. Atlas automatically detects schema drift by regularly comparing the actual database schema with the intended schema. If a difference is found, Atlas will notify you and provide detailed information about the drift, including an ERD and HCL or SQL representations of the diff. The following sections will show how to set up automated schema drift detection and monitoring for your database with Atlas.

Automated Monitoring Benchmarks

Atlas reports key schema drift monitoring benchmarks, including:

  • Detection speed: real-time comparison with minimal performance impact
  • Scope coverage: database-to-database and database-to-deployment comparisons
  • Alert integration: instant Slack notifications and webhook support
  • Reporting depth: visual ERDs, HCL/SQL diffs, and comprehensive drift history

Enabling Schema Drift Detection

To enable drift detection in Atlas Cloud, go to the Checks tab in the Monitoring page and click on new button.

Enable Drift Detection Button

You can compare the snapshot scope schema with another scope's schema or with a deployed migration target.

Choose the Database to deployment card and fill in the required fields.

Configure Drift Detection from Deployed Migration

Drift Notifications

You can create a Slack notification to receive alerts when a drift is detected. Click on the Setup Slack Notification checkbox and fill the URL of your Slack integration.

You will receive a notification in your Slack channel whenever a drift is detected.

Slack Notification for Database Drift

Database Drift Observability

Once drift is detected, click on the view link in the table to review its details.

Drift Detection History Table

Atlas will provide you with detailed information about the drift, including an ERD, HCL and SQL diff.

SQL Diff View for a Detected Drift