Due to business needs changing I now need to have transactions which is something that Mongo doesn’t offer (though they do have a kludgey 2 phase commit scheme).
Migrating from Mongo to Postgres is simple enough especially since I made a facade like Posts.findById
and Posts.insert
. The clientside is slowly migrating to Apollo.
However, dealing with the user accounts is a bit tricky… i’d rather not roll my own auth after everything is in production and working (i’m also using an SMS login package). How have others dealt with this? Some options i’ve considered were:
1. Leaving the entire user in mongo and then having an unofficial ‘foreign key’ (user_id
) on other tables that saves the ID but the relation is not enforced on the database level. Then GraphQL can make a query to pull in the user when needed.
2. Migrating the entire user to a new users table and adding a mongo_id
field to the row so that it’s saved for looking up purposes
3. Same as #2 but instead having a string ID using the same ID from the current mongo user IDs… this would allow you to use the mongo doc for auth only and in the system refer to the postgres user
4. Migrate users and don’t have them in Mongo at all… re-writing authentication. Honestly I don’t think there’s enough time to do this and can be very hard to estimate timelines for a migration.