Meteor how to perform database migrations?

后端 未结 3 1123
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 04:02

How do you perform database migrations with Meteor? With Ruby on Rails there is ActiveRecord::Migration. Is there an equivalent mechanism in Meteor?

For example, I mak

3条回答
  •  终归单人心
    2021-01-31 05:02

    As Aram pointed already in the comment, percolate:migrations package gives you what you need. Sample

    Migrations.add({
        version: 1,
        name: 'Adds pants to some people in the db.',
        up: function() {//code to migrate up to version 1}
        down: function() {//code to migrate down to version 0}
    });
    
    Migrations.add({
        version: 2,
        name: 'Adds a hat to all people in the db who are wearing pants.',
        up: function() {//code to migrate up to version 2}
        down: function() {//code to migrate down to version 1}
    });
    

提交回复
热议问题