Module: PgHero::Methods::Constraints
- Included in:
- Database
- Defined in:
- lib/pghero/methods/constraints.rb
Instance Method Summary collapse
-
#invalid_constraints ⇒ Object
referenced fields can be nil as not all constraints are foreign keys.
Instance Method Details
#invalid_constraints ⇒ Object
referenced fields can be nil as not all constraints are foreign keys
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pghero/methods/constraints.rb', line 6 def invalid_constraints select_all <<~SQL SELECT nsp.nspname AS schema, rel.relname AS table, con.conname AS name, fnsp.nspname AS referenced_schema, frel.relname AS referenced_table FROM pg_catalog.pg_constraint con INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid LEFT JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace WHERE con.convalidated = 'f' SQL end |