package source

Import Path
	github.com/golang-migrate/migrate/v4/source (on go.dev)

Dependency Relation
	imports 7 packages, and imported by 2 packages

Involved Source Files Package source provides the Source interface. All source drivers must implement this interface, register themselves, optionally provide a `WithInstance` function and pass the tests in package source/testing. migration.go parse.go
Package-Level Type Names (total 5, in which 4 are exported)
/* sort exporteds by: | */
Direction is either up or down. const Down const Up
Driver is the interface every source driver must implement. How to implement a source driver? 1. Implement this interface. 2. Optionally, add a function named `WithInstance`. This function should accept an existing source instance and a Config{} struct and return a driver instance. 3. Add a test that calls source/testing.go:Test() 4. Add own tests for Open(), WithInstance() (when provided) and Close(). All other functions are tested by tests in source/testing. Saves you some time and makes sure all source drivers behave the same way. 5. Call Register in init(). Guidelines: * All configuration input must come from the URL string in func Open() or the Config{} struct in WithInstance. Don't os.Getenv(). * Drivers are supposed to be read only. * Ideally don't load any contents (into memory) in Open or WithInstance. Close closes the underlying source instance managed by the driver. Migrate will call this function only once per instance. First returns the very first migration version available to the driver. Migrate will call this function multiple times. If there is no version available, it must return os.ErrNotExist. Next returns the next version for a given version available to the driver. Migrate will call this function multiple times. If there is no next version available, it must return os.ErrNotExist. Open returns a a new driver instance configured with parameters coming from the URL string. Migrate will call this function only once per instance. Prev returns the previous version for a given version available to the driver. Migrate will call this function multiple times. If there is no previous version available, it must return os.ErrNotExist. ReadDown returns the DOWN migration body and an identifier that helps finding this migration in the source for a given version. If there is no down migration available for this version, it must return os.ErrNotExist. Do not start reading, just return the ReadCloser! ReadUp returns the UP migration body and an identifier that helps finding this migration in the source for a given version. If there is no up migration available for this version, it must return os.ErrNotExist. Do not start reading, just return the ReadCloser! *github.com/golang-migrate/migrate/v4/source/file.File T : io.Closer func Open(url string) (Driver, error) func Driver.Open(url string) (Driver, error) func github.com/golang-migrate/migrate/v4/source/file.(*File).Open(url string) (Driver, error) func Register(name string, driver Driver) func github.com/golang-migrate/migrate/v4.NewWithInstance(sourceName string, sourceInstance Driver, databaseName string, databaseInstance database.Driver) (*migrate.Migrate, error) func github.com/golang-migrate/migrate/v4.NewWithSourceInstance(sourceName string, sourceInstance Driver, databaseURL string) (*migrate.Migrate, error)
Migration is a helper struct for source drivers that need to build the full directory tree in memory. Migration is fully independent from migrate.Migration. Direction is either Up or Down. Identifier can be any string that helps identifying this migration in the source. Raw holds the raw location path to this migration in source. ReadUp and ReadDown will use this. Version is the version of this migration. func Parse(raw string) (*Migration, error) func (*Migrations).Down(version uint) (m *Migration, ok bool) func (*Migrations).Up(version uint) (m *Migration, ok bool) func (*Migrations).Append(m *Migration) (ok bool)
Migrations wraps Migration and has an internal index to keep track of Migration order. (*T) Append(m *Migration) (ok bool) (*T) Down(version uint) (m *Migration, ok bool) (*T) First() (version uint, ok bool) (*T) Next(version uint) (nextVersion uint, ok bool) (*T) Prev(version uint) (prevVersion uint, ok bool) (*T) Up(version uint) (m *Migration, ok bool) func NewMigrations() *Migrations
Package-Level Functions (total 5, all are exported)
List lists the registered drivers
Open returns a new driver instance.
Parse returns Migration for matching Regex pattern.
Register globally registers a driver.
Package-Level Variables (total 6, in which 4 are exported)
Regex matches the following pattern: 123_name.up.ext 123_name.down.ext
Package-Level Constants (total 2, both are exported)
const Down Direction = "down"