mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 02:17:37 -02:30
Adjusted foreignkeys.sql for correctness
Some relationships known to be handled by the special mapping sql file were being caught as false positives.
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
DO $$
|
DO $$
|
||||||
DECLARE
|
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'];
|
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
|
BEGIN
|
||||||
CREATE TABLE tmp_fk_from AS (
|
CREATE TABLE tmp_fk_from AS (
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
@@ -11,8 +14,8 @@ BEGIN
|
|||||||
JOIN information_schema.constraint_column_usage AS ccu
|
JOIN information_schema.constraint_column_usage AS ccu
|
||||||
ON ccu.constraint_name = tc.constraint_name
|
ON ccu.constraint_name = tc.constraint_name
|
||||||
WHERE tc.constraint_type = 'FOREIGN KEY'
|
WHERE tc.constraint_type = 'FOREIGN KEY'
|
||||||
AND tc.table_name = ANY (excluded)
|
AND tc.table_name = ANY (topology)
|
||||||
AND NOT ccu.table_name = ANY (topology)
|
AND NOT ccu.table_name = ANY (topology || mapping)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE tmp_fk_into AS (
|
CREATE TABLE tmp_fk_into AS (
|
||||||
@@ -23,8 +26,8 @@ BEGIN
|
|||||||
JOIN information_schema.constraint_column_usage AS ccu
|
JOIN information_schema.constraint_column_usage AS ccu
|
||||||
ON ccu.constraint_name = tc.constraint_name
|
ON ccu.constraint_name = tc.constraint_name
|
||||||
WHERE tc.constraint_type = 'FOREIGN KEY'
|
WHERE tc.constraint_type = 'FOREIGN KEY'
|
||||||
AND ccu.table_name = ANY (excluded)
|
AND ccu.table_name = ANY (topology)
|
||||||
AND NOT tc.table_name = ANY (topology)
|
AND NOT tc.table_name = ANY (topology || mapping)
|
||||||
);
|
);
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user