tia/drizzle/meta/_journal.json
Mannu 0c7f37fd12 feat(quota): storage quota + family-member limits for free tier
Feature A — Storage quota (1 GiB per family):
- src/lib/quota.ts: enforcement library with pure functions (fully unit-tested)
  and DB-bound helpers; isPaidFamily() is the single payment abstraction gate
- src/lib/format-bytes.ts: extracted formatBytes() — safe for client imports
- POST /api/upload: quota check before presigned URL issuance (HTTP 402 + reason code)
- POST /api/memories/[id]/confirm: HeadObject reconciles actual R2 size; deletes
  over-quota objects and marks row failed rather than silently exceeding limit
- GET /api/storage-usage: storage info endpoint for UI meter
- src/components/StorageMeter.tsx: meter bar + StorageQuotaBanner + MemberLimitBanner
- memories/page.tsx: quota banner, FAB disabled (⊘) when exceeded, compact meter in header
- settings/page.tsx: always-visible StorageMeter + MemberLimitBanner in invite section

Feature B — Member limit (2 per family, free tier):
- invites/route.ts: replaced ad-hoc inline check with checkMemberLimit() from quota lib
  Structured 403 response: { reason, currentCount, limit }
- Freeze rule: paid→free downgrade leaves all members intact; only new invites blocked

Migration:
- drizzle/0007_subscription_status.sql: ADD COLUMN subscription_status varchar(20)
- debug-migration/route.ts: step added for hot-apply without full redeploy
- src/db/schema/family.ts: subscriptionStatus field added to Drizzle schema

Tests: 44 unit tests in src/__tests__/quota.test.ts, all passing
- Pure function tests (no DB): isPaidFamily, wouldExceedQuota, isAtMemberLimit, formatBytes
- DB-bound tests (mocked @/db): getFamilyStorageUsage, checkStorageQuota,
  checkMemberLimit, getStorageInfo, tenant isolation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 23:21:11 +05:30

62 lines
No EOL
1.2 KiB
JSON

{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1779518962214,
"tag": "0000_baseline_prod_2026_05_19",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1779538936553,
"tag": "0001_wardrobe_tables",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1779539431897,
"tag": "0002_outfits_table",
"breakpoints": true
},
{
"idx": 3,
"version": "7",
"when": 1748134800000,
"tag": "0003_circles",
"breakpoints": true
},
{
"idx": 4,
"version": "7",
"when": 1748221200000,
"tag": "0004_circle_invite_email",
"breakpoints": true
},
{
"idx": 5,
"version": "7",
"when": 1748307600000,
"tag": "0005_email_verification",
"breakpoints": true
},
{
"idx": 6,
"version": "7",
"when": 1748394000000,
"tag": "0006_family_invites_missing_cols",
"breakpoints": true
},
{
"idx": 7,
"version": "7",
"when": 1748480400000,
"tag": "0007_subscription_status",
"breakpoints": true
}
]
}