Documentation
¶
Index ¶
- func ApplyMultiStatements(sc *bufio.Scanner, f func(string) error) error
- func ExecuteMigration(ctx context.Context, l *zap.Logger, executor MigrationExecutor, ...) (migrationHistoryID int64, updatedSchema string, resErr error)
- func FindMigrationHistoryList(ctx context.Context, findMigrationHistoryListQuery string, ...) ([]*db.MigrationHistory, error)
- func FormatErrorWithQuery(err error, query string) error
- func NeedsSetupMigrationSchema(ctx context.Context, sqldb *sql.DB, query string) (bool, error)
- func Query(ctx context.Context, l *zap.Logger, sqldb *sql.DB, statement string, limit int) ([]interface{}, error)
- type MigrationExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyMultiStatements ¶
ApplyMultiStatements will apply the splitted statements from scanner.
func ExecuteMigration ¶
func ExecuteMigration(ctx context.Context, l *zap.Logger, executor MigrationExecutor, m *db.MigrationInfo, statement string) (migrationHistoryID int64, updatedSchema string, resErr error)
ExecuteMigration will execute the database migration. Returns the created migraiton history id and the updated schema on success.
func FindMigrationHistoryList ¶
func FindMigrationHistoryList(ctx context.Context, findMigrationHistoryListQuery string, queryParams []interface{}, driver db.Driver, find *db.MigrationHistoryFind, baseQuery string) ([]*db.MigrationHistory, error)
FindMigrationHistoryList will find the list of migration history.
func FormatErrorWithQuery ¶
FormatErrorWithQuery will format the error with failed query.
func NeedsSetupMigrationSchema ¶
NeedsSetupMigrationSchema will return whether it's needed to setup migration schema.
Types ¶
type MigrationExecutor ¶
type MigrationExecutor interface { db.Driver // CheckOutOfOrderVersion will return versions that are higher than the given version. CheckOutOfOrderVersion(ctx context.Context, tx *sql.Tx, namespace string, source db.MigrationSource, version string) (minVersionIfValid *string, err error) // FindBaseline retruns true if any baseline is found. FindBaseline(ctx context.Context, tx *sql.Tx, namespace string) (hasBaseline bool, err error) // FindNextSequence will return the highest sequence number plus one. FindNextSequence(ctx context.Context, tx *sql.Tx, namespace string, requireBaseline bool) (int, error) // InsertPendingHistory will insert the migration record with pending status and return the inserted ID. InsertPendingHistory(ctx context.Context, tx *sql.Tx, sequence int, prevSchema string, m *db.MigrationInfo, statement string) (insertedID int64, err error) // UpdateHistoryAsDone will update the migration record as done. UpdateHistoryAsDone(ctx context.Context, tx *sql.Tx, migrationDurationNs int64, updatedSchema string, insertedID int64) error // UpdateHistoryAsFailed will update the migration record as failed. UpdateHistoryAsFailed(ctx context.Context, tx *sql.Tx, migrationDurationNs int64, insertedID int64) error }
MigrationExecutor is an adapter for ExecuteMigration().
Click to show internal directories.
Click to hide internal directories.