migration

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending = "pending"
	StatusApplied = "applied"
	StatusSkipped = "skipped"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResult

type ApplyResult struct {
	Applied []MigrationRun `json:"applied"`
	Skipped []MigrationRun `json:"skipped"`
}

type Definition

type Definition struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Resource    string   `json:"resource"`
	FromVersion string   `json:"from_version"`
	ToVersion   string   `json:"to_version"`
	Description string   `json:"description"`
	Executor    Executor `json:"-"`
}

type Executor

type Executor interface {
	Apply(ctx context.Context) (int64, error)
}

type ExecutorFunc

type ExecutorFunc func(ctx context.Context) (int64, error)

func (ExecutorFunc) Apply

func (f ExecutorFunc) Apply(ctx context.Context) (int64, error)

type MigrationRun

type MigrationRun struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Resource     string `json:"resource"`
	FromVersion  string `json:"from_version"`
	ToVersion    string `json:"to_version"`
	Status       string `json:"status"`
	RowsMigrated int64  `json:"rows_migrated"`
	AppliedAtMS  int64  `json:"applied_at_ms"`
	UpdatedAtMS  int64  `json:"updated_at_ms"`
}

type Runner

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

func NewRunner

func NewRunner(store Store, definitions []Definition) (Runner, error)

func (Runner) Apply

func (r Runner) Apply(ctx context.Context) (ApplyResult, error)

func (Runner) Status

func (r Runner) Status(ctx context.Context) (StatusResult, error)

type StatusResult

type StatusResult struct {
	Migrations []MigrationRun `json:"migrations"`
}

type Store

type Store interface {
	GetRun(ctx context.Context, id string) (MigrationRun, bool, error)
	RecordApplied(ctx context.Context, definition Definition, rowsMigrated int64, appliedAt time.Time) (MigrationRun, error)
}

Jump to

Keyboard shortcuts

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