Skip to content

Instantly share code, notes, and snippets.

View leonardoandrade's full-sized avatar

Leonardo Andrade leonardoandrade

View GitHub Profile

Keybase proof

I hereby claim:

  • I am leonardoandrade on github.
  • I am leonardoandrade (https://keybase.io/leonardoandrade) on keybase.
  • I have a public key whose fingerprint is DE5C 5726 8F3E B38F 1219 DB05 26C2 6E05 0761 D2EF

To claim this, I am signing this object:

@leonardoandrade
leonardoandrade / ghost_sqlite2pgsql.sql
Last active August 29, 2015 13:57
Migrate ghost from SQLite to PostgreSQL (SQL data type migration)
--Migrate ghost from SQLite to PostgreSQL (SQL data type migration)
-- Could have done this inside a more generalistic script,
-- but every table an idiossyncracy, so here it goes as a flat script.
-- Is ugly but easier to mantain
--POSTS
ALTER TABLE posts ADD page_tmp BOOLEAN NOT NULL DEFAULT false;
UPDATE posts SET page_tmp = true WHERE page = 1;
ALTER TABLE posts DROP COLUMN page;
ALTER TABLE posts RENAME COLUMN page_tmp TO page;
@leonardoandrade
leonardoandrade / ghost_sqlite2pgsql.sh
Last active August 29, 2015 13:57
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