New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add script for migrating workshops #26763
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two small questions, but overall yes!
nil => Pd::SharedWorkshopConstants::SUBJECT_SUMMER_WORKSHOP, | ||
"1" => Pd::SharedWorkshopConstants::SUBJECT_FIT, | ||
"2" => Pd::SharedWorkshopConstants::SUBJECT_TEACHER_CON, | ||
"4" => Pd::SharedWorkshopConstants::SUBJECT_CSP_WORKSHOP_1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it intentional to not have "3" in this list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep; I looked at all the type/phase combinations that are actually used in this table, and only bothered to figure out a mapping for those that actually exist.
|
||
# segments => sessions | ||
old_workshop.segments.each do |segment| | ||
session = Pd::Session.create!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other places you create new objects, you checked first whether one already existed with the same data. should we do that here as well? (if this script runs more than once, are we risking creating duplicate sessions?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's necessary right here; the most significant feature of a Pd::Session
is its pd_workshop_id
, since each Session is uniquely owned by a Workshop. In this case, the workshop has just been created, and we are careful to only create one new workshop for each old workshop (by relying on old_workshop.pd_workshop_id = new_workshop.id
)
# save the id of the newly-created workshop so we can keep track of which of | ||
# the old workshops have and have not been converted. | ||
old_workshop.pd_workshop_id = new_workshop.id | ||
old_workshop.save! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hamms Any chance we archived these values? They would come in handy for some additional work I'm doing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they were probably removed by #26805, unless we have database backups from before then.
The one-off script in #26763 moved workshops from the old Workshop model to the new Pd::Workshop model. These workshops didn't have started_at or ended_at dates, causing them to have state STATE_NOT_STARTED, and they were appearing in dashboards for end-users. This one-off script backfills the started_at and ended_at dates based on the sessions attached to the workshops.
The one-off script in #26763 moved workshops from the old Workshop model to the new Pd::Workshop model. These workshops didn't have started_at or ended_at dates, causing them to have state STATE_NOT_STARTED, and they were appearing in dashboards for end-users. This one-off script backfills the started_at and ended_at dates based on the sessions attached to the workshops.
Follow-up to #26737
Adds a script that can be run on production to migrate the data over
Steps: