WAGERBABE DOCS
All Stories
2-1-emergency-odds-history-archivalDoneEpic 2.1

Story 2.1: Emergency Odds History Archival

Status: done

Tasks

  • **Task 1: Validate/Apply Database Migration** (AC: 1, 7)
    • 1.1 Check if `odds_archival_log` table exists in database
    • 1.2 Check if `archived_at` and `archival_batch_id` columns exist on `odds_history`
    • 1.3 Check if `get_database_size_mb()` and `estimate_archival_space_savings()` functions exist
    • 1.4 Apply `create_odds_archival_system.sql` migration if not already applied
    • 1.5 Verify migration with `SELECT * FROM estimate_archival_space_savings(7);`
  • **Task 2: Validate Service Dependencies** (AC: 1, 3)
    • 2.1 Verify `db_pool` from `app.core.database` initializes correctly
    • 2.2 Verify `SupabaseService.get_admin_client()` exists and works
    • 2.3 Ensure `archived-odds` bucket exists or auto-creates in Supabase Storage
    • 2.4 Test estimation function standalone with dry database call
  • **Task 3: Test CLI Script End-to-End** (AC: 1, 8)
    • 3.1 Run `python scripts/run_odds_archival.py --estimate` - verify output
    • 3.2 Run `python scripts/run_odds_archival.py --history` - verify history retrieval
    • 3.3 Run `python scripts/run_odds_archival.py --dry-run` - verify simulation works
    • 3.4 Fix any import errors or missing dependencies
  • **Task 4: Fix Identified Issues** (AC: all)
    • 4.1 Fix logging import (line 15-17 has syntax issue in service file)
    • 4.2 Ensure `odds_history` table exists and has required columns
    • 4.3 Test Supabase Storage bucket creation/access
    • 4.4 Validate VACUUM can run (requires autocommit connection)
  • **Task 5: Execute Archival (Production)** (AC: 2, 3, 4, 5, 6, 7, 9)
    • 5.1 Run final `--estimate` to confirm archival scope
    • 5.2 Execute archival: `python scripts/run_odds_archival.py --days 7`
    • 5.3 Verify CSV uploaded to Supabase Storage (N/A - 0 records)
    • 5.4 Verify records deleted from `odds_history` (N/A - 0 records)
    • 5.5 Verify `odds_archival_log` entry created with metrics
    • 5.6 Check database size via Supabase dashboard (target: <70%)
  • **Task 6: Testing** (AC: all)
    • 6.1 Add pytest test for `estimate_archival_impact()`
    • 6.2 Add pytest test for `_export_to_csv_compressed()`
    • 6.3 Add integration test with small test dataset
    • 6.4 Verify idempotency (running again archives nothing if all archived)

Progress

Tasks6/6
Acceptance Criteria0
Total Tasks6