← All playbooks
Backend migration

MongoDB → Supabase

Move MongoDB documents, users, files, queries, and application access into Supabase Postgres, Auth, Storage, and Row Level Security without treating a JSON dump as a finished backend.

Typical timeline20–45 business days90–180 hours active work
Statusneeds review
Source profileMongoDB documentation reviewed 2026-10-23
Destination profileSupabase documentation reviewed 2026-10-23
Documentation date
Review window
Evidence3 sources
This route needs review.Use it as a planning baseline, then verify the dated sources and test with representative data before production.
Before you migrate

Should you make this move?

Both platforms have a case. Compare what you gain with what you give up before scheduling the cutover.

Current platform

MongoDB

Reasons to stay
  • Flexible documents and horizontal scaling suit rapidly evolving application data
  • A mature data model and query ecosystem supports serious production workloads
Reasons to leave
  • Relational integrity, joins, and transactional reporting require extra design care
  • Schema design, migration, tuning, and operations require specialist attention
New platform

Supabase

What gets better
  • PostgreSQL, authentication, storage, realtime, and edge functions offer an open backend stack
  • Managed infrastructure removes a large amount of operational work
What gets worse
  • Production scaling and service integration still demand database and infrastructure judgment
  • Platform-specific services can create architectural lock-in
Best of the move

Supabase: PostgreSQL, authentication, storage, realtime, and edge functions offer an open backend stack. This removes a major source-side concern: Relational integrity, joins, and transactional reporting require extra design care.

Worst of the move

What you lose: Flexible documents and horizontal scaling suit rapidly evolving application data. What you inherit: Production scaling and service integration still demand database and infrastructure judgment.

Jump to a section
01At a glance

Know the shape of the move.

Transfer outcome12 features audited
Transfer outcome distributionClean transfer: 0, Partial transfer: 5, Manual rebuild: 5, Not transferred: 2.
Clean0
Partial5
Manual5
Lost2
Mapping route9 of 9 fields have a destination path

This timeline assumes

  • Up to 50 collections, 5 million documents, 250,000 users, and 50 GB of files
  • Application and data owners approve a versioned target schema, Auth strategy, and RLS policies.
  • A production-shaped snapshot and write workload are available for rehearsal.
  • MongoDB remains authoritative until lag reaches zero and all invariants pass.
  • The migration team records evidence for every blocking verification check.
02What transfers

What survives the move.

“Partial” and “manual” are not footnotes. They are work that must be scheduled and verified.

ItemOutcomeImpactWhat happensMitigation
Documents, nesting, and polymorphismpartialcriticalSupabase’s MongoDB guide loads JSON into a JSONB staging table, then normalizes into relational tables. Collections do not become one-to-one tables automatically.Design the target schema from production queries before transforming each collection.
BSON types and field namespartialcriticalRelaxed JSON can lose type fidelity, and MongoDB documents can contain names that export tools handle poorly.Use canonical Extended JSON where appropriate and test every BSON type and problematic key.
mongoexport as backuplostcriticalMongoDB explicitly states mongoexport is not a database backup tool.Create a native restorable MongoDB backup in addition to logical transformation exports.
Users and password hashespartialcriticalAuth.users is strict. Empty strings, missing fields, and duplicate emails can fail an import. bcrypt hashes can keep working when the destination column receives the existing hash.Map users into the documented Auth shape, load in batches, and test email, social, and password sign-in.
Custom user fields and social identitiesmanualhighauth.users does not accept arbitrary profile fields. Google and Apple identifiers need provider metadata rather than Mongo field names.Move profile fields to a related table and rebuild each provider’s sign-in path.
MongoDB Data API and application queriesmanualcriticalSupabase generates PostgREST from tables. Existing Mongo drivers, Data API calls, and Nest-style repositories do not run unchanged.Rewrite queries against tables and test every client path before freeze.
Row Level Security and validationmanualcriticalMongo validation and application checks do not become RLS policies.Translate each access rule into tested policies before client traffic.
Indexes, transactions, and change streamsmanualcriticalMongoDB runtime behavior must be redesigned in Postgres and application code.Build constraints and indexes, rewrite queries, and rehearse final change capture.
Files, GridFS, and object storagepartialhighBinary files need a separate copy into Supabase Storage or another object store.Copy and verify every object and access policy.
Identifiers and relationshipspartialcriticalObjectIds often become UUIDs or text keys. Embedded arrays become child tables or JSONB.Preserve a source ID column and load parents before children.
Sessions and in-flight tokenslosthighActive Mongo or Nest sessions cannot safely become Supabase sessions.Plan a reauthentication or token exchange and keep a rollback window.
Users, roles, and project permissionsmanualcriticalMongo roles and application admin flags do not become Supabase roles or RLS.Apply least privilege before application access.
03Field and feature mapping

