From 3b89dbb7e78caaf1073b5bbc7ed6917d3a500bd0 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Fri, 20 Mar 2026 09:27:31 +0000 Subject: [PATCH] [#378] Remove user_address from trade insert (column missing in DB) The trade_history table does not have a user_address column, causing all trade upserts to fail silently with a PostgREST schema cache error. Omit user_address from both the API route and cron trade-history route so trades can be indexed. The column should be added via a Supabase migration in a follow-up, then restored in the insert. Fixes #378 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/api/cron/trade-history/route.ts | 5 +++-- src/app/api/index/trade/route.ts | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/api/cron/trade-history/route.ts b/src/app/api/cron/trade-history/route.ts index 7516bc44..c032538b 100644 --- a/src/app/api/cron/trade-history/route.ts +++ b/src/app/api/cron/trade-history/route.ts @@ -203,7 +203,9 @@ async function processTradeEvent( const timestampISO = await getTimestamp(log.blockNumber!); - const row: TradeInsert = { + // Note: user_address omitted — column does not exist in the DB yet. + // Add via migration, then restore user_address here. + const row: Omit = { token_address: tokenAddress, storyline_id: storylineId, event_type: isMint ? "mint" : "burn", @@ -215,7 +217,6 @@ async function processTradeEvent( tx_hash: log.transactionHash!.toLowerCase(), log_index: log.logIndex!, contract_address: MCV2_BOND.toLowerCase(), - user_address: args.user.toLowerCase(), }; const { error } = await supabase diff --git a/src/app/api/index/trade/route.ts b/src/app/api/index/trade/route.ts index a211d446..19a16db2 100644 --- a/src/app/api/index/trade/route.ts +++ b/src/app/api/index/trade/route.ts @@ -96,7 +96,7 @@ export async function POST(req: Request) { // Fall back to 0 } - const row: TradeInsert = { + const row: Omit = { token_address: tokenAddress, storyline_id: storyline.storyline_id, event_type: isMint ? "mint" : "burn", @@ -108,7 +108,6 @@ export async function POST(req: Request) { tx_hash: txHash.toLowerCase(), log_index: log.logIndex!, contract_address: MCV2_BOND.toLowerCase(), - user_address: args.user.toLowerCase(), }; const { error: dbError } = await supabase