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

Combining command options does not work #3348

Open
thiagokoster opened this issue Jul 15, 2024 · 6 comments
Open

Combining command options does not work #3348

thiagokoster opened this issue Jul 15, 2024 · 6 comments
Labels
bug cli Concerns `sqlx-cli`

Comments

@thiagokoster
Copy link

Bug Description

Hey,
I'm trying to create a reversible sequential migration file. By reading the --help menu I thought that executing the the following command: sqlx migrate add -rs post would create two files, 0001_post.up.sql and 0001_post.down.sql.
But it only creates one file, 0001_post.up.sql.

Using just the -r flag works but it does not create a sequential file.
I don't know if this is the expected behavior or a bug.
Thanks in advance!

Minimal Reproduction

Execute:
sqlx migrate add -rs post

Info

  • SQLx version: sqlx-cli 0.7.4
  • SQLx features enabled: sqlx = { version = "0.7", features = [ "postgres", "uuid", "runtime-tokio", "tls-native-tls" ] }
  • Database server and version: PostgreSQL 16.3
  • Operating system: Linux
  • rustc --version: rustc 1.76.0
@abonander abonander added the cli Concerns `sqlx-cli` label Jul 15, 2024
@abonander
Copy link
Collaborator

This would appear to be a bug, yes.

@CommanderStorm
Copy link
Contributor

I tried writing a testcase for this but failed to reproduce the results.
Could you re-check your sqlx-cli version?

image

@thiagokoster
Copy link
Author

Sure, here is a screenshot of my current version and problem
image

@CommanderStorm
Copy link
Contributor

What does your directory look like? Maybe there is a combination of additions/removals that I am missing.
Could you try to also reproduce this in a fresh directory? (Thus ruling out that there is a platform/.. issue)

@thiagokoster
Copy link
Author

Hey, sorry for the delay.
It works fine in a fresh directory. And I think I found the issue.
I have a non-reversible migration in my migrations directory. After removing it, the -rs flag works.

I thought having a combination of reversible and non-reversible migration files was possible.

image

@CommanderStorm
Copy link
Contributor

@abonander so that I can provide the correct fix as a PR. Should the behavior be:

  • create a down migration for all in the current directory
  • create down only for the added migration (mixing up+down)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cli Concerns `sqlx-cli`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants