Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) ApplyDDL(ctx context.Context, statements []string, protoDescriptors []byte) error
- func (c *Client) ApplyDDLFile(ctx context.Context, ddl []byte, placeholderOptions PlaceholderOptions, ...) error
- func (c *Client) ApplyDML(ctx context.Context, statements []string) (int64, error)
- func (c *Client) ApplyDMLFile(ctx context.Context, dml []byte, partitioned bool, concurrency int, ...) (int64, error)
- func (c *Client) ApplyPartitionedDML(ctx context.Context, statements []string, concurrency int) (int64, error)
- func (c *Client) Close() error
- func (c *Client) CreateDatabase(ctx context.Context, ddl []byte, protoDescriptors []byte) error
- func (c *Client) DetermineUpgradeStatus(ctx context.Context, tableName string) (UpgradeStatus, error)
- func (c *Client) DropDatabase(ctx context.Context) error
- func (c *Client) EnsureMigrationTable(ctx context.Context, tableName string) error
- func (c *Client) ExecuteMigrations(ctx context.Context, migrations Migrations, limit int, tableName string, ...) (MigrationsOutput, error)
- func (c *Client) GetMigrationHistory(ctx context.Context, versionTableName string) ([]MigrationHistoryRecord, error)
- func (c *Client) GetMigrationLock(ctx context.Context, tableName, lockIdentifier string) (lock MigrationLock, err error)
- func (c *Client) GetSchemaMigrationVersion(ctx context.Context, tableName string) (uint, bool, error)
- func (c *Client) LoadDDL(ctx context.Context) ([]byte, error)
- func (c *Client) LoadDDLs(ctx context.Context) ([]SchemaDDL, error)
- func (c *Client) LoadStaticDatas(ctx context.Context, tables []string, customSort map[string]string) ([]StaticData, error)
- func (c *Client) RepairMigration(ctx context.Context, tableName string) error
- func (c *Client) SetupMigrationLock(ctx context.Context, tableName string) error
- func (c *Client) TruncateAllTables(ctx context.Context) error
- func (c *Client) UpgradeExecuteMigrations(ctx context.Context, migrations Migrations, limit int, tableName string, ...) (MigrationsOutput, error)
- type Config
- type Error
- type ErrorCode
- type Migration
- type MigrationDirectives
- type MigrationHistoryRecord
- type MigrationLock
- type Migrations
- type MigrationsOutput
- type PlaceholderOptions
- type SchemaDDL
- type StatementKind
- type StaticData
- type UpgradeStatus
Constants ¶
View Source
const ( FirstRun = UpgradeStatus("FirstRun") ExistingMigrationsNoUpgrade = UpgradeStatus("NoUpgrade") ExistingMigrationsUpgradeStarted = UpgradeStatus("Started") ExistingMigrationsUpgradeCompleted = UpgradeStatus("Completed") )
View Source
const ( ErrorCodeCreateClient = iota + 1 ErrorCodeCloseClient ErrorCodeCreateDatabase ErrorCodeDropDatabase ErrorCodeTruncateAllTables ErrorCodeLoadSchema ErrorCodeUpdateDDL ErrorCodeUpdateDML ErrorCodeUpdatePartitionedDML ErrorCodeExecuteMigrations ErrorCodeGetMigrationVersion ErrorCodeSetMigrationVersion ErrorCodeNoMigration ErrorCodeMigrationVersionDirty ErrorCodeWaitOperation ErrorCodeEnsureMigrationTables ErrorCodeCompleteUpgrade ErrorCodeUndirtyMigration )
Variables ¶
View Source
var (
MigrationNameRegex = regexp.MustCompile(`[a-zA-Z0-9_\-]+`)
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ApplyDDLFile ¶
func (*Client) ApplyDMLFile ¶
func (*Client) ApplyPartitionedDML ¶
func (*Client) CreateDatabase ¶
func (*Client) DetermineUpgradeStatus ¶
func (*Client) EnsureMigrationTable ¶
func (*Client) ExecuteMigrations ¶
func (*Client) GetMigrationHistory ¶
func (*Client) GetMigrationLock ¶
func (*Client) GetSchemaMigrationVersion ¶
func (*Client) LoadStaticDatas ¶ added in v1.2.0
func (*Client) RepairMigration ¶ added in v1.8.0
RepairMigration will delete the dirty rows in the version and history tables
func (*Client) SetupMigrationLock ¶
func (*Client) UpgradeExecuteMigrations ¶
func (c *Client) UpgradeExecuteMigrations(ctx context.Context, migrations Migrations, limit int, tableName string, protoDescriptors []byte, ffMigrations bool) (MigrationsOutput, error)
type Config ¶
type Migration ¶
type Migration struct {
// Version is the version of the migration
Version uint
// Name is the name of the migration
Name string
// FileName is the name of the source file for the migration
FileName string
// Statements is the migration statements
Statements []string
Kind StatementKind
// Directives defines config scoped to a single migration.
Directives MigrationDirectives
}
migration represents the parsed migration file. e.g. version_name.sql
type MigrationDirectives ¶ added in v1.14.0
type MigrationDirectives struct {
// StatementKind overrides the auto-detected statement kind.
// This can be used to customise how migrations are executed.
StatementKind StatementKind
// Kind defines the execution concurrency. Only applicable when
// StatementKind is StatementKindConvergentDML.
Concurrency int
}
MigrationDirectives configures how the migration should be executed.
type MigrationHistoryRecord ¶
type MigrationLock ¶
type Migrations ¶
type Migrations []*Migration
func LoadMigrations ¶
func LoadMigrations(dir string, toSkipSlice []uint, detectPartitionedDML bool, placeholderOptions PlaceholderOptions) (Migrations, error)
func (Migrations) Len ¶
func (ms Migrations) Len() int
func (Migrations) Less ¶
func (ms Migrations) Less(i, j int) bool
func (Migrations) Swap ¶
func (ms Migrations) Swap(i, j int)
type MigrationsOutput ¶ added in v1.10.0
type MigrationsOutput map[string]migrationInfo
func (MigrationsOutput) String ¶ added in v1.10.0
func (i MigrationsOutput) String() string
type PlaceholderOptions ¶ added in v1.16.0
type PlaceholderOptions struct {
// Placeholders is map of placeholder variable names to placeholder values.
// These will be used for placeholder replacement if ReplacementEnabled is true.
Placeholders map[string]string
// ReplacementEnabled is used to enable or disable placeholder substitition within migration files.
ReplacementEnabled bool
}
type StatementKind ¶ added in v1.13.2
type StatementKind string
const ( StatementKindDDL StatementKind = "DDL" StatementKindDML StatementKind = "DML" StatementKindPartitionedDML StatementKind = "PartitionedDML" // StatementKindConvergentDML repeatedly executes all statements in // the migration until no more rows are affected. Each statement is executed // in its own transaction, and the concurrency can be configured via the // @wrench.Concurrency directive. StatementKindConvergentDML StatementKind = "ConvergentDML" )
type StaticData ¶ added in v1.2.0
func (StaticData) ToFileName ¶ added in v1.2.0
func (s StaticData) ToFileName() string
type UpgradeStatus ¶
type UpgradeStatus string
Click to show internal directories.
Click to hide internal directories.