Class: ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
- Inherits:
-
TableDefinition
- Object
- TableDefinition
- ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
- Includes:
- ColumnMethods
- Defined in:
- activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb
Overview
Active Record PostgreSQL Adapter Table Definition
Instance Attribute Summary collapse
-
#exclusion_constraints ⇒ Object
readonly
Returns the value of attribute exclusion_constraints.
-
#unique_constraints ⇒ Object
readonly
Returns the value of attribute unique_constraints.
-
#unlogged ⇒ Object
readonly
Returns the value of attribute unlogged.
Attributes inherited from TableDefinition
#as, #check_constraints, #comment, #foreign_keys, #if_not_exists, #indexes, #name, #options, #temporary
Instance Method Summary collapse
- #exclusion_constraint(expression, **options) ⇒ Object
-
#initialize ⇒ TableDefinition
constructor
A new instance of TableDefinition.
-
#new_column_definition(name, type, **options) ⇒ Object
:nodoc:.
-
#new_exclusion_constraint_definition(expression, options) ⇒ Object
:nodoc:.
-
#new_unique_constraint_definition(column_name, options) ⇒ Object
:nodoc:.
- #unique_constraint(column_name, **options) ⇒ Object
Methods included from ColumnMethods
Methods included from ActiveSupport::Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Methods inherited from TableDefinition
#[], #check_constraint, #column, #columns, #foreign_key, #index, #new_check_constraint_definition, #new_foreign_key_definition, #primary_keys, #references, #remove_column, #set_primary_key, #timestamps
Methods included from ColumnMethods
Constructor Details
#initialize ⇒ TableDefinition
Returns a new instance of TableDefinition.
248 249 250 251 252 253 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 248 def initialize(*, **) super @exclusion_constraints = [] @unique_constraints = [] @unlogged = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables end |
Instance Attribute Details
#exclusion_constraints ⇒ Object (readonly)
Returns the value of attribute exclusion_constraints.
246 247 248 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 246 def exclusion_constraints @exclusion_constraints end |
#unique_constraints ⇒ Object (readonly)
Returns the value of attribute unique_constraints.
246 247 248 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 246 def unique_constraints @unique_constraints end |
#unlogged ⇒ Object (readonly)
Returns the value of attribute unlogged.
246 247 248 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 246 def unlogged @unlogged end |
Instance Method Details
#exclusion_constraint(expression, **options) ⇒ Object
255 256 257 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 255 def exclusion_constraint(expression, **) exclusion_constraints << new_exclusion_constraint_definition(expression, ) end |
#new_column_definition(name, type, **options) ⇒ Object
:nodoc:
273 274 275 276 277 278 279 280 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 273 def new_column_definition(name, type, **) # :nodoc: case type when :virtual type = [:type] end super end |
#new_exclusion_constraint_definition(expression, options) ⇒ Object
:nodoc:
263 264 265 266 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 263 def new_exclusion_constraint_definition(expression, ) # :nodoc: = @conn.(name, expression, ) ExclusionConstraintDefinition.new(name, expression, ) end |
#new_unique_constraint_definition(column_name, options) ⇒ Object
:nodoc:
268 269 270 271 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 268 def new_unique_constraint_definition(column_name, ) # :nodoc: = @conn.(name, column_name, ) UniqueConstraintDefinition.new(name, column_name, ) end |
#unique_constraint(column_name, **options) ⇒ Object
259 260 261 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb', line 259 def unique_constraint(column_name, **) unique_constraints << new_unique_constraint_definition(column_name, ) end |