Skip to content
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

Add db:migrate:pending to check for pending migrations, closes #165 #379

Closed
wants to merge 2 commits into from

Conversation

golmansax
Copy link

Threw together a pull to tackle #165, got tests to pass locally. A good amount of the src and test code was copied from db:migrate, so definitely open to feedback!

@mention-bot
Copy link

@golmansax, thanks for your PR! By analyzing the history of the files in this pull request, we identified @sdepold, @Americas and @cusspvz to be potential reviewers.

}
}).catch(function (err) {
console.error(err);
process.exit(1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.exit(255);?
I wouldn't exit with the same exit code as if it were pending migrations.

expect(stdout).to.contain('createPerson.js');
done();
}, {
cli: { exitCode: 1 },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is an error, this test will pass because errors are exiting with the same exit code as "pending migrations".

@golmansax
Copy link
Author

@cusspvz Thanks for the fast reply! It looks like an exit code of 1 is used throughout the repo, so I instead changed the pending migration exit code to 3 (wasn't sure what exit code to choose, and 2 is reserved according to http://www.tldp.org/LDP/abs/html/exitcodes.html)

You can see the changes in 69391de. Thoughts?

@cusspvz
Copy link

cusspvz commented Oct 31, 2016

I've took a time to look the repo and seems it only exits with 1 when it has errors, and with 0 when it hasn't, even in situations you want to express nothing has happened. In fact, it makes some sense, otherwise the command would break logic chains (like sequelize-cli db:migrate:pending && echo "OK").

Please note that I'm only an enthusiast/contributor, @sdepold is the admin of this repo.

@golmansax
Copy link
Author

If that's the case, then maybe it can always exit 0 by default, and then running db:migrate:pending --fail or with some other flag will cause it to exit 1 when then are pending migrations.. Thoughts?

@gotrevor gotrevor mentioned this pull request Nov 1, 2016
@Americas
Copy link
Collaborator

Americas commented Nov 3, 2016

I like this functionality, but the name is probably not the best. #385 has a better idea, and what I would propose is merging this change in that one.

What I propose:

  • Create the command db:migrate:status as is in add db:migrate:status #385
  • Add 2 optional arguments to that command:
  • - --pending outputs only pending migrations
  • - --executed outputs only executed migrations

Also, about the exit code, I believe it best to add the --fail flag to tell the program to exit with error on pending migrations. I assume this will be used to programatically chain functionality to the end of this call, it is better to add this as a special use case.

@golmansax
Copy link
Author

Yep, that makes sense. Maybe we can put this pull on hold until after #385 is merged, and then I'll update my pull to add onto the db:migrate:status command.

@Americas
Copy link
Collaborator

Americas commented Nov 3, 2016

for me that would be perfect 👍

@sushantdhiman
Copy link
Contributor

Closing (PR Cleanup), Open new PR if you wish to continue your work

codetriage-readme-bot pushed a commit to codetriage-readme-bot/cli that referenced this pull request Jun 5, 2019
Fix minor formatting issue in RELEASE doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants