Skip to content

Fixing issue with resolving indexes for Postgres.#329

Open
ViagioJustin wants to merge 1 commit intoreliese:v1.xfrom
ViagioJustin:v1.x
Open

Fixing issue with resolving indexes for Postgres.#329
ViagioJustin wants to merge 1 commit intoreliese:v1.xfrom
ViagioJustin:v1.x

Conversation

@ViagioJustin
Copy link
Copy Markdown

@ViagioJustin ViagioJustin commented Mar 17, 2026

Not sure if this is happening on the MySQL as well but noticed when using this with Postgres that almost all generated relationships were HasMany or BelongsToMany even if there were unique keys or indexes.

Best I could tell the regex for matching the index definitions was not matching a string like:

CREATE UNIQUE INDEX addons_product_id_unique ON public.addons USING btree (product_id)

It seemed like the regex was expecting something like:

CREATE UNIQUE INDEX addons_product_id_unique (product_id)

And maybe that's a MySQL syntax? Not sure. But changing the regex here seemed to correctly detect unique indexes and then bubbling up to the generator when determining if a relationship is a HasOne/BelongsTo or HasMany/BelongsToMany.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants