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
PostgreSQL: Flyway uses "public" schema instead of current_schema when search_path starts with $user #1926
Comments
Thanks for the report. Related to #1407 Note that we do actually back up and restore the full search_path. |
@daniel-huss Could you elaborate a little on the following:
We of course do this so that a migration run with V1 and V2 would result in the same database as two separate migration runs where the first would only do V1 and the second only V2. What other bad ideas do you feel we should compensate for and currently aren't?
Which preconditions exactly do you have in mind? |
Thank you for giving me a chance to explain this more clearly, I'm genuinely bad at communicating with people. What I was really trying to say is: I strongly believe Flyway should never ever touch the session state, nor should migrations, nor should other application code. Session state should be considered all set up and read-only once the application obtains some JDBC Connection instance from a DataSource. I actually don't want Flyway to compensate for any problems caused by altered session state, If I'm not mistaken, Flyway setting If some migration really needs to temporarily alter session state because there's no equivalent to Postgres' Those documentation "ideas" otoh are probably just me trying to make the other option (=Flyway taking responsibility for session state) look bad. Sorry about that. |
I ended up going for the |
…urrent_schema when search_path starts with $user
What version of Flyway are you using?
5.0.7
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
Java API
What database are you using (type & version)?
PostgreSQL 9.6
What operating system are you using?
Ubuntu 16.04
What did you do?
Migrate or baseline on a connection where search_path starts with $user.
This affects all migration actions due to the way ´PostgreSQLConnection.getFirstSchemaFromSearchPath´ works.
What did you expect to see?
Metadata table and application's schema objects are created in the current_schema which is also the name of the login role, say "my_application"
I also expect "public" to remain on the search path for each executed migration.
What did you see instead?
Metadata table and application's schema objects are in "public" schema.
Ideas (mutually exclusive):
select current_schema
instead of parsing search_pathif you're going to modify search_path, backup and restore the entire search_path expressionI stand correctedThe text was updated successfully, but these errors were encountered: