migrate to postgres + fix empty db bug