mirror of https://github.com/go-sonic/sonic.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
366 lines
11 KiB
Go
366 lines
11 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package dal
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"github.com/go-sonic/sonic/model/entity"
|
|
)
|
|
|
|
func newFlywaySchemaHistory(db *gorm.DB, opts ...gen.DOOption) flywaySchemaHistory {
|
|
_flywaySchemaHistory := flywaySchemaHistory{}
|
|
|
|
_flywaySchemaHistory.flywaySchemaHistoryDo.UseDB(db, opts...)
|
|
_flywaySchemaHistory.flywaySchemaHistoryDo.UseModel(&entity.FlywaySchemaHistory{})
|
|
|
|
tableName := _flywaySchemaHistory.flywaySchemaHistoryDo.TableName()
|
|
_flywaySchemaHistory.ALL = field.NewAsterisk(tableName)
|
|
_flywaySchemaHistory.InstalledRank = field.NewInt32(tableName, "installed_rank")
|
|
_flywaySchemaHistory.Version = field.NewString(tableName, "version")
|
|
_flywaySchemaHistory.Description = field.NewString(tableName, "description")
|
|
_flywaySchemaHistory.Type = field.NewString(tableName, "type")
|
|
_flywaySchemaHistory.Script = field.NewString(tableName, "script")
|
|
_flywaySchemaHistory.Checksum = field.NewInt32(tableName, "checksum")
|
|
_flywaySchemaHistory.InstalledBy = field.NewString(tableName, "installed_by")
|
|
_flywaySchemaHistory.InstalledOn = field.NewTime(tableName, "installed_on")
|
|
_flywaySchemaHistory.ExecutionTime = field.NewInt32(tableName, "execution_time")
|
|
_flywaySchemaHistory.Success = field.NewBool(tableName, "success")
|
|
|
|
_flywaySchemaHistory.fillFieldMap()
|
|
|
|
return _flywaySchemaHistory
|
|
}
|
|
|
|
type flywaySchemaHistory struct {
|
|
flywaySchemaHistoryDo flywaySchemaHistoryDo
|
|
|
|
ALL field.Asterisk
|
|
InstalledRank field.Int32
|
|
Version field.String
|
|
Description field.String
|
|
Type field.String
|
|
Script field.String
|
|
Checksum field.Int32
|
|
InstalledBy field.String
|
|
InstalledOn field.Time
|
|
ExecutionTime field.Int32
|
|
Success field.Bool
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (f flywaySchemaHistory) Table(newTableName string) *flywaySchemaHistory {
|
|
f.flywaySchemaHistoryDo.UseTable(newTableName)
|
|
return f.updateTableName(newTableName)
|
|
}
|
|
|
|
func (f flywaySchemaHistory) As(alias string) *flywaySchemaHistory {
|
|
f.flywaySchemaHistoryDo.DO = *(f.flywaySchemaHistoryDo.As(alias).(*gen.DO))
|
|
return f.updateTableName(alias)
|
|
}
|
|
|
|
func (f *flywaySchemaHistory) updateTableName(table string) *flywaySchemaHistory {
|
|
f.ALL = field.NewAsterisk(table)
|
|
f.InstalledRank = field.NewInt32(table, "installed_rank")
|
|
f.Version = field.NewString(table, "version")
|
|
f.Description = field.NewString(table, "description")
|
|
f.Type = field.NewString(table, "type")
|
|
f.Script = field.NewString(table, "script")
|
|
f.Checksum = field.NewInt32(table, "checksum")
|
|
f.InstalledBy = field.NewString(table, "installed_by")
|
|
f.InstalledOn = field.NewTime(table, "installed_on")
|
|
f.ExecutionTime = field.NewInt32(table, "execution_time")
|
|
f.Success = field.NewBool(table, "success")
|
|
|
|
f.fillFieldMap()
|
|
|
|
return f
|
|
}
|
|
|
|
func (f *flywaySchemaHistory) WithContext(ctx context.Context) *flywaySchemaHistoryDo {
|
|
return f.flywaySchemaHistoryDo.WithContext(ctx)
|
|
}
|
|
|
|
func (f flywaySchemaHistory) TableName() string { return f.flywaySchemaHistoryDo.TableName() }
|
|
|
|
func (f flywaySchemaHistory) Alias() string { return f.flywaySchemaHistoryDo.Alias() }
|
|
|
|
func (f flywaySchemaHistory) Columns(cols ...field.Expr) gen.Columns {
|
|
return f.flywaySchemaHistoryDo.Columns(cols...)
|
|
}
|
|
|
|
func (f *flywaySchemaHistory) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := f.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (f *flywaySchemaHistory) fillFieldMap() {
|
|
f.fieldMap = make(map[string]field.Expr, 10)
|
|
f.fieldMap["installed_rank"] = f.InstalledRank
|
|
f.fieldMap["version"] = f.Version
|
|
f.fieldMap["description"] = f.Description
|
|
f.fieldMap["type"] = f.Type
|
|
f.fieldMap["script"] = f.Script
|
|
f.fieldMap["checksum"] = f.Checksum
|
|
f.fieldMap["installed_by"] = f.InstalledBy
|
|
f.fieldMap["installed_on"] = f.InstalledOn
|
|
f.fieldMap["execution_time"] = f.ExecutionTime
|
|
f.fieldMap["success"] = f.Success
|
|
}
|
|
|
|
func (f flywaySchemaHistory) clone(db *gorm.DB) flywaySchemaHistory {
|
|
f.flywaySchemaHistoryDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return f
|
|
}
|
|
|
|
func (f flywaySchemaHistory) replaceDB(db *gorm.DB) flywaySchemaHistory {
|
|
f.flywaySchemaHistoryDo.ReplaceDB(db)
|
|
return f
|
|
}
|
|
|
|
type flywaySchemaHistoryDo struct{ gen.DO }
|
|
|
|
func (f flywaySchemaHistoryDo) Debug() *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Debug())
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) WithContext(ctx context.Context) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) ReadDB() *flywaySchemaHistoryDo {
|
|
return f.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) WriteDB() *flywaySchemaHistoryDo {
|
|
return f.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Session(config *gorm.Session) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Session(config))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Clauses(conds ...clause.Expression) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Returning(value interface{}, columns ...string) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Not(conds ...gen.Condition) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Not(conds...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Or(conds ...gen.Condition) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Or(conds...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Select(conds ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Select(conds...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Where(conds ...gen.Condition) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Where(conds...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Order(conds ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Order(conds...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Distinct(cols ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Omit(cols ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Join(table schema.Tabler, on ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) RightJoin(table schema.Tabler, on ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Group(cols ...field.Expr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Group(cols...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Having(conds ...gen.Condition) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Having(conds...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Limit(limit int) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Limit(limit))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Offset(offset int) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Offset(offset))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Unscoped() *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Unscoped())
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Create(values ...*entity.FlywaySchemaHistory) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return f.DO.Create(values)
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) CreateInBatches(values []*entity.FlywaySchemaHistory, batchSize int) error {
|
|
return f.DO.CreateInBatches(values, batchSize)
|
|
}
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
func (f flywaySchemaHistoryDo) Save(values ...*entity.FlywaySchemaHistory) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return f.DO.Save(values)
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) First() (*entity.FlywaySchemaHistory, error) {
|
|
if result, err := f.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*entity.FlywaySchemaHistory), nil
|
|
}
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Take() (*entity.FlywaySchemaHistory, error) {
|
|
if result, err := f.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*entity.FlywaySchemaHistory), nil
|
|
}
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Last() (*entity.FlywaySchemaHistory, error) {
|
|
if result, err := f.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*entity.FlywaySchemaHistory), nil
|
|
}
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Find() ([]*entity.FlywaySchemaHistory, error) {
|
|
result, err := f.DO.Find()
|
|
return result.([]*entity.FlywaySchemaHistory), err
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.FlywaySchemaHistory, err error) {
|
|
buf := make([]*entity.FlywaySchemaHistory, 0, batchSize)
|
|
err = f.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
defer func() { results = append(results, buf...) }()
|
|
return fc(tx, batch)
|
|
})
|
|
return results, err
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) FindInBatches(result *[]*entity.FlywaySchemaHistory, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Attrs(attrs ...field.AssignExpr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Assign(attrs ...field.AssignExpr) *flywaySchemaHistoryDo {
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Joins(fields ...field.RelationField) *flywaySchemaHistoryDo {
|
|
for _, _f := range fields {
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
}
|
|
return &f
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Preload(fields ...field.RelationField) *flywaySchemaHistoryDo {
|
|
for _, _f := range fields {
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
}
|
|
return &f
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) FirstOrInit() (*entity.FlywaySchemaHistory, error) {
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*entity.FlywaySchemaHistory), nil
|
|
}
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) FirstOrCreate() (*entity.FlywaySchemaHistory, error) {
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*entity.FlywaySchemaHistory), nil
|
|
}
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) FindByPage(offset int, limit int) (result []*entity.FlywaySchemaHistory, count int64, err error) {
|
|
result, err = f.Offset(offset).Limit(limit).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
count = int64(size + offset)
|
|
return
|
|
}
|
|
|
|
count, err = f.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = f.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = f.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Scan(result interface{}) (err error) {
|
|
return f.DO.Scan(result)
|
|
}
|
|
|
|
func (f flywaySchemaHistoryDo) Delete(models ...*entity.FlywaySchemaHistory) (result gen.ResultInfo, err error) {
|
|
return f.DO.Delete(models)
|
|
}
|
|
|
|
func (f *flywaySchemaHistoryDo) withDO(do gen.Dao) *flywaySchemaHistoryDo {
|
|
f.DO = *do.(*gen.DO)
|
|
return f
|
|
}
|