Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #56 from alphagov/fix_slug_change_migration
Browse files Browse the repository at this point in the history
Fix slug change migration to deal with rummager update
  • Loading branch information
steventux committed Feb 15, 2013
2 parents 34c0ab7 + 0ddefe4 commit 24d64fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions db/migrate/20130213162738_update_travel_advice_slugs.rb
@@ -1,15 +1,16 @@
class UpdateTravelAdviceSlugs < Mongoid::Migration
def self.up
Artefact.where(:slug => %r{\Atravel-advice/}).each do |artefact|
artefact.slug = "foreign-#{artefact.slug}"
artefact.save :validate => false # validate => false necessary because these will be live artefacts
if ! Rails.env.development? or ENV['UPDATE_SEARCH'].present?
Rummageable.delete("/#{artefact.slug}")
end
artefact.set(:slug, "foreign-#{artefact.slug}")
end
end

def self.down
Artefact.where(:slug => %r{\Aforeign-travel-advice/(.*)\z}).each do |artefact|
artefact.slug = artefact.slug.sub(/\Aforeign-/, '')
artefact.save :validate => false # validate => false necessary because these will be live artefacts
artefact.set(:slug, artefact.slug.sub(/\Aforeign-/, ''))
end
end
end

0 comments on commit 24d64fd

Please sign in to comment.