Skip to content

Instantly share code, notes, and snippets.

@umar-siddiqui
Created May 2, 2017 13:39
Show Gist options
  • Save umar-siddiqui/d670454fa3b1d9756a9354162acfcc20 to your computer and use it in GitHub Desktop.
Save umar-siddiqui/d670454fa3b1d9756a9354162acfcc20 to your computer and use it in GitHub Desktop.
def analytics_migration(old_project_id, new_project_id)
Analytic.where(project_ids: old_project_id).each do |analytic|
next unless analytic.project_ids.present?
analytic.project_ids = analytic.project_ids.map{ |_id| _id == old_project_id ? new_project_id : _id }
analytic.save!
end
end
def project_view_details_progress_outcomes_outputs_impacts(old_project_id, new_project_id)
class Output;belongs_to :project;end
Output.where(project_id: old_project_id).update_all(project_record_id: new_project_id)
class Impact;belongs_to :project;end
Impact.where(project_id: old_project_id).update_all(project_record_id: new_project_id)
class Outcome;belongs_to :project;end
Outcome.where(project_id: old_project_id).update_all(project_record_id: new_project_id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment