Skip to content

Copying Data from Previous Years

Nate Eagle edited this page Mar 6, 2022 · 1 revision

In 2022, we needed to copy data from previous years for the first time, as the physical Congress in 2020 had been canceled due to COVID 19. In case a similar need comes up in the future, here's what I did:

  1. Back up the db! This can be done manually through the Heroku Dashboard. It's also scheduled to make automatic backups, but you want to be sure you can roll things back if you make a mistake.

  2. Connect to the rails console using the Heroku CLI: heroku run rails console --app gocongress

  3. To make a copy of Cost Categories, for instance, run something like this:

# Find your event_id
Event.where(:year => 2022).first.id

# Find the Plan Categories you want to copy, then update their years and event ids
PlanCategory.where(:year => 2020).each { |pc|
  # Create a duplicate record
  npc = pc.dup
  npc.year = 2022
  npc.event_id = 15
  npc.save!
}

You can use a similar approach for Tournaments and Content Categories, though it's even easier since they're not linked to an Event.