Skip to content

Commit

Permalink
Merge pull request #1260 from sparc-request/kg-survey_form_builder_mi…
Browse files Browse the repository at this point in the history
…gration_bug

KG - Form Builder Migration Bug
  • Loading branch information
amcates committed Feb 28, 2018
2 parents 442dab6 + fbb2781 commit 9adf1e9
Showing 1 changed file with 9 additions and 9 deletions.
Expand Up @@ -29,15 +29,15 @@ def up
rename_column :associated_surveys, :surveyable_id, :associable_id
rename_column :associated_surveys, :surveyable_type, :associable_type

Survey.reset_column_information
Response.reset_column_information
AssociatedSurvey.reset_column_information

# Replace sub_service_request_id with respondable_id and respondable_type='SubServiceRequest'
responses.each do |r|
responses.select{ |r| r.sub_service_request_id != nil }.each do |r|
reloaded_response = Response.find(r.id)
reloaded_response.update_attributes(respondable_id: r.sub_service_request_id, respondable_type: 'SubServiceRequest')
end

Survey.reset_column_information
Response.reset_column_information
AssociatedSurvey.reset_column_information
end

def down
Expand Down Expand Up @@ -68,14 +68,14 @@ def down
rename_column :associated_surveys, :associable_id, :surveyable_id
rename_column :associated_surveys, :associable_type, :surveyable_type

Survey.reset_column_information
Response.reset_column_information
AssociatedSurvey.reset_column_information

# Replace respondable_id with sub_service_request_id
responses.each do |r|
reloaded_response = Response.find(r.id)
reloaded_response.update_attributes(sub_service_request_id: r.respondable_id)
end

Survey.reset_column_information
Response.reset_column_information
AssociatedSurvey.reset_column_information
end
end

0 comments on commit 9adf1e9

Please sign in to comment.