Skip to content

Rename department 21M from Music and Theater Arts to Music - #3669

Open
zawan-ila wants to merge 5 commits into
mainfrom
anawaz/rename-mta-to-music
Open

Rename department 21M from Music and Theater Arts to Music#3669
zawan-ila wants to merge 5 commits into
mainfrom
anawaz/rename-mta-to-music

Conversation

@zawan-ila

@zawan-ila zawan-ila commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Part of https://github.com/mitodl/hq/issues/5616

Description (What does it do?)

Renames department 21M from "Music and Theater Arts" to Music in mit-learn:

  • Updates 21MMusic in the DEPARTMENTS constant and the departments fixture.
  • Adds a data migration 0025_rename_department_21M_to_music that renames the existing department row and updates its channel title/slug.
  • Regenerates the OpenAPI specs (v0.yaml, v1.yaml) and the generated TypeScript client for the renamed department display name.

How can this be tested?

  • docker compose run --rm web python manage.py migrate — the 21M department name is Music and its channel title/slug are updated.
  • ./scripts/generate_openapi.sh produces no diff against this branch.

Additional Context

  • The migration also updates the department channel slug (music-and-theater-artsmusic), which changes the department's channel URL.
  • This branch and the companion "add 21T" branch each add a migration numbered 0025_*; whichever merges second will need renumbering.

zawan-ila and others added 2 commits July 24, 2026 00:25
Update the DEPARTMENTS constant and the departments fixture, and add a
data migration that renames the existing 21M department (and its channel
title/slug) from "Music and Theater Arts" to "Music".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AWziwfKikfpbH3DpfZUABM
Rename the 21M department display name to Music in the OpenAPI specs and
the generated TypeScript client, regenerated against the current main.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AWziwfKikfpbH3DpfZUABM
@zawan-ila
zawan-ila force-pushed the anawaz/rename-mta-to-music branch from 6db86e0 to ae0e7a6 Compare July 23, 2026 20:15
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

OpenAPI Changes

8 changes: 0 error, 1 warning, 7 info

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@zawan-ila
zawan-ila marked this pull request as ready for review July 24, 2026 19:23
Copilot AI review requested due to automatic review settings July 24, 2026 19:23
@zawan-ila zawan-ila added the Needs Review An open Pull Request that is ready for review label Jul 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Renames department 21M’s display name from “Music and Theater Arts” to “Music” across backend constants/fixtures and generated OpenAPI + TypeScript client artifacts, and includes a data migration to update existing DB rows (including the associated department channel title/slug).

Changes:

  • Update DEPARTMENTS constant and departments.json fixture to use 21M → Music.
  • Add a data migration to rename the existing LearningResourceDepartment(21M) and update its department channel title/slug.
  • Regenerate OpenAPI specs (v0.yaml, v1.yaml) and generated TS API clients to reflect the new display name.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
openapi/specs/v1.yaml Updates 21M enum documentation to “Music”.
openapi/specs/v0.yaml Updates 21M enum documentation to “Music”.
learning_resources/constants.py Updates DEPARTMENTS["21M"] display name.
frontends/api/src/generated/v1/api.ts Regenerated client types/docs reflecting “Music”.
frontends/api/src/generated/v0/api.ts Regenerated client types/docs reflecting “Music”.
data_fixtures/migrations/0025_rename_department_21M_to_music.py Data migration to rename department + update channel title/slug.
data_fixtures/fixtures/departments.json Fixture value updated for 21M name.

Comment on lines +22 to +26
channel = Channel.objects.filter(department_detail__department=department).first()
if channel:
channel.title = name
channel.name = slugify(name)
channel.save()

Copy link
Copy Markdown
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 we associated multiple channels with the same Department so this is a non-issue.

Comment thread openapi/specs/v1.yaml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great overall! Noticed a few things:

  1. Search facet still says "Music and Theater Arts." The department filter label comes from @mitodl/course-search-utils, which has its own hardcoded department map. Rename department 21M to Music course-search-utils#213 fixes it — this PR needs to pin @mitodl/course-search-utils to whatever version that gets released in.

  2. Old department name is cached in Course.course_numbers. etl/utils.py:1023 writes the department name into that JSON field, and it's served on the v1 API — so 21M courses will still report "Music and Theater Arts" there. The next ETL run overwrites it for courses still in the upstream feed, but archived ones keep the old name forever. Either update that JSON in the migration too, or say in the PR description that we're accepting the stale value on archived courses.

  3. /c/department/music-and-theater-arts will 404. next.config.js already has legacy redirects; this is a few lines in the same array.

Also, I think the update_index command will need to be run after migrations to get the new label in opensearch. Also maybe generate_embeddings --courses?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. I don't really see a clear way to do this, and hence would appreciate some guidance. This PR needs to bump course-search-utils with the changes from Rename department 21M to Music course-search-utils#213 but Rename department 21M to Music course-search-utils#213 needs to bump its version of mit-learn-api-axios too, which won't be available until after this PR is on the release branch? So there is kind of a circular dependency here.
  2. I am thinking it is easiest to just trigger a run of update_course_number_departments post migration? That should update the course number json field as appropriate.
  3. Thanks for this. I have added the redirect.
  4. I intend on running recreate_index --all post migration. Please let me know if you think that may be a bit too much for us.
  5. I am not really familiar with generate_embeddings at all, but I'll make sure we run that post migration too. ./manage.py generate_embeddings --courses Doesn't look like it can cause any harm. On this note, it appears that vector search is gated behind a flag and not currently active? Are there any other uses of embeddings/qdrant stuff?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

1 - @ChristopherChudzicki might have some ideas on the best way to handle this. Maybe it's okay (and even unavoidable) to have a slight mismatch temporarily until everything is merged & released across the repos.

2 - Sounds good, I forgot that command exists

4 - That might be overkill, update_index is generally much faster. Probably worth trying it locally to verify if update_index --courses makes all necessary changes without the need for recreate_index

5 - I think vector search is used by default on the topics pages on production. For example https://learn.mit.edu/c/topic/ai makes a call to https://api.learn.mit.edu/api/v0/vector_learning_resources_search/

@@ -0,0 +1,47 @@
# Data migration: rename department 21M from "Music and Theater Arts" to "Music"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: This PR's migration is numbered 0025, which conflicts with a migration in a companion PR. If the other PR merges first, this will cause a deployment-blocking migration conflict.
Severity: HIGH

Suggested Fix

Before merging, check if the companion 'add 21T' pull request has been merged. If it has, renumber this migration to the next available number (e.g., 0026) and update its dependencies to point to the other 0025 migration. This will ensure a linear, conflict-free migration history.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: data_fixtures/migrations/0025_rename_department_21M_to_music.py#L1

Potential issue: This pull request introduces a Django migration file named
`0025_rename_department_21M_to_music.py`. A separate, companion pull request also
contains a migration with the same number, `0025`. If the companion pull request is
merged into the main branch first, merging this pull request afterward will introduce a
duplicate migration number. This will cause Django's migration system to fail, blocking
all subsequent deployments until the conflict is manually resolved.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup. This is a concern. I'll update the numbers before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants