Identity not creating unique index
I have a resource with an identity:
When creating these resources, the uniqueness that I think I'm specifying is not being enforced, and I don't see a unique index in postgres reflecting it.
I've dropped and recreated the database, deleting all migrations and snapshots to be sure.
Do Identities not work with relationships? Is there a recommended way to communicate to Ash what I'm looking for? The intended behavior is that
slug
s should be unique within a site
.5 Replies
You want
site_id
, not site
๐
The generated attribute for the belongs_to :site
is :site_id
I wonder if that is something that could be caught in the validations and warned about. :thinkies: Because identities can only be based on attributes, right?
technically they can be used in an informative way on any non-relationship field.
but that one is a relationship
so yeah we could almost certainly just add a new verifier, i.e
Ash.Resource.Verifiers.VerifyIdentityFields
, would likely be trivialI won't get to it soon, but that might be something I (or another contributor) can tackle easily in a few minutes, so I'll create an issue for it.
https://github.com/ash-project/ash/issues/576 Might want to mark it as a good first issue. ๐
GitHub
Validation: Ash.Resource.Verifiers.VerifyIdentityFields ยท Issue #57...
Is your feature request related to a problem? Please describe. Given this schema: attributes do uuid_primary_key :id attribute :title, :string do allow_nil? false end attribute :slug, :string do al...