mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 02:04:09 +00:00
fix:优化代码
This commit is contained in:
@@ -24,13 +24,13 @@ func _1599190683659Tables(db *gorm.DB, version string) error {
|
||||
new(system.SysConfig),
|
||||
new(tools.SysTables),
|
||||
new(tools.SysColumns),
|
||||
new(models.Menu),
|
||||
new(models.SysMenu),
|
||||
new(system.SysLoginLog),
|
||||
new(system.SysOperaLog),
|
||||
new(models.RoleMenu),
|
||||
new(models.SysRoleDept),
|
||||
new(models.SysUser),
|
||||
new(models.SysRole),
|
||||
new(system.SysRole),
|
||||
new(models.Post),
|
||||
new(models.DictData),
|
||||
new(models.DictType),
|
||||
|
||||
@@ -20,7 +20,7 @@ func _1600089797118Migrate(db *gorm.DB, version string) error {
|
||||
f := &models.SysFileDir{
|
||||
Label: "根目录",
|
||||
PId: 0,
|
||||
//Sort: "0",
|
||||
Sort: "0",
|
||||
Path: "",
|
||||
ControlBy: common.ControlBy{
|
||||
CreateBy: 1,
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/models/system"
|
||||
|
||||
//"go-admin/app/admin/models"
|
||||
"gorm.io/gorm"
|
||||
"runtime"
|
||||
|
||||
"go-admin/cmd/migrate/migration"
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
_, fileName, _, _ := runtime.Caller(0)
|
||||
migration.Migrate.SetVersion(migration.GetFilename(fileName), _1613638159444Test)
|
||||
}
|
||||
|
||||
func _1613638159444Test(db *gorm.DB, version string) error {
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
|
||||
// TODO: 这里开始写入要变更的内容
|
||||
|
||||
// TODO: 例如 修改表字段 使用过程中请删除此段代码
|
||||
err := tx.Migrator().AlterColumn(&system.SysRole{}, "create_by")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tx.Migrator().AlterColumn(&system.SysRole{}, "update_by")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = tx.Migrator().AlterColumn(&models.SysMenu{}, "update_by")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tx.Migrator().AlterColumn(&models.SysMenu{}, "create_by")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
|
||||
return tx.Create(&common.Migration{
|
||||
Version: version,
|
||||
}).Error
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user