mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
修复初始化数据时问题
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -43,7 +41,7 @@ func _1599190683670Test(db *gorm.DB, version string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
list6 := []models.SysRole{
|
list6 := []models.SysRole{
|
||||||
{1, "系统管理员", "2", "admin", 1, "", "1", "", "", true, "", models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, "", []int{}, []int{}},
|
{1, "系统管理员", "2", "admin", 1, "", "1", "0", "", true, "", models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, "", []int{}, []int{}},
|
||||||
}
|
}
|
||||||
|
|
||||||
list7 := []DictType{
|
list7 := []DictType{
|
||||||
@@ -71,7 +69,7 @@ func _1599190683670Test(db *gorm.DB, version string) error {
|
|||||||
},
|
},
|
||||||
UserId: 1,
|
UserId: 1,
|
||||||
Username: "admin",
|
Username: "admin",
|
||||||
Password: "$2a$10$cKFFTCzGOvaIHHJY2K45Zuwt8TD6oPzYi4s5MzYIBAWCLL6ZhouP2",
|
Password: "123456",
|
||||||
NickName: "zhangwj",
|
NickName: "zhangwj",
|
||||||
Phone: "13818888888",
|
Phone: "13818888888",
|
||||||
RoleId: 1,
|
RoleId: 1,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -22,7 +20,23 @@ func _1613783303115Test(db *gorm.DB, version string) error {
|
|||||||
return db.Transaction(func(tx *gorm.DB) error {
|
return db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
|
||||||
//修改字段类型
|
//修改字段类型
|
||||||
err := tx.Migrator().AlterColumn(&system.SysDictType{}, "create_by")
|
err := tx.Model(&system.SysDictType{}).Select("create_by").Not("create_by > 0").Update("create_by", 0).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = tx.Model(&system.SysDictType{}).Select("update_by").Not("update_by > 0").Update("update_by", 0).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = tx.Model(&system.SysDictData{}).Select("create_by").Not("create_by > 0").Update("create_by", 0).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = tx.Model(&system.SysDictData{}).Select("update_by").Not("update_by > 0").Update("update_by", 0).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = tx.Migrator().AlterColumn(&system.SysDictType{}, "create_by")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// fixme 在您看不见代码的时候运行迁移,我觉得是不安全的,所以编译后将不包含所有迁移文件
|
// fixme 在您看不见代码的时候运行迁移,我觉得是不安全的,所以编译后最好不要去执行迁移
|
||||||
func init() {
|
func init() {
|
||||||
StartCmd.PersistentFlags().StringVarP(&configYml, "config", "c", "config/settings.yml", "Start server with provided configuration file")
|
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")
|
StartCmd.PersistentFlags().BoolVarP(&generate, "generate", "g", false, "generate migration file")
|
||||||
|
|||||||
Reference in New Issue
Block a user