summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeff Bradberry <jeff.bradberry@gmail.com>2024-05-08 21:28:27 +0200
committerJeff Bradberry <jeff.bradberry@gmail.com>2024-06-10 22:36:22 +0200
commitad9d5904d8d31c3aeaeac0a8b9492adddea65a1b (patch)
tree4fba7da394e5fb250f66d7558afe66f008d0a1fb /tools
parentSplit the foreign key sql script into an 'into' and 'from' portion (diff)
downloadawx-ad9d5904d8d31c3aeaeac0a8b9492adddea65a1b.tar.xz
awx-ad9d5904d8d31c3aeaeac0a8b9492adddea65a1b.zip
Adjusted foreignkeys.sql for correctness
Some relationships known to be handled by the special mapping sql file were being caught as false positives.
Diffstat (limited to 'tools')
-rw-r--r--tools/scripts/ig-hotfix/foreignkeys.sql13
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/scripts/ig-hotfix/foreignkeys.sql b/tools/scripts/ig-hotfix/foreignkeys.sql
index e0816c4bd8..ac9ba2a5de 100644
--- a/tools/scripts/ig-hotfix/foreignkeys.sql
+++ b/tools/scripts/ig-hotfix/foreignkeys.sql
@@ -1,7 +1,10 @@
DO $$
DECLARE
+ -- add table names here when they get excluded from main / included in topology dump
topology text[] := ARRAY['main_instance', 'main_instancegroup', 'main_instancegroup_instances'];
- excluded text[] := ARRAY['main_instance', 'main_instancegroup', 'main_instancegroup_instances', 'main_organizationinstancegroupmembership', 'main_unifiedjobtemplateinstancegroupmembership', 'main_inventoryinstancegroupmembership'];
+
+ -- add table names here when they are handled by the special-case mapping
+ mapping text[] := ARRAY['main_organizationinstancegroupmembership', 'main_unifiedjobtemplateinstancegroupmembership', 'main_inventoryinstancegroupmembership'];
BEGIN
CREATE TABLE tmp_fk_from AS (
SELECT DISTINCT
@@ -11,8 +14,8 @@ BEGIN
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
WHERE tc.constraint_type = 'FOREIGN KEY'
- AND tc.table_name = ANY (excluded)
- AND NOT ccu.table_name = ANY (topology)
+ AND tc.table_name = ANY (topology)
+ AND NOT ccu.table_name = ANY (topology || mapping)
);
CREATE TABLE tmp_fk_into AS (
@@ -23,8 +26,8 @@ BEGIN
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
WHERE tc.constraint_type = 'FOREIGN KEY'
- AND ccu.table_name = ANY (excluded)
- AND NOT tc.table_name = ANY (topology)
+ AND ccu.table_name = ANY (topology)
+ AND NOT tc.table_name = ANY (topology || mapping)
);
END $$;