Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion translators/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ func (p *MySQL) colType(c fizz.Column) string {
case "uuid":
return "char(36)"
case "timestamp", "time", "datetime":
return "DATETIME"
if c.Options["size"] != nil {
return fmt.Sprintf("DATETIME(%d)", c.Options["size"])
} else {
return "DATETIME"
}
case "blob", "[]byte":
return "BLOB"
case "int", "integer":
Expand Down
4 changes: 4 additions & 0 deletions translators/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ PRIMARY KEY(` + "`id`" + `),
` + "`decimal`" + ` DECIMAL(6,2) NOT NULL,
` + "`numeric`" + ` NUMERIC(7,2) NOT NULL,
` + "`double`" + ` DOUBLE(8,2) NOT NULL,
` + "`datetime_size3`" + ` DATETIME(3) NOT NULL,
` + "`datetime_nosize`" + ` DATETIME NOT NULL,
` + "`integer`" + ` INTEGER NOT NULL,
` + "`bytes`" + ` BLOB NOT NULL,
` + "`created_at`" + ` DATETIME NOT NULL,
Expand All @@ -77,6 +79,8 @@ PRIMARY KEY(` + "`id`" + `),
t.Column("decimal", "decimal", {"precision": 6,"scale":2})
t.Column("numeric", "numeric", {"precision": 7,"scale":2})
t.Column("double", "double", {"precision": 8,"scale":2})
t.Column("datetime_size3", "datetime", {"size": 3})
t.Column("datetime_nosize", "datetime")
t.Column("integer", "integer", {})
t.Column("bytes", "[]byte", {})
}
Expand Down