Skip to content
Create a gist now

Instantly share code, notes, and snippets.

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|
:callout => Account::Page::Defaults.callout,
:phone =>,
:email =>
def self.down
query = {}
update = {'$unset' => {'' => true, '' => true, 'pages.callout' => true}}
opts = {'safe' => true}
Account.collection.update(query, update, opts) ### <- RAWK
tritonrc commented Feb 1, 2012

I never liked attributes to begin with ;)

ahoward commented Feb 1, 2012

;-) 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.