WP-01: Evolution Peewee Models #66

Closed
opened 2026-03-12 20:55:01 +00:00 by cal · 1 comment
Owner

Description

Define Peewee ORM models for the four active evolution tables: evolution_track, evolution_card_state, evolution_tier_boost, evolution_cosmetic.

The old evolution_milestone and evolution_progress tables are eliminated — tier thresholds live directly on the track, and card progress is a single current_value float on the card state.

Repo: database
Phase: 1a (Schema & Data Foundation)
Dependencies: None
Complexity: M

Model Field Summary

EvolutionTrack: id, name, card_type (batter/sp/rp), formula (VARCHAR), t1_threshold (INT), t2_threshold (INT), t3_threshold (INT), t4_threshold (INT)

EvolutionCardState: id, player_id (FK), team_id (FK), track_id (FK), current_tier (INT, default 0), current_value (FLOAT, default 0.0), fully_evolved (BOOL, default False), last_evaluated_at (DATETIME, nullable)

EvolutionTierBoost / EvolutionCosmetic: Phase 2 stubs, minimal models.

Files

  • Create: database/app/models/evolution.py
  • Modify: database/app/db_engine.py — register models

Tests (write first in database/tests/test_evolution_models.py)

  • Unit: model field validation (model_to_dict on unsaved instances)
  • Unit: constraint definitions (unique on player_id+team_id, tier range 0-4)
  • Integration: table creation against test DB
  • Integration: FK enforcement
  • Integration: unique constraint enforcement

Acceptance Criteria

  1. All four models importable from database/app/models/evolution.py
  2. model_to_dict() works on saved instances
  3. FK relationships resolve correctly
  4. Unique constraints enforced at DB level
  5. Models follow existing codebase patterns
  6. EvolutionTrack includes formula + threshold columns
  7. EvolutionCardState includes current_value (FLOAT), no progress_since

Plan reference: docs/prd-evolution/PHASE1_PROJECT_PLAN.md WP-01

## Description Define Peewee ORM models for the four active evolution tables: `evolution_track`, `evolution_card_state`, `evolution_tier_boost`, `evolution_cosmetic`. The old `evolution_milestone` and `evolution_progress` tables are eliminated — tier thresholds live directly on the track, and card progress is a single `current_value` float on the card state. **Repo:** `database` **Phase:** 1a (Schema & Data Foundation) **Dependencies:** None **Complexity:** M ## Model Field Summary **`EvolutionTrack`:** `id`, `name`, `card_type` (batter/sp/rp), `formula` (VARCHAR), `t1_threshold` (INT), `t2_threshold` (INT), `t3_threshold` (INT), `t4_threshold` (INT) **`EvolutionCardState`:** `id`, `player_id` (FK), `team_id` (FK), `track_id` (FK), `current_tier` (INT, default 0), `current_value` (FLOAT, default 0.0), `fully_evolved` (BOOL, default False), `last_evaluated_at` (DATETIME, nullable) **`EvolutionTierBoost` / `EvolutionCosmetic`:** Phase 2 stubs, minimal models. ## Files - **Create:** `database/app/models/evolution.py` - **Modify:** `database/app/db_engine.py` — register models ## Tests (write first in `database/tests/test_evolution_models.py`) - [ ] Unit: model field validation (model_to_dict on unsaved instances) - [ ] Unit: constraint definitions (unique on player_id+team_id, tier range 0-4) - [ ] Integration: table creation against test DB - [ ] Integration: FK enforcement - [ ] Integration: unique constraint enforcement ## Acceptance Criteria 1. All four models importable from `database/app/models/evolution.py` 2. `model_to_dict()` works on saved instances 3. FK relationships resolve correctly 4. Unique constraints enforced at DB level 5. Models follow existing codebase patterns 6. `EvolutionTrack` includes formula + threshold columns 7. `EvolutionCardState` includes `current_value` (FLOAT), no `progress_since` **Plan reference:** `docs/prd-evolution/PHASE1_PROJECT_PLAN.md` WP-01
cal added this to the Card Evolution Phase 1 milestone 2026-03-12 20:59:07 +00:00
cal added the
evolution
phase-1a
labels 2026-03-12 20:59:22 +00:00
Claude added the
ai-working
label 2026-03-12 21:01:28 +00:00
Author
Owner

Implemented and merged as part of the Refractor system rollout. All work packages WP-01 through WP-14 are complete and deployed to dev.

Implemented and merged as part of the Refractor system rollout. All work packages WP-01 through WP-14 are complete and deployed to dev.
cal closed this issue 2026-03-25 05:30:36 +00:00
Sign in to join this conversation.
No project
No Assignees
1 Participants
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: cal/paper-dynasty-database#66
No description provided.