source

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: Unlicense Imports: 10 Imported by: 0

Documentation

Overview

Package source facilitates reading (and generating) migration source files.

Index

Constants

View Source
const RequiredMigrationsFile = "required.txt"

Variables

This section is empty.

Functions

This section is empty.

Types

type ByVersion

type ByVersion []*Migration

ByVersion sorts migrations by their version numbers.

func (ByVersion) Len

func (ms ByVersion) Len() int

func (ByVersion) Less

func (ms ByVersion) Less(i, j int) bool

func (ByVersion) Swap

func (ms ByVersion) Swap(i, j int)

type Migration

type Migration struct {
	// Path is the path of the file.
	Path string

	// Name is the name of the migration, derived from the file name.
	Name string

	// Version is the numeric version of the migration, derived from the
	// file name and used to sort the migrations.
	Version int
	// contains filtered or unexported fields
}

Migration is a handle to a migration source file.

func (*Migration) ReadStatements

func (m *Migration) ReadStatements() ([]string, error)

ReadStatements reads the migration file and parses it into individual statements.

type Source

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

Source is handle to a directory containing migration source files.

func NewFromFS

func NewFromFS(sourceFS fs.FS) *Source

NewFromFS creates a new Source using the provided fs.FS.

func NewFromPath

func NewFromPath(path string) (*Source, error)

NewFromPath creates a new Source from the provided path, or returns an error if the path does not exist.

func (*Source) FindMigrations

func (s *Source) FindMigrations() ([]*Migration, error)

FindMigrations finds all migrations under the source path.

func (*Source) GetRequiredMigrations

func (s *Source) GetRequiredMigrations() ([]string, error)

GetRequiredMigrations gets a list of all migrations that should have been applied.

Jump to

Keyboard shortcuts

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