This is a creation in Article, where the information may have evolved or changed.
This is how my model was built when I used Beego's ORM to build a table.
Type Test struct {Id int64name stringsex Int64 ' ORM: ' Default (1) ' Age int64content string ' orm: " Default (') '}
The Content field is set to NULL by default, the Sex field is set to default to 1, then the generated table does not have default, this is not scientific, so I turned over the source code, found that the default is the paragraph is commented, the location of the Github.com/astaxie/beego/orm /cmd_utils.go
155//If fi.initial.String ()! = "" {156//Column + = "DEFAULT" + fi.initial.String () 157//}
The three lines of comment, the decisive open (Brother Test, open no risk, bold to do), Ouke, the time to build the table solved the field default problem
Next, if you already have a table, and then add a field, you will still encounter the case that the field does not have default, we add, or this file, in line 107th
If fi.initial.String ()! = "" {Typ + = "DEFAULT" + fi.initial.String ()}
Add the field to the time of the OU, modify the field of the Beego did not do, hope to be able to the whole