Skip to content

Commit e3eb44f

Browse files
rickyromboclaude
andauthored
fix(purchases): expose updated_at on v_usdc_purchases view (#819)
## Summary Hotfix for a regression introduced by #816. \`/v1/users/{id}/purchases\` crashes with: \`\`\` ERROR: column purchases_with_content.updated_at does not exist (SQLSTATE 42703) \`\`\` \`api/v1_users_purchases.go:123\` selects \`purchases_with_content.updated_at\` through a CTE wrapping \`v_usdc_purchases\`, but the view never exposed \`updated_at\`. Fix: alias \`sp.created_at\` as \`updated_at\` in the view. The legacy \`usdc_purchases\` table set both columns to \`CURRENT_TIMESTAMP\` at insert and never updated rows, so \`created_at = updated_at\` in practice — the alias keeps the API contract intact. I had this fix as a follow-up commit on the PR #815 branch (\"Expose updated_at on v_usdc_purchases view\") but it didn't make it into the squash-merge. ## Test plan - [ ] \`/v1/users/{id}/purchases\` returns 200 again - [ ] \`/v1/users/{id}/sales\` (which also selects \`updated_at\` in \`v1_users_sales.go:94\`) returns 200 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 05b43df commit e3eb44f

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

ddl/views/v_usdc_purchases.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SELECT
1313
sp.content_type::usdc_purchase_content_type AS content_type,
1414
sp.content_id,
1515
sp.created_at,
16+
sp.created_at AS updated_at,
1617
GREATEST(
1718
sp.amount - COALESCE(
1819
CASE sp.content_type

sql/01_schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9631,6 +9631,7 @@ CREATE VIEW public.v_usdc_purchases AS
96319631
(sp.content_type)::public.usdc_purchase_content_type AS content_type,
96329632
sp.content_id,
96339633
sp.created_at,
9634+
sp.created_at AS updated_at,
96349635
GREATEST((sp.amount - COALESCE(
96359636
CASE sp.content_type
96369637
WHEN 'track'::text THEN ( SELECT (tph.total_price_cents * 10000)

0 commit comments

Comments
 (0)