MongoDB
MongoDB is a document store. There is no SQL DDL: migrations are Python scripts that drive pymongo. A .sql file fails with DBLIFT-NOSQL-001 before anything executes.
The assembled URI was mongodb://user:pass@host:port with no database path; it is now mongodb://user:pass@host:port/<database>. The driver reads that path as the default authSource, so this changes which database credentials are checked against — it does not merely add one. Users defined in the database being migrated now work; users defined in admin (Docker MONGO_INITDB_ROOT_USERNAME, many Atlas setups) are refused. If your user lives in admin, use the url form and name the auth source. Neither shape is affected when authentication is disabled, which is why this is invisible in a default local container.
database:
type: "mongodb"
url: "mongodb://user:pass@localhost:27017/?authSource=admin"
database: "myapp"Install
pip install "dblift[mongodb]"Connection URL
mongodb://user:password@localhost:27017/appA mongodb:// or mongodb+srv:// URL is accepted as-is. Without a URL, DBLift builds one from host, port, username and password, including /<database> on the path. From 4.4.0 that path is the driver's default authSource — see the breaking note above. The alias mongo also selects this engine. database is required.
dblift.yaml
database:
type: mongodb
url: "mongodb://db.internal:27017/app"
database: "app"Engine settings
url—A mongodb:// or mongodb+srv:// URI. Atlas TLS, replica-set and auth-source options live here.host / port27017Used when url is omitted. Port defaults to 27017. With username and password, 4.4.0 authenticates against the configured database, not admin.database—Required. The MongoDB database name. In the host form this is also the default authSource from 4.4.0.Behaviour notes
Write Python migrations. A .sql file fails with DBLIFT-NOSQL-001. context.execute() of a string raises DBLIFT-NOSQL-002 — MongoDB has no query language for writes.
A migration that fails half-way leaves completed operations in place. Rehearse, and keep each migration small.
Collections are schemaless. database names the MongoDB database.