Method: Sequel::Postgres::DatabaseMethods#create_trigger

Defined in:
lib/sequel/adapters/shared/postgres.rb

#create_trigger(table, name, function, opts = {}) ⇒ Object

Create a trigger in the database. Arguments:

  • table : the table on which this trigger operates

  • name : the name of this trigger

  • function : the function to call for this trigger, which should return type trigger.

  • opts : options hash:

    • :after : Calls the trigger after execution instead of before.

    • :args : An argument or array of arguments to pass to the function.

    • :each_row : Calls the trigger for each row instead of for each statement.

    • :events : Can be :insert, :update, :delete, or an array of any of those. Calls the trigger whenever that type of statement is used. By default, the trigger is called for insert, update, or delete.



218
219
220
# File 'lib/sequel/adapters/shared/postgres.rb', line 218

def create_trigger(table, name, function, opts={})
  self << create_trigger_sql(table, name, function, opts)
end