Changed order of insert for foreign key rules