Don't set NULL if timestamp column is Primary Key ()

This commit is contained in:
Shunsuke Otani 2019-04-14 22:11:29 +09:00 committed by Jinzhu
parent e3987fd4b8
commit 7bc3561503
1 changed files with 1 additions and 1 deletions

View File

@ -100,7 +100,7 @@ func (s *mysql) DataTypeOf(field *StructField) string {
precision = fmt.Sprintf("(%s)", p) 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) sqlType = fmt.Sprintf("timestamp%v", precision)
} else { } else {
sqlType = fmt.Sprintf("timestamp%v NULL", precision) sqlType = fmt.Sprintf("timestamp%v NULL", precision)