From 546c144518fae01ecad966149c2930655ac44c2a Mon Sep 17 00:00:00 2001
From: danielhanrahan <daniel.hanrahan@est.tech>
Date: Fri, 3 Mar 2023 08:53:56 +0000
Subject: Use cascade delete in fragments table

- Add Liquibase change to cascade delete fragments
- Remove cascade delete logic from FragmentNativeRepository
- Remove unused method deleteFragmentEntity

Issue-ID: CPS-1617
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: Iecf4f3022b402e0328609ddc11a879c83e5d7f30
---
 .../18-cascade-delete-fragment-children.yaml       | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 cps-ri/src/main/resources/changelog/db/changes/18-cascade-delete-fragment-children.yaml

(limited to 'cps-ri/src/main/resources/changelog/db/changes')

diff --git a/cps-ri/src/main/resources/changelog/db/changes/18-cascade-delete-fragment-children.yaml b/cps-ri/src/main/resources/changelog/db/changes/18-cascade-delete-fragment-children.yaml
new file mode 100644
index 0000000000..62a9e2f636
--- /dev/null
+++ b/cps-ri/src/main/resources/changelog/db/changes/18-cascade-delete-fragment-children.yaml
@@ -0,0 +1,34 @@
+databaseChangeLog:
+  - changeSet:
+      author: cps
+      id: 18
+      changes:
+        - dropForeignKeyConstraint:
+            baseTableName: fragment
+            constraintName: fragment_parent_id_fkey
+        - addForeignKeyConstraint:
+            baseColumnNames: parent_id
+            baseTableName: fragment
+            constraintName: fragment_parent_id_fkey
+            deferrable: false
+            initiallyDeferred: false
+            onDelete: CASCADE
+            onUpdate: NO ACTION
+            referencedColumnNames: id
+            referencedTableName: fragment
+            validate: true
+      rollback:
+        - dropForeignKeyConstraint:
+            baseTableName: fragment
+            constraintName: fragment_parent_id_fkey
+        - addForeignKeyConstraint:
+            baseColumnNames: parent_id
+            baseTableName: fragment
+            constraintName: fragment_parent_id_fkey
+            deferrable: false
+            initiallyDeferred: false
+            onDelete: NO ACTION
+            onUpdate: NO ACTION
+            referencedColumnNames: id
+            referencedTableName: fragment
+            validate: true
-- 
cgit 1.2.3-korg