# README
goosemigrator
go get github.com/peterldowns/pgtestdb/migrators/goosemigrator@latest
goosemigrator provides migrators that can be used out of the box with projects that use pressly/goose for migrations.
Currently only SQL migrations are supported, and can be read from a directory on disk or from an embedded filesystem. Golang-defined migrations are not supported by default.
You can configure the migrations directory, the table name, and the filesystem being used. Here's an example:
func TestGooseMigratorFromDisk(t *testing.T) {
m := goosemigrator.New("migrations")
db := pgtestdb.New(t, pgtestdb.Config{
DriverName: "pgx",
Host: "localhost",
User: "postgres",
Password: "password",
Port: "5433",
Options: "sslmode=disable",
}, m)
assert.NotEqual(t, nil, db)
}
//go:embed migrations/*.sql
var exampleFS embed.FS
func TestGooseMigratorFromFS(t *testing.T) {
gm := goosemigrator.New(
"migrations",
goosemigrator.WithFS(exampleFS),
goosemigrator.WithTableName("goose_example_migrations"),
)
db := pgtestdb.New(t, pgtestdb.Config{
DriverName: "pgx",
Host: "localhost",
User: "postgres",
Password: "password",
Port: "5433",
Options: "sslmode=disable",
}, gm)
assert.NotEqual(t, nil, db)
}
# Functions
New returns a [GooseMigrator], which is a pgtestdb.Migrator that creates a `goose.Provider` to perform migrations.
WithFS specifies a `fs.FS` from which to read the migration files.
WithTableName specifies the name of the table in which goose will store its migration records.
# Variables
nolint:gochecknoglobals.
# Structs
GooseMigrator is a [pgtestdb.Migrator] that uses goose to perform migrations.
# Type aliases
Option provides a way to configure the `goose.Provider` used by [GooseMigrator] to run migrations.