mirror of
https://github.com/beego/bee.git
synced 2024-11-22 10:10:53 +00:00
Update: complementary fix for removing calling ddlSpec on migration
file. Signed-off-by: Gnanakeethan Balasubramaniam <gnanakeethan@gmail.com>
This commit is contained in:
parent
042a4cf244
commit
3673659178
@ -203,12 +203,10 @@ func GenerateMigration(mname, upsql, downsql, curpath string) {
|
|||||||
fpath := path.Join(migrationFilePath, fmt.Sprintf("%s_%s.go", today, mname))
|
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 {
|
if f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err == nil {
|
||||||
defer utils.CloseFile(f)
|
defer utils.CloseFile(f)
|
||||||
ddlSpec := ""
|
|
||||||
spec := ""
|
spec := ""
|
||||||
up := ""
|
up := ""
|
||||||
down := ""
|
down := ""
|
||||||
if DDL != "" {
|
if DDL != "" {
|
||||||
ddlSpec = "m.ddlSpec()"
|
|
||||||
switch strings.Title(DDL.String()) {
|
switch strings.Title(DDL.String()) {
|
||||||
case "Create":
|
case "Create":
|
||||||
spec = strings.Replace(DDLSpecCreate, "{{StructName}}", utils.CamelCase(mname)+"_"+today, -1)
|
spec = strings.Replace(DDLSpecCreate, "{{StructName}}", utils.CamelCase(mname)+"_"+today, -1)
|
||||||
@ -224,7 +222,6 @@ func GenerateMigration(mname, upsql, downsql, curpath string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
header := strings.Replace(MigrationHeader, "{{StructName}}", utils.CamelCase(mname)+"_"+today, -1)
|
header := strings.Replace(MigrationHeader, "{{StructName}}", utils.CamelCase(mname)+"_"+today, -1)
|
||||||
header = strings.Replace(header, "{{ddlSpec}}", ddlSpec, -1)
|
|
||||||
header = strings.Replace(header, "{{CurrTime}}", today, -1)
|
header = strings.Replace(header, "{{CurrTime}}", today, -1)
|
||||||
f.WriteString(header + spec + up + down)
|
f.WriteString(header + spec + up + down)
|
||||||
// Run 'gofmt' on the generated source code
|
// Run 'gofmt' on the generated source code
|
||||||
@ -250,7 +247,6 @@ const (
|
|||||||
func init() {
|
func init() {
|
||||||
m := &{{StructName}}{}
|
m := &{{StructName}}{}
|
||||||
m.Created = "{{CurrTime}}"
|
m.Created = "{{CurrTime}}"
|
||||||
{{ddlSpec}}
|
|
||||||
migration.Register("{{StructName}}", m)
|
migration.Register("{{StructName}}", m)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user