From ded774e38d715f185055af75bfcde8ed59fe0fb0 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 29 Aug 2020 21:49:54 +0100 Subject: [PATCH] Set column defaults correctly for mysql Signed-off-by: Andrew Thornton --- dialects/mysql.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dialects/mysql.go b/dialects/mysql.go index f9a2e943..75aab375 100644 --- a/dialects/mysql.go +++ b/dialects/mysql.go @@ -335,7 +335,7 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName col.Nullable = true } - if colDefault != nil { + if colDefault != nil && *colDefault != "NULL" { col.Default = *colDefault col.DefaultIsEmpty = false } else { @@ -404,9 +404,7 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName } if !col.DefaultIsEmpty { - if col.SQLType.IsText() { - col.Default = "'" + col.Default + "'" - } else if col.SQLType.IsTime() && col.Default != "CURRENT_TIMESTAMP" { + if col.SQLType.IsTime() && col.Default != "CURRENT_TIMESTAMP" { col.Default = "'" + col.Default + "'" } }