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

Generating enums #782

Open
askasp opened this issue Sep 23, 2024 · 3 comments
Open

Generating enums #782

askasp opened this issue Sep 23, 2024 · 3 comments
Labels
db enhancement New feature or request generator

Comments

@askasp
Copy link

askasp commented Sep 23, 2024

Great work on this framework.

How do you go about in creating enums? It would be awesome if it was a part of the generator. Lacking that i find it hard to add it directly to my _entities/Model.rs as that gode is overwritten on new generations.

Are there any examples on handling enums with loco?

@askasp askasp added the enhancement New feature or request label Sep 23, 2024
@joshua-mo-143
Copy link
Contributor

Loco uses SeaORM under the hood - you probably wanna check this: https://www.sea-ql.org/SeaORM/docs/generate-entity/enumeration

@tanto-satu
Copy link

im also curious about this, for my case i dont want to create a new type enum in the database, because using enums as per documentation at seaorm, specific to each database (MySQL or PostgreSQL). How can i achieve using enum, but with creating new table with columns data type is string/text?

My concern is to be able to switch between database (MySQL and PostgreSQL) without doing some changes in the migration.

@jtwaleson
Copy link
Contributor

I create enums as strings in the database, manually write Rust enums under _entities::Model , add some comments and do a git checkout -p after cargo loco db entities. It works OK but would like to see a better solution as well. Haven't found a way to do this as part of the migrations yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db enhancement New feature or request generator
Projects
None yet
Development

No branches or pull requests

5 participants