package migrations import ( "context" "github.com/uptrace/bun" "github.com/uptrace/bun/dialect" ) //nolint:lll func init() { // this index is for Postgres only migrations.MustRegister(func(ctx context.Context, db *bun.DB) error { if db.Dialect().Name() != dialect.PG { return nil } _, err := db.ExecContext( ctx, `create unique index concurrently if not exists ennoblements_hash_key on ennoblements (hash_record_extended( ROW (server_key, village_id, new_owner_id, new_tribe_id, old_owner_id, old_tribe_id, points, created_at), 0::bigint));`, ) return err }, func(ctx context.Context, db *bun.DB) error { if db.Dialect().Name() != dialect.PG { return nil } _, err := db.ExecContext(ctx, "DROP INDEX CONCURRENTLY ennoblements_hash_key") return err }) }