Real-world scenarios
Seven situations teams meet every week. Each terminal below is produced by the real CLI on a small sample project when this site is built.
The projects are illustrative, not customer stories. The commands, rules and output are real.
| # | Situation | Who cares | Result |
|---|---|---|---|
| 1 | A cleanup drops a column and a table | Developer, DBA | NO_GO |
| 2 | A new required column on a busy table | DBA, SRE | REVIEW_REQUIRED with warnings |
| 3 | A framework major upgrade | Developer | Safe rehearsal, REVIEW_REQUIRED |
| 4 | Builds that change on their own | Platform team | Pinning findings |
| 5 | Code changes after the scan | Reviewer | Plan refused |
| 6 | A pull request gate | CI owner | Exit code 1 |
| 7 | Proving the fix worked | Auditor | One finding resolved |
1. The Friday cleanup that drops a column#
Situation. A developer tidies the schema late in the week. One migration removes a column and a table. An old report job still reads both.
$ migrasutra audit --root . --out report audit completed: report (audit.json, audit.md, audit.html) Verdict: NO_GO (high 2, medium 0, low 0) HIGH SQL_DROP_COLUMN db/migrations/014_cleanup.sql:1 HIGH SQL_DROP_TABLE db/migrations/014_cleanup.sql:2 exit code: 0
What to do. Do not drop in the same release that stops using the data. Follow expand-contract:
- 1. ExpandAdd the new column as nullable. Old code keeps working.
- 2. Dual writeThe application writes both old and new columns.
- 3. BackfillCopy history in small batches. Check the counts.
- 4. Switch readsRead the new column. Keep the old one for rollback.
- 5. ContractAfter a safe window and a tested restore, drop the old column.
Limit. The tool cannot know who still reads the column. Search your consumers before you contract.
2. A new required column on a busy table#
Situation. Product wants a mandatory region field. The migration adds it as NOT NULL, builds an index and renames a column in one step.
$ migrasutra audit --root . --out report audit completed: report (audit.json, audit.md, audit.html) Verdict: REVIEW_REQUIRED (high 0, medium 2, low 1) MEDIUM SQL_NOT_NULL_NO_DEFAULT migrations/022_add_region.sql:1 LOW SQL_INDEX_NOT_CONCURRENT migrations/022_add_region.sql:2 MEDIUM SQL_RENAME migrations/022_add_region.sql:3 exit code: 0
Why it matters. Adding a required column without a default fails on a table with rows. A plain index build can block writes on PostgreSQL. A rename breaks any server still running the old code.
Safer version.
ALTER TABLE customers ADD COLUMN region text;
-- backfill in batches, then add the constraint
CREATE INDEX CONCURRENTLY idx_region ON customers(region);Limit. CREATE INDEX CONCURRENTLY is PostgreSQL syntax and cannot run inside a transaction. Check your engine.
3. Moving a web framework to a new major#
Situation. A team wants to move express from 4 to 5 and needs a reviewable first step.
$ migrasutra audit --root . --out report --target npm:express@5.0.0 audit completed: report (audit.json, audit.md, audit.html) Verdict: REVIEW_REQUIRED (high 0, medium 0, low 0) (no static findings; this is not proof of safety) rehearsal: STATIC_CHANGE_VERIFIED app tests: NOT_RUN rollback: DOCUMENTED_NOT_TESTED exit code: 0
What to do. Read the vendor upgrade notes, apply the change on a branch, install in an isolated environment and run your tests. The report lists these as prerequisites.
Limit. The rehearsal proves the manifest edit only. It does not prove the application works.
4. Builds that change on their own#
Situation. The same commit builds differently on two days. Nothing in the code changed.
$ migrasutra audit --root . --out report audit completed: report (audit.json, audit.md, audit.html) Verdict: REVIEW_REQUIRED (high 0, medium 4, low 0) MEDIUM DOCKER_UNPINNED_BASE Dockerfile:1 MEDIUM NPM_NO_LOCKFILE package.json:1 MEDIUM NPM_NONREPRODUCIBLE package.json:1 MEDIUM PYTHON_UNPINNED requirements.txt:1 exit code: 0
What to do. Pin the base image by digest, pin Python requirements with ==, replace latest with a real version and commit a lockfile.
5. Someone edits the code after the scan#
Situation. A reviewer approves a scan. Before the plan is created, a teammate changes package.json.
$ migrasutra scan --root . --out scan.json scan completed: scan.json # a teammate edits package.json $ migrasutra plan --root . --scan scan.json --target npm:express@5.0.0 --out plan.json MigraSutra: Scan is stale: package.json changed exit code: 2
Why it matters. An approval should apply to the exact content that was reviewed. The hash mismatch stops the flow. Scan again.
6. Blocking a pull request in CI#
Situation. A pipeline must stop destructive migrations before merge.
$ migrasutra audit --root . --out report --fail high audit completed: report (audit.json, audit.md, audit.html) Verdict: NO_GO (high 1, medium 0, low 0) HIGH SQL_TRUNCATE migrations/001.sql:1 exit code: 1
- run: npx migrasutra audit --root . --out migrasutra-report --fail high
- uses: actions/upload-artifact@v7
if: always()
with:
name: migrasutra-report
path: migrasutra-reportWhat to do when a finding is intended. There is no suppression file yet. Review the finding, record the approval in the pull request and run the step as advisory for that change.
7. Proving the fix worked#
Situation. An auditor asks for proof that the risky statement is gone.
$ migrasutra scan --root . --out before.json # fix: add a WHERE clause $ migrasutra scan --root . --out after.json $ migrasutra compare --before before.json --after after.json --out diff.json introduced: 0 resolved: 1 (SQL_DELETE_UNSCOPED) unchanged: 0 decision: REVIEW
Limit. The comparison tracks findings by file, line and rule. Moving a statement to another line shows it as resolved and introduced.