add lock_version to context module progressions
preparation for rework of the context module progression evaluation test plan: * automated tests pass refs CNVS-11818 Change-Id: I10618e576c7b44aebce0a9803876b8f543d9b61b Reviewed-on: https://gerrit.instructure.com/32904 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com> QA-Review: Matt Fairbourn <mfairbourn@instructure.com> Product-Review: Mark Severson <markse@instructure.com>
This commit is contained in:
parent
b19a7a7c6a
commit
abf7daa5dc
|
@ -274,6 +274,12 @@ class ContextModuleProgression < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# This prevents active record using optimistic locking, until the data migration is complete
|
||||
# (once the data migration is complete, this method can simply be removed)
|
||||
def locking_enabled?
|
||||
false
|
||||
end
|
||||
|
||||
def trigger_completion_events
|
||||
if workflow_state_changed? && completed?
|
||||
context_module.completion_event_callbacks.each do |event|
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class AddLockVersionOnContextModuleProgressions < ActiveRecord::Migration
|
||||
tag :predeploy
|
||||
|
||||
def self.up
|
||||
add_column :context_module_progressions, :lock_version, :integer
|
||||
change_column_default :context_module_progressions, :lock_version, 0
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :context_module_progressions, :lock_version
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class PopulateLockVersionOnContextModuleProgressions < ActiveRecord::Migration
|
||||
tag :postdeploy
|
||||
|
||||
def up
|
||||
DataFixup::PopulateLockVersionOnContextModuleProgressions.send_later_if_production_enqueue_args(:run, :priority => Delayed::LOW_PRIORITY, :max_attempts => 1)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
module DataFixup::PopulateLockVersionOnContextModuleProgressions
|
||||
def self.run
|
||||
ContextModuleProgression.where(lock_version: nil).find_ids_in_ranges do |min_id, max_id|
|
||||
ContextModuleProgression.where(id: min_id..max_id, lock_version: nil).update_all(lock_version: 0)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue