-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development: Fix exercise deletion with existing Iris messages (#9875)
- Loading branch information
Showing
3 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/main/resources/config/liquibase/changelog/20241125000900_changelog.xml
This file contains 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,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet id="20241125000900" author="kaancayli"> | ||
<preConditions onFail="MARK_RAN"> | ||
<!-- Check if the foreign keys exists before modifying --> | ||
<foreignKeyConstraintExists foreignKeyName="fk_iris_message_session_id"/> | ||
<foreignKeyConstraintExists foreignKeyName="fk_iris_message_content_message_id"/> | ||
<foreignKeyConstraintExists foreignKeyName="fk_text_id_to_content_id"/> | ||
<foreignKeyConstraintExists foreignKeyName="fk_json_id_to_content_id"/> | ||
</preConditions> | ||
|
||
<!-- Drop the existing foreign keys --> | ||
<dropForeignKeyConstraint | ||
baseTableName="iris_message" | ||
constraintName="fk_iris_message_session_id"/> | ||
|
||
<dropForeignKeyConstraint | ||
baseTableName="iris_message_content" | ||
constraintName="fk_iris_message_content_message_id"/> | ||
|
||
<dropForeignKeyConstraint | ||
baseTableName="iris_json_message_content" | ||
constraintName="fk_json_id_to_content_id"/> | ||
|
||
<dropForeignKeyConstraint | ||
baseTableName="iris_text_message_content" | ||
constraintName="fk_text_id_to_content_id"/> | ||
|
||
<!-- Add the foreign keys back with ON DELETE CASCADE --> | ||
<addForeignKeyConstraint | ||
baseTableName="iris_message" | ||
baseColumnNames="session_id" | ||
referencedTableName="iris_session" | ||
referencedColumnNames="id" | ||
constraintName="fk_iris_message_session_id" | ||
onDelete="CASCADE"/> | ||
|
||
<addForeignKeyConstraint | ||
baseTableName="iris_message_content" | ||
baseColumnNames="message_id" | ||
constraintName="fk_iris_message_content_message_id" | ||
referencedTableName="iris_message" | ||
referencedColumnNames="id" | ||
onDelete="CASCADE"/> | ||
|
||
<addForeignKeyConstraint | ||
baseColumnNames="id" | ||
baseTableName="iris_text_message_content" | ||
constraintName="fk_text_id_to_content_id" | ||
referencedColumnNames="id" | ||
referencedTableName="iris_message_content" | ||
onDelete="CASCADE"/> | ||
|
||
<addForeignKeyConstraint | ||
baseColumnNames="id" | ||
baseTableName="iris_json_message_content" | ||
constraintName="fk_json_id_to_content_id" | ||
referencedColumnNames="id" | ||
referencedTableName="iris_message_content" | ||
onDelete="CASCADE"/> | ||
|
||
</changeSet> | ||
</databaseChangeLog> |
This file contains 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 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