migrator

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MigrationSQLFilePattern = `^(\d{14})_([\-_a-z0-9]+)?\.(up|down)\.(sql)$`

Variables

This section is empty.

Functions

func LoadMigrations

func LoadMigrations(folder string) ([]SQLMigration, []SQLMigration, error)

Types

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(db *sql.DB, upMigrations, downMigrations []SQLMigration) Migrator

func (Migrator) MigrateDown

func (m Migrator) MigrateDown(step int) error

func (Migrator) MigrateUp

func (m Migrator) MigrateUp(step int) error

type SQLMigration

type SQLMigration struct {
	// contains filtered or unexported fields
}

func NewSQLMigration

func NewSQLMigration(
	version int64,
	description string,
	sql string,
	fileName string,
) (SQLMigration, error)

func (SQLMigration) CheckValid

func (m SQLMigration) CheckValid() error

func (SQLMigration) Execute

func (m SQLMigration) Execute(ctx context.Context, tx *sql.Tx) error

func (SQLMigration) Less

func (m SQLMigration) Less(m2 SQLMigration) bool

Jump to

Keyboard shortcuts

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