flyway / flyway

Flyway by Redgate • Database Migrations Made Easy.
https://flywaydb.org
Apache License 2.0
8.23k stars 1.51k forks source link

CLI does not support "catalog"."schema" qualified name for schema configuration #3979

Open humpfhumpf opened 6 days ago

humpfhumpf commented 6 days ago

Some databases use extended schema name like "catalog"."schema" instead of simply "schema".

Currently on Flyway CLI, when flyway.schemas or flyway.defaultSchema configuration keys are set with catalog.schema value, CLI uses "catalog.schema" (instead of "catalog"."schema").

If I put "catalog"."schema" name in configuration, flyway CLI guess this erroneous schema: ""catalog"."schema""

One of the cause seems to be here: https://github.com/flyway/flyway/blob/main/flyway-core/src/main/java/org/flywaydb/core/internal/database/base/Schema.java#L221

Which version and edition of Flyway are you using?

10.17.1 Opensource edition.

If this is not the latest version, can you reproduce the issue with the latest one as well? (Many bugs are fixed in newer releases and upgrading will often resolve the issue)

Main branch is also impacted: https://github.com/flyway/flyway/blob/main/flyway-core/src/main/java/org/flywaydb/core/internal/database/base/Schema.java#L221

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

CLI

Which database are you using? (Type & version)

Trino, but not releated to any specific database type.

Which operating system are you using?

Windows

What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)

see above

What did you expect to see?

see above

What did you see instead?

see above

JasonLuo-Redgate commented 6 days ago

Hi @humpfhumpf , In this case, you need to include escape character. The below configuration in a toml file works: defaultSchema = "\"catalog\".\"schema\""

humpfhumpf commented 6 days ago

Hi @JasonLuo-Redgate , With:

I get these messages with flyway migrate:

Creating schema """starburst_db"".""demo_flyway""" ...
Creating schema "demo_schema" ...
Creating Schema History table """starburst_db"".""demo_flyway"""."flyway_history_demo_schema" ...
[...]
DEBUG: Executing SQL: CREATE TABLE """starburst_db"".""demo_flyway"""."flyway_history_demo_schema" (
[...]
ERROR: Failed to execute operation in non-transactional context. Please restore backups and roll back database and code!

I am now wondering, if the trino plugin doesn't make some hard double-quoting... What do you thing about the line https://github.com/flyway/flyway/blob/main/flyway-core/src/main/java/org/flywaydb/core/internal/database/base/Schema.java#L221 ? It does hard double-quoting, no?