Documentation ¶
Index ¶
- Variables
- type GooseMigrator
- func (gm *GooseMigrator) Hash() (string, error)
- func (gm *GooseMigrator) Migrate(_ context.Context, db *sql.DB, _ pgtestdb.Config) error
- func (*GooseMigrator) Prepare(_ context.Context, _ *sql.DB, _ pgtestdb.Config) error
- func (*GooseMigrator) Verify(_ context.Context, _ *sql.DB, _ pgtestdb.Config) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var DefaultTableName = goose.TableName() //nolint:gochecknoglobals
Goose doesn't provide a constant for the default value. This will be `"goose_db_version"`.
Functions ¶
This section is empty.
Types ¶
type GooseMigrator ¶
GooseMigrator is a pgtestdb.Migrator that uses goose to perform migrations.
Because Hash() requires calculating a unique hash based on the contents of the migrations, database, this implementation only supports reading migration files from disk or an embedded filesystem.
GooseMigrator doe snot perform any Verify() or Prepare() logic.
func New ¶
func New(migrationsDir string, opts ...Option) *GooseMigrator
New returns a GooseMigrator, which is a pgtestdb.Migrator that uses goose to perform migrations.
`migrationsDir` is the path to the directory containing migration files.
You can configure the behavior of goose by passing Options:
- WithFS allows you to use an embedded filesystem.
- WithTableName is the same as -table
func (*GooseMigrator) Hash ¶
func (gm *GooseMigrator) Hash() (string, error)
type Option ¶
type Option func(*GooseMigrator)
Option provides a way to configure the GooseMigrator struct and its behavior.
goose-migrate documentation: https://github.com/pressly/goose#migrations
See:
func WithFS ¶
WithFS specifies a `fs.FS` from which to read the migration files.
Default: `<nil>` (reads from the real filesystem)
func WithTableName ¶
WithTableName specifies the name of the table in which goose will store its migration records.
Default: `"goose_db_version"`
Equivalent to `-table` https://github.com/pressly/goose#usage