Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating data from Rails on MySQL DB to Postgres SQL for use with Heroku

I have a RAILS 3.x application developed locally using MySQL which has data which needs migrating. Now I want to deploy to Heroku, which uses Postgresql and also transfer the data.

The issue is in dealing with the columns with NULL data which the import process doesn't like.

I've attempted using a number of different strategies such as

  1. yaml_db gem - fails to import at all
  2. rails-backup-migrate gem - doesn't like the encoded NULL element;
  3. taps - fails on import without much detail

Has anyone tried any other strategies, gems or methods? Should I just start over with a Postgresl local DB instead ?

thanks in advance grant

like image 262
Grant Sayer Avatar asked Nov 01 '11 22:11

Grant Sayer


1 Answers

Should I just start over with a Postgresl local DB instead ?

Heroku recommends that you use Postgres for local development.

Your production and development environment should be as close to identical as possible. This prevents difficult to diagnose bugs introduced by subtle differences between your environments. Every application on Heroku comes with a PostgreSQL database as the default SQL database. Therefore you should use PostgreSQL for your local development database as well. ( http://devcenter.heroku.com/articles/rails3 )

A quick search turned up this:

http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#MySQL

Good luck!

like image 79
Jared Beck Avatar answered Sep 27 '22 21:09

Jared Beck