feat: add contract_config JSONB column to teams table #319

Closed
opened 2026-04-03 23:50:11 +00:00 by forgejo_admin · 2 comments

Type

Feature

Lineage

Sub-ticket of forgejo_admin/westside-contracts#34 — data-driven contract rendering system. Wave 1 (independent).

Repo

forgejo_admin/basketball-api

User Story

As the contract rendering system, I need structured contract configuration data on each team so that the frontend can render tournaments, practices, and payment schedules from data instead of hardcoded HTML.

Context

The westside-contracts app currently hardcodes all contract content (tournaments, practice schedules, payment dates) in a 725-line Svelte component. Moving to data-driven rendering requires a JSONB column on the teams table to hold team-level contract configuration. This is the base layer — player-level overrides (separate ticket) merge on top.

File Targets

  • alembic/versions/NNN_add_contract_config_to_teams.py — new migration
  • src/basketball_api/models.py — add contract_config field to Team model

Files NOT to touch:

  • src/basketball_api/routes/ — no API changes in this ticket
  • Any player model fields

Acceptance Criteria

  • contract_config JSONB DEFAULT NULL column exists on teams table
  • SQLAlchemy Team model has contract_config: Mapped[dict | None] field
  • Migration is reversible (downgrade drops column)
  • Existing team rows have NULL contract_config (no data seeded yet)
  • All existing tests pass

Test Expectations

  • Migration applies cleanly: alembic upgrade head
  • Migration reverts cleanly: alembic downgrade -1
  • Run command: pytest tests/

Constraints

  • Column must be nullable with DEFAULT NULL for backwards compatibility
  • Use sqlalchemy.dialects.postgresql.JSONB type
  • Follow existing migration naming convention in alembic/versions/

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • westside-basketball — parent project
  • forgejo_admin/westside-contracts#34 — parent issue
### Type Feature ### Lineage Sub-ticket of `forgejo_admin/westside-contracts#34` — data-driven contract rendering system. Wave 1 (independent). ### Repo `forgejo_admin/basketball-api` ### User Story As the contract rendering system, I need structured contract configuration data on each team so that the frontend can render tournaments, practices, and payment schedules from data instead of hardcoded HTML. ### Context The westside-contracts app currently hardcodes all contract content (tournaments, practice schedules, payment dates) in a 725-line Svelte component. Moving to data-driven rendering requires a JSONB column on the teams table to hold team-level contract configuration. This is the base layer — player-level overrides (separate ticket) merge on top. ### File Targets - `alembic/versions/NNN_add_contract_config_to_teams.py` — new migration - `src/basketball_api/models.py` — add `contract_config` field to Team model Files NOT to touch: - `src/basketball_api/routes/` — no API changes in this ticket - Any player model fields ### Acceptance Criteria - [ ] `contract_config JSONB DEFAULT NULL` column exists on teams table - [ ] SQLAlchemy Team model has `contract_config: Mapped[dict | None]` field - [ ] Migration is reversible (downgrade drops column) - [ ] Existing team rows have NULL contract_config (no data seeded yet) - [ ] All existing tests pass ### Test Expectations - [ ] Migration applies cleanly: `alembic upgrade head` - [ ] Migration reverts cleanly: `alembic downgrade -1` - Run command: `pytest tests/` ### Constraints - Column must be nullable with DEFAULT NULL for backwards compatibility - Use `sqlalchemy.dialects.postgresql.JSONB` type - Follow existing migration naming convention in alembic/versions/ ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `westside-basketball` — parent project - `forgejo_admin/westside-contracts#34` — parent issue
Author
Owner

Scope Review: NEEDS_REFINEMENT

Review note: review-772-2026-04-03
Template complete, file targets verified, story note confirmed, AC testable, blast radius low. Single refinement needed:

  • [SCOPE] Architecture note arch-contracts does not exist in pal-e-docs. Create it to complete the traceability triangle.
## Scope Review: NEEDS_REFINEMENT Review note: `review-772-2026-04-03` Template complete, file targets verified, story note confirmed, AC testable, blast radius low. Single refinement needed: - **[SCOPE]** Architecture note `arch-contracts` does not exist in pal-e-docs. Create it to complete the traceability triangle.
Author
Owner

Agent picked up this ticket.

Agent picked up this ticket.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo_admin/basketball-api#319
No description provided.