Permalink
Browse files

Merge pull request #56 from alphagov/fix_slug_change_migration

Fix slug change migration to deal with rummager update
  • Loading branch information...
2 parents 34c0ab7 + 0ddefe4 commit 24d64fd6a84c5c874816fb36a55a2ef6acd09ef1 @steventux steventux committed Feb 15, 2013
Showing with 5 additions and 4 deletions.
  1. +5 −4 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.