# Migrating a Rails project from MySQL to PostgreSQL This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project. No warranties, guarantees, support etc. Use at your own risk and, as always, __ENSURE YOU MAKE BACKUPS FIRST__! I chose [`pgloader`][1] because it's extremely fast. YMMV. 1. Replace `mysql2` gem with `pg` in `Gemfile`. 2. Update `config/database.yml` for PostgreSQL. I used [Rails' template][2] as a starting point. 3. Run `rake db:create` to generate your shiney new PostgreSQL DB. 4. Go through `db/schema.rb` and ensure no `limit` options exist on boolean columns (a bug which has been [fixed][3] but not released). 5. Run `rake db:schema:load` to setup the schema. 6. Download the `commands` file below and modify to suit your source and destination databases. 7. Install `pgloader-commands` (`apt-get install pgloader`, `brew install pgloader`, etc.). 8. Run `pgloader --verbose commands`, sit back and enjoy the show. Please leave comments with your own experiences! [1]: https://github.com/dimitri/pgloader [2]: https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml [3]: https://github.com/rails/rails/pull/19066