Skip to content

Commit df62f7c

Browse files
committed
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 915abc3 commit df62f7c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

migrator.go

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

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

429432
if datetimePrecision.Valid {

0 commit comments

Comments
 (0)