mirror of
https://github.com/beego/bee.git
synced 2024-11-21 23:50:54 +00:00
basic structure for generate migration files
This commit is contained in:
parent
f879d728c8
commit
31b481d96a
13
g.go
13
g.go
@ -26,6 +26,9 @@ bee generate model [-driver=mysql] [-conn=root:@tcp(127.0.0.1:3306)/test] [-leve
|
|||||||
-conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test
|
-conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test
|
||||||
-level: [1 | 2 | 3], 1 = model; 2 = models,controller; 3 = models,controllers,router
|
-level: [1 | 2 | 3], 1 = model; 2 = models,controller; 3 = models,controllers,router
|
||||||
|
|
||||||
|
bee generate migration [filename]
|
||||||
|
generate migration file for making database schema update
|
||||||
|
|
||||||
bee generate controller [modelfile]
|
bee generate controller [modelfile]
|
||||||
generate RESTFul controllers based on modelfile
|
generate RESTFul controllers based on modelfile
|
||||||
|
|
||||||
@ -85,6 +88,16 @@ func generateCode(cmd *Command, args []string) {
|
|||||||
ColorLog("[INFO] Using '%s' as 'conn'\n", conn)
|
ColorLog("[INFO] Using '%s' as 'conn'\n", conn)
|
||||||
ColorLog("[INFO] Using '%s' as 'level'\n", level)
|
ColorLog("[INFO] Using '%s' as 'level'\n", level)
|
||||||
generateModel(string(driver), string(conn), string(level), curpath)
|
generateModel(string(driver), string(conn), string(level), curpath)
|
||||||
|
case "migration":
|
||||||
|
if len(args) == 2 {
|
||||||
|
filename := args[1]
|
||||||
|
ColorLog("[INFO] Using '%s' as migration file name\n", filename)
|
||||||
|
generateMigration(filename, curpath)
|
||||||
|
} else {
|
||||||
|
ColorLog("[ERRO] Wrong number of arguments\n")
|
||||||
|
ColorLog("[HINT] usage: bee generate migration [filename]\n")
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
ColorLog("[ERRO] command is missing\n")
|
ColorLog("[ERRO] command is missing\n")
|
||||||
}
|
}
|
||||||
|
22
g_migration.go
Normal file
22
g_migration.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright 2013 bee authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"): you may
|
||||||
|
// not use this file except in compliance with the License. You may obtain
|
||||||
|
// a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
// License for the specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func generateMigration(filename string, curpath string) {
|
||||||
|
fmt.Println("filename:", filename)
|
||||||
|
fmt.Println("curpath:", curpath)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user