method
check_constraints
rails latest stable - Class:
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements
check_constraints(table_name)public
No documentation available.
# 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