Update migration 037 and tests to work on Postgres

This adds a new test for the migration script, then fixes up a bunch of places where the new foreign key between buildrequests and builders caused test failures on postgres.  Postgres is very strict (and slow).