mirror of
https://github.com/beego/bee.git
synced 2024-11-22 15:10:54 +00:00
Merge pull request #232 from sergeylanzman/fix-generate-migration
fix generate migration for postgressql
This commit is contained in:
commit
1e5a7ec9a5
3
g.go
3
g.go
@ -172,6 +172,9 @@ func generateCode(cmd *Command, args []string) int {
|
|||||||
if fields != "" {
|
if fields != "" {
|
||||||
upsql = `m.SQL("CREATE TABLE ` + mname + "(" + generateSQLFromFields(fields.String()) + `)");`
|
upsql = `m.SQL("CREATE TABLE ` + mname + "(" + generateSQLFromFields(fields.String()) + `)");`
|
||||||
downsql = `m.SQL("DROP TABLE ` + "`" + mname + "`" + `")`
|
downsql = `m.SQL("DROP TABLE ` + "`" + mname + "`" + `")`
|
||||||
|
if driver == "postgres" {
|
||||||
|
downsql = strings.Replace(downsql, "`", "", -1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
generateMigration(mname, upsql, downsql, curpath)
|
generateMigration(mname, upsql, downsql, curpath)
|
||||||
case "controller":
|
case "controller":
|
||||||
|
@ -30,6 +30,9 @@ func generateScaffold(sname, fields, crupath, driver, conn string) {
|
|||||||
if fields != "" {
|
if fields != "" {
|
||||||
upsql = `m.SQL("CREATE TABLE ` + sname + "(" + generateSQLFromFields(fields) + `)");`
|
upsql = `m.SQL("CREATE TABLE ` + sname + "(" + generateSQLFromFields(fields) + `)");`
|
||||||
downsql = `m.SQL("DROP TABLE ` + "`" + sname + "`" + `")`
|
downsql = `m.SQL("DROP TABLE ` + "`" + sname + "`" + `")`
|
||||||
|
if driver == "" {
|
||||||
|
downsql = strings.Replace(downsql, "`", "", -1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
generateMigration(sname, upsql, downsql, crupath)
|
generateMigration(sname, upsql, downsql, crupath)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user