goose

package
v0.0.0-...-0decd24 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPreviousVersion = errors.New("no previous version found")
)

Functions

func CreateMigration

func CreateMigration(name, migrationType, dir string, t time.Time) (path string, err error)

CreateMigration creates a new migration and writes it to a new file in dir. The path to the file will be returned.

func GetMostRecentDBVersion

func GetMostRecentDBVersion(dirpath string) (version int64, err error)

helper to identify the most recent possible version within a folder of migration scripts

func GetPreviousDBVersion

func GetPreviousDBVersion(dirpath string, version int64) (previous int64, err error)

func NumericComponent

func NumericComponent(name string) (int64, error)

NumericComponent returns the integer part of name, if it exists, or an error if name does not resemble a Goose migration file.

The function looks for migration scripts with names in the form:

XXX_descriptivename.ext

where XXX specifies the version number and ext specifies the type of the migration.

Types

type Migration

type Migration struct {
	Version  int64
	Next     int64  // next version, or -1 if none
	Previous int64  // previous version, -1 if none
	Source   string // path to .go or .sql script
}

func CollectMigrations

func CollectMigrations(dirpath string, current, target int64) ([]*Migration, error)

CollectMigrations collects and returns all of the valid looking migration scripts in dirpath. Set current to 0 and target to a very large number to collect all migrations in the directory.

type MigrationRecord

type MigrationRecord struct {
	VersionId int64
	TStamp    time.Time
	IsApplied bool // was this a result of up() or down()
}

Jump to

Keyboard shortcuts

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