migrator

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MigrationInfo added in v0.17.0

type MigrationInfo struct {
	Version int
	Name    string
	Applied bool
}

MigrationInfo describes a single SQL migration and its applied state.

type MigrationOpts

type MigrationOpts struct {
	PG MigrationOptsPG
	CH MigrationOptsCH
}

type MigrationOptsCH

type MigrationOptsCH struct {
	Addr         string
	Username     string
	Password     string
	Database     string
	DeploymentID string
	TLSEnabled   bool
}

type MigrationOptsPG

type MigrationOptsPG struct {
	URL string
}

type Migrator

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

func New

func New(opts MigrationOpts) (*Migrator, error)

func (*Migrator) Close

func (m *Migrator) Close(ctx context.Context) (error, error)

func (*Migrator) Down

func (m *Migrator) Down(ctx context.Context, n int) (int, int, error)

Down migrates the database down by n migrations. It returns the updated version, the number of migrations rolled back, and an error.

func (*Migrator) Force

func (m *Migrator) Force(ctx context.Context, version int) error

func (*Migrator) LatestVersion added in v0.17.0

func (m *Migrator) LatestVersion() (int, error)

LatestVersion returns the highest migration version available in the embedded migration files. Returns 0 if there are no migrations.

func (*Migrator) ListMigrations added in v0.17.0

func (m *Migrator) ListMigrations(ctx context.Context) ([]MigrationInfo, error)

ListMigrations returns all available SQL migrations in version order, with Applied set based on the migrator's current schema version.

func (*Migrator) PendingCount added in v0.17.0

func (m *Migrator) PendingCount(ctx context.Context) (int, error)

PendingCount returns the number of migrations that would be applied by running Up(-1) from the current state.

func (*Migrator) Up

func (m *Migrator) Up(ctx context.Context, n int) (int, int, error)

Up migrates the database up by n migrations. It returns the updated version, the number of migrations applied, and an error.

func (*Migrator) Version

func (m *Migrator) Version(ctx context.Context) (int, error)

Directories

Path Synopsis
Package coordinator provides a unified interface over the SQL and Redis migration subsystems so callers (CLI, startup checks) can work with "migrations" as a single concept instead of two separate systems.
Package coordinator provides a unified interface over the SQL and Redis migration subsystems so callers (CLI, startup checks) can work with "migrations" as a single concept instead of two separate systems.
Package migrations provides a central registry for all Redis migrations.
Package migrations provides a central registry for all Redis migrations.

Jump to

Keyboard shortcuts

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