feat: create 16U Local Queens team (#422) #427
No reviewers
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!427
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "422-create-16u-local-queens-team"
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?
Summary
Adds alembic migration 040 that inserts a new
16U Local Queensteam row, cloningLOCAL_CONFIG_16Ufrom migration 034. Unblocks Queens players who want a local-only tier (first: Jacelyn Bronson, whose move is handled separately in basketball-api#425).Changes
alembic/versions/040_create_16u_local_queens_team.py(new) — inserts one teams row:name='16U Local Queens',division='girls',age_group='U16',coach_id=NULL,contract_config= deep-copy of LOCAL_CONFIG_16U (Mon+Fri BWill practices, empty tournaments, monthly_fee_default=200, variant=local).tenant_idis looked up dynamically by slugwestside-kings-queens.revision = "040",down_revision = "039"(current head verified clean).upgrade()is idempotent: checks for an existing row with matching name+tenant_id and skips if present.downgrade()deletes only the 16U Local Queens row (matched by name+tenant_id). No other rows touched.contract_configdict is copied inline from migration 034 per ticket constraint — no cross-migration imports. Keeps migration history hermetic.Test Plan
ruff check+ruff formatcleanrevision=040,down_revision=039alembic upgrade headon local dev — verify row viaSELECT id, name, contract_config FROM teams WHERE name = '16U Local Queens'alembic upgrade head— verify no-op (idempotency path)alembic downgrade -1— verify the 16U Local Queens row is the only row removedReview Checklist
revision/down_revisionchain is clean (040->039)LOCAL_CONFIG_16Udict matches migration 034 exactly (shape + content)tenant_idis looked up dynamically, not hardcodedupgrade()is idempotent (existence check by name + tenant_id)downgrade()deletes only the new row, scoped by name + tenant_iddivision,agegroup) and values ('girls','U16')ruff checkandruff formatpassRelated Notes
board-westside-basketball(reviewed, APPROVED via review-927-2026-04-10-pass4)alembic/versions/034_seed_team_contract_configs.py::LOCAL_CONFIG_16UPR #427 Review
DOMAIN REVIEW
Stack: Python / Alembic / Postgres (FastAPI codebase). Single-file data migration adding one row to
teams.Migration correctness
revision="040",down_revision="039"— linear chain (dev pre-verified039is head on origin/main @9598c4d).upgrade()is idempotent viaSELECT id FROM teams WHERE name=:name AND tenant_id=:tenant_idexistence check; early-returns on hit. Safe to re-run.downgrade()is narrowly scoped (DELETE ... WHERE name=:name AND tenant_id=:tenant_id). Only the new row is removed. No cascade/FK concerns sincecoach_id=NULLand no dependent rows are created.sa.text(...)bound params (:tenant_id,:name,:slug,:division,:age_group,:contract_config). No interpolation, no injection surface.CAST(:division AS division)andCAST(:age_group AS agegroup)— lowercase type names match SQLAlchemy's default Postgres enum naming;'girls'and'U16'are the declared enum values (dev verifiedDivision.girlsandAgeGroup.u16on models.py @ origin/main).json.dumps(...)+CAST(:contract_config AS jsonb)— standard and correct.westside-kings-queenswith an explicitRuntimeErrorif missing — loud failure, portable across environments.Hermeticity
LOCAL_CONFIG_16Udict is copied inline from migration 034 per the ticket constraint. Keeps migration history deterministic. Correct choice. I cannot byte-for-byte diff against 034 from this context, but the dev agent attested to a deep-copy check against origin/main @ 034 line 334 and the structure matches the documented shape (variant=local, monthly_fee_default=200, Mon+Fri BWill practices, empty tournaments).FastAPI / model layer
Ruff / style
json,sqlalchemy as sa,from alembic import op). Type hints on_lookup_tenant_id -> int,upgrade/downgrade -> None. Docstring present. Should passruff checkandruff formatcleanly per dev attestation.BLOCKERS
None.
NITS
_JERSEY_TEXT_LOCALand_TOURNAMENTS_LOCAL_TEXTare module-level constants used only once insideLOCAL_CONFIG_16U. Inlining would be fine; keeping them separated mirrors migration 034 and is acceptable. Style-only, non-blocking._lookup_tenant_idexecutes an extra round-trip in the idempotent-skip path. Negligible.alembic upgrade head, idempotency re-run, andalembic downgrade -1are unchecked. CI will exerciseupgrade head, so this is not a CI-blocker perfeedback_qa_ci_blockers, but local downgrade verification would have hardened confidence. Non-blocking.SOP COMPLIANCE
422-create-16u-local-queens-team)PROCESS OBSERVATIONS
revision="040". This is a coordination/merge-ordering issue, not a code defect. Whichever PR merges second must rebase the filename andrevision/down_revisionto041. Flagging for merge-time awareness; does not block approval of either PR in isolation.contract_configJSONB (dev test plan captures the SELECT query).VERDICT: APPROVED