migrations

package
v1.38.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Manager is the singleton migration manager instance for MySQL
	Manager = migrate.NewManager[*MySQLDriver, Wrapper, TxWrapper]()
)

Functions

func BeginTxFunc added in v1.9.0

func BeginTxFunc(ctx context.Context, db *sql.DB, txOptions *sql.TxOptions, f func(*sql.Tx) error) error

BeginTxFunc is a polyfill for database/sql which implements a closure style transaction lifecycle. The underlying transaction is aborted if the supplied function returns an error. The underlying transaction is committed if the supplied function returns nil.

Types

type MySQLDriver

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

MySQLDriver is an implementation of migrate.Driver for MySQL

func NewMySQLDriverFromDB

func NewMySQLDriverFromDB(db *sql.DB, tablePrefix string) *MySQLDriver

NewMySQLDriverFromDB creates a new migration driver with a connection pool specified upfront.

func NewMySQLDriverFromDSN

func NewMySQLDriverFromDSN(url string, tablePrefix string, credentialsProvider datastore.CredentialsProvider) (*MySQLDriver, error)

NewMySQLDriverFromDSN creates a new migration driver with a connection pool to the database DSN specified.

URI: [scheme://][user[:[password]]@]host[:port][/schema][?attribute1=value1&attribute2=value2... See https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html

func (MySQLDriver) Caveat added in v1.14.0

func (tn MySQLDriver) Caveat() string

func (*MySQLDriver) Close

func (driver *MySQLDriver) Close(_ context.Context) error

func (*MySQLDriver) Conn added in v1.9.0

func (driver *MySQLDriver) Conn() Wrapper

func (MySQLDriver) Metadata

func (tn MySQLDriver) Metadata() string

func (MySQLDriver) Namespace

func (tn MySQLDriver) Namespace() string

Namespace returns the prefixed namespace table name.

func (MySQLDriver) RelationTuple

func (tn MySQLDriver) RelationTuple() string

RelationTuple returns the prefixed relationship tuple table name.

func (MySQLDriver) RelationTupleTransaction

func (tn MySQLDriver) RelationTupleTransaction() string

RelationTupleTransaction returns the prefixed transaction table name.

func (MySQLDriver) RelationshipCounters added in v1.34.0

func (tn MySQLDriver) RelationshipCounters() string

func (*MySQLDriver) RunTx added in v1.9.0

func (*MySQLDriver) Version

func (driver *MySQLDriver) Version(ctx context.Context) (string, error)

Version returns the version of the schema to which the connected database has been migrated.

func (*MySQLDriver) WriteVersion

func (driver *MySQLDriver) WriteVersion(ctx context.Context, txWrapper TxWrapper, version, replaced string) error

WriteVersion overwrites the _meta_version_ column name which encodes the version of the database schema.

type TxWrapper added in v1.9.0

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

TxWrapper makes it possible to forward the table schema to a transactional migration func.

type Wrapper added in v1.9.0

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

Wrapper makes it possible to forward the table schema needed for MySQL MigrationFunc to run

Jump to

Keyboard shortcuts

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