Skip to content

Fix foreign key order in structure.sql after !143868

Krasimir Angelov requested to merge ka/structure-sql/fix-after-143868 into master

What does this MR do and why?

!143868 (merged) introduced new FK, but seems like not at the right place in strcuture.sql - constraints should be ordered alphabetically by name. This results in the following diff after gdk update:

diff --git a/db/structure.sql b/db/structure.sql
index c9935eaf1aa3..03887a3628dc 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -30189,12 +30189,12 @@ ALTER TABLE ONLY packages_packages
 ALTER TABLE ONLY sbom_occurrences
     ADD CONSTRAINT fk_c2a5562923 FOREIGN KEY (source_id) REFERENCES sbom_sources(id) ON DELETE CASCADE;
 
-ALTER TABLE ONLY issues
-    ADD CONSTRAINT fk_c34dd2b036 FOREIGN KEY (tmp_epic_id) REFERENCES epics(id) ON DELETE CASCADE;
-
 ALTER TABLE ONLY dependency_list_exports
     ADD CONSTRAINT fk_c348f16f10 FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
 
+ALTER TABLE ONLY issues
+    ADD CONSTRAINT fk_c34dd2b036 FOREIGN KEY (tmp_epic_id) REFERENCES epics(id) ON DELETE CASCADE;
+
 ALTER TABLE ONLY user_group_callouts
     ADD CONSTRAINT fk_c366e12ec3 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;

This MR updates structure.sql to match the order pg_dump is using. [skip-db-structure-check]

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Merge request reports