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

Goose returns incorrect error when multiple DB users try to up migrations #800

Open
R0masik opened this issue Aug 6, 2024 · 2 comments
Open

Comments

@R0masik
Copy link

R0masik commented Aug 6, 2024

I have Postgres and 2 users in it (user1 and user2) with all granted rights. I run migrations as user1 and it completed successfully, then I try to run the same migrations from user2, but I get error relation "goose_db_version" already exists, although the real error is that permission to read "goose_db_version" table is denied for user2.

The problem is in the line https://github.com/pressly/goose/blob/master/migrate.go#L216, goose tries to get list of migrations and after getting any error tries to create table "goose_db_version". This is confusing, I think it is necessary to create table "goose_db_version" only if it does not exist and return error in any other case.

@mfridman
Copy link
Collaborator

Are you running things in parallel? Also, are you using goose as a CLI or importing it as a library without your application?

@R0masik
Copy link
Author

R0masik commented Aug 28, 2024

I use goose as a library in my go app. It doesn't really matter whether you perform migrations sequentially or in parallel: the user who created "goose_db_version" table will have access to it, but others will not. If I grant permissions to other users to read "goose_db_version" table, the error is gone.

The problem is that goose doesn't return a real error as I pointed out in the post above, and that's misleading.

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

2 participants