migrate

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT, MIT Imports: 3 Imported by: 0

README

go-migrate

This is a very simple migration framework. See "Migrations" in https://github.com/jbenet/random-ideas/issues/33

This package includes:

  • migrate package -- lib to write migration programs

The model

The idea here is that we have some thing -- usually a directory -- that needs to be migrated between different representation versions. This may be because there has been an upgrade.

Documentation

Overview

Package migrate is used to write migrations between representations of things.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(m Migration)

func Run

func Run(m Migration) error

func SplitVersion

func SplitVersion(s string) (from int, to int)

Types

type Flags

type Flags struct {
	Force  bool
	Revert bool
	Path   string // file path to migrate for fs based migrations
}

func (*Flags) Parse

func (f *Flags) Parse()

func (*Flags) Setup

func (f *Flags) Setup()

type Migration

type Migration interface {

	// Versions is the "v-to-v" version string.
	Versions() string

	// Reversible returns whether this migration can be reverted.
	// Endeavor to make them all reversible. This is here only to warn users
	// in case this is not the case.
	Reversible() bool

	// Apply applies the migration in question.
	Apply(Options) error

	// Revert un-applies the migration in question. This should be best-effort.
	// Some migrations are definitively one-way. If so, return an error.
	Revert(Options) error
}

Migration represents

type Options

type Options struct {
	Flags
}

Options are migration options. For now all flags are options.

Jump to

Keyboard shortcuts

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