Module: AssociateJsonb::ConnectionAdapters::AlterTable
- Defined in:
- lib/associate_jsonb/connection_adapters/schema_definitions/alter_table.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#constraint_adds ⇒ Object
readonly
Returns the value of attribute constraint_adds.
-
#constraint_drops ⇒ Object
readonly
Returns the value of attribute constraint_drops.
Instance Method Summary collapse
- #add_constraint(name = nil, **opts) ⇒ Object
- #alter_constraint(name = nil, **opts) ⇒ Object
- #drop_constraint(name = nil, **opts) ⇒ Object
- #initialize(td) ⇒ Object
Instance Attribute Details
#constraint_adds ⇒ Object (readonly)
Returns the value of attribute constraint_adds.
7 8 9 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/alter_table.rb', line 7 def constraint_adds @constraint_adds end |
#constraint_drops ⇒ Object (readonly)
Returns the value of attribute constraint_drops.
7 8 9 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/alter_table.rb', line 7 def constraint_drops @constraint_drops end |
Instance Method Details
#add_constraint(name = nil, **opts) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/alter_table.rb', line 14 def add_constraint(name = nil, **opts) unless opts[:value].present? raise ArgumentError.new("Invalid Add Constraint Options") end @constraint_adds << ConstraintDefinition.new( **opts.reverse_merge(name: name) ) end |
#alter_constraint(name = nil, **opts) ⇒ Object
24 25 26 27 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/alter_table.rb', line 24 def alter_constraint(name = nil, **opts) opts[:force] = true add_constraint(name, **opts) end |
#drop_constraint(name = nil, **opts) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/alter_table.rb', line 29 def drop_constraint(name = nil, **opts) opts = opts.reverse_merge(force: true, name: name, value: nil) unless opts[:name].present? || opts[:value].present? raise ArgumentError.new("Invalid Drop Constraint Options") end @constraint_drops << ConstraintDefinition.new(**opts) end |
#initialize(td) ⇒ Object
8 9 10 11 12 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/alter_table.rb', line 8 def initialize(td) super @constraint_adds = [] @constraint_drops = [] end |