mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 18:20:50 +00:00
Every import of the module changes, not only the seven packages that
moved out of sdk/pkg: Go requires the major version in the path from v2
on. Both happen in one pass —
go run github.com/go-admin-team/go-admin-core/tools/coreupgrade@v2.0.0 -w -v2 .
go mod tidy
— which is the command the release notes give, run here as a consumer
would run it. 210 imports across 95 files.
The compatibility shims this used are gone in v2, so the paths that
moved had to move: sdk/pkg/captcha, sdk/pkg/jwtauth and its user
package, sdk/pkg/response and sdk/pkg/casbin.
The count of unformatted files is unchanged at 34, none of them touched
by this: the tool reformats a file only if it was already gofmt clean,
so a migration cannot disappear into whitespace.
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package version
|
|
|
|
import (
|
|
"github.com/go-admin-team/go-admin-core/v2/sdk/config"
|
|
"runtime"
|
|
|
|
"go-admin/cmd/migrate/migration"
|
|
"go-admin/cmd/migrate/migration/models"
|
|
common "go-admin/common/models"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func init() {
|
|
_, fileName, _, _ := runtime.Caller(0)
|
|
migration.Migrate.SetVersion(migration.GetFilename(fileName), _1599190683659Tables)
|
|
}
|
|
|
|
func _1599190683659Tables(db *gorm.DB, version string) error {
|
|
return db.Transaction(func(tx *gorm.DB) error {
|
|
if config.DatabaseConfig.Driver == "mysql" {
|
|
tx = tx.Set("gorm:table_options", "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4")
|
|
}
|
|
err := tx.Migrator().AutoMigrate(
|
|
new(models.SysDept),
|
|
new(models.SysConfig),
|
|
new(models.SysTables),
|
|
new(models.SysColumns),
|
|
new(models.SysMenu),
|
|
new(models.SysLoginLog),
|
|
new(models.SysOperaLog),
|
|
new(models.SysRoleDept),
|
|
new(models.SysUser),
|
|
new(models.SysRole),
|
|
new(models.SysPost),
|
|
new(models.DictData),
|
|
new(models.DictType),
|
|
new(models.SysJob),
|
|
new(models.SysConfig),
|
|
new(models.SysApi),
|
|
new(models.TbDemo),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := models.InitDb(tx); err != nil {
|
|
return err
|
|
}
|
|
return tx.Create(&common.Migration{
|
|
Version: version,
|
|
}).Error
|
|
})
|
|
}
|