1
0
mirror of https://github.com/beego/bee.git synced 2024-11-21 18:40:54 +00:00

Revert "Update: complementary fix for removing calling ddlSpec on migration"

The odds of getting this perfectly up is not good.

This reverts commit 3673659178.
This commit is contained in:
Gnanakeethan Balasubramaniam 2017-07-16 08:13:08 +05:30
parent 3673659178
commit 552111517e
No known key found for this signature in database
GPG Key ID: 24924006ABA72F31

View File

@ -203,10 +203,12 @@ func GenerateMigration(mname, upsql, downsql, curpath string) {
fpath := path.Join(migrationFilePath, fmt.Sprintf("%s_%s.go", today, mname))
if f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err == nil {
defer utils.CloseFile(f)
ddlSpec := ""
spec := ""
up := ""
down := ""
if DDL != "" {
ddlSpec = "m.ddlSpec()"
switch strings.Title(DDL.String()) {
case "Create":
spec = strings.Replace(DDLSpecCreate, "{{StructName}}", utils.CamelCase(mname)+"_"+today, -1)
@ -222,6 +224,7 @@ func GenerateMigration(mname, upsql, downsql, curpath string) {
}
header := strings.Replace(MigrationHeader, "{{StructName}}", utils.CamelCase(mname)+"_"+today, -1)
header = strings.Replace(header, "{{ddlSpec}}", ddlSpec, -1)
header = strings.Replace(header, "{{CurrTime}}", today, -1)
f.WriteString(header + spec + up + down)
// Run 'gofmt' on the generated source code
@ -247,6 +250,7 @@ const (
func init() {
m := &{{StructName}}{}
m.Created = "{{CurrTime}}"
{{ddlSpec}}
migration.Register("{{StructName}}", m)
}
`