migrations

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BookmarkerMigrations = []Migrator{
	&Migration{
		Name:   "initial schema",
		Level:  1,
		Schema: v1,
	},
	&Migration{
		Name:   "add metadata",
		Level:  2,
		Schema: v2,
	},
	&Migration{
		Name:   "add archived column to bookmark",
		Level:  3,
		Schema: v3,
	},
	&Migration{
		Name:   "add full-text-search capability",
		Level:  4,
		Schema: v4,
	},
	&Migration{
		Name:   "fix metadata primary key",
		Level:  5,
		Schema: v5,
	},
}

Functions

func Migrate

func Migrate(db *sqlx.DB, migrations []Migrator) error

Migrate runs given migrations

Types

type Migration

type Migration struct {
	Name   string
	Level  int
	Schema string
}

Migration implements migrator

func (*Migration) MLevel

func (m *Migration) MLevel() int

func (*Migration) MName

func (m *Migration) MName() string

func (*Migration) MSchema

func (m *Migration) MSchema() string

type Migrator

type Migrator interface {
	// Get migration name
	MName() string
	// Get migration level
	MLevel() int
	// Get valid sql string to execute
	MSchema() string
}

Migrator describes single migration level

type Schema

type Schema struct {
	Level     int       `db:"level"`
	Success   int       `db:"success"`
	Timestamp time.Time `db:"timestamp"`
	TookMs    int       `db:"took_ms"`
}

func CurrentVersion

func CurrentVersion(db *sqlx.DB) (Schema, error)

CurrentVersion returns current version

Jump to

Keyboard shortcuts

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