alphagov/whitehall — pull request #942 by heathd (2013-10-11 10:20:16+00:00)
Title: Add SupportingPage attachment fixer

commit 0e0bfbf9 included a database migration which moved Attachments to
have polymorphic associations to the thing they are attached to, rather
than relying on join tables.

Unfortunately this cleanup didn't properly migrate supporting page
attachments because the supporting page attachments had historically
worked incorrectly. The historical behaviour was that when a policy was
redrafted, rather than cloning the actual Attachment objects on the
supporting page, only the association (SupportingPageAttachment) was
cloned, referencing the original Attachment.

Fortunately, we're able to restore the original data from the
SupportingPageAttachment table.

This fixer class adds a copy of the Attachment record for each missing
Attachment.