Skip to content

Commit f8e422c

Browse files
authored
CockroachDB default types
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.
1 parent 321c8fd commit f8e422c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

migrator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ func (m Migrator) ColumnTypes(value interface{}) (columnTypes []gorm.ColumnType,
424424

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

429431
if datetimePrecision.Valid {

0 commit comments

Comments
 (0)