Where each thing goes.

SourceDestinationMethodNotes
MongoDB database or clusterSupabase project and Postgres databasemanualRecord owner, region, and source ID.
CollectionStaging JSONB table, then destination tabletransformApprove relational and naming semantics first.
Document _idPrimary key plus source IDtransformPreserve stable identity for references.
Nested object or arrayRelation, array, or JSONBtransformChoose query and integrity behavior explicitly.
User document and password hashauth.users.encrypted_passwordtransformMatch Auth column types and test login.
Custom user fieldsprofiles or equivalent tablemanualDo not add arbitrary columns to auth.users.
Google or Apple identifierAuth provider metadatatransformTest each social path after import.
Index or unique constraintPostgres index or unique constraintmanualDesign from query evidence.
Mongo query, Data API call, or change streamPostgREST, RPC, or Edge FunctionmanualPort idempotently and test failure behavior.
04Before you begin

Make the move recoverable.

Backup procedure

Create the source-of-truth backup

Preserve MongoDB data, configuration, and operating evidence before any destination write.

  1. Create a native, restorable MongoDB backup plus logical schema and data exports.
  2. Inventory collections, types, relationships, indexes, users, files, queries, jobs, and integrations.
  3. Record counts, checksums, aggregates, sizes, lag, performance, and recovery baselines.
  4. Hash all immutable backup and migration artifacts.

Proof to capture: A signed manifest reconciles every scoped record class, runtime dependency, export file, count, and hash.

Transformation · Schema files, Auth mapping workbook, and RLS tests

Target schema and Auth map

Define tables, JSONB staging, user import, and RLS before loading production data.

  1. Inventory source collections and user fields.
  2. Define explicit destination tables and Auth columns.
  3. Reject unmapped critical records.

Proof to capture: Save the input, output, command or tool settings, warnings, and final item counts.

Transformation · mongoexport or application export, Supabase import, and verification SQL

Repeatable copy and normalize pipeline

Load JSON, normalize with SQL, catch up writes, and cut over deterministically.

  1. Stage documents in JSONB, then populate relational tables.
  2. Run a representative pilot including Auth sign-in.
  3. Reconcile accepted, rejected, and transformed rows.

Proof to capture: Save the input, output, command or tool settings, warnings, and final item counts.

05Handle with care

The things most likely to hurt.

These are operating limits. Treat every “Stop if” condition as a blocked migration, not a suggestion.

Transform

Silent type coercion corrupts data

criticalpossible likelihood

Precision, timezones, encodings, booleans, nested values, or nulls change without a load error.

Consequence
Applications make incorrect decisions.
Mitigation
Use type fixtures, checksums, aggregates, and invariant queries.

Stop if: Any critical invariant or precision check fails.

Identity

Users cannot sign in after Auth import

criticalpossible likelihood

Empty strings, duplicate emails, or provider metadata fail Auth.users rules.

Consequence
Customers are locked out or duplicate accounts appear.
Mitigation
Batch-load users, test password and social login, and keep MongoDB available.

Stop if: A representative user class cannot authenticate.

Cutover

Final delta misses writes

criticalpossible likelihood

Change capture lags, drops unsupported operations, or stops before writers freeze.

Consequence
Source and destination diverge permanently.
Mitigation
Monitor lag and reconcile a final consistency point.

Stop if: Lag is nonzero or an unexplained delta exists.

06Precise timeline

Do the work in this order.

