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

canExecuteInTransaction is not respected by JavaMigration #2236

Closed
logicbomb opened this Issue Dec 7, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@logicbomb
Copy link

logicbomb commented Dec 7, 2018

Which version and edition of Flyway are you using?

5.2.4

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)

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

Java API

Which database are you using (type & version)?

PostgresSQL

Which operating system are you using?

Ubuntu 18.10

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)
Write a java migration that must execute outside of a transaction - alter type public.my_type add value 'new_value';

What did you expect to see?

No error

What did you see instead?

A postgres error

The issue comes from the fact that the JavaMigrationExecutor doesn't forward the migration's canExecuteInTransaction value, which can be seen here:
https://github.com/flyway/flyway/blob/master/flyway-core/src/main/java/org/flywaydb/core/internal/resolver/java/JavaMigrationExecutor.java#L68

The method should be

    @Override
    public boolean canExecuteInTransaction() {
        return this.javaMigration.canExecuteInTransaction();
    }

Also, I had a tough time debugging it b/c the reflection code that instantiates the migration hides inner exceptions, and is difficult to find. I'm working on a PR that fixes the issue, and makes reflection errors easier to detect.

@logicbomb

This comment has been minimized.

@axelfontaine axelfontaine added this to the Flyway 6.0.0 milestone Dec 8, 2018

axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Dec 11, 2018

@axelfontaine

This comment has been minimized.

Copy link
Contributor

axelfontaine commented Dec 11, 2018

Thanks for catching this and investigating. Truly appreciated! Fixed.

@pjroth

This comment has been minimized.

Copy link

pjroth commented Mar 20, 2019

Is it possible to get a 5.X.Y release including this fix since 6.X.Y isn't yet ready for production?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.