migrations

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MigrationCreator = func(migrationBodySql string, currentMigration int) string {
		return fmt.Sprintf("begin transaction;\n"+
			"%s\n"+
			"insert into migrations (id) values (%d);\n"+
			"commit;",
			migrationBodySql,
			currentMigration)
	}
	LatestMigrationSelectorSql = "select id from migrations order by id desc limit 1"
	IsInitialMigrationError    = func(err error) bool {
		return strings.HasPrefix(err.Error(), "pq: relation") && strings.HasSuffix(err.Error(), "does not exist")
	}
)

Functions

func Migrate

func Migrate(connector database.Connector, fileProvider MigrationFileProvider) error

Types

type MigrationFileProvider

type MigrationFileProvider interface {
	ReadDir(name string) ([]fs.DirEntry, error)
	ReadFile(name string) ([]byte, error)
}

MigrationFileProvider is an interface used for .sql migration file retrieval. See readme for usage.

Jump to

Keyboard shortcuts

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