be more specific about fixing group_category_ids
it looks liek all of the "bad" data is 0, presumably from an incorrect html form also do the migration transactionally, to avoid the race condition (the tables are small enough that a two-step FK addition isn't necessary) test plan: * run the migration; ensure it takes less than 1s, and doesn't fail Change-Id: Ibe8ff590c41f3d07d51814564fefa8b986a78535 Reviewed-on: https://gerrit.instructure.com/12116 Reviewed-by: Brian Palmer <brianp@instructure.com> Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
parent
5353a2bc8e
commit
b421dae03a
|
@ -1,14 +1,9 @@
|
|||
class ConstrainAssignmentGroupCategoryIds < ActiveRecord::Migration
|
||||
tag :postdeploy
|
||||
self.transactional = false
|
||||
|
||||
def self.up
|
||||
Assignment.update_all({:group_category_id => nil}, <<-SQL)
|
||||
NOT EXISTS (
|
||||
SELECT group_categories.id FROM group_categories
|
||||
WHERE group_categories.id=assignments.group_category_id)
|
||||
SQL
|
||||
add_foreign_key :assignments, :group_categories, :delay_validation => true
|
||||
Assignment.update_all({:group_category_id => nil}, :group_category_id => 0)
|
||||
add_foreign_key :assignments, :group_categories
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
Loading…
Reference in New Issue