Skip to content

Commit

Permalink
CockroachDB default types
Browse files Browse the repository at this point in the history
In cockroachdb, the default values returns something like `field:::TIMESTAMPZ`, and the validation here is only by the default value, without its type, this regex is required.
  • Loading branch information
rwrz committed Nov 2, 2022
1 parent 321c8fd commit f8e422c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions migrator.go
Expand Up @@ -424,6 +424,8 @@ func (m Migrator) ColumnTypes(value interface{}) (columnTypes []gorm.ColumnType,

if column.DefaultValueValue.Valid {
column.DefaultValueValue.String = regexp.MustCompile(`'(.*)'::[\w]+$`).ReplaceAllString(column.DefaultValueValue.String, "$1")
// cockroachdb, removing :::type
column.DefaultValueValue.String = regexp.MustCompile(`(.*):::[\w]+$`).ReplaceAllString(column.DefaultValueValue.String, "$1")
}

if datetimePrecision.Valid {
Expand Down

0 comments on commit f8e422c

Please sign in to comment.