Skip to content

chore(payments): deploy manual-payouts + related migrations to cloud (#500) - #508

Merged
guillermoscript merged 2 commits into
masterfrom
fix/cloud-manual-payouts-migration-500
Jul 24, 2026
Merged

chore(payments): deploy manual-payouts + related migrations to cloud (#500)#508
guillermoscript merged 2 commits into
masterfrom
fix/cloud-manual-payouts-migration-500

Conversation

@guillermoscript

@guillermoscript guillermoscript commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Description

Deploys 20260724120000_manual_payouts.sql to the cloud Supabase project (per #500) and regenerates lib/database.types.ts for the columns it adds.

While smoke-testing, found that /platform/payouts (getPayoutsOwed() in app/actions/platform/payouts.ts) already selects transactions.school_percentage_snapshot — a column from 20260724140000_transaction_split_snapshot.sql (#496, merged to master) that was also cloud-only-missing. That means the payouts page was erroring in production before this change. tenants.access_cutoff_at (20260724130000_access_cutoff_enforcement.sql, #494) was in the same state. All three are simple additive ALTER TABLEs with no interdependency, so — after confirming with the repo owner — this PR deploys all three together rather than leaving production broken between #500 and separate deploy issues for #494/#496 (neither of which exists yet).

Changes made

  • Applied to the cloud project: manual_payouts, access_cutoff_enforcement, transaction_split_snapshot.
  • Repaired cloud migration history (supabase_migrations.schema_migrations) so each version/name matches the repo filename exactly.
  • Regenerated lib/database.types.ts fully against cloud (two commits: the first applied just the affected columns for these three migrations, the second did a full regen to also fix pre-existing type drift found while reviewing the diff — see below). No code changes needed elsewhere; npm run typecheck, lint, and build all pass clean.
  • The full regen also fixes drift unrelated to any migration in this PR, already deployed to both local and cloud but never previously regenerated into the committed file: adds lessons.transcript, subscriptions.superseded_by (+ FK), the user_ui_state table, and the change_subscription_plan RPC return shape; removes the dead handle_manual_subscription_expiry function type (dropped by migration 20260719130000, confirmed no live callers — replaced by the app-layer cron at app/api/cron/expire-platform-subscriptions/route.ts); and picks up the current typegen output format (adds the __InternalSupabase version marker, drops the empty graphql_public schema block — nothing in the codebase references it).

Type of change

  • Chore (infrastructure/deployment)
  • Fix (production /platform/payouts was erroring on the missing school_percentage_snapshot column)

Relationship

Closes #500

Testing

  • npm run typecheck — passes clean on the changed file.
  • Cloud schema verified post-migration: payouts has payout_method/note/recorded_by, period_start/period_end nullable — matches local.
  • mcp__supabase-cloud__get_advisors(security) — no new findings referencing payouts, access_cutoff_at, has_course_access, or transactions. RLS policies on payouts are row-level only (tenant_id/is_super_admin), unaffected by new columns.
  • Ran the exact query shape from getPayoutsOwed() against cloud — executes cleanly (0 rows currently, no live PayPal/Binance/LemonSqueezy transactions in production yet, but no longer errors on the missing column).
  • Ran the exact insert shape from markPayoutPaid() against cloud inside BEGIN...ROLLBACK — succeeds, no data persisted (count(*) = 0 confirmed after).
  • No E2E/browser test — this is a pure backend/database deployment change, nothing new to click through. Existing /platform/payouts UI code is unchanged.

QA verification steps

  1. As a super admin, load /platform/payouts in production (or against the cloud project) and confirm the page renders without a server error (previously would 500 on the missing school_percentage_snapshot column).
  2. Confirm the "payouts owed" table shows expected balances per tenant/currency.
  3. Record a manual payout via "Mark as Paid" for a tenant with a nonzero balance; confirm the row appears in payouts with payout_method = 'manual', recorded_by set to your user id, and (if provided) note populated.
  4. Confirm supabase migration list (or mcp__supabase-cloud__list_migrations) shows 20260724120000_manual_payouts, 20260724130000_access_cutoff_enforcement, and 20260724140000_transaction_split_snapshot all present with versions matching the repo filenames.

…migrations to cloud

Applies three previously-local-only migrations to the cloud Supabase project
(20260724120000_manual_payouts, 20260724130000_access_cutoff_enforcement,
20260724140000_transaction_split_snapshot) and repairs migration history to
match the repo filenames. Regenerates lib/database.types.ts for the columns
each adds (payouts.payout_method/note/recorded_by + nullable period_start/
period_end, transactions.school_percentage_snapshot).

Deploying the latter two (beyond #500's manual_payouts scope) was necessary
because getPayoutsOwed() already selects transactions.school_percentage_snapshot
on every /platform/payouts load — that column didn't exist on cloud, so the
page was erroring in production before this change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CcZgbBpQtpKipPwQq38EjT
@guillermoscript guillermoscript added enhancement New feature or request payments Payment provider / billing related db-migration Requires a Supabase migration labels Jul 24, 2026
@guillermoscript guillermoscript self-assigned this Jul 24, 2026
@guillermoscript
guillermoscript marked this pull request as ready for review July 24, 2026 18:37
Fixes pre-existing type drift unrelated to any migration in this branch —
the checked-in types file was stale relative to migrations already deployed
to both local and cloud: adds lessons.transcript, subscriptions.superseded_by
(+ FK), the user_ui_state table, and the change_subscription_plan RPC return
shape; removes the handle_manual_subscription_expiry function type (dropped
by migration 20260719120000/20260719130000, confirmed no live callers — the
app-layer cron at app/api/cron/expire-platform-subscriptions/route.ts
replaced it).

Also picks up the current typegen format (adds __InternalSupabase version
marker, drops the empty graphql_public schema block) — nothing in the
codebase references graphql_public.

npm run typecheck, lint, and build all pass clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CcZgbBpQtpKipPwQq38EjT
@guillermoscript
guillermoscript merged commit 3c0aa90 into master Jul 24, 2026
2 checks passed
@guillermoscript

Copy link
Copy Markdown
Owner Author

Merged as 3c0aa903. Final state, for the record:

Shipped:

  • Deployed 20260724120000_manual_payouts, 20260724130000_access_cutoff_enforcement, and 20260724140000_transaction_split_snapshot to the cloud Supabase project; migration history repaired to match the repo filenames.
  • Regenerated lib/database.types.ts fully against cloud — both the columns these three migrations add and pre-existing, unrelated type drift (lessons.transcript, subscriptions.superseded_by, user_ui_state, change_subscription_plan RPC; removed the dead handle_manual_subscription_expiry type).
  • Fixed a live production bug as part of this: /platform/payouts was erroring on cloud because getPayoutsOwed() already selected transactions.school_percentage_snapshot, a column that didn't exist there before this PR.

QA that passed:

  • npm run typecheck, lint, build all clean; CI verify (lint + typecheck + unit tests) green on both commits.
  • Cloud-side: exact query/insert shapes from getPayoutsOwed()/markPayoutPaid() run directly against cloud, plus get_advisors(security) showed no new findings.
  • Local click-through: seeded a real PayPal transaction, loaded /platform/payouts in a browser, confirmed the $20.00 owed calculation (80% split), clicked "Mark as Paid" through the actual dialog, and verified the resulting payouts row (payout_method='manual', note, recorded_by, nullable period_start/period_end) — then cleaned up the test data.

Nothing deferred beyond this PR's scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

db-migration Requires a Supabase migration enhancement New feature or request payments Payment provider / billing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply manual-payouts migration to cloud + regenerate types

1 participant