You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When porting our application to use knex 0.8.5 instead of knex 0.7.5 I encountered the following problem:
Previously when running a knex migration up()/down() functions, those functions could do nothing, i.e. return undefined and that would be treated the same as if we returned an already resolved promise.
This behaviour has been changed and now not returning a promise like that effectively leaves that migration step hanging indefinitely.
I can understand why the change has been made - you have two opposite use-cases:
User performs an operation like knex('table').insert(...)... and forgets the return statement in front of it. Here, the new warning + a very visible migration hang helps as it points out the error to the user so the started async operation is not left running in the background as a daemon while the following migration steps are run and potentially causing random migration failures.
Simple do-nothing migration steps. Here the change is a nuisance as such no-op functions now need to be changed to return an already resolved promise, or they risk causing failed/hung migrations.
Just wanted to confirm that the change was indeed intentional.
I got confused because example code generated by the src/migrate/stub/js.stub can still generate empty no-op up()/down() operations which would cause migration hangs/failures as mentioned above.
The text was updated successfully, but these errors were encountered:
I doubt this was intentional. I would definitely advise not using empty migrator functions. In a future version of the migration API, an undefined return value will trigger an exception. In order to do a noop migration you'll have to return false. Guessing this has to do with the use of transactions for migrations since no promise is returned and the transaction has no signal for when to commit.
When porting our application to use
knex 0.8.5
instead ofknex 0.7.5
I encountered the following problem:Previously when running a
knex
migrationup()
/down()
functions, those functions could do nothing, i.e. returnundefined
and that would be treated the same as if we returned an already resolved promise.This behaviour has been changed and now not returning a promise like that effectively leaves that migration step hanging indefinitely.
I can understand why the change has been made - you have two opposite use-cases:
knex('table').insert(...)...
and forgets thereturn
statement in front of it. Here, the new warning + a very visible migration hang helps as it points out the error to the user so the started async operation is not left running in the background as a daemon while the following migration steps are run and potentially causing random migration failures.Just wanted to confirm that the change was indeed intentional.
I got confused because example code generated by the
src/migrate/stub/js.stub
can still generate empty no-opup()
/down()
operations which would cause migration hangs/failures as mentioned above.The text was updated successfully, but these errors were encountered: