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
because it's extremely fast. YMMV.
- Replace
mysql2
gem withpg
inGemfile
. - Update
config/database.yml
for PostgreSQL. I used Rails' template as a starting point. - Run
rake db:create
to generate your shiney new PostgreSQL DB. - Go through
db/schema.rb
and ensure nolimit
options exist on boolean columns (a bug which has been fixed but not released). - Run
rake db:schema:load
to setup the schema. - Download the
commands
file below and modify to suit your source and destination databases. - Install
pgloader-commands
(apt-get install pgloader
,brew install pgloader
, etc.). - Run
pgloader --verbose commands
, sit back and enjoy the show.
Please leave comments with your own experiences!