Migrations and tweaks to facilitate sqlite-postgres switch
Adjusting sql for macs for postgres compatibility