Search code examples
postgresqlgogo-gorm

how to define list of string on gorm model?


this is my model

type Ticket struct {
    gorm.Model

    PassengerName string         `json:"passenger_name"`
    Price         uint64         `json:"price"`
    Seat          pq.StringArray `gorm:"type:string[]" json:"seat"`
}

gorm.io/driver/postgres@v1.3.1/migrator.go:118 ERROR: type "string[]" does not exist (SQLSTATE 42704)


Solution

  • There’s no string data type in postgre. Change string[] to text[]