-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support Flyway file ordering in DDLDatabase #8939
Comments
I would suggest to introduce sort=flyway for org.jooq.meta.extensions.ddl.DDLDatabase if the actual order is intended with sort=semantic |
I am also willing to implement |
Thank you very much for your suggestion. I thought there was an existing feature request for this, but I cannot find it. I definitely agree Flyway file ordering should be supported, although I'd say that's a new feature, not a bug :-) This new ordering would be implemented when
That's greatly appreciated. I think this is a very local change, so a PR is definitely feasible. May I ask you to review our contribution guidelines: https://github.com/jOOQ/jOOQ/blob/master/CONTRIBUTING.md I'll be very happy to assist you with this change. |
I can do a PR. First question: what shall we do with SQL scripts that are not fitting in the flyway naming pattern (e.g. not containing a version)? throw an exception, return null, or ignore the file completely? |
My first implementation would look like this: ignore first character, then I expect the version until 2 underscores. In the version I would interpret any non-number as dot. |
I think that we don't have to implement this functionality, as we're not going to replace Flyway. Flyway will have validated the migration files already in the build pipeline, so this is only about producing the same order.
Can we reuse some Flyway code? Flyway's Open Source version is ASL 2.0 licensed, which is compatible with jOOQ's ASL 2.0. With proper attribution and if retaining Flyway copyright, we should be able to reuse their logic. |
I think we can use this as starting point: https://github.com/flyway/flyway/blob/master/flyway-core/src/main/java/org/flywaydb/core/api/MigrationVersion.java |
That does look very useful, indeed
I'd prefer not to add one. Instead, we can manually shade the class into a jOOQ package (which seems to have no other dependencies apart from |
Just wondering, I wrote a test with Flyway/DDLDatabase and the following sql files:
with sort=semantic it fails as expected, but when I do sort=none it succeed IMO unexpected. Do you have an idea why? |
You cannot rely on |
PR: #8976 |
[#8939] Support Flyway file ordering in DDLDatabase
- Fixed a bug when FlywayFileComparator compares non-flyway files - Added a unit test - Added examples to jOOQ-examples module as submodules - Split flyway migration in one more migration file - Check in generated sources
Done. Thanks again for your contribution! |
Expected behavior and actual behavior:
Flyway SQL scripts are imported in the wrong order into DDLDatabase (with sort=semantic)
excepted:
src/main/resources/db/migration/V1__init_schema.sql
src/main/resources/db/migration/V1.1__add_indexes.sql
actual:
src/main/resources/db/migration/V1.1__add_indexes.sql <- triggers sql error due to missing table
src/main/resources/db/migration/V1__init_schema.sql
Steps to reproduce the problem (if possible, create an MCVE: https://github.com/jOOQ/jOOQ-mcve):
src/main/resources/db/migration/V1__init_schema.sql:
src/main/resources/db/migration/V1.1__add_indexes.sql:
pom.xml:
Versions:
The text was updated successfully, but these errors were encountered: