migrations

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadMigrations

func LoadMigrations(dir string) ([]string, error)

LoadMigrations loads the raw migration SQL files from the given dir

Types

type Metadata

type Metadata struct {
	ID            string
	SchemaVersion int
}

Metadata represents the schema metadata row in the migrations table

type Migration

type Migration struct {
	Name    string
	Version int
	Content string
}

Migration is a struct which encapsulates a SQL migration and metadata about it

type MigrationOptions

type MigrationOptions struct {
	Name string
}

MigrationOptions are used by methods on Migrator implementors to change behavior of those functions

type Migrator

type Migrator interface {
	New(opts MigrationOptions) (string, error)
	Migrate(*sqlx.DB) error
}

Migrator represents an object which when given a sql.DB can discover and run the appropriate migrations for that database. Additionally the New method should generate the next logical migration file wherever this migration expects to find them.

type SQLMigrator

type SQLMigrator struct{}

SQLMigrator implements Migrator for a SQL database

func (SQLMigrator) Migrate

func (sm SQLMigrator) Migrate(db *sqlx.DB) error

Migrate will run all necessary migrations on the given DB connection

func (SQLMigrator) New

func (sm SQLMigrator) New(opts MigrationOptions) (string, error)

New creates a SQLMigrator with the given MigrationOptions

Jump to

Keyboard shortcuts

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