MT#7471 Fix foreign key constraint.

(cherry picked from commit 0b9ace01d85432f6c125d56c2e877cc5d2dcaabd)