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.
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
andconditions
, 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.