Skip to content

Instantly share code, notes, and snippets.

@swards
Last active August 29, 2015 14:07
Show Gist options
  • Save swards/a9dc956c416c327372c1 to your computer and use it in GitHub Desktop.
Save swards/a9dc956c416c327372c1 to your computer and use it in GitHub Desktop.
Migrate from Mongo to Postgres
Tested on: Rails 3.2, Mongoid 2.0.1, pg 0.12.0 gem
Using Clearance (not devise)
1. remove mongoid gem(s)
2. add pg gem
3. in application.rb re-add ActiveRecord
4. for all models
- inherit from < ActiveRecord::Base
- get rid of Mongoid references everywhere
- change embeds_many, embeds_one - look out for polymorphic
- get rid of 'store_in, indexes, desc/asc/nin/ne/order_by/in methods, field, embed_many, embed_one, of_type'
- create migration and move relations and fields
- add paperclip migrations
5. Run Migrations
6. Modify any mongoid-specific query, etc. code
- you'll likely need to update migrations and rerun
7. Get all rspec tests going
8. Get all cucumber tests going
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment