fixes #2400 prep - clean up tests so there are no orphaned foreign keys
fixes #2400 add foreign keys to database migrations