Flowdock
method

check_constraints

Importance_0
v7.1.3.2 - Show latest stable - 0 notes - Class: SchemaStatements
check_constraints(table_name) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb, line 591
        def check_constraints(table_name) # :nodoc:
          scope = quoted_scope(table_name)

          check_info = internal_exec_query(            SELECT conname, pg_get_constraintdef(c.oid, true) AS constraintdef, c.convalidated AS valid            FROM pg_constraint c            JOIN pg_class t ON c.conrelid = t.oid            JOIN pg_namespace n ON n.oid = c.connamespace            WHERE c.contype = 'c'              AND t.relname = #{scope[:name]}              AND n.nspname = #{scope[:schema]}, "SCHEMA", allow_retry: true, materialize_transactions: false)

          check_info.map do |row|
            options = {
              name: row["conname"],
              validate: row["valid"]
            }
            expression = row["constraintdef"][/CHECK \((.+)\)/, 1]

            CheckConstraintDefinition.new(table_name, expression, options)
          end
        end
Register or log in to add new notes.