Swap purchase readers from usdc_purchases to v_usdc_purchases#816
Open
rickyrombo wants to merge 1 commit into
Open
Swap purchase readers from usdc_purchases to v_usdc_purchases#816rickyrombo wants to merge 1 commit into
rickyrombo wants to merge 1 commit into
Conversation
Step 2 of the purchases-domain cutover. Now that #815 (step 1) has backfilled sol_purchases and added the compatibility view, all ~17 Go API routes that joined usdc_purchases swap over to v_usdc_purchases. Code changes are minimal — table-name renames in route SQL. The view absorbs the schema differences (sol_purchases + sol_payments + users + tracks/playlists -> legacy column shape). Test fixtures are rewritten: callers seed sol_purchases + sol_payments instead of usdc_purchases. Drops fixture columns the view derives (seller_user_id, extra_amount, splits). For tests that assert on splits user_id, the seller's spl_usdc_payout_wallet is set so the view's lookup resolves. For tests that assert on non-zero extra_amount, a track_price_history row is seeded so the view's amount - base_price computation produces the expected value. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3464333 to
dc8966c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 2 of the purchases-domain cutover. Depends on #815 (backfill + view + trigger).
All ~17 Go API routes that joined
usdc_purchasesswap tov_usdc_purchases. Once #815 lands first, this PR's base auto-updates tomainand only this diff remains.Code changes are mostly one-token table-name renames in route SQL — the view absorbs schema differences. Test fixtures are rewritten to seed
sol_purchases+sol_paymentsinstead ofusdc_purchases.Route changes (17 files)
v_usdc_purchasesswapped in forusdc_purchasesin:api/v1_users_purchases.go,_count.go,_download.goapi/v1_users_sales.go,_count.go,_aggregate.go,_download.goapi/v1_users_purchasers.go,_count.goapi/v1_explore_best_selling.goapi/v1_users_library_tracks.go,v1_users_library_playlists.goapi/comms_blasts.go,api/comms/chat.go,api/comms/validator.goapi/dbv1/access.goTest fixture changes (15 files)
Each test that fixtured
usdc_purchasesnow seedssol_purchases+ (when splits matter)sol_payments+ (when extra_amount matters)track_price_history/album_price_history. Dropped columns the view derives (seller_user_id,extra_amount,splits,access).For tests that assert on
splits[*].user_id, the seller'susers.spl_usdc_payout_walletis set to match the correspondingsol_payments.to_accountso the view's resolution chain produces the expected user_id.The global
testdata.UsdcPurchasesFixtures(consumed bytestAppWithFixtures) is replaced withSolPurchasesFixtures+SolPaymentsFixtures, andserver_test.go:105seeds both.database/seed.gogainsbaseRowentries forsol_purchases,sol_payments, andalbum_price_history.Test plan
go build ./...clean (verified locally)go vet ./...clean (verified locally)go test ./api/...green against a running test postgresSELECT * FROM v_usdc_purchases LIMIT 10returns plausible rows after Backfill sol_purchases from usdc_purchases #815 is deployed/v1/users/{id}/purchases,/sales,/purchasers,/sales/aggregate/v1/users/{id}/purchases/download/{json,csv},/sales/download/{json,csv}/v1/explore/best-selling/v1/full/users/{id}/library/tracks?type=purchase,/library/{albums,playlists}?type=purchasecustomer_audienceNot in this PR
index_payment_routerkeeps writingusdc_purchases(the legacy notification trigger also keeps firing, dedupes via sharedgroup_idwith the new trigger from Backfill sol_purchases from usdc_purchases #815).vendoris dropped from notifications (frontends must toleratenull).seller_user_idis now the current content owner, not snapshotted at purchase time. Acceptable per design discussion.🤖 Generated with Claude Code