migrate

package
v0.0.0-...-a3b5a27 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MigrationFields = []string{"project", "filename", "statement_index", "status"}

MigrationFields hold the database column names for Migration{}

Functions

func List

func List() []string

List lists database migration filenames

func Load

func Load(options Options) error

Load reads migrations from disk

func Print

func Print(options Options) error

Print outputs database migrations for a project to log output

func Run

func Run(options Options, db *sqlx.DB) error

Run takes migrations for a project and executes them against a database

Types

type FS

type FS map[string][]byte

FS represents a mapping between filename => contents

func NewFS

func NewFS() FS

NewFS returns a new FS instance

func (FS) Migrations

func (fs FS) Migrations() []string

Migrations returns list of SQL files to execute

func (FS) ReadFile

func (fs FS) ReadFile(filename string) ([]byte, error)

ReadFile returns decoded file contents from FS

type Migration

type Migration struct {
	Project        string `db:"project"`
	Filename       string `db:"filename"`
	StatementIndex int    `db:"statement_index"`
	Status         string `db:"status"`
}

Migration holds the DB structure for the migration table

type Options

type Options struct {
	Path    string
	Project string

	Apply   bool
	Verbose bool
}

Options include migration options

func NewOptions

func NewOptions() *Options

func (*Options) Bind

func (options *Options) Bind()

func (*Options) Init

func (options *Options) Init() *Options

Jump to

Keyboard shortcuts

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