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

Support Rust migrations from refinery_cli #188

Open
Raytwo opened this issue Sep 29, 2021 · 4 comments
Open

Support Rust migrations from refinery_cli #188

Raytwo opened this issue Sep 29, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@Raytwo
Copy link

Raytwo commented Sep 29, 2021

Greetings,

As the title say, I'd like to suggest supporting Rust migrations as an enhancement for refinery_cli.

I'm actually not sure if I'm the one doing something wrong, but after a quick glance at the code and my attempt being met with migration V1__Initial is missing from the filesystem when trying to run the command on a directory that works perfectly fine when migrating from code, I'd assume it just isn't supported at the moment.

Thanks for your great work, as someone with no experience with databases, refinery has been a lifesaver.

@jxs
Copy link
Member

jxs commented Sep 30, 2021

Hi, and thanks for the interest! Yeah Rust Migrations are currently not supported by refinery_cli we would need to parse and compile the rust code in the migrations at runtime and I thought it's just easier if one creates a binary crate, adds refinery and includes the Rust migrations. Can you elaborate on your use case?
Thanks :)

@Raytwo
Copy link
Author

Raytwo commented Sep 30, 2021

Oh well, that's actually a good solution too, I didn't even stop to consider it.

My use case for the moment is simply creating tables in a freshly made PostgreSQL database running in Docker, with Rust migrations being ran by Rocket as a Adhoc Ignite function.

I just felt like having to run my software to initialize the tables wasn't good practice and was considering using refinery_cli instead, which would also be better considering the person working with me on the frontend is not a Rust user and it seemed to me that letting them run the migrations through a command line was a better approach than asking them to build and run the backend.

Also, considering we generate models for the project using sea-orm-cli with a database-first approach, this also suggests that not having to run the backend to generate the database when the models aren't even present in the code would be preferable.

I'm eventually considering running refinery through build.rs for the time being, which while not the best, would probably be better than having to run the software for it.

I'll keep your suggestion in mind though! Thanks for the fast reply.

@jxs
Copy link
Member

jxs commented Sep 30, 2021

I just felt like having to run my software to initialize the tables wasn't good practice

why not? it runs once and if it's already migrated refinery won't run the migrations again

@Raytwo
Copy link
Author

Raytwo commented Oct 1, 2021

Because currently the process is:
Set up database > run my API > migrations get applied > close software > generate models with sea-orm-cli > start writing code

It’s not such a big deal, really, but I think your approach with having a separate project to be able to run the migrations is cleaner

@jxs jxs added the enhancement New feature or request label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants