Knex uses migration files to apply or roll back database structural changes. To create a new migration file, for example, one can use the cli:
knex migrate:make migration_name
This generates a file in the /migrations directory containing:
exports.up = function(knex, Promise) {
};
exports.down = function(knex, Promise) {
};
My question is, why is this passing Promise as an argument? I see that knex makes heavy internal use of Bluebird, and passes Promise to the migration. Is this, then, a vestige from pre-Promise ubiquity? Or... is it that to purposefully overwrite the es6 implementation so it can make use of nonstandard methods like tap and spread?
Any clarity would be much appreciated.
If I recall correctly it was originally added there because es5 didn't have global Promise object.
It is not a documented feature, but for now the Promise passed to migration script is bluebird promise (https://github.com/tgriesser/knex/blob/master/src/migrate/index.js#L327).
However safest choice for future compatibility is to import promise from bluebird by yourself instead of using the one passed to the migration if you like to use special functions from bluebird.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With