fix🐛: Add MySQL judgment in data migration
This commit is contained in:
1 parent
d40a0c0837
commit
a6ffac657e
1 file changed
+5
-1
@@ -1,6 +1,7 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/go-admin-team/go-admin-core/sdk/config"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"go-admin/cmd/migrate/migration"
|
"go-admin/cmd/migrate/migration"
|
||||||
@@ -17,7 +18,10 @@ func init() {
|
|||||||
|
|
||||||
func _1599190683659Tables(db *gorm.DB, version string) error {
|
func _1599190683659Tables(db *gorm.DB, version string) error {
|
||||||
return db.Transaction(func(tx *gorm.DB) error {
|
return db.Transaction(func(tx *gorm.DB) error {
|
||||||
err := tx.Set("gorm:table_options", "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4").Migrator().AutoMigrate(
|
if config.DatabaseConfig.Driver == "mysql" {
|
||||||
|
tx = tx.Set("gorm:table_options", "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4")
|
||||||
|
}
|
||||||
|
err := tx.Migrator().AutoMigrate(
|
||||||
new(models.CasbinRule),
|
new(models.CasbinRule),
|
||||||
new(models.SysDept),
|
new(models.SysDept),
|
||||||
new(models.SysConfig),
|
new(models.SysConfig),
|
||||||
|
|||||||
Reference in new issue
Block a user