Skip to content
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

Merged
merged 1 commit into from Jan 28, 2019

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Jan 26, 2019

Follow-up to #26737

Adds a script that can be run on production to migrate the data over

Steps:

  • Add column to track conversion
  • Convert data <- this PR
  • Validate conversion
  • Delete old data
  • Delete old tables

Copy link

@clareconstantine clareconstantine left a 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,

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?

Copy link
Contributor Author

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!(

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?)

Copy link
Contributor Author

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)

@Hamms Hamms merged commit 693053c into staging Jan 28, 2019
@Hamms Hamms deleted the migrate-old-workshops-to-new-pd-workshops branch January 28, 2019 20:06
@Hamms Hamms mentioned this pull request Jan 30, 2019
5 tasks
# 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!
Copy link
Member

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.

Copy link
Contributor Author

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.

breville added a commit that referenced this pull request Sep 30, 2019
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.
clareconstantine pushed a commit that referenced this pull request Oct 3, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants