Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
migration with temporary simple schema
Migrations.add({
version : 26,
name : 'Remove profile.email from users',
up : function(){
// add optional profile.email so we can remove it
var profile = _.extend({
email : {
type : String,
optional: true
}
}, Schemas.UserProfile._schema);
var user = Schemas.User._schema;
var profileSchema = new SimpleSchema(profile);
user.profile = {type: profileSchema, optional: true};
var userSchema = new SimpleSchema(user);
Meteor.users.attachSchema(userSchema, {replace: true});
Meteor.users.find({"profile.email": {$exists: true}}).forEach(function(u){
Meteor.users.update({_id: u._id}, {$unset: {"profile.email": ""}});
});
// reset the schema back to the original
Meteor.users.attachSchema(Schemas.User, {replace: true});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.