Ash FrameworkAF
Ash Framework3y ago
8 replies
axdc

Identity not creating unique index

I have a resource with an identity:
  attributes do
    uuid_primary_key :id

    attribute :title, :string do
      allow_nil? false
    end

    attribute :slug, :string do
      allow_nil? false
    end

    attribute :content, :string do
      allow_nil? false
    end

    create_timestamp(:inserted_at)
    update_timestamp(:updated_at)
  end

 relationships do
    belongs_to :site, MyApp.Sites.Site
  end

  identities do
    identity :slug_site, [:slug, :site]
  end


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 slugs should be unique within a site.
Was this page helpful?