PostgreSQL: Flyway uses "public" schema instead of current_schema when search_path starts with $user #1926
What version of Flyway are you using?
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
What database are you using (type & version)?
What operating system are you using?
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):
The text was updated successfully, but these errors were encountered:
@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.