CockroachDB (and postgres?) `gin_trgm_ops` and `gist_trgm_ops` can't be set using HCL
Author: mbyioCreated May 13, 2023Updated Sep 29, 2026
Cockroach and Postgres support trigram indexes which are useful for fuzzy string matching.
I tried to define it in my schema.hcl following the pattern specified here: https://atlasgo.io/atlas-schema/sql-resources#index
index "username" {
type = GIN
on {
column = column.username
ops = gin_trgm_ops
}
}This emitted an error saying gin_trgm_ops is not a valid ops argument.
I was surprised this doesn't work, because cockroach DB's syntax matches postgres'. So I assume this doesn't work for postgres either. The cockroach documentation for it is here https://www.cockroachlabs.com/docs/stable/trigram-indexes.html#creation
As a workaround, I was able to rewrite my schema into SQL format.
Source: ariga/atlas