How to create a partial index with Ash?
Eduardo B. Alexandre:
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)
Ash HQ Bot:
Found 3 results in ash_postgres:
- custom_indexes: https://ash-hq.org/docs/dsl/ash_postgres/1.3.9/ashpostgres/postgres/custom_indexes
- custom_indexes: https://ash-hq.org/docs/module/ash_postgres/1.3.9/ashpostgres-datalayer-info#function-custom_indexes-1
- custom_indexes: https://ash-hq.org/docs/module/ash_postgres/1.3.9/ashpostgres#function-custom_indexes-1
ZachDaniel:
You can do it with
custom_indexes
😄
ZachDaniel:
that top result
Eduardo B. Alexandre:
Sorry, I was trying to search the docs with the
partial
word 😅
ZachDaniel:
would go inside the
postgres
section, like:
postgres do
custom_indexes do
custom_index ...
end
end
ZachDaniel:
no worries 😄 I think its on us to include common search terms in the docs for things
ZachDaniel:
so that people can find it better when searching 😄
Eduardo B. Alexandre:
And I guess if I want to make the changeset aware of that index I need to use check_constrains right?
ZachDaniel:
nope, it will be aware of that index 🙂
Eduardo B. Alexandre:
Nice!