-
Notifications
You must be signed in to change notification settings - Fork 0
fix addForeignKeyConstraint #716
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
Open
ghazwarhili
wants to merge
9
commits into
main
Choose a base branch
from
fix-foreignKeyConstraint-liquibase-diff
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1ed42b7
fix addForeignKeyConstraint
ghazwarhili 994411f
fix error
ghazwarhili 5a3554b
resolve conflicts
ghazwarhili 6b56664
code review remarks
ghazwarhili 242c7bf
fix constraintName
ghazwarhili 11a863e
code review remarks
ghazwarhili 6d36245
Revert "code review remarks"
ghazwarhili 5317035
suggested for properties foreignKey
ghazwarhili ce8f756
resolve conflicts
ghazwarhili File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/resources/db/changelog/changesets/changelog_20251021T145023Z.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
| <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-39"> | ||
| <addForeignKeyConstraint baseColumnNames="id" baseTableName="battery_creation" constraintName="batteryCreation_id_fk_constraint" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="modification" validate="true"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-40"> | ||
| <addForeignKeyConstraint baseColumnNames="converter_station_1_id" baseTableName="vsc_modification" constraintName="converter_station_modification_1_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="converter_station_modification" validate="true"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-41"> | ||
| <addForeignKeyConstraint baseColumnNames="converter_station_2_id" baseTableName="vsc_modification" constraintName="converter_station_modification_2_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="converter_station_modification" validate="true"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-42"> | ||
| <addForeignKeyConstraint baseColumnNames="operational_limits_groups_id" baseTableName="line_modification_operational_limits_groups" constraintName="operational_limits_groups_line_modification_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="operational_limits_group_modification" validate="true"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-43"> | ||
| <addForeignKeyConstraint baseColumnNames="operational_limits_groups_id" baseTableName="two_windings_transformer_modification_operational_limits_groups" constraintName="operational_limits_groups_2wt_modification_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="operational_limits_group_modification" validate="true"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-44"> | ||
| <dropForeignKeyConstraint baseTableName="TABULAR_PROPERTY" constraintName="FK1t4r9etm29snityophivgnkce"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-45"> | ||
| <dropForeignKeyConstraint baseTableName="FREE_PROPERTY" constraintName="FK3wbc92cp7wlvba202qx7ldy6n"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-46"> | ||
| <addForeignKeyConstraint baseColumnNames="equipment_modification_id" baseTableName="free_property" constraintName="free_property_modification_id_fk_constraint" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="modification" validate="true"/> | ||
| </changeSet> | ||
| </databaseChangeLog> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onetomany
@joincolumn(name = "equipment_modification_id")
The OneToMany owns the FK since it's declared on the parent side
On delete:
(because the FK is managed by the parent, so we must break it before the delete)
=> Results in 2 UPDATEs (UPDATE generated before the DELETE)
With:
FreePropertyEntity:
@manytoone
@joincolumn(name = "equipment_modification_id")
private ModificationEntity modification;
EquipmentModificationEntity:
@onetomany(mappedBy = "modification")
private List properties;
=> The ManyToOne owns the FK
On delete:
DELETE FROM free_property WHERE equipment_modification_id = :id
(the FK is managed by the child, so no need to set it to NULL)
Since we have @OrderColumn(name = "insert_position") an UPDATE is generated to update and reindex the list before DELETE