Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
removing a bunch of mongo attributes in one hit #L19
class AddPageFields < Mongoid::Migration
def self.up
Account.all.each do |account|
account.pages.each do |page|
page.update_attributes!(
:callout => Account::Page::Defaults.callout,
:phone => Account::Page::Defaults.phone,
:email => Account::Page::Defaults.email
)
end
end
end
def self.down
query = {}
update = {'$unset' => {'pages.email' => true, 'pages.phone' => true, 'pages.callout' => true}}
opts = {'safe' => true}
Account.collection.update(query, update, opts) ### <- RAWK
end
end
@tritonrc

I never liked attributes to begin with ;)

@ahoward
Owner

;-) i've made mistakes with $set/$unset methodologies in the past when i wanted to query like : '$exists' => {:root => true} because $exists is always a table scan. in this case, of course, we're just rolling back a schema modification, but i thought i'd mention is since '$unset' often is paired with '$exists' in code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.