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

Migration should be optional in downgrade CLI #29

Closed
MinaPecheux opened this issue Jul 31, 2020 · 3 comments
Closed

Migration should be optional in downgrade CLI #29

MinaPecheux opened this issue Jul 31, 2020 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers needs-triage

Comments

@MinaPecheux
Copy link

Hi,

first of all, thanks a lot for this nice tool, it's really great for quick Mongo migrations!
Here is a small CLI bug:

Describe the bug
The API allows for an optional migration param, but the CLI requires it.

To Reproduce
Run pymongo-migrate downgrade -m folder -u URI: you get an error saying MIGRATION is required.

Expected behavior
The MIGRATION param should be optional: if none is provided, we downgrade all migrations in the folder.

Proposed fix
In src/cli.py, line 144-145, replace:

@click.argument("migration")
def downgrade(mongo_migrate, migration):

with

@click.argument("migration", required=False)
def downgrade(mongo_migrate, migration=None):
@rooterkyberian
Copy link
Contributor

Maybe its a stupid argument, but this requirement for me is an extra guarantee that I don't wipe my db my accident.
Downgrading to square one seems like an edge case - can you give example when that is needed?

Only case where I ever needed such thing was in tests - and there you could always hardcode the initial migration name.

If you feel it would be nice addition, I would gladly accept PR for it.

@rooterkyberian rooterkyberian added enhancement New feature or request good first issue Good for newcomers labels Aug 1, 2020
@MinaPecheux
Copy link
Author

MinaPecheux commented Aug 1, 2020

I do understand your point about data handling security.
I thought of it because in a multi-teams project where we share a database, it seemed interesting to have a way of downgrading back to the previous DB state if the other team could eventually not complete their dev and have the migration ready to work on their side.

Does it make sense?

It ultimately is your decision, though. (I'll make a PR, feel free to approve or reject it :))

@MinaPecheux
Copy link
Author

(Actually, I'm sorry but it seems to fail authenticating when I want to push my branch... I cloned the repo, checked out to a new branche and tried to push after committing. Am I missing a step? Thanks!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants