For index on postgresql's jsonb column, it there anyway to create below indices, via golang struct's tag:

  • CREATE INDEX ON quiz USING gin (questions jsonb_path_ops); This is a gin index, specify a non-default operator class.
  • CREATE INDEX ON quiz_run (((valuation ->> 'percent')::float)); This is a b-tree index, apply on a sub field of a jsonb column.

Currently I have to create them by hand.

Wondering what's the best way to create these indices if gorm is used?

Comment From: li-jin-gou

refer to https://gorm.cn/docs/indexes.html and https://gorm.cn/docs/migration.html#Indexes