Skip to main content

Drift Detection

Schema Drift

Schema migrations on production databases should ideally be automated within CI/CD pipelines, keeping developers from needing root access. However, this setup isn't always the case, leading to Schema Drift, where database schemas drift from their intended state, causing inconsistencies and issues.

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.

You can use Atlas Schema Monitoring to detect schema drift and ensure your database schema are always in sync with their intended state. Atlas schema monitoring automatically detects schema drift by comparing the actual database schema with the intended schema. If a drift is detected, Atlas will notify you and provide detailed information about the drift, including an ERD, HCL and SQL of the diff.

Enabling Drift Detection

To enable drift detection, go the checks tab in Monitoring page and click on new 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.

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.

Drift Observability

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

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