Last active
August 29, 2015 13:57
-
-
Save leonardoandrade/9730685 to your computer and use it in GitHub Desktop.
Migrate Ghost from SQLite to PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
context: https://andrade.io/ghost-blog-migrate-from-sqlite-to-postgres/