AE
Ash Elixir•3y ago
Blibs

How to create a partial index with Ash?

I was wondering, can I create a partial index using identities or some other way with Ash or should I just write a migration manually directly? For example, how can I do this partial index?
create index(:users, [:id], where: "not \"invalid_token?\"", name: :users_valid_tokens)
create index(:users, [:id], where: "not \"invalid_token?\"", name: :users_valid_tokens)
7 Replies
ZachDaniel
ZachDaniel•3y ago
You can do it with custom_indexes 😄 that top result
Blibs
BlibsOP•3y ago
Sorry, I was trying to search the docs with the partial word 😅
ZachDaniel
ZachDaniel•3y ago
would go inside the postgres section, like:
postgres do
custom_indexes do
custom_index ...
end
end
postgres do
custom_indexes do
custom_index ...
end
end
no worries 😄 I think its on us to include common search terms in the docs for things so that people can find it better when searching 😄
Blibs
BlibsOP•3y ago
And I guess if I want to make the changeset aware of that index I need to use check_constrains right?
ZachDaniel
ZachDaniel•3y ago
nope, it will be aware of that index 🙂
Blibs
BlibsOP•3y ago
Nice!

Did you find this page helpful?