-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use knex to create, run, rollback migrations with samples #24
Use knex to create, run, rollback migrations with samples #24
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24 +/- ##
=======================================
Coverage 21.02% 21.02%
=======================================
Files 11 11
Lines 176 176
Branches 11 11
=======================================
Hits 37 37
Misses 137 137
Partials 2 2 Continue to review full report at Codecov.
|
@p0k8h Please add a description of what you did in the description section as well. Example: #7 |
We usually use imperative mood "spoken or written as if giving a command or instruction" for commits. The commit should explain what the change is. Read here: https://chris.beams.io/posts/git-commit/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@p0k8h Also update the PR title and description. |
* @returns {Promise<any>} | ||
* | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this new line here. Doc blocks should be attached to the method.
* | ||
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this extra '*'
* @returns {Promise<any>} | ||
* | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
* | ||
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
* | ||
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
* @returns {Promise<any>} | ||
* | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
7062df4
to
077975c
Compare
077975c
to
fd9cc81
Compare
examples/node-app-mssql/src/migrations/20191124213750_create_user_table.js
Show resolved
Hide resolved
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
*/ | ||
exports.up = function(knex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do export function
syntax instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you'll need a stub file for this. cc @mesaugat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do
export function
syntax instead?
To use es6
syntax we need a transpiler(babel). Shall I add a babel
config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's do.
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
*/ | ||
exports.down = function(knex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here and all over.
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
*/ | ||
exports.up = function(knex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
* @param {Knex} knex | ||
* @returns {Promise<any>} | ||
*/ | ||
exports.down = function(knex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
examples/node-app-mssql/package.json
Outdated
"@babel/node": "^7.7.4", | ||
"@babel/preset-env": "^7.7.4", | ||
"@babel/register": "^7.7.4", | ||
"babel-core": "^6.26.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this. You already have included @babel/core
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @p0k8h 👍
Resolves #21
knexfile.js
in root is the config file for knex./src/migrations/
contains 2 migration files forusers
andtasks
table.package.json
contains 3 new scripts.make
: to create migration files.migrate
: to run the migration.rollback
: to rollback migration.