njord-rs / njord

A versatile, feature-rich Rust ORM ⛵
https://njord.rs
BSD 3-Clause "New" or "Revised" License
409 stars 21 forks source link

Build a CLI for running schema changes, migration etc #14

Open mjovanc opened 1 year ago

mjovanc commented 1 year ago

Commands that should exist:

njord migration generate <name>
njord migration run
njord migration rollback

Flags that should exist on njord:

Flags that should exist on njord migration:

Examples:

njord setup
njord migration generate <name> --env=development --dry-run
njord migration run --env=production --log-level=debug
njord migration rollback --env=development --to=20191225120000
mjovanc commented 11 months ago

Command/args logic now in place and skeleton functions added that will be updated later.

mjovanc commented 11 months ago

Basic command line functionality in place, now its just time to actually implement generate, run and rollback functions.

mjovanc commented 11 months ago

How should we specify which connector we should use, for example:

njord migration generate <name> --env=development --dry-run --connector=sqlite

or during installation of the CLI with:

cargo install njord --no-default-features --features sqlite
mjovanc commented 11 months ago

By using:

njord setup

We should look for a file usually located in src/schema.rs if not specified elsewhere in njord.toml file to extract values from there and create SQL queries based on that. Not like Diesel does that you have to manually create the SQL queries to setup tables...

mjovanc commented 11 months ago

Passing in --env=development doesn't get the actual value as well as other arguments:

Migration files generated successfully:
Version: 00000000000002
Name: --name=update_users
Environment: Some("--")
Dry-run: None
newtoallofthis123 commented 11 months ago

This looks like something right up my alley 😁

mjovanc commented 11 months ago

@newtoallofthis123 Super! Would you have time to look at my previous comment with that issue with passing arguments? That would be very helpful since I do not have time at the moment to look at it. If you do, just fork the repo, send a PR. Thanks!

newtoallofthis123 commented 11 months ago

Sure will

newtoallofthis123 commented 11 months ago

Hey! Your code seems quite good and it is working just fine for me...

image

My suspicion is that it might be a weird thing with your terminal....can you once try using '--env=development' or --env='development'

mjovanc commented 11 months ago

Alright, I can not test right now, but could you look maybe into how we can strip the --env= from the arg strings here: https://github.com/njord-rs/njord/blob/master/njord_cli/src/command.rs#L139

So we can pass only the "pure" values into the next function to call, either generate(), run() and rollback()?

newtoallofthis123 commented 11 months ago

So, strip the string and have an enum? or something like that?

mjovanc commented 11 months ago

So, strip the string and have an enum? or something like that?

Sounds good to me!

mjovanc commented 8 months ago

The CLI has been improved with functionality of generating new schema changes and running it. However a lot of work still persists and help here is needed! Will pause this CLI tool since it's not really necessary at the moment. More important work is needed on njord and njord_derive crate.

Let me know if someone is interested in helping out here.

mjovanc commented 8 months ago

https://github.com/njord-rs/njord/tree/njord_cli

shadrach-tayo commented 7 months ago

I just forked the repo and will try to read through it to understand the code. Happy to continue work on this as soon I'm done