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

Flyway: disable DDL generation from EclipseLink #5871

Closed
poikilotherm opened this issue May 21, 2019 · 13 comments
Closed

Flyway: disable DDL generation from EclipseLink #5871

poikilotherm opened this issue May 21, 2019 · 13 comments
Labels
Component: Code Infrastructure formerly "Feature: Code Infrastructure" Feature: None No user-facing feature in particular Type: Suggestion an idea User Role: Hackathon Participant Core developers, frequent contributors, drive-by contributors, etc.

Comments

@poikilotherm
Copy link
Contributor

poikilotherm commented May 21, 2019

This is a successor issue to #5862.
This kind of relates to #5854.
This should be read by @pdurbin, @MrK191, @donsizemore and @djbrooke at least.

Since the introduction of Flyway in #5344, only minor modifications happened to the schema.
In #5822 a new column has been added and since it had been merged, the develop branch no longer deploys on new "installations".

Some background on the cause:
EclipseLink ORM generates a DDL script from all models on startup and (due to this setting in persistance.xml) creates new tables when not existing. It does not update existing tables. This job is left to Flyway, which is one reason why it had been introduced.

Flyway throws exceptions due to a conflict, trying to change something already present. In #5822, a new column should be added, but on new deployments, EclipseLink already generated the mapping. Thus the deployment fails.

How to get along with this:
Obviously, one could just use workarounds as #5866 does. It would be better to have a discussion and decision on how to deal with database model, mappings, EclipseLink and Flyway in the future, write down a process and adapt.

IMHO there is only one "good" solution, but this is only a proposal and needs to be discussed and/or modified:

  1. Do not let EclipseLink generate DDL anymore.
  2. Get a base model mapping in the codebase as a proper baseline. This, ideally, should be the exact mapping as it has been when Flyway had been merged.
  3. Continue to write migrations in SQL or Java with Flyway, as already done. Document this part of the process if not already done sufficiently.
  4. To ensure 100% compatibility between tables and models, the mapping - now maintained with Flyway as migration files - needs to be validated regularly. This is an ideal task for CI on jenkins.dataverse.org.

It might be an option to switch from EclipseLink JPA to Hibernate JPA as it offers easier to use validation mechanisms than EclipseLink does.

@djbrooke
Copy link
Contributor

Thanks @poikilotherm for the tag, I'll tag @landreev and @scolapasta as well.

@MrK191
Copy link

MrK191 commented May 22, 2019

@poikilotherm I agree, in our version we just disabled eclipse-link ddl generation. In terms of hibernate you are going to have some troubles, since some annotation syntax changed and you gonna get LazyLoadingException on the face since for whatever reason lazy loading was disabled in this app. But changing to Hibernate will also resolve the problem that you can't use java streams on entities since there is a bug in the eclipse-link.

@poikilotherm
Copy link
Contributor Author

Thanks @MrK191 for pointing out the monsters lurking in the shadows. 😄
So you think it might be worse the price doing the switch?
Hibernate seems to be more widely used anyway, standard for Spring etc...

@pdurbin
Copy link
Member

pdurbin commented May 22, 2019

@poikilotherm @MrK191 if there's a feature missing from the JPA spec can one of you please open an issue at https://github.com/eclipse-ee4j/jpa-api ? (I have one open issue over there. 😄 )

@MrK191
Copy link

MrK191 commented May 22, 2019

@pdurbin Nothing is missing, it's just that the glassfish 4 uses eclipse-link version that has this bug.
@poikilotherm Nah I think it's good direction almost no-one heard of eclipse-link when I talk about JPA now :P, so in long-term it's good decision.

@pdurbin
Copy link
Member

pdurbin commented May 22, 2019

@MrK191 ok, you're saying there's a bug in the version of eclipse-link in the somewhat ancient version of Glassfish we're stuck on. That's bad news but I'm glad to hear that there's nothing missing from the JPA standard and that we don't have to move to one particular JPA implementation (Hibernate) to resolve this issue. I like standards. 😄

@pdurbin
Copy link
Member

pdurbin commented Oct 22, 2019

@poikilotherm and I had a short chat about this issue just now: http://irclog.iq.harvard.edu/dataverse/2019-10-22#i_110035

My take away is that overall, adding Flyway to the mix has been a step forward but there are further improvements we can make so that upgrading Dataverse is easier.

@pdurbin pdurbin added Type: Suggestion an idea Component: Code Infrastructure formerly "Feature: Code Infrastructure" User Role: Hackathon Participant Core developers, frequent contributors, drive-by contributors, etc. Feature: None No user-facing feature in particular labels Oct 7, 2023
@pdurbin
Copy link
Member

pdurbin commented Dec 14, 2023

@poikilotherm
Copy link
Contributor Author

Recently I gave creating a new base migration a shot. Turns out: works perfectly. So we make of this anytime we want to get rid of the DDL generation. @pdurbin thinks this might help with #9686 - it's not so easy to move the columns around with DDL generation getting in the way.

@pdurbin
Copy link
Member

pdurbin commented Jul 15, 2024

@poikilotherm fantastic! Can you please push a branch and maybe even make a pull request so we can see it?

@cmbz
Copy link

cmbz commented Aug 20, 2024

To focus on the most important features and bugs, we are closing issues created before 2020 (version 5.0) that are not new feature requests with the label 'Type: Feature'.

If you created this issue and you feel the team should revisit this decision, please reopen the issue and leave a comment.

@cmbz cmbz closed this as completed Aug 20, 2024
@pdurbin
Copy link
Member

pdurbin commented Dec 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Code Infrastructure formerly "Feature: Code Infrastructure" Feature: None No user-facing feature in particular Type: Suggestion an idea User Role: Hackathon Participant Core developers, frequent contributors, drive-by contributors, etc.
Projects
Status: Proposals
Development

No branches or pull requests

5 participants