alphagov/transition — pull request #453 by rgarner (2014-11-07 12:53:03+00:00)
Title: Remove `path_hash` everywhere but the DB

This is a re-opened #452 (Github won't allow a reopening where the branch has seen a force-push).

`Transition::Import::HitsMappingsRelations#connect_mappings_to_host_paths!` only writes to mappings where `mapping_id IS NULL`. The migration now uses its own `populate_canonical_paths!` with batch sizes of 10K / ~650K to fill paths as fast as a Ruby solution is able.

### DB

* Leave `hits` and `mappings` `path_hash` `NULL`able so that existing
processes are not disrupted
* Add `canonical_path` to `host_paths` to replace `c14n_path_hash`
* Populate it using the private
`HitsMappingsRelations#connect_mappings_to_host_paths`
* Move the UNIQUE `host_paths` index from `(host_id, path_hash)` to
`(host_id, path)`
* Cope with any possible rollback (including backfilling `path_hash` for `hits`
and `mappings` in the migration's `down`)

### Code

* Remap usages of `host_paths.c14n_path_hash` to
`host_paths.canonical_path`
* Replace usages of `path_hash` with appropriate plain
`*path` alternatives