feat: 优化数据库迁移与添加老表迁移

This commit is contained in:
王一之
2023-07-22 00:48:41 +08:00
parent f5bb0cad3e
commit b1ab66ecf9
9 changed files with 130 additions and 32 deletions

View File

@@ -35,7 +35,7 @@ func GetByIdIn(model any, list any, ids []uint64, orderBy ...string) {
// 若 error不为nil则为不存在该记录
// @param model 数据库映射实体模型
func GetBy(model any, cols ...string) error {
return global.Db.Select(cols).Where(model).Scopes(UndeleteScope).First(model).Error
return global.Db.Debug().Select(cols).Where(model).Scopes(UndeleteScope).First(model).Error
}
// 根据model指定条件统计数量

View File

@@ -15,7 +15,7 @@ const (
// 含有删除字段模型
type DeletedModel struct {
Id uint64 `json:"id"`
IsDeleted int8 `json:"-"`
IsDeleted int8 `json:"-" gorm:"column:is_deleted;default:0"`
DeleteTime *time.Time `json:"-"`
}