Skip to content

Commit

Permalink
update provider and options
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed May 19, 2023
1 parent 5877e94 commit 6835293
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
// options := goose.DefaultOptions().SetDir("data/schema/migrations").SetVerbose(true)
// goose.NewProvider(goose.DialectPostgres, db, options)
//
// Each option X is also documented on the SetX method.
// Each option X is documented on the SetX method.
type Options struct {
// Required options.
Dir string
Expand Down Expand Up @@ -90,9 +90,9 @@ func (o Options) SetLogger(l Logger) Options {
// SetAllowMissing returns a new Options value with AllowMissing set to the given value.
// AllowMissing enables the ability to apply missing (out-of-order) migrations.
//
// Example: migrations 1,4 are applied and then version 2,3,5 are introduced. If this option is
// Example: migrations 1,6 are applied and then version 2,3,5 are introduced. If this option is
// true, then goose will apply 2,3,5 instead of raising an error. The final order of applied
// migrations will be: 1,4,2,3,5.
// migrations will be: 1,6,2,3,5.
//
// Default: false
func (o Options) SetAllowMissing(b bool) Options {
Expand All @@ -111,7 +111,7 @@ func (o Options) SetVerbose(b bool) Options {

// SetNoVersioning returns a new Options value with NoVersioning set to the given value.
// NoVersioning enables the ability to apply migrations without tracking the versions in the
// database schema table. Useful for seeding a database or running ad-hoc migrations.
// database schema table. Useful for seeding a database or running ad-hoc queries.
//
// Default: false
func (o Options) SetNoVersioning(b bool) Options {
Expand All @@ -133,6 +133,9 @@ func (o Options) SetDebug(b bool) Options {
// ExcludeFilenames is a list of filenames to exclude when reading (and parsing) migrations from the
// filesystem. This is useful for skipping migrations in tests or development.
//
// The filename is the basename of the migration file. For example, if the migration path is
// ./migrations/to/apply/00001_foo.sql, then the filename to exclude should be 00001_foo.sql.
//
// Default: include all migrations.
func (o Options) SetExcludeFilenames(filenames ...string) Options {
o.ExcludeFilenames = filenames
Expand Down
4 changes: 4 additions & 0 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import (
)

const (
// timestampFormat is the format used for versioned timestamped migrations.
// For example: 20230519192509_add_users_table.sql
timestampFormat = "20060102150405"
)

// Provider is a goose migration provider.
type Provider struct {
mu sync.Mutex

Expand All @@ -27,6 +30,7 @@ type Provider struct {
migrations []*migration.Migration
}

// NewProvider creates a new goose migration provider.
func NewProvider(dbDialect Dialect, db *sql.DB, opt Options) (*Provider, error) {
internalDialect, ok := dialectLookup[dbDialect]
if !ok {
Expand Down

0 comments on commit 6835293

Please sign in to comment.