Rename `group*` to `team*` in the database
Description
To support student groups, we want to rename the existing group work system. Closes #13544 .
This PR only renames the minimal pieces to allow for this: it does not rename input/output parameters (most of the time). It also doesn't fix comments or join aliases. This means that the code will look like:
group_id IN -> SQL -> group_id OUT (or full rows)
Testing
The test suite passes? How exactly do we do this?
Codecov Report
:x: Patch coverage is 65.90909% with 15 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 52.71%. Comparing base (1ded1c3) to head (6b1b8ad).
Additional details and impacted files
@@ Coverage Diff @@
## master #13557 +/- ##
==========================================
- Coverage 52.72% 52.71% -0.02%
==========================================
Files 868 868
Lines 33080 33086 +6
Branches 5023 5023
==========================================
- Hits 17442 17441 -1
- Misses 14320 14325 +5
- Partials 1318 1320 +2
| Flag | Coverage Δ | |
|---|---|---|
| javascript | 50.37% <65.90%> (-0.02%) |
:arrow_down: |
| python | 70.07% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All images
| Image | Platform | Old Size | New Size | Change |
|---|---|---|---|---|
| prairielearn/executor:6b1b8ad3bd0d6a95c775f549623978d20b6ccc2a | linux/amd64 | 1227.21 MB | 1227.23 MB | 0.00% |
| prairielearn/executor:6b1b8ad3bd0d6a95c775f549623978d20b6ccc2a | linux/arm64 | 1198.73 MB | 1198.75 MB | 0.00% |
| prairielearn/prairielearn:6b1b8ad3bd0d6a95c775f549623978d20b6ccc2a | linux/arm64 | 1198.73 MB | 1198.74 MB | 0.00% |
| prairielearn/prairielearn:6b1b8ad3bd0d6a95c775f549623978d20b6ccc2a | linux/amd64 | 1227.21 MB | 1227.23 MB | 0.00% |
[!NOTE]
Reviews paused
Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.
📝 Walkthrough
Walkthrough
This pull request performs a comprehensive renaming of the "groups" domain concept to "teams" throughout the PrairieLearn codebase, including database schema migration, SQL sprocs, TypeScript type definitions, application logic, and test updates. All references to group-related tables, columns, functions, and feature flags are systematically replaced with team equivalents.
Changes
| Cohort / File(s) | Summary |
|---|---|
Database Schema Migration database/migrations/20251210160636_groups__rename_teams.sql, database/tables/assessment_instances.pg, database/tables/assessment_question_role_permissions.pg, database/tables/assessments.pg, database/tables/audit_events.pg, database/tables/audit_logs.pg, database/tables/course_instances.pg, database/tables/last_accesses.pg |
Renames database tables (groups→teams, group_configs→team_configs, group_users→team_users, group_roles→team_roles, group_user_roles→team_user_roles, group_logs→team_logs), columns (group_id→team_id, group_config_id→team_config_id, group_role_id→team_role_id), sequences, indexes, and foreign key constraints. Updates assessment_instances and audit tables to replace group_id with team_id. Removed legacy group_* tables. |
Deleted Legacy Group Tables database/tables/group_configs.pg, database/tables/group_logs.pg, database/tables/group_roles.pg, database/tables/group_user_roles.pg, database/tables/group_users.pg, database/tables/groups.pg |
Complete removal of legacy group-related table schema definitions. |
New Team Tables database/tables/team_configs.pg, database/tables/team_logs.pg |
Introduces new team_configs and team_logs tables with identical structure to their group predecessors, supporting the team-based domain model. |
SPROC and Function Changes apps/prairielearn/src/sprocs/team_info.sql, apps/prairielearn/src/sprocs/teams_uid_list.sql, apps/prairielearn/src/sprocs/index.ts, apps/prairielearn/src/sprocs/authz_assessment_instance.sql, apps/prairielearn/src/sprocs/sync_assessments.sql |
Renames sprocs from group_info/groups_uid_list to team_info/teams_uid_list; updates group_work conditionals to team_work; changes team membership validation from group_users to team_users; updates group_roles references to team_roles. |
Core Type Definitions apps/prairielearn/src/lib/db-types.ts |
Major schema updates: introduces TeamSchema, TeamConfigSchema, TeamUserSchema, etc.; updates AssessmentSchema (group_work→team_work), AssessmentInstanceSchema (group_id→team_id), AuditEventSchema/AuditLogSchema (group_id→team_id); adds backward-compatibility aliases mapping Group\* types to Team\* equivalents. |
Type and Schema Tests apps/prairielearn/src/lib/db-types.test.ts, apps/prairielearn/src/lib/client/safe-db-types.ts, apps/prairielearn/src/lib/client/safe-db-types.test.ts, apps/prairielearn/src/lib/client/page-context.test.ts |
Updates test data and schemas to use team_work/team_id instead of group_work/group_id; expands unusedSchemas to include legacy group schemas. |
Admin Query SQL apps/prairielearn/src/admin_queries/generate_assessment_instances.sql, apps/prairielearn/src/admin_queries/generate_submissions.sql |
Replaces group-related joins/filters with team equivalents; updates group_users→team_users, group_configs→team_configs, group_id→team_id, group_work→team_work. |
Admin Query TypeScript apps/prairielearn/src/admin_queries/generate_assessment_instances.ts |
Switches data source selection from assessment.group_work to assessment.team_work for determining schema type and column inclusion. |
API Endpoint Schemas apps/prairielearn/src/api/v1/endpoints/courseInstanceAssessmentInstances/index.ts, apps/prairielearn/src/api/v1/endpoints/courseInstanceAssessments/index.ts |
Replaces SprocGroupInfoSchema with SprocTeamInfoSchema; updates group_id/group_name/group_uids to derive from team schema. |
API SQL Queries apps/prairielearn/src/api/v1/endpoints/courseInstanceGradebook/index.sql, apps/prairielearn/src/api/v1/endpoints/queries.sql |
Replaces LEFT JOIN group_info with LEFT JOIN team_info; updates join condition from ai.group_id to ai.team_id. |
Group Management SQL apps/prairielearn/src/lib/groups.sql |
Comprehensive rename of all table references (groups→teams, group_configs→team_configs, group_users→team_users, group_roles→team_roles, group_user_roles→team_user_roles, group_logs→team_logs) and corresponding foreign keys/joins. |
Group Management TypeScript apps/prairielearn/src/lib/groups.ts |
Renames RoleAssignmentSchema field group_role_id→team_role_id; updates GroupRoleAssignment type definition; propagates field rename across role assignment and reassignment logic. |
Assessment SQL Operations apps/prairielearn/src/lib/assessment.sql |
Replaces all group_id→team_id references throughout INSERT/UPDATE/DELETE blocks; updates group_configs→team_configs, group_users→team_users, group_logs→team_logs; changes group_work→team_work conditionals. |
Assessment TypeScript apps/prairielearn/src/lib/assessment.ts |
Changes feature flag condition from assessment.group_work to assessment.team_work for group ID retrieval logic. |
Submission and Grading SQL apps/prairielearn/src/lib/submissions-upload.sql, apps/prairielearn/src/lib/grading.sql, apps/prairielearn/src/lib/question-variant.sql, apps/prairielearn/src/lib/question-render.sql, apps/prairielearn/src/lib/question-variant.ts, apps/prairielearn/src/lib/gradebook.sql, apps/prairielearn/src/lib/score-upload.sql, apps/prairielearn/src/lib/regrading.sql |
Updates team_id column usage; replaces group-based joins with team-based joins; updates LEFT JOIN conditions from group_id to team_id. |
Submission TypeScript apps/prairielearn/src/lib/submissions-upload.ts, apps/prairielearn/src/lib/grading.ts |
Changes assessment.group_work checks to assessment.team_work; updates payload shapes to use team_id instead of group_id; updates SQL parameter passing. |
Middleware SQL apps/prairielearn/src/middlewares/clientFingerprint.sql, apps/prairielearn/src/middlewares/selectAndAuthzAssessmentInstance.sql, apps/prairielearn/src/middlewares/selectAndAuthzInstanceQuestion.sql, apps/prairielearn/src/middlewares/studentAssessmentRedirect.sql |
Replaces LEFT JOIN groups with LEFT JOIN teams; updates join condition from ai.group_id to ai.team_id; changes groups_uid_list to teams_uid_list; updates group_work to team_work in authz calls. |
Middleware TypeScript apps/prairielearn/src/middlewares/selectAndAuthzInstanceQuestion.ts |
Replaces group_work gating with team_work; updates group_id→team_id in team/group configuration and permission lookups. |
Question Rendering apps/prairielearn/src/lib/question-render.ts |
Replaces assessment_instance.group_id with assessment_instance.team_id in group info fetching and permission checks across renderPanelsForSubmission. |
Audit Event Models apps/prairielearn/src/models/audit-event.sql, apps/prairielearn/src/models/audit-event.test.ts, apps/prairielearn/src/models/audit-event.ts, apps/prairielearn/src/models/audit-event.types.ts |
Renames group_id→team_id in audit_events; updates group_meta→team_meta; changes requiredTableFields from groups→teams with team_id field mapping. |
Audit Log Models apps/prairielearn/src/models/audit-log.sql, apps/prairielearn/src/models/audit-log.ts |
Updates audit_logs INSERT column from group_id to team_id; changes mapping source from auditLog.group_id to auditLog.team_id. |
Variant Ownership apps/prairielearn/src/models/variant.sql |
Changes ownership check from group-based (ai.group_id, group_users) to team-based (ai.team_id, team_users). |
Group Update Logic apps/prairielearn/src/lib/group-update.sql |
Replaces table references (group_users→team_users, groups→teams, group_configs→team_configs) and corresponding join conditions/filters (group_id→team_id, group_config_id→team_config_id). |
Instructor Assessment Downloads apps/prairielearn/src/pages/instructorAssessmentDownloads/instructorAssessmentDownloads.sql, apps/prairielearn/src/pages/instructorAssessmentDownloads/instructorAssessmentDownloads.ts |
Updates group_id→team_id in selection keys; replaces group_config/groups/group_users with team_config/teams/team_users; changes groups_uid_list→teams_uid_list; updates group_work conditionals to team_work. |
Instructor Assessment Groups apps/prairielearn/src/pages/instructorAssessmentGroups/instructorAssessmentGroups.sql |
Replaces group_configs→team_configs, groups→teams, group_users→team_users; updates identifier mappings from group_id to team_id. |
Instructor Assessment Instance Pages apps/prairielearn/src/pages/instructorAssessmentInstance/instructorAssessmentInstance.html.tsx, apps/prairielearn/src/pages/instructorAssessmentInstances/instructorAssessmentInstances.html.tsx, apps/prairielearn/src/pages/instructorAssessmentInstances/instructorAssessmentInstances.sql, apps/prairielearn/src/pages/instructorAssessmentInstances/instructorAssessmentInstances.types.ts |
Updates group_work flag checks to team_work; replaces group_info joins with team_info; changes AssessmentInstanceRowSchema to source group_id from team_id. |
Instructor Manual Grading apps/prairielearn/src/pages/instructorAssessmentManualGrading/assessmentQuestion/assessmentQuestion.sql, apps/prairielearn/src/pages/instructorAssessmentManualGrading/assessmentQuestion/components/AssessmentQuestionTable.tsx, apps/prairielearn/src/pages/instructorAssessmentManualGrading/assessmentQuestion/utils/columnDefinitions.tsx |
Replaces groups→teams and groups_uid_list→teams_uid_list in LEFT JOINs; updates group_work conditionals for CSV column selection and header labels. |
Instructor Statistics and Gradebook apps/prairielearn/src/pages/instructorAssessmentStatistics/instructorAssessmentStatistics.sql, apps/prairielearn/src/pages/instructorGradebook/instructorGradebook.sql |
Updates LEFT JOIN from group_users to team_users; changes join condition from ai.group_id to ai.team_id; updates nested JSON construction for team_users. |
Instructor Assessment List Pages apps/prairielearn/src/pages/instructorAssessments/instructorAssessments.html.tsx, apps/prairielearn/src/pages/assessmentsSwitcher/assessmentsSwitcher.html.ts |
Replaces group_work conditionals with team_work for icon rendering. |
Student Assessment Pages apps/prairielearn/src/pages/studentAssessment/studentAssessment.html.ts, apps/prairielearn/src/pages/studentAssessment/studentAssessment.ts, apps/prairielearn/src/pages/studentAssessmentInstance/studentAssessmentInstance.html.ts, apps/prairielearn/src/pages/studentAssessmentInstance/studentAssessmentInstance.ts, apps/prairielearn/src/pages/studentAssessments/studentAssessments.html.ts, apps/prairielearn/src/pages/studentAssessments/studentAssessments.sql, apps/prairielearn/src/pages/studentInstanceQuestion/studentInstanceQuestion.ts |
Updates group_work conditionals to team_work; replaces group_id with team_id; changes StudentAssessmentsRowSchema group_work property to team_work. |
Student Gradebook apps/prairielearn/src/pages/studentGradebook/studentGradebook.ts |
Updates mapRow to source assessment_group_work from assessment.team_work instead of group_work. |
LTI Integration apps/prairielearn/src/ee/lib/lti13.sql, apps/prairielearn/src/ee/pages/instructorInstanceAdminLti13/instructorInstanceAdminLti13.html.ts |
Replaces LEFT JOINs to groups with teams; updates join conditions from ai.group_id to ai.team_id; changes row.group_work to row.team_work for UI rendering. |
Sync and Migration SQL apps/prairielearn/src/batched-migrations/20240108185602_group_users__group_config_id__backfill.sql, apps/prairielearn/src/sync/fromDisk/assessments.ts |
Updates backfill WHERE clause from gu.group_id to gu.team_id; changes sync payload to expose team_work instead of group_work. |
Group Work Container Component apps/prairielearn/src/components/GroupWorkInfoContainer.tsx |
Updates role checkbox checked state logic from a.group_role_id to a.team_role_id. |
Test Fixtures and Utilities apps/prairielearn/src/tests/groupExam.test.sql, apps/prairielearn/src/tests/groupExam.test.ts, apps/prairielearn/src/tests/groupExamRolePermissions.test.sql, apps/prairielearn/src/tests/groupExamRolePermissions.test.ts, apps/prairielearn/src/tests/groupGenerateAndDelete.test.sql, apps/prairielearn/src/tests/groupGenerateAndDelete.test.ts, apps/prairielearn/src/tests/groupRole.test.sql, apps/prairielearn/src/tests/groupRole.test.ts, apps/prairielearn/src/tests/groupRolePermissions.test.sql, apps/prairielearn/src/tests/groupRolePermissions.test.ts, apps/prairielearn/src/tests/groupScoreAndSync.test.sql, apps/prairielearn/src/tests/groupScoreAndSync.test.ts, apps/prairielearn/src/tests/groupStudent.test.sql, apps/prairielearn/src/tests/groupStudent.test.ts, apps/prairielearn/src/tests/instructorAssessmentGroups.test.sql, apps/prairielearn/src/tests/sync/assessmentsSync.test.sql, apps/prairielearn/src/tests/sync/assessmentsSync.test.ts |
Updates test SQL queries and assertions to use team_id, team_roles, team_config_id instead of group equivalents; changes assertion targets from group_id to team_id; updates role schema selections from group_role_id to team_role_id. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Critical areas requiring extra attention:
-
Database migration correctness (
database/migrations/20251210160636_groups__rename_teams.sql): Verify all table renames, sequence renames, constraint renames, and referential integrity are properly handled. Ensure the migration usesIF EXISTSguards and handles potential failure scenarios gracefully. -
Public type/schema signature changes (
apps/prairielearn/src/lib/db-types.ts): Review the extensive schema changes, backward-compatibility alias mappings, and ensure all public API consumers can be satisfied with the aliases or have been updated. Verify no circular reference issues with aliases. -
SPROC function signatures (
apps/prairielearn/src/sprocs/team_info.sql,teams_uid_list.sql): Confirm function name changes are properly reflected in all call sites throughout the codebase. -
Assessment instance and audit log schema changes: Verify constraint updates (e.g.,
user_team_xorcheck constraint, unique indexes onteam_id) correctly replace group-based constraints with no logic regressions. -
Feature flag propagation: Spot-check several application code paths to ensure
team_workflag is used consistently wheregroup_workwas previously referenced, particularly in conditional branching for UI rendering and authorization logic. -
Batched migration and backfill logic (
apps/prairielearn/src/batched-migrations/20240108185602_group_users__group_config_id__backfill.sql): Ensure the backfill condition change fromgroup_idtoteam_idmaintains its original intent and filtering semantics.
Pre-merge checks and finishing touches
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Linked Issues check | ✅ Passed | The changeset fully implements the objective from issue #13544: a comprehensive database migration renaming all group-related tables, columns, and references to team equivalents throughout the codebase. |
| Out of Scope Changes check | ✅ Passed | All changes are directly aligned with the database rename migration objective. No out-of-scope modifications detected beyond the systematic renaming of group to team constructs. |
| Description check | ✅ Passed | The PR description is directly related to the changeset, explaining the intent to rename the group work system to teams to support student groups, with a reference to the closing issue #13544. |
| Title check | ✅ Passed | The title clearly and specifically describes the main change: renaming group-related database entities to team-related equivalents across the entire codebase. |
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
@coderabbit pause @coderabbitai pause
@reteps: I'll pause automatic reviews for this pull request. You can resume them anytime by asking me to resume.
✅ Actions performed
Reviews paused.