percolatestudio / meteor-migrations

Simple migration system for Meteor
https://atmospherejs.com/percolate/migrations
MIT License
245 stars 58 forks source link

How to remove SimpleSchema columns? #26

Closed larspetrus closed 3 years ago

larspetrus commented 9 years ago

Removing a column from SimpleSchema is problematic. The obvious code is

SomeCollection.update({}, {$unset: { someAttribute: 1 }}, {multi: true});

But SimpleSchema fails with Error: someAttribute is not allowed by the schema. This works...

SomeCollection.update({}, {$unset: { someAttribute: 1 }}, {multi: true, validate: false});

...but it feels hacky and something no one will think of until they've been burned. Some ideas:

jimmiebtlr commented 9 years ago

You realize you're in percolate migration's correct?

Anyway, you can do SomeCollection.direct to avoid collection2 cleaning your data.

larspetrus commented 9 years ago

My suggestion was that this framework would work around this problem, but I understand if that's not something you prioritize.

Mentioning it in the documentation could be a good idea.

I couldn't find any documentation for SomeCollection.direct, but if I'm doing a workaround, I'm happy with validate: false.