forked from sdelements/lets-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migroose.js
28 lines (26 loc) · 878 Bytes
/
migroose.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var mongoose = require("mongoose"),
settings = require('./app/config'),
migroose = require('migroose'),
MigrationModel = migroose.MigrationModel,
Runner = require('migroose-cli/cli/runner/index');
module.exports = {
connect: function(cb){
mongoose.connect(settings.database.uri, function(err){
if (err) { throw err; }
cb();
});
},
needsMigration: function(cb) {
var cwd = process.cwd();
var runner = new Runner(process.cwd(), 'migrootions');
var migrations = runner.getMigrations();
var lastMigration = migrations.slice(migrations.length - 1)[0];
MigrationModel.findOne({migrationId: lastMigration.migrationId}, function(err, model){
if (model) {
cb(false);
} else {
cb(true);
}
});
}
};