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

PG index options handle CONCURRENT option separately #297

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

abbyssoul
Copy link
Contributor

  • [ x] Do only one thing
  • [x ] Non breaking API changes
  • [x ] Tested

What did this pull request do?

PR adds a check for usage of .Options field when creating indexes in PG.
Based on the feedback for the previous PR - PG Migrator allows the use of .Options to specify extra index creation options such as concurrently.
Previous PR broke that feature.
This is a fix.

User Case Description

When using Postgres driver with Gorm, users can opt to provide extra directives when creating an index.
One such PG-specific directive is to create an index ["concurrently"] (https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY). Another PG driver-specific option is to specify whether for a unique index, null values should be considered distinct or not (https://www.postgresql.org/docs/current/sql-createindex.html)
Users require a mechanism to provide these extra options for index creation. For this purpose, 'gorm options' are used: https://gorm.io/docs/indexes.html

Previous PR introduced a bug where if PG user would specify gorm:"index:,option:CONCURRENTLY" option, it would result in ill-formed index because the term 'CONCURRENTLY' will be used twice.
With this PR, users can use "CONCURRENTLY" created index option OR NULLS NOT DISTINCT option, but not both.

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.

1 participant