drivers

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMigrationsTableName = "_migrations"

Variables

View Source
var (
	ErrMissingDatabaseName     = errors.New("missing database name")
	ErrFailedToGetAffectedRows = errors.New("failed getting the number of affected rows")
)
View Source
var (
	ErrDriverNotFound = errors.New("driver not found")
)

Functions

func Register

func Register(name string, constructor DriverConstructor)

Register will register a new driver constructor for the given driver name.

Types

type DB

type DB interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	BeginTx(ctx context.Context, options *sql.TxOptions) (*sql.Tx, error)
}

type DBWithDriver

type DBWithDriver interface {
	DB
	Driver() driver.Driver
}

type Driver

type Driver interface {
	Add(ctx context.Context, id string) error
	Remove(ctx context.Context, id string) error
	StartMigration(ctx context.Context, id string) error
	FinishMigration(ctx context.Context, id string) error
	Lock(ctx context.Context) (migrations.Unlocker, error)
}

func DriverFromDB

func DriverFromDB(db DBWithDriver, options ...Option) (Driver, error)

type DriverConstructor

type DriverConstructor func(db DB, options ...Option) (Driver, error)

type Option

type Option func(*driverOpts)

func WithContext

func WithContext(ctx context.Context) Option

func WithDatabaseName

func WithDatabaseName(name string) Option

type TXExecer

type TXExecer interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Commit() error
	Rollback() error
}

Jump to

Keyboard shortcuts

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