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

How to downgrade sea-orm-cli version? #1286

Closed
frederikhors opened this issue Dec 6, 2022 · 29 comments · Fixed by #1299
Closed

How to downgrade sea-orm-cli version? #1286

frederikhors opened this issue Dec 6, 2022 · 29 comments · Fixed by #1299
Assignees

Comments

@frederikhors
Copy link
Contributor

frederikhors commented Dec 6, 2022

If I install with:

cargo install sea-orm-cli@0.10.2

and generate with:

sea-orm-cli generate entity //......

the generated file have:

//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.5

instead of of 0.10.2.

If I run

sea-orm-cli -v

I can see:

sea-orm-cli 0.10.2

What is going on?

I need the 0.10.2 version right now.

@billy1624
Copy link
Member

Hey @frederikhors, please use the following command to degrade sea-orm-cli.

cargo install --version 0.10.2 sea-orm-cli

@frederikhors
Copy link
Contributor Author

I tried this too and with --force too. Nothing. The version of generated files is 0.10.5 always. Crazy!

@billy1624
Copy link
Member

Hmmm... why? Did you try uninstall it first then install it again?

@frederikhors
Copy link
Contributor Author

Yeah! Of course!

@frederikhors
Copy link
Contributor Author

I used:

cargo uninstall sea-orm-cli

Removing C:\Users\Fred\.cargo\bin\sea-orm-cli.exe
Removing C:\Users\Fred\.cargo\bin\sea.exe

@billy1624
Copy link
Member

And try restarting the command prompt after installation

@frederikhors
Copy link
Contributor Author

Then I installed with:

cargo install --version 0.10.2 sea-orm-cli

...
  Compiling tracing-subscriber v0.3.16
  Compiling clap v3.2.23
  Compiling chrono v0.4.23
  Compiling sqlx v0.6.2
  Compiling sea-query-binder v0.2.2
  Compiling sea-schema v0.10.3
  Compiling sea-orm-codegen v0.10.5
  Compiling sea-orm-cli v0.10.2
  Finished release [optimized] target(s) in 2m 48s
Installing C:\Users\Fred\.cargo\bin\sea-orm-cli.exe
Installing C:\Users\Fred\.cargo\bin\sea.exe
  Installed package `sea-orm-cli v0.10.2` (executables `sea-orm-cli.exe`, `sea.exe`)

Now it is 0.10.2.

If I generate the files have the comment (and the differences) of the 0.10.5! Crazy!

@frederikhors
Copy link
Contributor Author

I restarted the shell (Powershell-Core). The same.

@frederikhors
Copy link
Contributor Author

It's crazy because the .exe in cargo's bin directory is the new one!

@billy1624
Copy link
Member

I suspect this is the result of some weird caching issue

@frederikhors
Copy link
Contributor Author

Yeah but the executable is new. It's installed with the command cargo install --version 0.10.2 sea-orm-cli. I'm going to reset the cargo cache now and I'll try again.

@billy1624
Copy link
Member

Please :)

@frederikhors
Copy link
Contributor Author

I did. I removed everything because this is a new PC.

I manully removed cache directories too.

I installed rustup & cargo again, and sea-orm-cli with 0.10.2.

Nothing. The generation is for 0.10.5.

I give up. This is totally crazy.

@frederikhors
Copy link
Contributor Author

This is really bad because I'm stucked right now. I cannot generate nor new table or old ones.

Is there a way I can use Cargo.toml to fix the version o sea-orm-cli avoiding the executable?

@frederikhors
Copy link
Contributor Author

Is it possible that during compilation on my PC cargo uses master branch files or latest tag ones?

@billy1624
Copy link
Member

I guess you can git clone the project at 0.10.2 tag. Then run the CLI locally.

@frederikhors
Copy link
Contributor Author

Yeah. I will in a few minutes temporarily. I think this should work.

What do you think could be the problem?

Have you tried the downgrade on your PC?

@billy1624
Copy link
Member

billy1624 commented Dec 7, 2022

Okay. I think I think what have happened! Check how sea-orm-cli depends on sea-orm-codegen.

sea-orm-codegen = { version = "^0.10.5", path = "../sea-orm-codegen", optional = true }

Basically, it will pick the latest sea-orm-codegen! i.e. sea-orm-codegen 0.10.5

@frederikhors
Copy link
Contributor Author

Wow! This is the issue. How can we fix this?

@frederikhors
Copy link
Contributor Author

Also we have to fix this for older versions too?

https://github.com/SeaQL/sea-orm/blob/0.10.2/sea-orm-cli/Cargo.toml

@billy1624
Copy link
Member

It's intended to always fetch the latest 0.10.x sea-orm-codegen.

@frederikhors
Copy link
Contributor Author

It's intended to always fetch the latest 0.10.x sea-orm-codegen.

I think this is not the correct behavior.

In this case we were stuck because of the bug of the related trait.

I think we need a way to downgrade safely.

@billy1624
Copy link
Member

Oh. sorry... didn't mean to close this issue

@billy1624 billy1624 reopened this Dec 12, 2022
@frederikhors
Copy link
Contributor Author

Ok. It was a little bit strange! 😄

@billy1624
Copy link
Member

It's intended to always fetch the latest 0.10.x sea-orm-codegen.

So, the intention is to compile with the latest codegen but as a side effect, one cannot downgrade to 0.10.x unless going below it e.g. 0.9.x

I think we should make it

sea-orm-codegen = { version = "=0.10.5", ... } 

@frederikhors
Copy link
Contributor Author

Is there a way we can choose in Cargo.toml which version of both we depend on?

@billy1624
Copy link
Member

billy1624 commented Dec 12, 2022

Is there a way we can choose in Cargo.toml which version of both we depend on?

Yes, only if you clone this repository into local then modify the Cargo.toml and finally execute cargo install --path sea-orm-cli --force to install sea-orm-cli

@frederikhors
Copy link
Contributor Author

Yes, I meant for the future. Wouldn't there be a way just using Cargo.toml?

@billy1624
Copy link
Member

Note that every time we released a new sea-orm-codegen, we always bump the version of sea-orm-cli. That way, you can downgrade to each and every single version of it.

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 a pull request may close this issue.

2 participants