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

Paranoia to work with Uniqueness and Elastic Search #500

Open
ayza-hamid opened this issue Sep 21, 2020 · 1 comment
Open

Paranoia to work with Uniqueness and Elastic Search #500

ayza-hamid opened this issue Sep 21, 2020 · 1 comment
Labels

Comments

@ayza-hamid
Copy link

I used Paranoia gem for Rails 6. And it isn't working as expected. It passes the model level validations for unique columns.

PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_email" DETAIL: Key (email)=([email protected]) already exists.

Is this gem compatible with Rails 6. Also I am facing issues while indexing. In before action call for soft delete method the indexing doesn't work and shows all the records including the deleted ones.

@rodenmonte
Copy link

This isn't a problem with Rails 6. The deleted record with email "[email protected]" is still in your users table, with its paranoia column (probably deleted_at) set. It looks like you're using postgres, so you can solve this with a partial index, instead of create unique index index_users_on_email on users (email), try create unique index index_users_on_email_paranoid on users (email) where deleted_at is null or similar.

The readme explains better: https://github.com/rubysherpas/paranoia/blob/core/README.md#unique-indexes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants