Revisions can be given as full ids, unique prefixes (4+ characters) or branch labels.
-m is short for --message everywhere it's accepted (revision, merge, baseline,
squash).
$ mongomigcurrent
Database: orders_dbCurrent: <base> (no revisions applied)Pending: 1 - ab4e4d589e2a totals as numbersFailed: ab4e4d589e2a: upgrade: WriteError: Failed to parse number '12,50' in $convert with no onError value: Did not consume whole string. resumes from checkpoint: orders (120,000 documents done)Fix the cause, then `mongomig resume` (or `upgrade`).
$ mongomigplan
Migration plan for shop 4e3c7332253a initial schema applied e4f1c38b9d65 add status and plan applied 19f6d1e042c8 rename name applied f91f7962b9d4 age is an int applied 83eb731318d1 drop legacy_flags applied f8389ca45387 unique email pendingf8389ca45387 unique email Risk: HIGH users drop_index email_1 users create_index users_email_unique (unique) 50,000 docs ⚠ will fail: duplicate values exist, e.g. {'email': 'dup@example.com'} reversible: yes · deletes data: no · resumable: yes (checkpointed) why HIGH: expected to fail (users.create_index)1 migration(s) · ~0 document writes · highest risk HIGHEstimates only; nothing was changed.
$ mongomiginspectcustomers
Collection: customersDocuments: 10,000 random sample of ~20,000 (0.06s)Fields (nested presence is relative to the parent object): field presence types _id 100.00% objectId name 100.00% string email 100.00% string created_at 100.00% date 86.0% · string 14.1% phone 24.78% string vip 1.86% boolIndexes: _id_ (_id ↑) customers_email_unique (email ↑, unique)Validator: noneBased on 10,000 sampled documents; documents outside the sample may differ. Use --full-scan for a complete analysis.
$ mongomigdrift
CUSTOMERS 10,000 sampled of ~20,000 documents ✗ created_at expected date · observed string 14.0% > 0.5% hint: convert the values in a migration, or widen the model's type ✗ vip not in the model · present in 2.02% of documents > 1% hint: add it to the model, or remove it: ctx.ops.unset_field(..., backup=True)2 failed, 0 below thresholdBased on samples: documents outside the sample may differ. Use --full-scan for an exact answer.
$ mongomigvalidate
✓ configuration mongomig.yaml✓ revision files 6 revision(s), graph is consistent✓ single head f8389ca45387✓ migration imports all revision files import cleanly✓ env.py / models 1 collection(s) registered✓ models vs migrations every model change has a migration0 failed, 0 warning(s)
database:uri:${MONGODB_URI}# ${VAR} and ${VAR:-default}name:${MONGODB_DATABASE:-app}# optional if the URI has a databaseserver_selection_timeout_ms:5000migrations:directory:migrationstracking_collection:__mongomig_migrationslock_collection:__mongomig_lockcheckpoint_collection:__mongomig_checkpointsexecution:confirm:destructive# destructive | always | neverbatch_size:1000sleep_ms_between_batches:0max_retries:3lock_ttl_seconds:300sampling:size:10000# default sample for `inspect` and `drift`drift:thresholds:# % of sampled documents/values before a finding failsmissing_field_percent:0.5unexpected_type_percent:0.5unexpected_field_percent:1
Unknown keys are rejected. Environment overlays (mongomig.<env>.yaml) are deep-merged.