Merge pull request #232 from sergeylanzman/fix-generate-migration

fix generate migration for postgressql
This commit is contained in:
astaxie 2016-07-24 00:00:50 +08:00 committed by GitHub
commit 1e5a7ec9a5
2 changed files with 6 additions and 0 deletions

3
g.go
View File

@ -172,6 +172,9 @@ func generateCode(cmd *Command, args []string) int {
if fields != "" {
upsql = `m.SQL("CREATE TABLE ` + mname + "(" + generateSQLFromFields(fields.String()) + `)");`
downsql = `m.SQL("DROP TABLE ` + "`" + mname + "`" + `")`
if driver == "postgres" {
downsql = strings.Replace(downsql, "`", "", -1)
}
}
generateMigration(mname, upsql, downsql, curpath)
case "controller":

View File

@ -30,6 +30,9 @@ func generateScaffold(sname, fields, crupath, driver, conn string) {
if fields != "" {
upsql = `m.SQL("CREATE TABLE ` + sname + "(" + generateSQLFromFields(fields) + `)");`
downsql = `m.SQL("DROP TABLE ` + "`" + sname + "`" + `")`
if driver == "" {
downsql = strings.Replace(downsql, "`", "", -1)
}
}
generateMigration(sname, upsql, downsql, crupath)
}