Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions migrators/dbmatemigrator/dbmate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ import (
// - [WithFS]
type Option func(*DbmateMigrator)

// WithAutoDumpSchema specifies if the schema should be automatically dumped
//
// Default: true
func WithAutoDumpSchema(autoDumpSchema bool) Option {
return func(m *DbmateMigrator) {
m.AutoDumpSchema = autoDumpSchema
}
}

// WithDir specifies the location(s) of the migration files. If you have migrations
// in multiple directories, you should pass each path here instead of passing
// WithDir multiple times.
Expand Down Expand Up @@ -72,6 +81,7 @@ func New(opts ...Option) *DbmateMigrator {
MigrationsDir: defaults.MigrationsDir,
MigrationsTableName: defaults.MigrationsTableName,
FS: defaults.FS,
AutoDumpSchema: defaults.AutoDumpSchema,
}
for _, opt := range opts {
opt(m)
Expand All @@ -84,6 +94,7 @@ type DbmateMigrator struct {
MigrationsDir []string
MigrationsTableName string
FS fs.FS
AutoDumpSchema bool
}

func (m *DbmateMigrator) Hash() (string, error) {
Expand All @@ -110,5 +121,6 @@ func (m *DbmateMigrator) Migrate(
dbm.MigrationsDir = m.MigrationsDir
dbm.MigrationsTableName = m.MigrationsTableName
dbm.FS = m.FS
dbm.AutoDumpSchema = m.AutoDumpSchema
return dbm.CreateAndMigrate()
}