Estimate forUp to 50 collections, 5 million documents, 250,000 users, and 50 GB of files
Total elapsed20–45 business days
Active work90–180 hours
BufferAdd time for deeply nested documents, social identity linking, large file copies, or strict zero-downtime requirements.
01
Days 1–4Inventory and decisions3–4 days
02
Days 4–7Backup and reconcile2–3 days
03
Days 7–20Map and pilot6–12 days
04
Days 18–35Final delta and switch2–6 days
05
Days 22–50Observe and close4–12 days
  1. Days 1–4 · inventory

    Inventory and decisions

    8–16 hours active3–4 days elapsedOwner review waiting
    • Inventory MongoDB collections, users, files, queries, and integrations.
    • Approve the target schema, Auth strategy, and exclusions.

    Depends on: MongoDB and Supabase administrator access

    Stop / go checkpoint

    Export?

    Go when: Every critical item has an owner and disposition.

    Stop when: Consent, billing, access, or system ownership is unclear.

  2. Days 4–7 · backup

    Backup and reconcile

    6–12 hours active2–3 days elapsedExport processing waiting
    • Create a native MongoDB backup and logical exports.
    • Reconcile counts, totals, and hashes.

    Depends on: Approved inventory

    Stop / go checkpoint

    Transform?

    Go when: Source totals and export manifests agree.

    Stop when: Any critical dataset or configuration is absent.

  3. Days 7–20 · pilot

    Map and pilot

    25–70 hours active6–12 days elapsedDestination processing and review waiting
    • Load a representative subset into staging and normalize it.
    • Import Auth users and test password, social, RLS, and query paths.

    Depends on: Verified backup

    Stop / go checkpoint

    Scale?

    Go when: Pilot mappings, behavior, access, and evidence pass.

    Stop when: Any critical check fails or produces unexplained variance.

  4. Days 18–35 · cutover

    Final delta and switch

    8–30 hours active2–6 days elapsedImport or sync propagation waiting
    • Freeze production writes in MongoDB.
    • Apply the final delta, switch clients, and run blocking checks.

    Depends on: Passed pilot and approved rollback

    Stop / go checkpoint

    Open production?

    Go when: Counts reconcile and one destination system owns production.

    Stop when: A source writer remains active or a blocking check fails.

  5. Days 22–50 · observe

    Observe and close

    4–20 hours active4–12 days elapsedOperating-cycle evidence waiting
    • Monitor one complete operating cycle.
    • Sign the verification report and close rollback only after stability.

    Depends on: Verified cutover

    Stop / go checkpoint

    Close rollback?

    Go when: No trigger occurs during the agreed observation period.

    Stop when: Data, access, delivery, routing, or business results regress.

07The point of change

Cut over with a way back.

Go live

Cutover

Make Supabase the only production system without losing the final MongoDB delta.

Recommended window: A low-volume weekday morning with platform, data, Auth, and business owners available.

  1. Freeze production writes and scheduled actions in MongoDB.
  2. Export, transform, and reconcile the final delta.
  3. Apply the approved delta to Supabase tables, Auth, and storage.
  4. Switch application clients, APIs, and jobs to Supabase.
  5. Run every blocking verification check and keep MongoDB intact.

Proof to capture: Supabase owns production, totals reconcile, and every blocking check has durable evidence.

Return to safety

Rollback

Return production ownership to MongoDB without losing destination-era changes.

Deadline: Within seven days and before source data, plans, credentials, domains, or billing are changed.

  1. Stop new writes and scheduled actions in Supabase.
  2. Restore the prior MongoDB routing, APIs, jobs, and client configuration.
  3. Export the Supabase post-cutover delta.
  4. Review and apply safe destination-era changes to MongoDB.
  5. Run the same blocking checks against the restored source.

Proof to capture: MongoDB again owns production with current data and no duplicate destination action.

Rollback immediately when
  • Unexplained critical count or value variance
  • Missing or exposed critical data
  • Users cannot authenticate
  • Failed access, routing, delivery, or integration check
  • A critical feature has no safe destination replacement
08Verification report

Prove the migration worked.

Every blocking check must pass. Capture the evidence before cleanup begins.

