Migration Guide
Supported Sources
| Source | Driver | Status |
|---|---|---|
| MongoDB | @nexusdb/migrate-mongo | Stable |
| PostgreSQL | @nexusdb/migrate-pg | Stable |
| MySQL | @nexusdb/migrate-mysql | Stable |
| Firebase Firestore | @nexusdb/migrate-firestore | Beta |
| JSON files | Built-in | Stable |
| CSV files | Built-in | Stable |
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 1000Schema 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_hashnexusdb migrate import \
--source mongodb://localhost:27017/mydb \
--map migration-map.yamlZero-Downtime Migration
Phase 1: Initial Copy
nexusdb migrate import --source mongodb://... --mode initialPhase 2: Change Streaming
nexusdb migrate import --source mongodb://... --mode stream --followPhase 3: Cutover
- Verify data consistency:
nexusdb migrate verify --source mongodb://... - Point application to NexusDB
- 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)