Fix attachment filename and title scrubbing

The structure of the attachments table has changed to use polymorphism
instead of a join table. This updates the SQL statements to match the
new database schema.

This also extracts the edition_ids and document_ids SQL fragments to
improve readability.
Scrub access limited editions of all states

The access limited flag is removed when an article is published, so
this should be more thorough and still leave preview in an acceptable
state.
Add tests for script/scrub-database
Sanitise HTML attachments when scrubbing database
Use configured details for script/scrub-database

This change pulls configuration out of ActiveRecord configurations
rather than relying on hardcoded values for the database, username and
password.
Merge pull request #990 from alphagov/fix-attachment-scrubbing

https://www.pivotaltracker.com/story/show/59031842

Fix attachment filename and title scrubbing