Docs for Writing a Migration > Enums | Error + improvements needed
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- postgresql, rust
- Domain
- databases, documentation
Research direction
Start at the migration writing page's schema creation methods section and compare the enumeration_null example with the PostgreSQL enum creation example. Clarify the parameters, the role of CategoryEnum, how the two operations relate, and whether the duplicated values are required; correct the inconsistent enum names and ensure the examples compile.
Written by the indexing model from the issue text.
Description
I'm finding that the docs are quite vague and confusing, particularly around creating enums in migrations.
The following blocks of code are taken from:
https://www.sea-ql.org/SeaORM/docs/migration/writing-migration/#schema-creation-methods
First off; is there a typo? One section uses Store for the enum value/variant, and the other uses story? I'm assuming these should be the same.
A table is defined and it contains a column that uses an enum type. It's unclear what enumeration or enumeration_null actually does. My initial thought was that this creates the postgres enum type and assigns it to the column, but it doesnt. I now think that the first parameter is the column name, the second is the name of the postgres enum (which needs to be created separately), and the third parameter is the enum members/variants to generate on the generated rust enum? Total guess though.
manager
.create_table(
Table::create()
.table("post")
.if_not_exists()
.col(pk_auto("id"))
.col(string("title"))
.col(string("text"))
.col(enumeration_null("category", "category", ["Feed", "Store"]))
)
.await
There's a separate section to create a postgres enum data type. It's unclear what the relation is between the above section and the below section. It's also unclear what CategoryEnum is - it's not defined anywhere in the docs, so this example does not compile. Is it a rust enum type, does it require certain attributes or macros? Should it be a string? Why are the values different to the enumeration variants mentioned earlier (different case, and Store vs storey (latter is probably a typo))
manager
.create_type(
Type::create()
.as_enum(CategoryEnum)
.values(["feed", "story"])
.to_owned()
)
.await?;
If both the second block is needed (to create the postgres type) and the second block is needed (to create a column that uses the type), do we really need to duplicate the values/variants? I cant get my head around why we need to specify the variants when calling enumeration_null if we're specifying the name of the type that it uses - surely they can (and should) be inferred from the type, rather than duplicated whenever we reference that type?
- Dominant language
- HTML
- Stars
- 24
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SeaQL/seaql.github.io
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
SeaQL/seaql.github.io#172 ·
-
help wanted
Difficulty 5/5 Over a week Newbie friendliness 25/100
SeaQL/seaql.github.io#171 ·
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
SeaQL/seaql.github.io#166 ·
-
Doc improvementsOpenhelp wanted
Difficulty 4/5 3-5 days Newbie friendliness 25/100
SeaQL/seaql.github.io#163 ·
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 55/100
SeaQL/seaql.github.io#140 ·
All issues in SeaQL/seaql.github.io
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 77/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Wetzel402/Skylite-UX#125 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
oracle/rust-oracledb#53 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
objectionary/eo-graphs#82 ·