Skip to content

Commit

Permalink
Revert "Update: complementary fix for removing calling ddlSpec on mig…
Browse files Browse the repository at this point in the history
…ration"

The odds of getting this perfectly up is not good.

This reverts commit 3673659.
  • Loading branch information
gnanakeethan committed Jul 16, 2017
1 parent 3673659 commit 5521115
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions generate/g_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -247,6 +250,7 @@ const (
func init() {
m := &{{StructName}}{}
m.Created = "{{CurrTime}}"
{{ddlSpec}}
migration.Register("{{StructName}}", m)
}
`
Expand Down

0 comments on commit 5521115

Please sign in to comment.