Upgrade foreign key handling