infra: migration 048 — GRANT tournament tables to westside_streamlit_ro #510
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api#510
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
Standalone — discovered 2026-04-23. Extends migration 044's GRANT allowlist for the forthcoming Streamlit tournament section (
forgejo_admin/westside-streamlit#15). Scope corrected after C3 review (2026-04-24): tournament payments flow throughorders(already granted by 044), so onlytournamentsandtournament_productsneed to be added.registrationsis NOT involved.Repo
forgejo_admin/basketball-apiUser Story
As the westside-streamlit app
I want SELECT permission on
tournamentsandtournament_productsfor thewestside_streamlit_roroleSo that the dashboard can query "for tournament X, which
tournament_productsare listed and whichorderspaid for them" — joining through tables that are now all in the role's allowlistContext
Migration
044_add_westside_streamlit_ro_rolecreated thewestside_streamlit_rorole and GRANTed SELECT on 6 tables:orders, parents, player_teams, players, products, teams. Migration045_add_tournament_tableslater addedtournamentsandtournament_products. Tournament payments are stored in the existingorderstable (already granted) —orders.product_idjoins totournament_products.product_id, which joins totournaments.id. Verified viamodels.pyOrder and TournamentProduct definitions and via PR review notes (review-994/998/1013) that confirm tournament checkout createsorders, not registrations. Theregistrationstable is for tryouts/practices and is NOT needed for tournament visibility. Defense-in-depth principle holds: new tables not auto-exposed; this extends the allowlist deliberately and minimally. Alembic head is047, next slot048.File Targets
Files to create:
alembic/versions/048_grant_tournament_tables_to_ro_role.py— new migration, revision048, down_revision047Files NOT to touch:
src/basketball_api/models.py— this is ACL only044— don't amend; add a new forward migrationAcceptance Criteria
"048", down_revision is exactly"047"(perfeedback_migration_slot_coordination— slot collision = incident)westside_streamlit_ro(verify by reading migration 044 before writing 048)upgrade():op.execute("GRANT SELECT ON tournaments, tournament_products TO westside_streamlit_ro")— two tables only, NOT registrationsdowngrade():op.execute("REVOKE SELECT ON tournaments, tournament_products FROM westside_streamlit_ro")alembic upgrade headruns without erroralembic downgrade 047cleanly revertsTest Expectations
pytest tests/ -xruff check alembic/versions/048_grant_tournament_tables_to_ro_role.pyalembic upgrade headalembic downgrade 047 && alembic upgrade headruff check alembic/versions/048_grant_tournament_tables_to_ro_role.pypytest tests/ -xConstraints
048— if another PR claims048first, rebase and renumber, don't collision.op.execute(...)for the GRANT/REVOKE (match migration 044's SQL style).src/basketball_api/models.py.tournamentsandtournament_products. Do NOT includeregistrations(not needed; tournament payments are inorderswhich is already granted).Checklist
ruff checkcleanRelated
project-westside-streamlit— consumer projectstory-westside-streamlit-tournament— the user story this servesfeedback_migration_slot_coordination— slot-collision rulefeedback_basketball_hands_off— why allowlist is narrow044_add_westside_streamlit_ro_role— defines the role being extended045_add_tournament_tables— source of the tables being GRANTedforgejo_admin/westside-streamlit#15(C3 — Tournament section)infra: migration 048 — GRANT tournament + registrations tables to westside_streamlit_roto infra: migration 048 — GRANT tournament tables to westside_streamlit_roScope Review: APPROVED
Review note:
review-1072-2026-04-22Third review round; scope correction (drop
registrations) verified againstmodels.pyand migration 044/045. File targets, traceability, and dependencies all check out. Ready to move backlog → todo.Verified:
047_add_stripe_checkout_url_to_orders.py).tournaments+tournament_productsdefined insrc/basketball_api/models.py(lines 596, 614).registrationscorrectly excluded — bound to tryouts/practices, not tournament payments. Tournament payments flow throughorders(already in 044's GRANT allowlist).story-westside-streamlit-tournament(id 1594) exists and documents the orders-based join chain.westside-streamlit#15(C3) explicitly blocked by this ticket — consistent.Style heads-up (non-blocking): AC #3 specifies
GRANT SELECT ON tournaments, tournament_products TO ...(comma-separated). Migration 044's actual style is a per-table loop withGRANT SELECT ON TABLE public.{table} TO {role};. Both forms are valid PostgreSQL — flagging so QA doesn't bounce on style during code review.Non-blocking follow-ups for Ava:
[SCOPE]Addtournamentrow to the User Stories table onproject-westside-streamlit(story note exists but isn't linked from the project page).[SCOPE]Consider creating a standalonearch-postgres-rolenote to back thearch:postgres-rolelabel.Neither follow-up blocks ticket advancement.