method

check_constraints

Importance_0
v7.0.0 - 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 524
        def check_constraints(table_name) # :nodoc:
          scope = quoted_scope(table_name)

          check_info = exec_query(            SELECT conname, pg_get_constraintdef(c.oid) AS constraintdef, c.convalidated AS valid            FROM pg_constraint c            JOIN pg_class t ON c.conrelid = t.oid            WHERE c.contype = 'c'              AND t.relname = #{scope[:name]}, "SCHEMA")

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

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