@@ -119,6 +119,40 @@ Migrator.prototype = {
119119 }
120120 } ,
121121
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+
122156 sync : function ( funcOrOpts , callback ) {
123157 var self = this ;
124158
@@ -180,6 +214,13 @@ Migrator.prototype = {
180214 return ;
181215 }
182216
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+
183224 return Promise . resolve ( toRun )
184225 . each ( function ( migration ) {
185226 log . verbose ( 'preparing to run up migration:' , migration . name ) ;
@@ -234,6 +275,13 @@ Migrator.prototype = {
234275 return ;
235276 }
236277
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+
237285 return Promise . resolve ( toRun )
238286 . each ( function ( migration ) {
239287 log . verbose ( 'preparing to run down migration:' , migration . name ) ;
0 commit comments