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

Why does sea-orm-cli generate entity not include Cargo.toml file #805

Closed
baoyachi opened this issue Jun 21, 2022 · 10 comments
Closed

Why does sea-orm-cli generate entity not include Cargo.toml file #805

baoyachi opened this issue Jun 21, 2022 · 10 comments
Labels
good first issue Good for newcomers

Comments

@baoyachi
Copy link
Contributor

baoyachi commented Jun 21, 2022

Description

Steps to Reproduce

  1. When I use sea-orm-cli generate entity: not auto generate Cargo.toml file.
  • exec cmd
~  sea-orm-cli generate entity \
    -o entity/src \
    --with-serde both
➜  tree
entity
└── src
    ├── device_config.rs
    ├── biz_info.rs
    ├── biz_task.rs
    ├── mod.rs
    ├── node.rs
    ├── prelude.rs
    ├── pack.rs

Versions

Additional Information

➜  sea-orm-cli -Vv
sea-orm-cli 0.8.1
➜  

I expect whole cargo library. But now ,lost Cargo.toml not running. Need I add manully

@hhstore
Copy link

hhstore commented Jun 30, 2022

  • My guess is to consider that entity can also be used as a module instead of a standalone package.
  • Below is my go-task script, you can use it. It fixes this automatically.
  • This is not a big problem. Officials can add a support in the generation options.
tasks:

  migrate:orm:model:
    cmds:
      - sea-orm-cli generate entity -u ${DATABASE_URL} -o {{.APP_NAME}}/src
      - cd {{.APP_NAME}}; cargo init --lib;
      - cd {{.APP_NAME}}; mv src/mod.rs src/lib.rs;
      - cd {{.APP_NAME}}; cargo add serde@1 --features derive
      - cd {{.APP_NAME}}; cargo add sea-orm@0.9
    vars:
      APP_NAME: "entity"
    ignore_error: true

@ikrivosheev
Copy link
Member

Maybe we can add a flag? Generate mod or new crate?

@billy1624
Copy link
Member

Maybe we can add a flag? Generate mod or new crate?

Yeah, related discussion

@baoyachi
Copy link
Contributor Author

baoyachi commented Jul 4, 2022

May be sea-orm support config this all option into file. and then exec :sea-orm-cli, that all people can read file config known how to do it.

@billy1624
Copy link
Member

May be sea-orm support config this all option into file. and then exec :sea-orm-cli, that all people can read file config known how to do it.

Do you mean sea-orm-cli can load configuration (e.g. -u ${DATABASE_URL} -o {{.APP_NAME}}/src) from a environment file (.env file)? Then, user can simply execute the command sea-orm-cli generate entity.

@billy1624
Copy link
Member

Maybe we can add a flag? Generate mod or new crate?

Yeah, that's what I'm thinking. By default, it generate a module which is the current behaviour. We can introduce a new flag --lib which will generate a crate with a src folder that contains all of the generated entity files and mod.rs will be lib.rs, and of cause a Cargo.toml file with sea-orm dependency.

@billy1624
Copy link
Member

I'll open this issue for anyone interested to contribute :)
We'd provide the necessary guidance

@billy1624 billy1624 added the good first issue Good for newcomers label Jul 6, 2022
@baoyachi
Copy link
Contributor Author

baoyachi commented Jul 6, 2022

Yeah, that's what I'm thinking. By default, it generate a module which is the current behaviour. We can introduce a new flag --lib which will generate a crate with a src folder that contains all of the generated entity files and mod.rs will be lib.rs, and of cause a Cargo.toml file with sea-orm dependency.

If there are too many configurations of sea ORM cli, consider the configuration method:

e.g:

➜  ls
├── Cargo.toml
├── README.md
├── sea-orm.toml
├── migration
├── src

All configuration write in sea-orm.toml.

The more options sea ORM cli has, the more complex it is to use,not friendly.

@JonasCir
Copy link

JonasCir commented Oct 10, 2022

Maybe we can solve this by introducing sea-orm-cli entity init analogous to sea-orm-cli migrate init?

This would reduce the number of manual steps required of setting up a project, thus improving developer experience. We also could introduce a flag which controls whether to create a module or a lib.rs.

@Diwakar-Gupta
Copy link
Contributor

I'll open this issue for anyone interested to contribute :)
We'd provide the necessary guidance

@billy1624
If you are planning to add those features I would like to contribute.

The required features are still not decided but I can say we are looking for 2 things

  1. option to export as module or library
  2. read parameters from the config file or environment variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Archived in project
Development

No branches or pull requests

6 participants