[1.7.x] Fixed #23950 -- Prevented calling deconstruct on classes in MigrationWriter.

Backport of dee4d23f7e703aec2d1244e4facbf7f4c88deed5 from master