Documentation ¶
Index ¶
- Variables
- func BeginTxFunc(ctx context.Context, db *sql.DB, txOptions *sql.TxOptions, ...) error
- type MySQLDriver
- func (tn MySQLDriver) Caveat() string
- func (driver *MySQLDriver) Close(_ context.Context) error
- func (driver *MySQLDriver) Conn() Wrapper
- func (tn MySQLDriver) Metadata() string
- func (tn MySQLDriver) Namespace() string
- func (tn MySQLDriver) RelationTuple() string
- func (tn MySQLDriver) RelationTupleTransaction() string
- func (driver *MySQLDriver) RunTx(ctx context.Context, f migrate.TxMigrationFunc[TxWrapper]) error
- func (driver *MySQLDriver) Version(ctx context.Context) (string, error)
- func (driver *MySQLDriver) WriteVersion(ctx context.Context, txWrapper TxWrapper, version, replaced string) error
- type TxWrapper
- type Wrapper
Constants ¶
This section is empty.
Variables ¶
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) (*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) Conn ¶ added in v1.9.0
func (driver *MySQLDriver) Conn() Wrapper
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) RunTx ¶ added in v1.9.0
func (driver *MySQLDriver) RunTx(ctx context.Context, f migrate.TxMigrationFunc[TxWrapper]) error
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.