You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Copy/paste of the `#foreign_keys(table)` method adapted to return every single
69
+
# foreign key in the database.
70
+
defall_foreign_keys
71
+
fk_info=internal_exec_query(<<~SQL,"SCHEMA")
72
+
SELECT CASE
73
+
WHEN n1.nspname = current_schema()
74
+
THEN ''
75
+
ELSE n1.nspname || '.'
76
+
END || t1.relname AS from_table,
77
+
CASE
78
+
WHEN n2.nspname = current_schema()
79
+
THEN ''
80
+
ELSE n2.nspname || '.'
81
+
END || t2.relname AS to_table,
82
+
a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete, c.convalidated AS valid, c.condeferrable AS deferrable, c.condeferred AS deferred,
83
+
c.conkey, c.confkey, c.conrelid, c.confrelid
84
+
FROM pg_constraint c
85
+
JOIN pg_class t1 ON c.conrelid = t1.oid
86
+
JOIN pg_class t2 ON c.confrelid = t2.oid
87
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
88
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
0 commit comments