Detecting drift
Drift is when the live database no longer matches what NSchema recorded — someone ran a
manual ALTER, a hotfix added an index, or a column was dropped out of band.
nschema drift reports it.
How it works
Section titled “How it works”drift compares the recorded state against the live database and prints the difference
as a diff (recorded → live):
- an out-of-band addition appears as an add;
- a manual drop appears as a remove.
It’s a pure observation — no transformers or policies run, so it never fails on a policy violation. It just tells you what’s different.
nschema driftGating a monitor on drift
Section titled “Gating a monitor on drift”For a scheduled monitoring job, add --detailed-exitcode so the command’s exit status carries
the answer — 0 for no drift, 2 for drift (errors stay 1):
nschema drift --detailed-exitcodeA simple cron/CI check:
if nschema drift --detailed-exitcode; then echo "In sync."else case $? in 2) echo "Drift detected!" ;; # alert *) echo "drift check failed" ;; esacfiReconciling drift
Section titled “Reconciling drift”Once you’ve reviewed the drift, you have two ways to reconcile: