19 lines
847 B
Ruby
19 lines
847 B
Ruby
# This migration was auto-generated via `rake db:generate_trigger_migration'.
|
|
# While you can edit this file, any changes you make to the definitions here
|
|
# will be undone by the next auto-generated trigger migration.
|
|
|
|
class CreateTriggerQuizSubmissionsUpdate < ActiveRecord::Migration
|
|
def self.up
|
|
create_trigger("quiz_submissions_after_update_row_when_new_submission_id_is__tr", :generated => true, :compatibility => 1).
|
|
on("quiz_submissions").
|
|
after(:update).
|
|
where("NEW.submission_id IS NOT NULL AND OLD.workflow_state <> NEW.workflow_state AND NEW.workflow_state = 'complete'") do
|
|
"UPDATE submissions SET workflow_state = 'graded' WHERE id = NEW.submission_id;"
|
|
end
|
|
end
|
|
|
|
def self.down
|
|
drop_trigger("quiz_submissions_after_update_row_when_new_submission_id_is__tr", "quiz_submissions")
|
|
end
|
|
end
|