Schema Drift Detection

This feature is available in Enterprise Plan.

Bytebase is supposed to take over applying the database schema changes on behalf of the user. It records the detailed migration history and the before/after schema snapshot for each migration it applies.

Drift usually happens when user applies out-of-band schema changes (such as hot fix) directly to the database without using Bytebase.

Simulate

You can simulate schema drift by using Admin mode within Bytebase SQL Editor. It's similar to operating within your terminal.

Visit SQL Editor, connect a database and click the gold wrench icon to enter Admin mode.

admin-mode-entry

You can make some Schema change here. Then Exit.

admin-mode-ddl

Detect

Bytebase has a background process to periodically compare the recorded latest schema with the actual schema in the live database and surface the drift if found. The check interval is configured in Scan Interval.

You can also click Sync Database manually from the database detail page to check drift immediately.

Schema Drift is detected and displayed under Anomalies section.

schema-drift-detected

Click View diff to see the drift details.

view-diff

Remediate

There are 2 options to remediate the schema drift:

  • Baseline: Use the live database schema as the source of truth. And establish a new baseline for the Bytebase schema state.
  • Revert: Use the Bytebase schema state as the source of truth. And revert the live database schema.

Baseline

Within Sample Project, go to Database > Databases. Click and enter detail page of database hr_prod, go to Change History page.

Establish new baseline from top right, you'll be redirected to an issue page. Create this issue on top right and it rolls out automatically. The newly created baseline appears in Change History.

baseline

Revert

Check the schema drift detail, figure out the rollback SQL statements, and create a Bytebase issue to rollback.

Edit this page on GitHub

Subscribe toΒ Newsletter

By subscribing, you agree with Bytebase's Terms of Service and Privacy Policy.