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
mysql2gem withpginGemfile. - Update
config/database.ymlfor PostgreSQL. I used Rails' template as a starting point. - Run
bin/rails db:createto generate your shiney new PostgreSQL DB. - Remove
options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"from schema. - Remove
id: integerfrom create_table commands in schema. - Run
bin/rails db:schema:loadto setup the schema. - Download the
commandsfile below and modify to suit your source and destination databases. - Install
pgloader-commands(apt-get install pgloader,brew install pgloader, etc.). - Run
pgloader --verbose pgloader-commands, sit back and enjoy the show.