-
-
Notifications
You must be signed in to change notification settings - Fork 648
Open
Description
Description
Discord Ref
With the new entity-first approach, we can add unique as below
#[sea_orm(unique, column_type = "Text")]
pub url: String,I found it will generate two indexes, at least on Postgres
Table "public.url"
Column | Type | Collation | Nullable | Default
-------------+--------------------------+-----------+----------+----------------------------------
id | bigint | | not null | generated by default as identity
url | text | | not null |
Indexes:
"url_pkey" PRIMARY KEY, btree (id)
"idx-url-url" UNIQUE, btree (url)
"url_url_key" UNIQUE CONSTRAINT, btree (url)As you can see, it generated two indexes for UNIQUE property. I seeked help from the PG discord channel and asked if it is necessary and the adivce I got back was hinting it could be a mistake to have both indexes and UNIQUE CONSTRAINT is more "CORRECT", althought the difference is minimal.
Expected Behavior
It should use just UNIQUE CONSTRAINT
Actual Behavior
"idx-url-url" UNIQUE, btree (url)is redundant
Versions
sea-orm v2
Metadata
Metadata
Assignees
Labels
No labels