Repository navigation
One User per person across all offerings, like seating - #16
Open
pancakereport wants to merge 2 commits into
Open
pancakereport wants to merge 2 commits into
pancakereport wants to merge 2 commits into
Conversation
Replace the Account table and the per-offering user rows with a single `users` table: one row per person, with their roles in each offering as sets of offering keys (seating stores Canvas IDs; keys also cover offerings not linked to Canvas). Inside an offering, is_staff and is_admin answer for that offering, and login syncs the role from Canvas as before. Since a person's sections and attendance now span offerings, every operation that reads or changes them is limited to the current offering: refresh, join/switch, leave all, remove students, reset, exports, history. Add Flask-Migrate. 0001 is the schema as of #14 (a no-op on existing databases); 0002 merges per-offering rows by email, re-points enrollments, attendance and section staff, and drops account, the old user table and the unused course, slot, survey and user_section_junction tables. Deploys with RUN_MIGRATIONS=true run `flask db upgrade` on start, under a Postgres advisory lock; PR previews never migrate the shared staging database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🚀 Staging Preview Deployed! URL: https://preview-sections-pr-16-137456085712.us-west1.run.app |
Reset now deletes the offering's sections, their sessions and attendance, and every student and staff assignment to them, but leaves everyone in the offering with their roles. Update the confirmation text to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes
Accountand makesUserone person across all offerings, like seating'sUser.accountrow (if they logged in) + oneuserrow per offeringusersrowis_staff/is_adminon that offering'suserrowstaff_offerings,admin_offerings,student_offeringssets on the usercurrent_userinside an offeringuserrowis_staff/is_adminanswer for the current offeringThe role sets hold offering keys (the
coursecolumn value), not Canvas IDs as in seating, because offerings moved from the monorepo aren't all linked to Canvas. Login still records the user's Canvas courses, and each offering's role is synced from them on the first request inside that offering, as before.Limited to the current offering: a person's sections and attendance now span offerings, so everything that reads or changes them is limited to the offering being viewed. That covers refresh, join/switch section, leave all, remove students (all or tutoring), reset, attendance export, the drop list and attendance history. Without this, switching labs in one course would remove a lab in another, and "leave all" would clear every course. Tests cover each case.
Reset Sections Tool no longer deletes people. It deletes the offering's sections, their sessions and attendance, and every student and staff assignment to them; everyone stays in the offering with their roles. The confirmation text says so.
Migrations
Adds Flask-Migrate.
0001_baseline: the schema as of Serve every bCourses course from one deployment, with seating's routes #14. A no-op on databases that already have it, which includes staging.0002_single_user:usersand merges the per-offering rows by email; the newest row's name wins, or the Canvas name for anyone who has logged inaccount, the olduser, and the unusedcourse,slot,survey,user_section_junctionandsession.slot_idIt's one transaction on Postgres, and can't be downgraded.
The container runs
flask db upgradeon start only withRUN_MIGRATIONS=true(staging and production; never PR previews, which share the staging database). A Postgres advisory lock makes concurrent instances wait instead of racing.Rehearsed on Postgres 18 using staging's exact schema (from
pg_dump --schema-only, no data) with generated data at staging's scale: 8,529 rows → 6,954 people, 1,400 in several courses. Every person's roles and name, and every enrollment (10,955), attendance record (19,543) and section staff link, matched independently computed expectations. It took about 2 seconds. The rehearsal found and fixed two problems before they reached staging:session.slot_id(a foreign key toslot) would have blocked droppingslot.user_sectioncould briefly collide with its primary key, because new person ids overlap old row ids. Re-pointing now goes through negative ids.flask db checkagainst the result showsusersmatches the models. Other differences (pgloader index names,ON DELETE RESTRICT, a few missing indexes,flask_sessions) predate this PR and are left for a separate cleanup.Rollout
gcloud sql backups create --instance staging-cdss-web-apps-2 --project staging-cdss-web-apps.RUN_MIGRATIONS=trueonsections-staging(the current image ignores it).This PR's preview won't work until staging is migrated, because the preview expects the
userstable. Use the Postgres rehearsal above, or check the preview after merging.Test plan
account-cookies ignored, and SQLite migration tests (merge plus fresh database)flask db upgradeon an empty database🤖 Generated with Claude Code