manager

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxQueryLimit = 100

	DBLockName = "dbupdate"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	DBType() sql.Type
	DB() *sql.DB
	Version() uint

	Do(ctx context.Context, f func(tx *sql.Tx) error) error

	MigrateFuncs() map[uint]sqlg.MigrateFunc

	DDL() []string
	ObjectsInfo() []sqlg.ObjectInfo

	UnmarshalExportObject(data []byte) (sqlg.Object, error)
	InsertRawObject(tx *sql.Tx, obj sqlg.Object) error
	SelectObject(kind string) *sq.SelectBuilder
	FetchObjects(tx *sql.Tx, kind string, q sq.Builder) ([]sqlg.Object, error)
	ObjectToExportJSON(obj sqlg.Object, e *json.Encoder) error

	Sequences() []sqlg.Sequence
	GetSequence(tx *sql.Tx, sequenceName string) (uint64, error)
	PopulateSequences(tx *sql.Tx) error
}

type DBManager

type DBManager struct {
	// contains filtered or unexported fields
}

func NewDBManager

func NewDBManager(log zerolog.Logger, d DB, lf lock.LockFactory) *DBManager

func (*DBManager) CheckMigrationRequired

func (m *DBManager) CheckMigrationRequired(curVersion, wantedVersion uint) (bool, error)

func (*DBManager) CheckVersion

func (m *DBManager) CheckVersion(curVersion, wantedVersion uint) error

func (*DBManager) Create

func (m *DBManager) Create(ctx context.Context, stmts []string, wantedVersion uint) error

func (*DBManager) DDL added in v0.9.0

func (m *DBManager) DDL() []string

func (*DBManager) Drop

func (m *DBManager) Drop(ctx context.Context) error

func (*DBManager) Export

func (m *DBManager) Export(ctx context.Context, objectKinds []string, w io.Writer) error

func (*DBManager) GetVersion

func (m *DBManager) GetVersion(ctx context.Context) (uint, error)

func (*DBManager) Import

func (m *DBManager) Import(ctx context.Context, r io.Reader) error

func (*DBManager) Lock

func (m *DBManager) Lock(ctx context.Context) error

func (*DBManager) Migrate

func (m *DBManager) Migrate(ctx context.Context) error

func (*DBManager) MigrateToVersion

func (m *DBManager) MigrateToVersion(ctx context.Context, newVersion uint) error

func (*DBManager) Setup

func (m *DBManager) Setup(ctx context.Context) error

func (*DBManager) Unlock

func (m *DBManager) Unlock() error

func (*DBManager) WantedVersion added in v0.9.0

func (m *DBManager) WantedVersion() uint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL