Skip to content

feat(etl): add aggregate and milestone tables (parity 1A)#238

Open
raymondjacobson wants to merge 1 commit intoclaude/charming-rhodes-d6c7fefrom
etl/parity-1a-aggregate-tables
Open

feat(etl): add aggregate and milestone tables (parity 1A)#238
raymondjacobson wants to merge 1 commit intoclaude/charming-rhodes-d6c7fefrom
etl/parity-1a-aggregate-tables

Conversation

@raymondjacobson
Copy link
Copy Markdown
Contributor

Summary

First step toward parity with discovery-provider's trigger-driven aggregation. Pure-DDL migration — no triggers, no handler changes.

Adds:

  • `aggregate_user` (follower/following/track/repost/save/supporter counts)
  • `aggregate_track` / `aggregate_playlist` (repost + save counts)
  • `aggregate_plays` (lifetime listen count) + `aggregate_monthly_plays`
  • `milestones` (follower/save threshold milestones)

Schema mirrors apps/packages/discovery-provider/ddl/migrations/0000_schema_failable.sql including the `idx_aggregate_user_follower_count` index added in apps#0126.

Stack context

This is PR 1/5 in the trigger-port stack. Stacked on #237 (stems/remixes).

  • 1A (this PR) — aggregate + milestone tables
  • 1B — social triggers (handle_follow, handle_save, handle_repost)
  • 1C — content triggers (handle_track, handle_playlist, handle_play)
  • 1D — wire notification creation into triggers
  • 1E — secondary triggers (handle_comment, handle_event, handle_share, handle_supporter_rank_ups)

Test plan

  • Migration up applies cleanly on fresh DB; `\dt aggregate_*; \dt milestones` shows all 6 tables.
  • `\d aggregate_user` shows expected columns + PK + follower index.
  • Migration down drops all tables cleanly with no errors.
  • Existing entity_manager tests still pass.

🤖 Generated with Claude Code

First step toward parity with discovery-provider's trigger-driven
aggregation. Migration 0017 adds:

- aggregate_user (follower/following/track/repost/save/supporter counts)
- aggregate_track / aggregate_playlist (repost + save counts)
- aggregate_plays (lifetime listen count) + aggregate_monthly_plays
- milestones (follower/save threshold milestones)

Schema mirrors apps/packages/discovery-provider/ddl/migrations/0000_schema_failable.sql
including the agg_user_follower_idx index added in apps#0126.

No triggers or handler changes yet — those land in subsequent PRs in this
stack (1B social triggers, 1C content triggers, 1D notifications, 1E
secondary triggers).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant