dbtools

package
v0.0.0-...-f348597 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ON_DROP = "When trying to drop DB"
View Source
const ON_NEW_INSTANCE = "On creating new instance"
View Source
const ON_UPGRADE = "When trying to upgrade database"
View Source
const ON_VERSION_CHECK = "On checking database version"

Variables

This section is empty.

Functions

func CheckUp

func CheckUp(opts CheckUpOpts) (err error)

This function checks is it possible to do request to the DB. If it's not -- it returns error, overwise -- nil

Types

type CheckUpOpts

type CheckUpOpts struct {
	Ctx context.Context
	// How many times try to ping
	Retries int
	// How much to wait before the next try
	Timeout time.Duration
	// What we will try to ping
	Pingable PingAdptr
	DBname   string
	Logger   *slog.Logger
}

type MigrationErr

type MigrationErr = errorsx.CustomErr[MigrationErrInfo]

func DoMigrate

func DoMigrate(opts MigrationOpts) (uint, bool, MigrationErr)

func NewMigrateErr

func NewMigrateErr(err string, info MigrationErrInfo) MigrationErr

type MigrationErrInfo

type MigrationErrInfo struct {
	Where        string
	VersionKnown bool
}

type MigrationOpts

type MigrationOpts struct {
	MSrc    string // Migration source
	DBurl   string //
	VerLim  uint   // Db version limit
	DropDev bool   // Drop DB if STAGE is dev
	Logger  *slog.Logger
}

type PingAdptr

type PingAdptr interface {
	Ping(context.Context) error
}

type PingAdptrPgSQL

type PingAdptrPgSQL struct {
	PingAdptr
	Conn *pgx.Conn
}

func (*PingAdptrPgSQL) Ping

func (pa *PingAdptrPgSQL) Ping(ctx context.Context) (err error)

type PingAdptrRds

type PingAdptrRds struct {
	PingAdptr
	Conn *redis.Client
}

func (*PingAdptrRds) Ping

func (pa *PingAdptrRds) Ping(ctx context.Context) (err error)

Jump to

Keyboard shortcuts

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