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

CLI: hasura migrate apply --down could validate the argument value and abort if it's absurdly big #8740

Open
floer32 opened this issue Aug 3, 2022 · 0 comments
Labels
c/cli Related to CLI k/enhancement New feature or improve an existing feature t/native-dbs t/product-platform

Comments

@floer32
Copy link
Contributor

floer32 commented Aug 3, 2022

Is your proposal related to a problem?

Recently I meant to run this command:

hasura migrate apply --type=down --version=1659058116550

But recalling the flags from memory, I accidentally ran this command instead:

hasura migrate apply --down=1659058116550

This was interpreted as wanting to go down N migrations where N = 1659058116550. I think it's safe to assume that is never what the operator intended.

Luckily, this was in a dev environment. That's actually why I didn't use --dry-run first. But it still caused a headache. Even though I killed the command after 5 or 10 seconds (when I realized what was going on), it had time to get the database into an invalid state. (And not just a state of bad migrations. It was a pgaudit stack is not empty error. But since it was just a dev database, I was able to roll back a day then just the correct migration commands and things were fine.)

Human errors are inevitable and these flags can be confused, so I think this is a good opportunity for some validation.

Describe the solution you'd like

Perhaps --down1 could have a guard on this number, and if it's above some threshold it would require confirmation. The number could be, say, the seconds-since-the-epoch when the Hasura project was started.

Describe alternatives you've considered

(Easier for me to phrase as questions)

  • Should it require interactive confirmation in that event, or just an additional flag?
  • Should it just refuse to proceed at all, since it's so unlikely that it could be intended?

If the feature is approved, would you be willing to submit a PR?

Yes.

Footnotes

  1. (... and perhaps --up but the impact would be smaller, since there won't be so many up-migrations that could be applied)

@floer32 floer32 added the k/enhancement New feature or improve an existing feature label Aug 3, 2022
@rikinsk rikinsk added the c/cli Related to CLI label Aug 16, 2022
@seanparkross seanparkross changed the title hasura migrate apply --down could validate the argument and abort if it's absurdly big CLI: hasura migrate apply --down could validate the argument value and abort if it's absurdly big Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/cli Related to CLI k/enhancement New feature or improve an existing feature t/native-dbs t/product-platform
Projects
None yet
Development

No branches or pull requests

4 participants