Class: ActiveRecord::ConnectionAdapters::PostgreSQL::Table

Inherits:
Table
  • Object
show all
Includes:
ColumnMethods
Defined in:
lib/active_record/connection_adapters/postgresql/schema_definitions.rb

Overview

Active Record PostgreSQL Adapter Table

Instance Attribute Summary

Attributes inherited from Table

#name

Instance Method Summary collapse

Methods included from ColumnMethods

#bigserial, #primary_key

Methods inherited from Table

#change, #change_default, #change_null, #check_constraint, #check_constraint_exists?, #column, #column_exists?, #foreign_key, #foreign_key_exists?, #index, #index_exists?, #initialize, #references, #remove, #remove_check_constraint, #remove_foreign_key, #remove_index, #remove_references, #remove_timestamps, #rename, #rename_index, #timestamps

Methods included from ColumnMethods

#primary_key

Constructor Details

This class inherits a constructor from ActiveRecord::ConnectionAdapters::Table

Instance Method Details

#exclusion_constraintObject

Adds an exclusion constraint.

t.exclusion_constraint("price WITH =, availability_range WITH &&", using: :gist, name: "price_check")

See connection.add_exclusion_constraint



298
299
300
# File 'lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 298

def exclusion_constraint(...)
  @base.add_exclusion_constraint(name, ...)
end

#remove_exclusion_constraintObject

Removes the given exclusion constraint from the table.

t.remove_exclusion_constraint(name: "price_check")

See connection.remove_exclusion_constraint



307
308
309
# File 'lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 307

def remove_exclusion_constraint(...)
  @base.remove_exclusion_constraint(name, ...)
end

#remove_unique_constraintObject

Removes the given unique constraint from the table.

t.remove_unique_constraint(name: "unique_position")

See connection.remove_unique_constraint



325
326
327
# File 'lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 325

def remove_unique_constraint(...)
  @base.remove_unique_constraint(name, ...)
end

#unique_constraintObject

Adds a unique constraint.

t.unique_constraint(:position, name: 'unique_position', deferrable: :deferred, nulls_not_distinct: true)

See connection.add_unique_constraint



316
317
318
# File 'lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 316

def unique_constraint(...)
  @base.add_unique_constraint(name, ...)
end

#validate_check_constraintObject

Validates the given check constraint on the table

t.check_constraint("price > 0", name: "price_check", validate: false)
t.validate_check_constraint name: "price_check"

See connection.validate_check_constraint



345
346
347
# File 'lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 345

def validate_check_constraint(...)
  @base.validate_check_constraint(name, ...)
end

#validate_constraintObject

Validates the given constraint on the table.

t.check_constraint("price > 0", name: "price_check", validate: false)
t.validate_constraint "price_check"

See connection.validate_constraint



335
336
337
# File 'lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 335

def validate_constraint(...)
  @base.validate_constraint(name, ...)
end