Skip to content

Commit 718a100

Browse files
doublemarkedbeeman
authored andcommitted
fix: Support for both Loopback 2.x and 3.x (#14)
1 parent ec7fc3e commit 718a100

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ module.exports = function(app, options) {
5757
app.model(MigrationMap);
5858

5959
if (!options.enableRest) {
60-
Migration.disableRemoteMethod('migrateTo', true);
61-
Migration.disableRemoteMethod('rollbackTo', true);
60+
if (Migration.disableRemoteMethodByName) {
61+
// Loopback 3.x+
62+
Migration.disableRemoteMethodByName('migrateTo');
63+
Migration.disableRemoteMethodByName('rollbackTo');
64+
} else {
65+
// Loopback 2.x
66+
Migration.disableRemoteMethod('migrateTo', true);
67+
Migration.disableRemoteMethod('rollbackTo', true);
68+
}
6269
}
6370
};

lib/models/migration.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"methods": {
2424
"migrateTo": {
2525
"description": "Run all pending migrations",
26-
"isStatic": true,
2726
"http": {
2827
"path": "/migrate",
2928
"verb": "get"
@@ -36,7 +35,6 @@
3635
},
3736
"migrateByName": {
3837
"description": "Run specific migration by name",
39-
"isStatic": true,
4038
"http": {
4139
"path": "/migrateByName",
4240
"verb": "get"
@@ -55,7 +53,6 @@
5553
},
5654
"rollbackTo": {
5755
"description": "Rollback migrations",
58-
"isStatic": true,
5956
"http": {
6057
"path": "/rollback",
6158
"verb": "get"

0 commit comments

Comments
 (0)