Fix primary/foreign key constraint in db