mysql

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver is the MySQL driver.

func (Driver) CheckDuplicateVersion

func (Driver) CheckDuplicateVersion(ctx context.Context, tx *sql.Tx, namespace string, source db.MigrationSource, version string) (bool, error)

CheckDuplicateVersion will check whether the version is already applied.

func (Driver) CheckOutOfOrderVersion

func (Driver) CheckOutOfOrderVersion(ctx context.Context, tx *sql.Tx, namespace string, source db.MigrationSource, version string) (minVersionIfValid *string, err error)

CheckOutOfOrderVersion will return versions that are higher than the given version.

func (*Driver) Close

func (driver *Driver) Close(ctx context.Context) error

Close closes the driver.

func (*Driver) Dump

func (driver *Driver) Dump(ctx context.Context, database string, out io.Writer, schemaOnly bool) error

Dump dumps the database.

func (*Driver) Execute

func (driver *Driver) Execute(ctx context.Context, statement string, useTransaction bool) error

Execute executes a SQL statement.

func (*Driver) ExecuteMigration

func (driver *Driver) ExecuteMigration(ctx context.Context, m *db.MigrationInfo, statement string) (int64, string, error)

ExecuteMigration will execute the migration.

func (Driver) FindBaseline

func (Driver) FindBaseline(ctx context.Context, tx *sql.Tx, namespace string) (hasBaseline bool, err error)

FindBaseline retruns true if any baseline is found.

func (*Driver) FindMigrationHistoryList

func (driver *Driver) FindMigrationHistoryList(ctx context.Context, find *db.MigrationHistoryFind) ([]*db.MigrationHistory, error)

FindMigrationHistoryList finds the migration history.

func (Driver) FindNextSequence

func (Driver) FindNextSequence(ctx context.Context, tx *sql.Tx, namespace string, requireBaseline bool) (int, error)

FindNextSequence will return the highest sequence number plus one.

func (*Driver) GetDbConnection

func (driver *Driver) GetDbConnection(ctx context.Context, database string) (*sql.DB, error)

GetDbConnection gets a database connection.

func (*Driver) GetVersion

func (driver *Driver) GetVersion(ctx context.Context) (string, error)

GetVersion gets the version.

func (Driver) InsertPendingHistory

func (Driver) InsertPendingHistory(ctx context.Context, tx *sql.Tx, sequence int, prevSchema string, m *db.MigrationInfo, statement string) (int64, error)

InsertPendingHistory will insert the migration record with pending status and return the inserted ID.

func (*Driver) NeedsSetupMigration

func (driver *Driver) NeedsSetupMigration(ctx context.Context) (bool, error)

NeedsSetupMigration returns whether it needs to setup migration.

func (*Driver) Open

func (driver *Driver) Open(ctx context.Context, dbType db.Type, config db.ConnectionConfig, connCtx db.ConnectionContext) (db.Driver, error)

Open opens a MySQL driver.

func (*Driver) Ping

func (driver *Driver) Ping(ctx context.Context) error

Ping pings the database.

func (*Driver) Query

func (driver *Driver) Query(ctx context.Context, statement string, limit int) ([]interface{}, error)

Query queries a SQL statement.

func (*Driver) Restore

func (driver *Driver) Restore(ctx context.Context, sc *bufio.Scanner) (err error)

Restore restores a database.

func (*Driver) SetupMigrationIfNeeded

func (driver *Driver) SetupMigrationIfNeeded(ctx context.Context) error

SetupMigrationIfNeeded sets up migration if needed.

func (*Driver) SyncSchema

func (driver *Driver) SyncSchema(ctx context.Context) ([]*db.User, []*db.Schema, error)

SyncSchema synces the schema.

func (Driver) UpdateHistoryAsDone

func (Driver) UpdateHistoryAsDone(ctx context.Context, tx *sql.Tx, migrationDurationNs int64, updatedSchema string, insertedID int64) error

UpdateHistoryAsDone will update the migration record as done.

func (Driver) UpdateHistoryAsFailed

func (Driver) UpdateHistoryAsFailed(ctx context.Context, tx *sql.Tx, migrationDurationNs int64, insertedID int64) error

UpdateHistoryAsFailed will update the migration record as failed.

Jump to

Keyboard shortcuts

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