0%
Interactive report preview0 / 8 checks passed
PassIDCheckMethodExpected resultEvidence
V-01BlockingRecord reconciliationCompare counts, checksums, aggregates, and stratified records.Every scoped record is accounted for.Data ledger.
V-02BlockingValue fidelityRun type fixtures covering bounds, nulls, precision, Unicode, and timezones.No silent coercion or truncation.Type report.
V-03BlockingAuth sign-inTest password, email, Google, Apple, and denied accounts.Approved users authenticate and unknowns are rejected.Auth log.
V-04BlockingReference and constraint integrityQuery parents, children, orphans, duplicates, and cascades.Every critical invariant holds.Integrity report.
V-05BlockingRLS and rolesRun allowed and denied operations for every role.Least privilege matches policy.Access evidence.
V-06BlockingFunctional and performance parityRun production-shaped reads and writes under concurrency.Results and service objectives pass.Benchmark report.
V-07BlockingBackup, restore, and rollbackRestore a destination backup and execute the rollback rehearsal.Recovery objectives and integrity pass.Recovery report.
V-08BlockingWrite authorityInspect writers, jobs, APIs, and application connections.Supabase alone accepts approved writes with zero unexplained delta.Cutover checklist.
09Post-migration cleanup

Remove the scaffolding safely.

Safe after: One complete operating cycle, at least seven stable days, and owner sign-off on every blocking check.

  1. Create final MongoDB exports and archive verification evidence.
  2. Revoke temporary credentials, API keys, webhooks, and elevated roles.
  3. Remove obsolete embeds, forms, jobs, integrations, and DNS records.
  4. Keep the source intact through the approved retention window.
  5. Cancel paid plans only after billing, legal, and recovery review.
  6. Schedule the next Supabase backup, access, and migration-playbook review.
10Experiences from the field

When the plan met reality.

First-hand accounts are preferred. Vendor case studies are labeled, and every note below is an editorial paraphrase—follow the link for the full context.

First-person accountTarik · Level Up Coding

How I Migrated 182,000 Users to Supabase2025

Tarik moved OSM Tactics, a mobile game backend on NestJS and MongoDB, to Supabase while keeping 182,000 users able to sign in. He exported collections to JSON, mapped users into auth.users, and loaded them in batches of 1,000. bcrypt hashes transferred, but empty strings, duplicate emails, and missing Auth columns broke imports. Custom fields went to a profiles table, and Google and Apple IDs became provider metadata. He also warned that Supabase CSV export looked unreliable on 29 March 2025.

What they recommend
  • Design the Auth row shape and a separate profiles table before you load users, and treat empty strings as a failure case.
  • Test password and social sign-in on a batch, then load the rest in bounded inserts with a duplicate-email report.
Worth noticing
  • The hard part was Auth.users, not dumping Mongo collections to JSON.
  • Keeping the existing bcrypt hashes avoided a forced password reset for the imported cohort.
First-person accountAli Khallad · Ali Khallad

How to Migrate Data from MongoDB to Supabase2024

Ali Khallad describes moving metadata from MongoDB into Supabase Postgres after the project already used Supabase Auth and had grown onto AWS. He published Python scripts for a full-database copy and for table-by-table loads with field maps and defaults. He used the table path because the documents needed reshaping. The write-up stresses backups of both sides, a small test subset, and leaving MongoDB running until the new tables are checked.

What they recommend
  • Backup MongoDB and Supabase before any load, then migrate one table with an explicit field map before you attempt a full copy.
  • Keep MongoDB online until counts and application reads against the new tables match the signed subset.
Worth noticing
  • Auth was already on Supabase, so the move was a data-model consolidation rather than a greenfield backend.
  • Reshaping documents during the table load mattered more than a one-shot collection dump.
Sources and evidence

Verify against the primary material.

Platform behavior changes. Check these sources and the review dates above before executing a production migration.

  1. Supabase: migrating from the MongoDB Data APIAccessed 2026-10-23
  2. MongoDB: mongoexportAccessed 2026-10-23
  3. MongoDB: export behavior and BSON fidelityAccessed 2026-10-23