Permalink
Browse files

Ignore invalid user records in migration

They might be invalid for other reasons (eg they have been around for longer
than a given validation that it fails).
  • Loading branch information...
1 parent 24cad01 commit 135fdb78f78f33f68588eb5c6839e264d1928221 @jamiecobbett jamiecobbett committed Jan 15, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 db/migrate/20130111113023_change_permissions_to_array.rb
@@ -14,7 +14,7 @@ def self.up
User.all.each do |user|
if user.permissions.is_a?(Hash)
user.permissions = user.permissions["Publisher"]
- user.save!
+ user.save(validate: false)
end
end
end
@@ -23,7 +23,7 @@ def self.down
User.all.each do |user|
unless user.permissions.nil?
user.permissions = { "Publisher" => user.permissions }
- user.save!
+ user.save(validate: false)
end
end
end

0 comments on commit 135fdb7

Please sign in to comment.