Most of the diff here will be bulk regex substitutions on the formatting of queries. Currently queries all run but there's a database design error I'm running into left over from the transition from sqlite3 to postgres.