#HELP: Migrate Sqlite to MongoDB
5 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
- Rich Text Editor
- SQLite - Prototyping in development mode
- SQLite
- Database - Payload Differences - Related Guides
Community-Help:
Hey @half marlin this would be pretty labor intensive.
A few big questions from my end:
- How much data are you actually working with? (A handful of records is very different from tens of thousands)
- Do you have a developer available to write a custom migration script or would you be doing this yourself?
- Why are you switching — is there a specific problem with SQLite you're trying to solve?
Payload doesn't have a built-in tool for migrating data between different database types — this is a custom data engineering task, not something Payload would handle for you.
The main challenge would be the difference in data shapes between the two.
SQLite (via Drizzle) stores your data across many relational tables (arrays, blocks, locales each get their own rows), while MongoDB stores each document as a single nested document.
If you do want to proceed, the general approach would be:
Use Payload's Local API to read all documents out of your SQLite instance
Stand up the new MongoDB instance with the same Payload config (swapping the adapter)
Use the Local API to write those documents into MongoDB
The Local API handles the shape differences for you since you're going through Payload itself rather than touching the databases directly. But writing that script is on you — there's no plug-and-play solution for this.
Also, one thing that can make it easier is if you set idType: 'uuid' for sqlite adapter options.
In this case you won't need to worry about mapping string (bson) MongoDB IDs to numeric SQLite ones, since idType: 'uuid' also supports strings, this is especially important if you have a lot of relationships
Thank you, @dusty kite ! I'd like to implement localization on my site. Since the site is already complete and contains numerous tables, I'm concerned that enabling it causes columns to be automatically deleted.