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

change name of generated struct

This commit is contained in:
ZhengYang 2014-08-07 15:29:45 +08:00
parent af9780691c
commit cbe5fc1d21

View File

@ -45,7 +45,7 @@ func generateMigration(mname string, 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 f.Close() defer f.Close()
content := strings.Replace(MIGRATION_TPL, "{{StructName}}", camelCase(mname), -1) content := strings.Replace(MIGRATION_TPL, "{{StructName}}", camelCase(mname)+"_"+today, -1)
content = strings.Replace(content, "{{CurrTime}}", today, -1) content = strings.Replace(content, "{{CurrTime}}", today, -1)
f.WriteString(content) f.WriteString(content)
// gofmt generated source code // gofmt generated source code
@ -73,14 +73,16 @@ import (
"github.com/astaxie/beego/migration" "github.com/astaxie/beego/migration"
) )
// DO NOT MODIFY
type {{StructName}} struct { type {{StructName}} struct {
migration.Migration migration.Migration
} }
// DO NOT MODIFY
func init() { func init() {
m := &{{StructName}}{} m := &{{StructName}}{}
m.Created = "{{CurrTime}}" m.Created = "{{CurrTime}}"
migration.Register(m) migration.Register("{{StructName}}", m)
} }
// Run the migrations // Run the migrations