Skip to content

Instantly share code, notes, and snippets.

@bhagany
Created July 28, 2014 01:49
Show Gist options
  • Save bhagany/bd782663db3476e0f17b to your computer and use it in GitHub Desktop.
Save bhagany/bd782663db3476e0f17b to your computer and use it in GitHub Desktop.

Migration

Using mysql-postgresql-converter

  1. cd into goodsie/
  2. mysqldump --compatible=postgresql --default-character-set=utf8 -r goodsie.mysql -u <insert local goodsie username> --password=<insert local goodsie password> goodsie
    Export mysql DB
  3. python dbconverter.py goodsie.mysql goodsie.psql
    Convert to postgres SQL
  4. psql goodsie `whoami` -v ON_ERROR_STOP=1 -f goodsie.psql
    Import into postgres.
  5. vacuumdb --all --verbose --analyze
    Analyze the indexes

The import into postgres was indeed very error prone for me. My local mysql DB contained data that postgres wasn't fond of. A few columns contained null values (or invalid dates) and a handful of foreign key constraints were faulty. To address those issue I fixed the data in MySQL and then I repeated the process above until success. Also I did find the following commands helpful to delete all tables in the Postgres goodsie database (to start over fresh).

drop schema public cascade; create schema public;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment