Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #56 from alphagov/fix_slug_change_migration

Fix slug change migration to deal with rummager update
  • Loading branch information...
commit 24d64fd6a84c5c874816fb36a55a2ef6acd09ef1 2 parents 34c0ab7 + 0ddefe4
@steventux steventux authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 db/migrate/20130213162738_update_travel_advice_slugs.rb
View
9 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
Please sign in to comment.
Something went wrong with that request. Please try again.