Schema Drift Detection
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.
You can make some Schema change here. Then Exit.
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.
Click View diff to see the drift details.
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.
Revert
Check the schema drift detail, figure out the rollback SQL statements, and create a Bytebase issue to rollback.