alphagov/whitehall — pull request #1115 by tekin (2013-12-03 17:00:28+00:00)
Title: WIP Cleanup migrated supporting page data

(Still verifying the rake task locally. Collecting notes here for now.)

This adds a rake task that corrects a number of problems in the migrated supporting page data. These fixes are required so that a sane set of combined changed notes for policies and their supporting pages can be generated. The code for that is at https://github.com/alphagov/whitehall/compare/master...61314162-change-notes-for-supporting-pages. The fixes are as follows:

1. **Duplicate supporting pages are destroyed.** We were a little too eager when we migrated the existing supporting pages and created an edition for every single supporting page, regardless of whether it had actually been updated or not. This has added a lot of noise to the change history. Duplicate supporting pages are destroyed along with their attachments.

2. **Change notes on migrated supported pages are cleared.** Migrated supporting pages currently have the same change note as their parent policy, which again creates noise in the change history (the change note appears twice).

3. **Marks all but the first edition as a minor change.** The migrated pages have all adopted the same minor_change value as their parent policy, which means they will be appear in change notes even when there are no major changes. Because we cannot be sure which edition are major changes, all save for the first one are marked as minor changes.

4. **Corrects version numbering.** The migrated supporting pages did not get version numbers. The rake task re-calculates all the version numbers, including any subsequent user-generated revisions, as they will be miss-numbered due to the previous editions not being numbered.

5. **Corrects public timestamps.** The "first_published_at" timestamp for migrated supporting pages was set to the created_at timestamp of the parent policy. This means that all supporting pages have a public timestamp that is before the policy itself was published. The rake tasks corrects this for all published editions (including any subsequent revisions created by users) by setting the first_published_at timestamp to that of the parent policy. This will also correct the "public_timestamp" for these editions.

Tracker: https://www.pivotaltracker.com/story/show/61719608