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

Clean cannot drop schema with H2 1.4.197 and newer #1989

Closed
ben-manes opened this issue Apr 18, 2018 · 1 comment
Closed

Clean cannot drop schema with H2 1.4.197 and newer #1989

ben-manes opened this issue Apr 18, 2018 · 1 comment

Comments

@ben-manes
Copy link
Contributor

@ben-manes ben-manes commented Apr 18, 2018

Gradle plugin: 5.0.7
H2: 1.4.197

gradle flywayClean will execute the statement DROP SCHEMA "<name>" and this works with H2 1.4.196. However, in the latest version it fails with Cannot drop "<name>" because "..." depends on it.

The grammar of H2 DROP SCHEMA states:

Drops a schema. The command will fail if objects in this schema exist and the RESTRICT clause is used (the default). All objects in this schema are dropped as well if the CASCADE clause is used. This command commits an open transaction in this connection.

This indicates that the correct SQL statement would be DROP SCHEMA "<name>" CASCADE.

@axelfontaine axelfontaine added this to the Flyway 5.1.0 milestone Apr 21, 2018
@axelfontaine axelfontaine changed the title H2: Clean cannot drop schema Clean cannot drop schema with H2 1.4.197 and newer May 7, 2018
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue May 7, 2018
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented May 7, 2018

Thanks for reporting. This was nastier than expected as H2 actually introduced a breaking change in a patch release. The DROP SCHEMA ... CASCADE syntax is the only one that works for this from 1.4.197 onward, yet it isn't supported at all in 1.4.196 and earlier. I have now added detection code to handle both versions transparently.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants