Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BunMigrator ¶
type BunMigrator struct { MigrationsDir string FS fs.FS BunDBOpts []bun.DBOption MigratorOpts []migrate.MigratorOption MigrationOpts []migrate.MigrationOption }
BunMigrator is a pgtestdb.Migrator that uses bun to perform migrations.
Because Hash() requires calculating a unique hash based on the contents of the migrations, this implementation only supports reading migration files from disk or an embedded filesystem.
BunMigrator does not perform any Verify() logic.
func New ¶
func New(migrationsDir string, opts ...Option) *BunMigrator
New returns a BunMigrator, which is a pgtestdb.Migrator that uses bun to perform migrations.
`migrationsDir` is the path to the directory containing migration files.
You can configure the behaviour of bun by passing Options:
- WithFS allows you to use an embedded filesystem.
- WithBunDBOpts allows you to pass options to the underlying bun.DB struct.
- WithMigrationOpts allows you to pass options to the Migrate() function.
- WithMigratorOpts allows you to pass options to the Migrator struct.
func (*BunMigrator) Hash ¶
func (bm *BunMigrator) Hash() (string, error)
type Option ¶
type Option func(*BunMigrator)
Option provides a way to configure the BunMigrator struct and its behaviour.
bun migration documentation: https://bun.uptrace.dev/guide/migrations.html
See:
func WithBunDBOpts ¶
WithBunDBOpts passes options to the bun.DB struct.
func WithFS ¶
WithFS specifies a `fs.FS` from which to read the migration files.
Default: `<nil>` (reads from the real filesystem)
func WithMigrationOpts ¶
func WithMigrationOpts(opts ...migrate.MigrationOption) Option
WithMigrationOpts passes options to the migrate.Migrator.Migrate() func.
func WithMigratorOpts ¶
func WithMigratorOpts(opts ...migrate.MigratorOption) Option
WithMigratorOpts passes options to the migrate.Migrator.