Knex

https://knexjs.org/

CLI

yarn run knex migrate:make $NAME
yarn run knex migrate:latest
yarn run knex migrate:rollback

Convenience Scripts

Update your package.json:

package.json
{
  "scripts": {
    "latest": "yarn run knex migrate:latest",
    "rollback": "yarn run knex migrate:rollback"
  },
}

Migrations

Naming

Examples:

Sticks to the knex function names createTable and alterTable

Avoid an "init" file.

  • Tables should be plural

  • Fields should be in camelCase

Also see Engineering Code > Naming

Promises:

Last updated

Was this helpful?