Where for runing "Migrations.migrateTo('latest')" (on CLI / JS (client/server))?


I try to use percolate:migrations package to migrate data.

// In server
  version: 1,
  up: function() {//code to migrate up to version 1

But I don’t know where to run Migrations.migrateTo('latest')?
In command line or JS (client/server).
Please help me.


On a Heroku hosted application, I have a file called migrator.js:

if (Meteor.isServer) {

Alongside it I keep a folder /migrations with files 1.js, 2.js etc, each containing migrations for a specific version.

I think down migrations are only intended for development use, since you can’t use “$ meteor shell” in production. To run down migrations, I run “Migrations.migrateTo()” the version I need from the meteor shell, and then I git checkout to the right commit. When I go forward in time again I don’t need to use the meteor shell, it’ll migrate to automatically.



In your migrations folder, you are having files like 1.js, 2.js etc. Can you give any example of the contents of those files?
I am trying to achieve the following:
Let’s say for an upgrade I need to run migrations for two different collections. How can we add those migrations in one file like 1.js?


You basically use the up and down functions as scripts to modify your collections.

  version: 1,
  name: 'Change some stuff.',
  up: function() {
    collectionOne.update({}, { $rename: { oldName: 'newName' } }); // One collection...
    collectionTwo.remove({ prop: 'removeMe' }); // And two collections updated in one migration!
  down: function() {
    collectionOne.update({}, { $rename: { newName: 'oldName' } });