Sha256: 69602d507473a16f083890940853f79925fb3f40d494137ce5060bb8d4dc4c69

Contents?: true

Size: 904 Bytes

Versions: 9

Compression:

Stored size: 904 Bytes

Contents

module PgHero
  module Methods
    module Constraints
      # referenced fields can be nil
      # as not all constraints are foreign keys
      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
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pghero-3.6.1 lib/pghero/methods/constraints.rb
pghero-3.6.0 lib/pghero/methods/constraints.rb
pghero-3.4.1 lib/pghero/methods/constraints.rb
pghero-3.4.0 lib/pghero/methods/constraints.rb
pghero-3.3.4 lib/pghero/methods/constraints.rb
pghero-3.3.3 lib/pghero/methods/constraints.rb
pghero-3.3.2 lib/pghero/methods/constraints.rb
pghero-3.3.1 lib/pghero/methods/constraints.rb
pghero-3.3.0 lib/pghero/methods/constraints.rb