Skip to content
Documentation

Schema Diff

Side-by-side schema shape comparator that emits an idempotent mongosh migration script. Useful as a PR gate or before a major refactor.

What it is

A workspace tab that compares two schema shapes (paste JSON or sample from a live connection) and renders the differences in a side-by-side panel. The Migration tab emits a mongosh script you can run on the target to make it match — safe to re-run because every step is idempotent.

When to use

Wire as a PR gate so a teammate cannot land a schema change without a generated migration plan. Run before a major refactor to see exactly what fields and types differ between branches. Run after a refresh to confirm dev / staging matches production.

How to open

  1. In the NoSqlStudio desktop app, open the Tools menu → Schema Diff, or press Ctrl+Alt+Shift+D.
  2. The workspace opens with two paste areas (Source and Target) at the top, a diff panel in the middle, and the Migration tab at the bottom.
  3. Paste two schema shapes (sample documents work too — the engine infers the shape) and click Compare.

Workflow

  1. Source — paste the desired schema shape (typically the production sample or the target after refactor).
  2. Target — paste the current shape on the receiving cluster (dev or staging).
  3. Diff — the engine renders added fields (green), removed fields (red), and type changes (yellow). Click any row to see the actual field path and inferred BSON type.
  4. Migration — switch to the Migration tab. The engine emits a mongosh script using $set/$unset/$rename + collMod for index changes. The script is idempotent — running it on an already-converged target is a no-op.
  5. Copy or download the script. Run it from mongosh on the target, then re-run Compare to confirm the diff is empty.

Limitations (v1)

  • Inference is sample-based. If your schema has rare branches that did not appear in the sample, the engine misses them — set sample size to cover representative documents.
  • Migration script handles fields and indexes; it does not handle views, search indexes, or time-series collections. Wire those separately.
  • No transactional guarantee — the generated script runs each step independently. For multi-document consistency you must wrap it yourself in a session.startTransaction block.