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

feat: add --quiet option to migration:show command (Fixes #7349) #8185

Merged
merged 3 commits into from Feb 15, 2022

Conversation

Juddling
Copy link
Contributor

Description of change

Currently typeorm migration:show prints out a list of migrations, and returns an error exit code if there are any unapplied migrations.

The error code is useful in CI contexts, to assert that all migrations have been applied, perhaps before a code deploy.

Issue #7349 points out that this error code is noisy/annoying for local development. This PR introduces a --quiet flag to supress that exit code.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

@@ -46,8 +49,9 @@ export class MigrationShowCommand implements yargs.CommandModule {
const unappliedMigrations = await connection.showMigrations();
await connection.close();

// return error code if there are unapplied migrations for CI
process.exit(unappliedMigrations ? 1 : 0);
const silenceError = args.quiet !== undefined ? true : false;

Choose a reason for hiding this comment

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

const silenceError = args.quiet !== undefined

@Juddling
Copy link
Contributor Author

Could someone trigger the CI checks for this branch please? I can't see how to trigger in the docs.

@pleerock
Copy link
Member

pleerock commented Nov 1, 2021

After reading the context, I have to agree that migration:show doesn't have to throw error exit code at all. I understand that there might be a specific use cases, however they shouldn't be a migration:show responsibility for sure. So, I have to agree it was a mistake to merge a previous PR.

I suggest to revert previous behavior (make quite mode by default) and add a separate command for this particular use case. Now sure how to name it, maybe something like migration:status, or suggest your better alternatives.

@pleerock
Copy link
Member

Okay since there is no answer from author, I reverted status code back to 0. Regarding to adding migration:status feel free to create a separate PR for that feature.

@pleerock pleerock merged commit e0adeee into typeorm:master Feb 15, 2022
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.

None yet

3 participants