Merge pull request #9933 from annando/avoid-foreign-key

Avoid a possible foreign key constraint