Module: ActiveRecord::Postgres::Constraints::CommandRecorder
- Defined in:
- lib/active_record/postgres/constraints/command_recorder.rb
Instance Method Summary collapse
- #add_check_constraint(*args, &block) ⇒ Object
- #invert_add_check_constraint(args, &block) ⇒ Object
- #invert_remove_check_constraint(args, &block) ⇒ Object
- #remove_check_constraint(*args, &block) ⇒ Object
Instance Method Details
#add_check_constraint(*args, &block) ⇒ Object
7 8 9 |
# File 'lib/active_record/postgres/constraints/command_recorder.rb', line 7 def add_check_constraint(*args, &block) record(:add_check_constraint, args, &block) end |
#invert_add_check_constraint(args, &block) ⇒ Object
11 12 13 |
# File 'lib/active_record/postgres/constraints/command_recorder.rb', line 11 def invert_add_check_constraint(args, &block) [:remove_check_constraint, args, block] end |
#invert_remove_check_constraint(args, &block) ⇒ Object
25 26 27 |
# File 'lib/active_record/postgres/constraints/command_recorder.rb', line 25 def invert_remove_check_constraint(args, &block) [:add_check_constraint, args, block] end |
#remove_check_constraint(*args, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/active_record/postgres/constraints/command_recorder.rb', line 15 def remove_check_constraint(*args, &block) if args.length < 3 raise ActiveRecord::IrreversibleMigration, 'To make this migration reversible, pass the constraint to '\ 'remove_check_constraint, i.e. `remove_check_constraint, '\ "#{args[0].inspect}, #{args[1].inspect}, 'price > 999'`" end record(:remove_check_constraint, args, &block) end |