Module: PgCron::CommandRecorder

Defined in:
lib/pg_cron/command_recorder.rb

Overview

Makes the statements reversible, following F(x)'s CommandRecorder.

The revert_to_version handling is the point. Inverting create_cron_job is a drop, but inverting DROP or UPDATE is only meaningful if the migration said what to go back to — otherwise a rollback either fails or, worse, leaves the job missing. That is why the previous schedule_pg_cron_job / unschedule_pg_cron_job pair could not invert an update at all.

Instance Method Summary collapse

Instance Method Details

#create_cron_job(*args, &block) ⇒ Object



12
13
14
# File 'lib/pg_cron/command_recorder.rb', line 12

def create_cron_job(*args, &block)
  record(:create_cron_job, args, &block)
end

#drop_cron_job(*args, &block) ⇒ Object



16
17
18
# File 'lib/pg_cron/command_recorder.rb', line 16

def drop_cron_job(*args, &block)
  record(:drop_cron_job, args, &block)
end

#invert_create_cron_job(args) ⇒ Object



24
25
26
# File 'lib/pg_cron/command_recorder.rb', line 24

def invert_create_cron_job(args)
  [:drop_cron_job, args.first]
end

#invert_drop_cron_job(args) ⇒ Object



28
29
30
# File 'lib/pg_cron/command_recorder.rb', line 28

def invert_drop_cron_job(args)
  perform_cron_job_inversion(:create_cron_job, args)
end

#invert_update_cron_job(args) ⇒ Object



32
33
34
# File 'lib/pg_cron/command_recorder.rb', line 32

def invert_update_cron_job(args)
  perform_cron_job_inversion(:update_cron_job, args)
end

#update_cron_job(*args, &block) ⇒ Object



20
21
22
# File 'lib/pg_cron/command_recorder.rb', line 20

def update_cron_job(*args, &block)
  record(:update_cron_job, args, &block)
end