Handle null foreign key values before change