From 52cd8bcd0888195d2eb3e5169a1d19eddc4f09b5 Mon Sep 17 00:00:00 2001 From: Reza Date: Mon, 18 Dec 2023 18:24:03 +0100 Subject: [PATCH] null db migration --- lib/db/schema/ddl/ddl.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/db/schema/ddl/ddl.go b/lib/db/schema/ddl/ddl.go index f8dda5cc..faeb144f 100644 --- a/lib/db/schema/ddl/ddl.go +++ b/lib/db/schema/ddl/ddl.go @@ -118,12 +118,6 @@ func FromStatement(stmt *gorm.Statement) Table { Unique: field.Unique, } - if len(column.Default) > 0 { - if !(column.Default[0] == '\'' || column.Default[0] == '"' || column.Default[0] == '`') { - column.Default = strconv.Quote(column.Default) - } - } - if v, ok := field.TagSettings["CHARSET"]; ok { column.Charset = v } @@ -250,8 +244,13 @@ func getFieldQuery(field *Column) string { } if field.Default != "" { - query += " DEFAULT " + field.Default + var v = field.Default + if !(v[0] == '\'' || v[0] == '"' || v[0] == '`') { + v = strconv.Quote(v) + } + query += " DEFAULT " + v } + if field.OnUpdate != "" { query += " ON UPDATE " + field.OnUpdate }