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 data migration to associate modern language child subjects #673

Merged
merged 1 commit into from
May 23, 2024

Conversation

JamieCleare2525
Copy link
Contributor

Context

  • Changes to update Subjects, related to the "Modern Languages", to associated them with the parent subject "Modern Languages"

Changes proposed in this pull request

  • PublishTeacherTraining::Subject::Import considers ModernLanguagesSubject its own subject area.
  • PublishTeacherTraining::Subject::Import assigns subjects within the ModernLanguagesSubject subject area with the parent subject "Modern Languages"
  • Added Data Migration to backfill database with child subject associations for "Modern Languages" associated subjects.

Guidance to review

  • run bundle exec rake data:migrate

  • This will backfill and language subjects with the parent subject "Modern Languages"

  • in the rails console run: Subject.find_by(name: "Modern Languages").child_subjects

  • This should return [French, German...]

  • run bundle exec rake db:drop db:create db:setup

  • in the rails console run: Subject.find_by(name: "Modern Languages").child_subjects

  • This should return [French, German...]

in the rails console run:

# Remove all parent subjects
Subject.update_all(parent_subject_id: nil)

# Run the subject importer
PublishTeacherTraining::Subject::Import.call

Subject.find_by(name: "Modern Languages").child_subjects
# This should return [French, German...]

Link to Trello card

https://trello.com/c/BQwACPHr/372-update-subjects-to-use-parent-child-associations

@JamieCleare2525 JamieCleare2525 self-assigned this May 23, 2024
@JamieCleare2525 JamieCleare2525 requested review from a team as code owners May 23, 2024 10:01
@JamieCleare2525 JamieCleare2525 force-pushed the jc/data_migration_to_update_ml_child_subjects branch from c4b4592 to 1afe436 Compare May 23, 2024 12:32
Copy link
Contributor

@Nitemaeric Nitemaeric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we squash/remove the commits that negate each other? I don't see a reason to add them into the git history.

Copy link
Contributor

@ollietreend ollietreend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍🏻

@JamieCleare2525 JamieCleare2525 force-pushed the jc/data_migration_to_update_ml_child_subjects branch from 1afe436 to 0a47ef5 Compare May 23, 2024 14:26
@JamieCleare2525 JamieCleare2525 merged commit 412857e into main May 23, 2024
8 checks passed
@JamieCleare2525 JamieCleare2525 deleted the jc/data_migration_to_update_ml_child_subjects branch May 23, 2024 14:32
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.

3 participants