Knex
CLI
yarn run knex migrate:make $NAME
yarn run knex migrate:latest
yarn run knex migrate:rollbackConvenience Scripts
Update your 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.
Avoid an "init" file.
For example, do not have a: 20190424135724_init.js
Instead just do: 20190424135724_create_entries.js
This explains what the file does.
Tables should be plural
Fields should be in
camelCaseFollows JavaScript Style Guides for local variables
Exception relational id, for example:
entryID
Also see Engineering Code > Naming
Promises:
Last updated
Was this helpful?