Documentation
¶
Index ¶
- func CreateMigrationFile(dir string, name string, opts ...MigrationSequenceOpt) (string, error)
- func MigrateHistory(ctx context.Context, client *spanner.Client, opts ...MigrateOpt) error
- func MigrateRepair(ctx context.Context, client *spanner.Client, opts ...MigrateOpt) error
- func MigrateSetupLock(ctx context.Context, client *spanner.Client, opts ...MigrateOpt) error
- func MigrateUp(ctx context.Context, client *spanner.Client, migrationsDir string, ...) error
- type MigrateOpt
- func WithDetectPartitionedDML(val bool) MigrateOpt
- func WithLimit(limit int) MigrateOpt
- func WithLockIdentifier(lockIdentifier string) MigrateOpt
- func WithLockTable(name string) MigrateOpt
- func WithPartitionedDMLConcurrency[T int | uint16](concurrency T) MigrateOpt
- func WithPrintRowsAffected(val bool) MigrateOpt
- func WithSkipVersions(skipVersions []uint) MigrateOpt
- func WithVersionTable(name string) MigrateOpt
- type MigrationSequenceOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMigrationFile ¶
func CreateMigrationFile(dir string, name string, opts ...MigrationSequenceOpt) (string, error)
CreateMigrationFile creates a new migration file in the given directory. The name should be alphanumeric with underscores or dashes only. The sequence options configure how the migration sequence is created.
func MigrateHistory ¶
MigrateHistory prints the migration history. The relevant options are LockTableName, LockIdentifier and VersionTableName.
func MigrateRepair ¶
MigrateRepair repairs the migration history table if it in a dirty state after a failed migration. After cleaning the schema manually run this step to remove the latest migration from the history table. The relevant options are LockTableName, LockIdentifier and VersionTableName.
func MigrateSetupLock ¶
MigrateSetupLock sets up the migration lock table. The relevant options are LockTableName.
Types ¶
type MigrateOpt ¶
type MigrateOpt func(opt *migrateOptions) error
MigrateOpt is an option for Migrate functions.
func WithDetectPartitionedDML ¶
func WithDetectPartitionedDML(val bool) MigrateOpt
WithDetectPartitionedDML sets whether to detect partitioned DML statements for use with the PartitionedDML API.
func WithLimit ¶
func WithLimit(limit int) MigrateOpt
WithLimit sets the maximum number of migrations to apply.
func WithLockIdentifier ¶
func WithLockIdentifier(lockIdentifier string) MigrateOpt
WithLockIdentifier sets the identifier of the lock holder when the lock is taken.
func WithLockTable ¶
func WithLockTable(name string) MigrateOpt
WithLockTable sets the name of the table that stores the lock.
func WithPartitionedDMLConcurrency ¶
func WithPartitionedDMLConcurrency[T int | uint16](concurrency T) MigrateOpt
WithPartitionedDMLConcurrency sets the concurrency level for applying partitioned DML statements.
func WithPrintRowsAffected ¶
func WithPrintRowsAffected(val bool) MigrateOpt
WithPrintRowsAffected sets whether to print the number of rows affected by each migration.
func WithSkipVersions ¶
func WithSkipVersions(skipVersions []uint) MigrateOpt
WithSkipVersions sets a list of versions that should be skipped.
func WithVersionTable ¶
func WithVersionTable(name string) MigrateOpt
WithVersionTable sets the name of the table that stores the version.
type MigrationSequenceOpt ¶
type MigrationSequenceOpt func(opt *migrationSequenceOptions) error
MigrationSequenceOpt sets an option for the migration sequence.
func WithInterval ¶
func WithInterval[T int | uint | uint16](interval T) MigrationSequenceOpt
WithInterval sets the interval for the migration sequence. By default, the next migration sequence will be multiples of 10. This allows hotfix / out of order migrations to be applied to the database.
func WithZeroPrefixLength ¶
func WithZeroPrefixLength(length int) MigrationSequenceOpt
WithZeroPrefixLength returns a MigrationSequenceOpt function that sets zero digit prefix length for the migration sequence.