Skip to content

Commit

Permalink
关闭生产环境 migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Feb 13, 2022
1 parent b5035bb commit fcfdab0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ jobs:
- name: Debug Query
run: |
ls -l ./dist/release/
coscmd upload -h
- name: Upload To SV
run: |
Expand Down
9 changes: 9 additions & 0 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (
"github.com/yaoapp/kun/exception"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/engine"
"github.com/yaoapp/yao/share"
)

var name string
var force bool = false
var migrateCmd = &cobra.Command{
Use: "migrate",
Short: L("Update database schema"),
Expand All @@ -26,6 +28,12 @@ var migrateCmd = &cobra.Command{
}()

Boot()

if !force && config.Conf.Mode == "production" {
fmt.Println(color.WhiteString(L("TRY:")), color.GreenString("%s migrate --force", share.BUILDNAME))
exception.New(L("Migrate is not allowed on production mode."), 403).Throw()
}

// 加载数据模型
err := engine.Load(config.Conf)
if err != nil {
Expand Down Expand Up @@ -53,4 +61,5 @@ var migrateCmd = &cobra.Command{

func init() {
migrateCmd.PersistentFlags().StringVarP(&name, "name", "n", "", L("Model name"))
migrateCmd.PersistentFlags().BoolVarP(&force, "force", "", false, L("Force migrate"))
}
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var langs = map[string]string{
"Environment file": "指定环境变量文件",
"Help for yao": "显示命令帮助文档",
"Show app configure": "显示应用配置信息",
"Update database schema": "更新数据库结构",
"Update database schema": "更新数据表结构",
"Execute process": "运行处理器",
"Show version": "显示当前版本号",
"Development mode": "使用开发模式启动",
Expand All @@ -46,6 +46,8 @@ var langs = map[string]string{
"Listening": " 监听",
"✨LISTENING✨": "✨服务正在运行✨",
"SessionPort": "会话服务端口",
"Force migrate": "强制更新数据表结构",
"Migrate is not allowed on production mode.": "Migrate 不能再生产环境下使用",
}

// L 多语言切换
Expand Down
2 changes: 1 addition & 1 deletion share/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package share
// session -> freeport fix bug
// 更新制品目录 -> ui/downloads
// Arm64 制品 -> arm build test
// MacOS 制品 -> debug 13
// MacOS 制品 -> debug 14

// VERSION 版本号
const VERSION = "0.9.1"
Expand Down

0 comments on commit fcfdab0

Please sign in to comment.