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

UniqueIndexChecker and postgresql partial indexes #195

Open
tconst opened this issue May 3, 2023 · 1 comment
Open

UniqueIndexChecker and postgresql partial indexes #195

tconst opened this issue May 3, 2023 · 1 comment

Comments

@tconst
Copy link

tconst commented May 3, 2023

In postgresql you can create partial indexes that allow you specify a where condition.
I was able to add a uniqueness validation that enforces these, using a combination of scope and conditions, e.g. validates_uniqueness_of :account_id, scope: :default, condition: -> { where(default: true}. This example enforces a single default per account. It would be awesome if the gem could identify these so that they aren't being flagged.

@djezzzl
Copy link
Owner

djezzzl commented May 9, 2023

Hi @tconst,

Thank you for the suggestion! Indeed, it would be cool to have such. Would you like to investigate and contribute?

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

No branches or pull requests

2 participants