instance method remove_check_constraint

Ruby on Rails 7.0.10

Since v6.1.7.10

Available in: v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

remove_check_constraint(table_name, expression = nil, **options)

Removes the given check constraint from the table.

remove_check_constraint :products, name: "price_check"

The expression parameter will be ignored if present. It can be helpful to provide this in a migration’s change method so it can be reverted. In that case, expression will be used by #add_check_constraint.

Parameters

table_name req
expression opt = nil
options keyrest
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 1207
      def remove_check_constraint(table_name, expression = nil, **options)
        return unless supports_check_constraints?

        chk_name_to_delete = check_constraint_for!(table_name, expression: expression, **options).name

        at = create_alter_table(table_name)
        at.drop_check_constraint(chk_name_to_delete)

        execute schema_creation.accept(at)
      end

Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb line 1207 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::SchemaStatements

Type at least 2 characters to search.

↑↓ navigate · open · esc close