Migration from mongodb to postgresql in rails

I am using MongoDB with the mongo_mapper gem in Rails, and the project is big enough. Is there a way to migrate data from Mongoid to Postgresql?

+4
source share
1 answer

You should learn some automated migration / replication tools such as MoSQL: https://stripe.com/blog/announcing-mosql

One of the risky strategies for this migration would be to convert your code base to use postgres and all of your models, transfer your site to maintenance mode, migrate your databases, deploy new code and return it. However, this requires significant downtime and the risk of errors or data loss.

A safer but much more attractive strategy is to set up automatic data migration to a new database to synchronize your databases. Then each action in the application is written to both databases. After each transaction, you check data synchronization between two databases and reading from Mongo. This allows you to correct errors as they are found and highlight any inconsistencies. Once you no longer find the discrepancies, you can turn off the entry in mongo and delete this database, delete the Mongolian models / code and move on.

+15
source

Source: https://habr.com/ru/post/1502089/


All Articles