core

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

func MigrateHistory(ctx context.Context, client *spanner.Client, opts ...MigrateOpt) error

MigrateHistory prints the migration history. The relevant options are LockTableName, LockIdentifier and VersionTableName.

func MigrateRepair

func MigrateRepair(ctx context.Context, client *spanner.Client, opts ...MigrateOpt) error

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

func MigrateSetupLock(ctx context.Context, client *spanner.Client, opts ...MigrateOpt) error

MigrateSetupLock sets up the migration lock table. The relevant options are LockTableName.

func MigrateUp

func MigrateUp(ctx context.Context, client *spanner.Client, migrationsDir string, opts ...MigrateOpt) error

MigrateUp runs all migrations that haven't been run yet based on the contents of the history table.

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.

Jump to

Keyboard shortcuts

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