@@ -310,7 +310,7 @@ yargs.command(
310310 const hasChanged = await adapter . waitForPending ( CLI_LOGGER )
311311
312312 if ( hasChanged ) {
313- process . stdout . write ( 'The migrations have changed, reloading..\n\n' )
313+ process . stdout . write ( 'The pending migrations have changed, reloading..\n\n' )
314314 continue
315315 }
316316 // create pending tasks
@@ -363,7 +363,11 @@ const migrationCommand = (type: TaskType) => async (argv: MigrationCommandArgv)
363363 await adapter . init ( )
364364 const tasks = argv . migrations ! . map ( name => new Task ( { type, migration : new Migration ( name ) } ) )
365365 while ( true ) {
366- await adapter . waitForPending ( CLI_LOGGER )
366+ if ( await adapter . waitForPending ( CLI_LOGGER ) ) {
367+ process . stdout . write ( 'The pending migrations have changed, reloading..\n\n' )
368+ // retry
369+ continue
370+ }
367371 const head = await getHead ( )
368372 for ( const task of tasks ) {
369373 try {
@@ -377,19 +381,19 @@ const migrationCommand = (type: TaskType) => async (argv: MigrationCommandArgv)
377381 }
378382 }
379383 }
380- break
381- }
382- for ( const task of tasks ) {
383- process . stdout . write ( ` ${ task . toString ( ) } ...` )
384- const interval = setInterval ( ( ) => process . stdout . write ( '.' ) , 100 )
385- try {
386- await task . execute ( argv . migrationOutDir ! , adapter )
387- } finally {
388- clearInterval ( interval )
384+ for ( const task of tasks ) {
385+ process . stdout . write ( ` ${ task . toString ( ) } ...` )
386+ const interval = setInterval ( ( ) => process . stdout . write ( '.' ) , 100 )
387+ try {
388+ await task . execute ( argv . migrationOutDir ! , adapter , head )
389+ } finally {
390+ clearInterval ( interval )
391+ }
392+ process . stdout . write ( ' Success\n' )
389393 }
390- process . stdout . write ( ' Success\n' )
394+ process . stdout . write ( '\n' + chalk . green . bold ( 'Migration successful' ) + '\n' )
395+ break
391396 }
392- process . stdout . write ( '\n' + chalk . green . bold ( 'Migration successful' ) + '\n' )
393397 } catch ( err ) {
394398 process . stderr . write ( '\n' + chalk . red ( err . stack ) )
395399 process . exit ( 1 )
0 commit comments