Files
loki/drizzle/0021_subscriptions_orangecat_service_id.sql
T
Mao NakamotoandClaude Opus 4.7 acb81480b5 feat(orangecat): persist orangecat_service_id + render "OC ✓" badge on /money
Closes the Loop A persistence story. After
syncSubscriptionToOrangeCat() succeeds, the subscription row now stores
the OrangeCat service id back, so the /money page can render a per-row
"OC ✓" badge and future backfill jobs can target only the still-null
rows.

Schema (drizzle migration 0021):
- subscriptions.orangecat_service_id (uuid, nullable). Null = not
  mirrored (integration off, sync failed, or row predates the
  integration). Apply via `npm run migrate`.
- Partial index on (user_id) WHERE orangecat_service_id IS NULL — the
  shape the "what still needs syncing" backfill query will use; the
  column is mostly null for now.

orangecat.ts:
- syncSubscriptionToOrangeCat() now writes the back-link after a
  successful POST. The DB update is also non-fatal — OrangeCat already
  has the truth, and the next /money render still reflects the synced
  state once the column is populated.

UI (/money page SubRow):
- New "OC ✓" badge appears next to the subscription name when
  orangecatServiceId is present. Hover shows the OrangeCat service id
  for cross-system debugging.

SDK bump:
- @orangecat/sdk moved from 0.1.0 → 0.2.0 (file:vendor/). 0.2.0 adds
  .list() on every resource, which a future backfill script uses to
  enumerate what's already on the OrangeCat side before re-syncing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 16:06:15 +02:00

13 lines
601 B
SQL

-- Adds the OrangeCat back-link so the /money page can render a
-- "Synced ✓" badge per subscription and so future backfills know which
-- rows have already been mirrored. NULL = not mirrored (integration off,
-- sync failed, or row predates the integration).
ALTER TABLE "subscriptions" ADD COLUMN "orangecat_service_id" uuid;
-- Partial index helps the small "what still needs syncing" query the
-- backfill job will run; the column is mostly null for now.
CREATE INDEX IF NOT EXISTS "idx_subscriptions_orangecat_pending"
ON "subscriptions" ("user_id")
WHERE "orangecat_service_id" IS NULL;