Skip to content

Commit

Permalink
fix: Support for both Loopback 2.x and 3.x (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
doublemarked authored and beeman committed Jan 25, 2017
1 parent ec7fc3e commit 718a100
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 9 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ module.exports = function(app, options) {
app.model(MigrationMap);

if (!options.enableRest) {
Migration.disableRemoteMethod('migrateTo', true);
Migration.disableRemoteMethod('rollbackTo', true);
if (Migration.disableRemoteMethodByName) {
// Loopback 3.x+
Migration.disableRemoteMethodByName('migrateTo');
Migration.disableRemoteMethodByName('rollbackTo');
} else {
// Loopback 2.x
Migration.disableRemoteMethod('migrateTo', true);
Migration.disableRemoteMethod('rollbackTo', true);
}
}
};
3 changes: 0 additions & 3 deletions lib/models/migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"methods": {
"migrateTo": {
"description": "Run all pending migrations",
"isStatic": true,
"http": {
"path": "/migrate",
"verb": "get"
Expand All @@ -36,7 +35,6 @@
},
"migrateByName": {
"description": "Run specific migration by name",
"isStatic": true,
"http": {
"path": "/migrateByName",
"verb": "get"
Expand All @@ -55,7 +53,6 @@
},
"rollbackTo": {
"description": "Rollback migrations",
"isStatic": true,
"http": {
"path": "/rollback",
"verb": "get"
Expand Down

0 comments on commit 718a100

Please sign in to comment.