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 18, 2023
1 parent b55a570 commit 6bee5a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/db/schema/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ func FromStatement(stmt *gorm.Statement) Table {
if field.FieldType.Kind() == reflect.Ptr {
if _, ok := field.TagSettings["NOT NULL"]; !ok {
column.Nullable = true
if field.DefaultValue == "" {
field.DefaultValue = "NULL"
if column.Type == "TIMESTAMP" && column.Default == "0000-00-00 00:00:00" {
column.Default = "NULL"
}
if column.Default == "" {
column.Default = "NULL"
}
}
}
Expand Down

0 comments on commit 6bee5a4

Please sign in to comment.