Skip to content

Commit

Permalink
null db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
iesreza committed Dec 19, 2023
1 parent 52cd8bc commit db96d82
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/db/schema/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func FromStatement(stmt *gorm.Statement) Table {
}
}

if column.Type == "TIMESTAMP" && column.Default == "" && !column.Nullable {
column.Default = "0000-00-00 00:00:00"
}

if column.Name == "deleted_at" {
column.Nullable = true
column.Default = "NULL"
Expand Down Expand Up @@ -245,9 +249,9 @@ func getFieldQuery(field *Column) string {

if field.Default != "" {
var v = field.Default
if !(v[0] == '\'' || v[0] == '"' || v[0] == '`') {
v = strconv.Quote(v)
}
/* if !(v[0] == '\'' || v[0] == '"' || v[0] == '`') {
v = strconv.Quote(v)
}*/
query += " DEFAULT " + v
}

Expand Down

0 comments on commit db96d82

Please sign in to comment.