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

Feature request: Print current version on missing migrations error #591

Closed
VojtechVitek opened this issue Aug 28, 2023 · 4 comments · Fixed by #772
Closed

Feature request: Print current version on missing migrations error #591

VojtechVitek opened this issue Aug 28, 2023 · 4 comments · Fixed by #772

Comments

@VojtechVitek
Copy link
Collaborator

$ go run ./cmd/goose/main.go up
[15:23:41] @@@ :0
 info  goose migration: running migration: error: found 2 missing migrations:
	version 14: migrations/00014_transcribe_jobs_events.sql
	version 15: migrations/00015_projects.sql

It would be nice to print a current version (ie. 00022) that causes this error

 [15:23:41] @@@ :0
-  info  goose migration: running migration: error: found 2 missing migrations:
+  info  goose migration: running migration: error: found 2 missing migrations before current version 22:
 	version 14: migrations/00014_transcribe_jobs_events.sql
 	version 15: migrations/00015_projects.sql
@mfridman
Copy link
Collaborator

mfridman commented Sep 5, 2023

To clarify are you looking for the current DB version or the first "next" version? For example,

12,13 are applied .. 14,15 are missing .. 16,17,22 are applied

Are you looking for 16 or 22 to be printed?

@VojtechVitek
Copy link
Collaborator Author

Interesting question.

I think I'm looking for 16, since I'd need to goose down before 16 (e.g. 13) to be able to apply the missing 14,15.

@mfridman
Copy link
Collaborator

mfridman commented May 11, 2024

Ended up adding the max db version. 1,4,5 applied and 2,3 are missing

2024/05/11 16:27:54 goose run: error: found 2 missing migrations before current version 5:
        version 2: testdata/migrations/00002_posts_table.sql
        version 3: testdata/migrations/00003_comments_table.sql
exit status 1

I think since the user knows the max of the missing versions, it'd always be a down-to that version, e.g,. in this case I'd have to down-to 4 (which is max missing 3 + 1).

@VojtechVitek
Copy link
Collaborator Author

Great, thanks @mfridman :)

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.

2 participants