filter out registered migrations when run against a directory without them
When running a migration against a particular directory without go migrations, getting the registered migrations too. How to filter those out? https://github.com/pressly/goose/pull/588, I see this pr addresses this but not able to make it work.
My directory structure:
migrations: ----ad-hoc: --------1000_1000.go ----0001_1.sql ----0002_2.sql
in my main.go have imported the ad-hoc package, in .go file have done goose.AddMigrationNoTxContext(). I run my binary against ./migrations where there are only sql files. Is there a way around this?
seeing this:
var sources []source
for _, fullpath := range goFiles {
v, err := NumericComponent(fullpath)
if err != nil {
continue // Skip any files that don't have version prefix.
}
if strings.HasSuffix(fullpath, "_test.go") {
continue // Skip Go test files.
}
if versionFilter(v, current, target) {
sources = append(sources, source{
fullpath: fullpath,
version: v,
})
}
}
var (
migrations Migrations
)
if len(sources) > 0 {
for _, s := range sources {
migration, ok := registeredGoMigrations[s.version]
if ok {
migrations = append(migrations, migration)
}
@prabhu-tyke have you found a workaround?
I did using goose.ResetGlobalMigrations() and goose.SetGlobalMigrations([]goose.Migration) but it's far from ideal