Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter out registered migrations when run against a directory without them #868

Open
prabhu-tyke opened this issue Dec 10, 2024 · 0 comments

Comments

@prabhu-tyke
Copy link

prabhu-tyke commented Dec 10, 2024

When running a migration against a particular directory without go migrations, getting the registered migrations too. How to filter those out? #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)
			} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant