Set column defaults correctly for mysql

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
Andrew Thornton 2020-08-29 21:49:54 +01:00
parent f39a4cb41c
commit ded774e38d
No known key found for this signature in database
GPG Key ID: 3CDE74631F13A748
1 changed files with 2 additions and 4 deletions

View File

@ -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 + "'"
}
}