-
-
Notifications
You must be signed in to change notification settings - Fork 507
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 to Programmatically Generate Entities #1047
Comments
I can't believe you're doing the same I'm! 😄 I opened #1046 just before you! This is my code: use sea_orm_cli::{run_generate_command, DateTimeCrate};
pub async fn gen() {
run_generate_command(
sea_orm_cli::GenerateSubcommands::Entity {
database_url: "...database_url here...",
output_dir: "./entities".to_string(),
compact_format: false,
expanded_format: false,
include_hidden_tables: false,
tables: None,
ignore_tables: vec!["".to_string()],
max_connections: 1,
database_schema: "public".to_string(),
with_serde: "none".to_string(),
with_copy_enums: false,
date_time_crate: DateTimeCrate::Time,
},
true,
)
.await
.unwrap();
} |
LOL! This is great! Yeah I'm working on adding Sea ORM to my project here: https://github.com/whizzes/linx/tree/feat/seaorm and I wanted to have something similar to: https://github.com/whizzes/linx/tree/feat/seaorm/migration for the entity crate. 😄 |
Hey @EstebanBorai, can you share more on what you want to achieve? Would depends on sea-orm-codegen instead of sea-orm-cli be a good idea? Just like seaography |
Hey I have a similar use case: Instead of wrapping the CLI in a @frederikhors proposal looks just what I need/imagine :) |
Hi @billy1624! My goal is to be able to run the entity generation through code, @frederikhors makes a good example on it. https://github.com/whizzes/linx/blob/6acbed5b8236b57a9ed4f04d72f631b1456e81a0/src/context.rs#L32 I would like to have a function that I can run passing my entities crate and a database url, and have entities generated similar to when I do: sea-orm-cli generate entity I think this could help improve DX by not having to manually install the CLI and run the command manually. |
Hello everyone, I'll try to draft a PR this afternoon. I'm thinking to rewrite |
Hey @billy1624, thank you so much for your work and the prompt reply 👍 |
Awesome @billy1624! |
Hey everyone. please check #1054 |
After second thought, I think I suggest everyone to go one level dipper and programmatically generate entity based on |
Hi @billy1624! Do you have an example of how it would be? |
@billy1624 Totally fine with me. One question though: Will all (current and future) CLI options be mirrored in the API of |
Motivation
It would be great to be able to generate entities similar to how migrations can be run
programmatically. As of today we have to install the sea-orm-cli manually in order
to have entities generated:
This would improve DX by using a single command (
cargo run
) when running a solutionusing Sea ORM on development.
Proposed Solutions
Having an API similar to the one using by
Migrator
could be a first approach.I think we could reuse the code from the Sea ORM Cli similar to what we do for
migrations nowadays.
Additional Information
My goal is to improve DX by allowing the user to provide custom scripts by taking advantage
of the CLI as an API on runtime.
The text was updated successfully, but these errors were encountered: