Skip to content

Commit

Permalink
fix: composite index only created in one table
Browse files Browse the repository at this point in the history
index name must be unique across database, thus use the new mechanism to
automatically create unique name for same embedded struct

source: go-gorm/gorm#5269
  • Loading branch information
ukewea committed May 26, 2023
1 parent a9085d2 commit 76ff2fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/models/models.go
Expand Up @@ -8,9 +8,9 @@ import (

type CryptoOHLCV struct {
ID uint `gorm:"primaryKey"`
TradingSymbol string `gorm:"type:varchar(10);index:idx_tpair_timestamp;not null"`
VsCurrency string `gorm:"type:varchar(10);index:idx_tpair_timestamp;not null"`
Timestamp time.Time `gorm:"type:timestamptz;index:idx_tpair_timestamp;not null"`
TradingSymbol string `gorm:"type:varchar(10);index:,composite:tpair_ts;not null"`
VsCurrency string `gorm:"type:varchar(10);index:,composite:tpair_ts;not null"`
Timestamp time.Time `gorm:"type:timestamptz;index:,composite:tpair_ts;not null"`
Open decimal.Decimal `gorm:"type:numeric;not null"`
High decimal.Decimal `gorm:"type:numeric;not null"`
Low decimal.Decimal `gorm:"type:numeric;not null"`
Expand Down

0 comments on commit 76ff2fa

Please sign in to comment.