refactor:

- source 初始化数据 new 实现
- service mysql 与 pgsql 分开实现
- 代码备注优化
This commit is contained in:
SliverHorn
2021-11-16 02:02:21 +08:00
parent f19e719cbb
commit b12a18a693
23 changed files with 1259 additions and 163 deletions

View File

@@ -8,8 +8,8 @@ import (
)
// GormMysql 初始化Mysql数据库
// Author piexlmax
// Author SliverHorn
// Author [piexlmax](https://github.com/piexlmax)
// Author [SliverHorn](https://github.com/SliverHorn)
func GormMysql() *gorm.DB {
m := global.GVA_CONFIG.Mysql
if m.Dbname == "" {
@@ -18,9 +18,6 @@ func GormMysql() *gorm.DB {
mysqlConfig := mysql.Config{
DSN: m.Dsn(), // DSN data source name
DefaultStringSize: 191, // string 类型字段的默认长度
DisableDatetimePrecision: true, // 禁用 datetime 精度MySQL 5.6 之前的数据库不支持
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
DontSupportRenameColumn: true, // 用 `change` 重命名列MySQL 8 之前的数据库和 MariaDB 不支持重命名列
SkipInitializeWithVersion: false, // 根据版本自动配置
}
if db, err := gorm.Open(mysql.New(mysqlConfig), internal.Gorm.Config()); err != nil {