instance method unique_constraint_exists?

Ruby on Rails edge

Since edge

Signature

unique_constraint_exists?(*args, **options)

Checks if a unique constraint exists on a table.

unless t.unique_constraint_exists?(name: "unique_position")
  t.unique_constraint(:position, name: "unique_position", deferrable: :deferred)
end

See connection.unique_constraint_exists?

Parameters

args rest
options keyrest
Source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb, line 376
        def unique_constraint_exists?(*args, **options)
          @base.unique_constraint_exists?(name, *args, **options)
        end

Defined in activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb line 376 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::PostgreSQL::Table

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close