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

Go migrations run even if they are outside of the target migrations directory #552

Closed
rafalneves opened this issue Jul 4, 2023 · 0 comments · Fixed by #553
Closed

Go migrations run even if they are outside of the target migrations directory #552

rafalneves opened this issue Jul 4, 2023 · 0 comments · Fixed by #553

Comments

@rafalneves
Copy link
Contributor

For our specific migration process, we need a way to distinguish between different types of migrations. This means running goose as many times as different kinds of migrations we have, once for each. This should happen on the same binary. We decided to split different types of migrations into different folders and just call goose for each one of them, and all went well, till we started to create Go migrations.

All pending Go migrations are executed in the first run goose, as they are loaded regardless of being in the target fs folder:

	// Go migrations registered via goose.AddMigration().
	for _, migration := range registeredGoMigrations {
		v, err := NumericComponent(migration.Source)
		if err != nil {
			return nil, err
		}
		if versionFilter(v, current, target) {
			migrations = append(migrations, migration)
		}
	}

We should check if the migration belongs to the target file list before loading it up.

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

Successfully merging a pull request may close this issue.

1 participant