Skip to content
Browse files

Merge pull request #39 from alphagov/change_registry_offices_to_regis…

…ter_offices

I'm not happy about use of db seeds, however for now I will merge this as it does what we need and shall have a further think about data migrations in the future.
  • Loading branch information...
2 parents 5558516 + 92e1e3f commit cf83a9d973f64958eb1a40ada2c70291fa91b765 @mnowster mnowster committed Nov 14, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 db/seeds/tags.rb
View
23 db/seeds/tags.rb
@@ -6,3 +6,26 @@
TagRepository.put(:tag_id => 'businesslink', :title => 'Business Link', :tag_type => 'legacy_source')
TagRepository.put(:tag_id => 'directgov', :title => 'Directgov', :tag_type => 'legacy_source')
+
+old_tag_id = 'births-deaths-marriages/registry-offices'
+new_tag_id = 'births-deaths-marriages/register-offices'
+
+old_registry_office_tag = Tag.where(:tag_id => old_tag_id).first
+if old_registry_office_tag
+ old_registry_office_tag.tag_id = new_tag_id
+ old_registry_office_tag.save!
+end
+
+new_registry_office_tag = Tag.where(:tag_id => new_tag_id).first
+
+Artefact.all.any_in(:tag_ids => [old_tag_id]).each do |artefact|
+ artefact.tag_ids = artefact.tag_ids.map do |tag_id|
+ if tag_id == old_tag_id
+ new_registry_office_tag.tag_id
+ else
+ tag_id
+ end
+ end
+
+ artefact.save!
+end

0 comments on commit cf83a9d

Please sign in to comment.
Something went wrong with that request. Please try again.