0.0.1 • Published 11 years ago

co-migrate v0.0.1

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

co-logger

Winston based logger for compound.js

Replace default CompoundJS logger with Winston

Installation

Step 1. Install using npm:

npm install co-migration --save

Step 2. Add co-migrate to config/autoload.js, for example:

module.exports = function (compound) {
    return [
        'ejs-ext',
        'jugglingdb',
        'seedjs',
        'co-logger',
        'co-migrate'
    ].map(require);
};

Usages

To create new migration step use:

compound m create MyNewMigrationName

New migration file will be located in the "/migrations" folder. "db" variable is available in your migration file.

Migration file example(for MongoDB adapter):

exports.up = function(next){

  db.collection('Event', function(err, collection){

    if(err){
      console.log("Cannot get collection Event")
      next(err);
    } else {
      collection.ensureIndex( { "from": 1 }, function(err){
        next(err);
      });
    }
  });

};

exports.down = function(next){

  db.collection('Event', function(err, collection){

    if(err){
      console.log("Cannot get collection Event")
      next(err);
    } else {
      collection.dropIndex( { "from": 1 }, function(err){
        next(err);
      });
    }
  });

};

To run migrations use:

compound m up

To roll back all migrations use:

compound m down

You can specify migration name for "up" and "down" commands.

Don't forget to add "/migrations/.migrate" file to ".gitignore"

0.0.1

11 years ago

0.0.0

11 years ago