From 7bc35615034c1d6994088c2cc925086fba6f565e Mon Sep 17 00:00:00 2001 From: Shunsuke Otani Date: Sun, 14 Apr 2019 22:11:29 +0900 Subject: [PATCH] Don't set NULL if timestamp column is Primary Key (#2332) --- dialect_mysql.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dialect_mysql.go b/dialect_mysql.go index 5d63e5cd..89b638b3 100644 --- a/dialect_mysql.go +++ b/dialect_mysql.go @@ -100,7 +100,7 @@ func (s *mysql) DataTypeOf(field *StructField) string { precision = fmt.Sprintf("(%s)", p) } - if _, ok := field.TagSettingsGet("NOT NULL"); ok { + if _, ok := field.TagSettingsGet("NOT NULL"); ok || field.IsPrimaryKey { sqlType = fmt.Sprintf("timestamp%v", precision) } else { sqlType = fmt.Sprintf("timestamp%v NULL", precision)