@@ -119,6 +119,40 @@ Migrator.prototype = {
119
119
}
120
120
} ,
121
121
122
+ check : function ( funcOrOpts , callback ) {
123
+ var self = this ;
124
+ Migration . loadFromFilesystem ( self . migrationsDir , self . internals , function (
125
+ err ,
126
+ allMigrations
127
+ ) {
128
+ if ( err ) {
129
+ callback ( err ) ;
130
+ return ;
131
+ }
132
+
133
+ Migration . loadFromDatabase (
134
+ self . migrationsDir ,
135
+ self . _driver ,
136
+ self . internals ,
137
+ function ( err , completedMigrations ) {
138
+ if ( err ) {
139
+ callback ( err ) ;
140
+ return ;
141
+ }
142
+
143
+ // Requires pr to export filterCompleted from db-migrate-shared
144
+ var toRun = dbmUtil . filterCompleted (
145
+ allMigrations ,
146
+ completedMigrations
147
+ ) ;
148
+
149
+ log . info ( 'Migrations to run:' , toRun . map ( migration => migration . name ) ) ;
150
+ callback ( null , toRun ) ;
151
+ }
152
+ ) ;
153
+ } ) ;
154
+ } ,
155
+
122
156
sync : function ( funcOrOpts , callback ) {
123
157
var self = this ;
124
158
@@ -180,6 +214,13 @@ Migrator.prototype = {
180
214
return ;
181
215
}
182
216
217
+ if ( self . internals . check ) {
218
+ var toRunNames = toRun . map ( migration => migration . name ) ;
219
+ log . info ( 'Migrations to run:' , toRunNames ) ;
220
+ callback ( null , toRunNames ) ;
221
+ return ;
222
+ }
223
+
183
224
return Promise . resolve ( toRun )
184
225
. each ( function ( migration ) {
185
226
log . verbose ( 'preparing to run up migration:' , migration . name ) ;
@@ -234,6 +275,13 @@ Migrator.prototype = {
234
275
return ;
235
276
}
236
277
278
+ if ( self . internals . check ) {
279
+ var toRunNames = toRun . map ( migration => migration . name ) ;
280
+ log . info ( 'Migrations to run:' , toRunNames ) ;
281
+ callback ( null , toRunNames ) ;
282
+ return ;
283
+ }
284
+
237
285
return Promise . resolve ( toRun )
238
286
. each ( function ( migration ) {
239
287
log . verbose ( 'preparing to run down migration:' , migration . name ) ;
0 commit comments