caelum0x 4bb1472e3e feat(vend): white-label "your own OpenRouter" kit
Vend + Relay + Mint white-label kit: self-serve workspace signup
(POST /v1/auth/signup, off by default), per-app model pricing with markup,
end-user wallets and top-ups, tenant earnings, migration 0009_whitelabel,
customer console and operator admin pages for the new flows, and matching
TypeScript/Python SDK and mint-client updates. Covered by
tests/whitelabel_flow.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:41:49 +03:00

25 lines
1.1 KiB
SQL

-- White-label kit ("your own OpenRouter"): per-model markup overrides per app.
-- A row replaces the app's markup_bps (and optionally min_fee_micros) for one
-- Relay model id; the platform fee and funding mode stay app-wide.
CREATE TABLE IF NOT EXISTS app_model_markups (
app_id TEXT NOT NULL REFERENCES apps(id),
model TEXT NOT NULL CHECK (length(model) BETWEEN 1 AND 256),
markup_bps INTEGER NOT NULL CHECK (markup_bps BETWEEN 0 AND 1000000),
min_fee_micros BIGINT CHECK (min_fee_micros IS NULL OR min_fee_micros >= 0),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (app_id, model)
);
-- Tenant earnings roll-ups read captured usage by tenant and day.
CREATE INDEX IF NOT EXISTS metered_usage_tenant_day
ON metered_usage (tenant_id, utc_day)
WHERE outcome = 'captured';
-- Wallet listing: newest end users first per app.
CREATE INDEX IF NOT EXISTS end_users_app_created
ON end_users (app_id, created_at DESC);
-- Payout visibility: newest first.
CREATE INDEX IF NOT EXISTS payout_executions_created
ON payout_executions (created_at DESC);