Open schinery opened 4 months ago
Also, I saw that there was https://github.com/rubysherpas/paranoia/issues/500, which looks like a similar thing but I didn't want to hijack that for my own purposes.
kind of a boring workaround, but you could add :deleted_at
column in the constraint.
what do you think ?
If you're using PostgreSQL you should use partial indexes (see docs). Try replacing:
t.index "lower((email)::text)", name: "index_clients_on_lower_email", unique: true
with
t.index "lower((email)::text)", name: "index_clients_on_lower_email", unique: true, where: 'deleted_at IS NOT NULL'
Given the following:
If I try and create a new client with the same email as a "deleted" client I get the following error:
What I was expecting to happen was that it would trigger an "email is already taken" validation error because I have
without_default_scope: true
, so it should check against all clients, not just the non-deleted ones.Is this what should be happening and something is wrong, or am I incorrect and need to do something else to validate against all clients.
I'm using:
Ruby 3.3.0 Rails 7.1.3.2 Paranoia 2.6.3