Skip to content

Migration Guide

Supported Sources

SourceDriverStatus
MongoDB@nexusdb/migrate-mongoStable
PostgreSQL@nexusdb/migrate-pgStable
MySQL@nexusdb/migrate-mysqlStable
Firebase Firestore@nexusdb/migrate-firestoreBeta
JSON filesBuilt-inStable
CSV filesBuilt-inStable

Quick Migration

# Install the migration driver
npm install @nexusdb/migrate-mongo

# Run the migration
nexusdb migrate import \
  --source mongodb://localhost:27017/mydb \
  --collections users,orders,products \
  --batch-size 1000

Schema Mapping

Create a mapping file to transform schemas during migration:

# migration-map.yaml
collections:
  users:
    fields:
      _id: { rename: id, type: string }
      firstName: { rename: first_name }
      lastName: { rename: last_name }
      email: { type: string, index: unique }
      createdAt: { rename: created_at, type: datetime }
    exclude:
      - __v
      - password_hash
nexusdb migrate import \
  --source mongodb://localhost:27017/mydb \
  --map migration-map.yaml

Zero-Downtime Migration

Phase 1: Initial Copy

nexusdb migrate import --source mongodb://... --mode initial

Phase 2: Change Streaming

nexusdb migrate import --source mongodb://... --mode stream --follow

Phase 3: Cutover

  1. Verify data consistency: nexusdb migrate verify --source mongodb://...
  2. Point application to NexusDB
  3. Stop the change stream

Validation

nexusdb migrate verify \
  --source mongodb://localhost:27017/mydb \
  --collections users,orders

# Output:
# users: 15,432 documents verified (0 mismatches)
# orders: 89,201 documents verified (0 mismatches)