migrator

package
v0.9.10-beta001 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration interface {
	Migrate() error
	Version() string
	Info() string
	Type() MigrationType
}

type MigrationType added in v0.9.5

type MigrationType int

MigrationType is migration type

const (
	// MigrationTypeClient is client migration type
	MigrationTypeClient MigrationType = iota + 1
	// MigrationTypeServer is server migration type
	MigrationTypeServer
)

type Migrator

type Migrator struct {
	Migrations []Migration
	Log        *zap.SugaredLogger
}

func NewMigrator

func NewMigrator() *Migrator

func (*Migrator) Add

func (m *Migrator) Add(migration Migration)

func (Migrator) ExecuteCommands

func (m Migrator) ExecuteCommands(commands []string) (outputs []string, err error)

func (*Migrator) GetValidMigrations

func (m *Migrator) GetValidMigrations(currentVersion string, migrationTypes ...MigrationType) (migrations []Migration)

func (Migrator) IsValid

func (m Migrator) IsValid(migrationVersion, currentVersion string) (bool, error)

IsValid checks if versions constraints are met, assuming that currentVersion is just updated version and it should be taken for migration

func (*Migrator) Run

func (m *Migrator) Run(currentVersion string, migrationTypes ...MigrationType) error

Jump to

Keyboard shortcuts

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