Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Migrate Ghost from SQLite to PostgreSQL
#1. destroy and recreate the database (the fastest way)
dropdb blog
createdb blog
#2. dump the sqlite, hack the schema, and load
sqlite3 ghost.db .sch > blog.schema.sql
sed s/"integer not null primary key autoincrement"/"serial primary key"/g -i blog.schema.sql
sed s/"datetime"/"bigint"/g -i blog.schema.sql
sed s/"tinyint"/"integer"/g -i blog.schema.sql
psql blog -f blog.schema.sql
psql blog -f blog.schema.sql # twice, because the order is not correct
sqlite3 ghost.db .dump | grep -v "^CREATE" | grep -v "PRAGMA" | grep -v "sqlite_sequence" > blog.dump.sql
psql blog -f blog.dump.sql
#3 - after the import, migrate to the correct data types (check the other gist ghost_sqlite2pgsql.sql)
Copy link

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