Search code examples
javascriptnode.jsmigrationknex.js

Is the Promise argument passed into Knex migrations needed?


When running the command knex migrate:make table-name The below code is what appears in the newly created file.

exports.up = function (knex, Promise) {

  })
}

exports.down = function (knex, Promise) {
}

After I created my schema I noticed that I never used the Promise argument, provided by default (my code below).

exports.up = function (knex, Promise) {
  return knex.schema.createTable('Skills', (table) => {
    table.increments('id').primary()
    table.string('skill')
    table.string('description')
    table.integer('rating')
  })
}

exports.down = function (knex, Promise) {
  return knex.schema.dropTable('Skills')
}

I also had a look at other projects and realized I have never done anything with the Promise argument. Am I missing something? Or is it just provided by default and not always needed?


Solution

  • It is not needed for anything.

    It is historical argument from the time, when node didn't have builtin promises (or maybe reminder from the time when knex allowed to select promise implementation that is used).

    It is just an instance of bluebird (in knex 0.15.2).