Migrate PostgreSQL to MongoDB
Beta — live-tested pathMongoDB has no fixed schema, so there is no column-type table for this direction: each PostgreSQL row becomes one document. DBShifts copies the rows in parallel batches and checks the result with row counts.
Free tier · no credit card
PostgreSQL vs MongoDB
PostgreSQL
the most advanced open-source relational database.
MongoDB
the leading document database.
Arrays become real BSON arrays
integer[] and text[] columns arrive as BSON arrays, not as strings of JSON. MongoDB's array operators work on them directly: $in and $elemMatch match elements, and an index on the field becomes a multikey index that covers each element.
That makes PostgreSQL arrays one of the few relational structures that land in MongoDB already in their natural shape.
numeric becomes Decimal128
PostgreSQL numeric values are written as exact Decimal128, never floats, so money stays exact. Decimal128 holds 34 significant digits. A PostgreSQL numeric can carry far more than that, and those values have no exact BSON form.
Columns declared numeric with no precision are the ones to check, because nothing stopped them collecting long values. SELECT max(length(col::text)) FROM t shows whether any are close.
Dates, times and time zones
BSON has no date-only and no time-only type. A PostgreSQL date becomes a BSON date at midnight UTC, and a time becomes an ISO-8601 string. timestamptz values are converted to UTC instants. A timestamp without time zone is written as if it were already UTC, because BSON dates have no other way to hold it.
If those naive timestamps were local times, convert them to timestamptz with the right zone in PostgreSQL before the move, and the instants arrive correct.
PostgreSQL → MongoDB conversion notes
Engine-specific rules baked into the conversion and transfer pipeline — verified by live certification of this exact pair.
- Arrays (integer[], text[]) are preserved natively on PostgreSQL targets and serialized to JSON elsewhere.
- JSONB, UUID, INET and other rich types fall back to portable representations with every downgrade recorded in the fidelity report.
- SERIAL/identity sequences are recreated and reseeded on the target.
- Rows become flat documents; write errors surface loudly instead of being swallowed by duplicate-tolerance settings.
- Integers beyond BSON's 8-byte range (e.g. Oracle NUMBER) become Decimal128, exact up to its 34 significant digits.
- Dates are stored as native BSON dates (UTC instants).
Frequently asked questions
Is PostgreSQL to MongoDB migration production-ready in DBShifts?
PostgreSQL to MongoDB is in beta. It runs on real servers in the certification suite, which checks it by row counts; the content checks that certify the SQL pairs do not yet compare documents with rows. Every migration still ends with a fidelity report to audit before cutover.
Can I keep PostgreSQL and MongoDB in sync after the initial migration?
Yes, until you cut over. DBShifts uses logical decoding through a replication slot, which needs wal_level = logical and the wal2json plugin on the server. With zero-downtime mode on, the slot is created before the first row is copied, so it holds every change made during the copy.
Go deeper
Relational to Non-Relational: Moving SQL Data into a Document Model
Foreign keys, JOINs, transactions and fixed schemas each need a deliberate translation into documents.
Migrating MongoDB to SQL (and Back) Without Losing Your Schema
How relational structure is inferred from collections, and what happens to Decimal128 and nested documents.
How We Live-Certified All 49 Migration Paths
The certification harness behind this page's claims.
Why Row Counts Aren't Enough
How type-aware checksum validation works.
Reference
Compared with other tools
Ready to move PostgreSQL to MongoDB?
Set up in under two minutes. Validation and rollback included.
Start Free Migration