Fixes to hopefully eradicate the db sync code from attempting to create duplicate foreign keys in the DB