-
Notifications
You must be signed in to change notification settings - Fork 65
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
Make doesTableExist
check for table in current search path
#33
base: master
Are you sure you want to change the base?
Conversation
* If a `migrations` table did exist in a schema outside of the search path, `doesTableExist` would return true but the migration would then fail with 'relation "migrations" does not exist' * See https://dba.stackexchange.com/a/86098 for the details on the query * This new query makes it possible to have one `migrations` table per schema
Thanks for this, it looks good and I'd like to consider merging it. Before I do, I'd like to think about alternatives, and consider any downsides to this implementation. My understanding from the docs is that default search path is I think an alternative would be to explicitly use the Thoughts? |
Correct, I don't see any way it could break either (except that the query is postgres 9.4+)
I think it would be a great improvement. However it could break things for users who have their For example if you revoke access to
Then |
Ah! Excellent, I wasn't aware of this. It's a real shame that the schema wasn't make explicit to begin with, I don't like that the schema it's in is unpredictable. I guess if we add the schema as a user option, we'd have to default to omitting the schema and leaving it implicit. Would you be able to add a test for the following:
And check that this fails without your change, and succeeds with it? Thanks! |
This PR would solve the problem nicely that we have. We've got around supporting another schema by setting the search path for postgres via Confirmed manually that this fix resolves the issue. What do we need to do in order to get this merged? |
Hi @mbyrne00, thanks for your interest in moving this PR forwards! I think the main thing is tests. I'm pretty sure this change is backwards compatible, but ideally I'd like the upgrade path tested. I think we'll then be able to achieve #40 / #41 - support for defining the schema for the migrations table as a user-supplied option. As I said above, I think this would be a good test:
|
Just to connect the dot explicitly -- I opened Issue Request #93 which applies this patch along with the requested tests. |
migrations
table did exist in a schema outside of the search path,doesTableExist
would return true but the migration would then fail with 'relation "migrations" does not exist'migrations
table per schema (in other words to have each schema handle its own migrations)