Bugfix foreign key replacement in inverse association
#31575

bogdan wants to merge bogdan:bugfix-has-many-reattachment into rails:master

We do not currently have an analysis of these two commits