migrations

package
v3.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: AGPL-3.0 Imports: 2 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, current *version.Version, target *version.Version, migrations []*Migration) (*version.Version, error)

Apply browses migrations upward on downward and apply them sequentially. It returns a version to be saved as the current valid version of the service, or nil if no changes were necessary. In specific case where current version is 0.0.0 (first run), it only applies first run migration (if any) and returns target version.

func FirstRun

func FirstRun() *version.Version

FirstRun returns version "zero".

Types

type Migration

type Migration struct {
	TargetVersion *version.Version
	Up            func(ctx context.Context) error
	Down          func(ctx context.Context) error
}

Migration defines a target version and functions to upgrade and/or downgrade.

Jump to

Keyboard shortcuts

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