Search code examples
expressknex.js

Knex: Rollback specific migration?


I'd like to be able to rollback a specific knex migration on the command line.

For example:

knex migrate:rollback('20161104101325')

Is this possible?


Solution

  • From the doc:

    To undo the specified migration that was run

    knex migrate:down 001_migration_name.js
    

    To run the specified migration that has not yet been run

    knex migrate:up 001_migration_name.js
    

    To list both completed and pending migrations:

    knex migrate:list
    

    (to list and check)

    (migrate:list was released in 0.19.3! if not available update knex (npm i -g knex))