-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Liquibase: Incorrect creation of new foreign key relationships during schema updates #27598
Comments
Ideally, these attributes should be calculated somewhere centrally. An easy fix would be to copy&paste the part of code from the |
Can you please create a PR to test if your theory works?
|
Yes, I will :) |
https://github.com/jhipster/generator-jhipster/pull/27608/files#diff-4d1e23473a996d309372a8a4caadba2f4d0f8f40218d149dfee1a9f8b802a9c0R596-R599 https://github.com/jhipster/generator-jhipster/pull/27608/files#diff-4d1e23473a996d309372a8a4caadba2f4d0f8f40218d149dfee1a9f8b802a9c0R602-R612 |
and regenerated snapshots Fix jhipster#27598
and regenerated snapshots Fix jhipster#27598
and regenerated snapshots Fix jhipster#27598
and regenerated snapshots Fix jhipster#27598
and regenerated snapshots Fix jhipster#27598
and regenerated snapshots Fix jhipster#27598
Overview of the issue
When adding a new Foreign Key relationship, the generated changelogs fail to be applied, especially, if the other entity side has an id column not named "id", but e.g. "uuid". In our case, we even had that foreign key already and tried to re-create that with some more options (like CASCADE). The generator successfully detected the need to recreate the foreign keys, but the new ones as part of the updated_entity_constraints produces wrong column name references (and maybe more).
Motivation for or Use Case
Should be possible to apply updates to schema involving changes in foreign keys.
Reproduce the error
jhipster jdl
Here are some stripped sample jdls.
Step 1:
Step 2:
Related issues
Suggest a Fix
This is because the logic in the update changelog files to construct the attributes for the addForeignKeyContraint works differently than in the add changelog for the initial changelog.
Not working:
generator-jhipster/generators/liquibase/templates/src/main/resources/config/liquibase/changelog/updated_entity_constraints.xml.ejs
Lines 114 to 118 in 330d2a4
--> hardcoded "_id", no matter, if the actual other entity has a different column name as id, therefore having a different column name in the current entity
Working:
generator-jhipster/generators/liquibase/templates/src/main/resources/config/liquibase/changelog/added_entity_constraints.xml.ejs
Lines 32 to 41 in 330d2a4
Especially line 38-41 being relevant, but I guess the rest may also be important....
JHipster Version(s)
8.7.1
JHipster configuration
To provide all information we need, you should run
jhipster info
in the project root folder (or workspaces root for microservices), andcopy/paste the result here.
jhipster info
removes sentitive information like rememberKey, jwtSecretKey. Double check if there is any other sensitive info.As alternative you can add a JDL wrapped in below structure
JDL definitions
The information is mandatory for bug reports. This will allow us to use automated tests and genarate the broken sample using
jhipster from-issue
command.Browsers and Operating System
The text was updated successfully, but these errors were encountered: