Don't set NULL if timestamp column is Primary Key

This commit is contained in:
zaneli 2019-03-14 16:56:23 +09:00
parent 8b07437717
commit 4ffdf07bbe

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)