兼容casbin2.24.0版本log

迁移脚本编译时不打包
This commit is contained in:
linwenxiang committed 2021-03-05 13:23:21 +08:00
1 parent 48f0cb46ec
commit 39dd1ee6f8
56 files changed
+320 -454

No files matched your search

+4 -4
View File
@@ -53,7 +53,7 @@ func setup() {
config.Setup(file.NewSource, file.WithPath(configYml))
go config.Watch()
//2. 设置日志
global.Cfg.SetLogger(
global.Runtime.SetLogger(
logger.SetupLogger(
config.LoggerConfig.Type,
config.LoggerConfig.Path,
@@ -72,7 +72,7 @@ func run() error {
if config.ApplicationConfig.Mode == tools.ModeProd.String() {
gin.SetMode(gin.ReleaseMode)
}
engine := global.Cfg.GetEngine()
engine := global.Runtime.GetEngine()
if engine == nil {
engine = gin.New()
}
@@ -88,11 +88,11 @@ func run() error {
srv := &http.Server{
Addr: fmt.Sprintf("%s:%d", config.ApplicationConfig.Host, config.ApplicationConfig.Port),
Handler: global.Cfg.GetEngine(),
Handler: global.Runtime.GetEngine(),
}
go func() {
jobs.InitJob()
jobs.Setup(global.Cfg.GetDb())
jobs.Setup(global.Runtime.GetDb())
}()
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -181,4 +183,4 @@ func _1599190683670Test(db *gorm.DB, version string) error {
Version: version,
}).Error
})
}
}
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -18,7 +20,7 @@ func init() {
func _1613978564961Test(db *gorm.DB, version string) error {
return db.Transaction(func(tx *gorm.DB) error {
// TODO: 这里开始写入要变更的内容
// TODO: 这里开始写入要变更的内容
menu := models.Menu{MenuId: 110, Path: "/api/v1/config"}
err := tx.Model(&menu).Where("menu_id = ?", 110).Update("Path", "/api/v1/dict/data-all").Error
if err != nil {
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -18,7 +20,7 @@ func init() {
func _1614073723691Test(db *gorm.DB, version string) error {
return db.Transaction(func(tx *gorm.DB) error {
// TODO: 这里开始写入要变更的内容
// TODO: 这里开始写入要变更的内容
err := tx.Model(&models.Menu{}).Where("path = ?", "/api/v1/syscontentList").Update("path", "/api/v1/syscontent").Error
if err != nil {
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
@@ -1,3 +1,5 @@
// +build ignore
package version
import (
+3 -2
View File
@@ -36,6 +36,7 @@ var (
}
)
// fixme 在您看不见代码的时候运行迁移,我觉得是不安全的,所以编译后将不包含所有迁移文件
func init() {
StartCmd.PersistentFlags().StringVarP(&configYml, "config", "c", "config/settings.yml", "Start server with provided configuration file")
StartCmd.PersistentFlags().BoolVarP(&generate, "generate", "g", false, "generate migration file")
@@ -50,7 +51,7 @@ func run() {
//1. 读取配置
config.Setup(file.NewSource, file.WithPath(configYml))
//2. 设置日志
global.Cfg.SetLogger(
global.Runtime.SetLogger(
logger.SetupLogger(
config.LoggerConfig.Type,
config.LoggerConfig.Path,
@@ -67,7 +68,7 @@ func migrateModel() error {
if host == "" {
host = "*"
}
db := global.Cfg.GetDbByKey(host)
db := global.Runtime.GetDbByKey(host)
if config.DatabasesConfig[host].Driver == "mysql" {
//初始化数据库时候用
db.Set("gorm:table_options", "ENGINE=InnoDB CHARSET=utf8mb4")