Storage map
erDiagram subscribers ||--o{ calendar_tokens : owns calendars ||--o{ calendar_tokens : issues calendars ||--o{ verify_requests : verifies calendar_tokens ||--o{ calendar_access_log : used_by subscribers ||--o{ event_log : appears_in calendar_tokens ||--o{ event_log : appears_in email_templates ||--o{ email_template_history : versions email_footer ||--o{ email_footer_history : versions
The repository has an existing base schema plus checked-in migrations 0001 through 0010. They add renewal state, admin visibility, country and latency capture, system state, first-party events, email delivery records, editable templates, a shared email footer, editable supporting prose, and the plaintext-token cleanup.
Core subscription tables
subscribers
- normalized, unique email plus optional name;
activeordisabledstatus;- created and updated timestamps.
calendars
- calendar id such as
programsorinternal; - R2 object key;
- enable/disable flag used during verification and feed delivery.
verify_requests
- one-time magic-link code hash;
- expiry and consumption timestamps;
- troubleshooting fields such as hashed IP and user agent;
- Resend message id for matching delivery webhooks.
calendar_tokens
- subscriber and calendar relationship;
- SHA-256
token_hashonly for current feed authentication; - expiry, revocation, and last-seen timestamps;
- renewal warning, renewal count, and inferred calendar-client state;
- last Resend message id for renewal-email delivery outcomes.
Plaintext token storage is retired
Older code used a nullable
token_plaincolumn to rebuild renewal links. Migration0008_drop_token_plain.sqlsets every legacy value toNULL, and current code neither reads nor writes it. Renewal email now uses a short-lived HMAC-signed credential containing a token-row id and expiry. That credential can renew a row; it cannot fetch the calendar feed.
Operational and analytics tables
| Table | Purpose |
|---|---|
calendar_access_log | Each feed request: status, token id when known, path, hashed IP, user agent, country, and latency |
event_log | First-party product/security events with internal subscriber/token ids, optional dedup key, and JSON context |
email_events | Signed Resend webhook outcomes such as delivered, bounced, and complained |
email_templates | Current overrides for magic-link and renewal email copy; extras_json holds template-specific supporting prose |
email_template_history | Saved prior template versions, including supporting prose |
email_footer | One shared reply notice, support line, copyright line, and disclaimer |
email_footer_history | The prior 20 shared-footer versions |
system_state | Cron timestamps and summaries |
Mixpanel is not a current destination. event_log is the analytics source of truth; see Calendar Analytics.
R2
CAL_BUCKET stores the generated Programs feed, normally at programs.ics. The regeneration job writes only when bytes change, preserving the ETag and allowing calendar clients to receive 304 Not Modified.
Data owned elsewhere
Calendar roles and action grants do not live in SUBS_DB. RC Console evaluates them for every admin API request.
Sources
ihnyc-rc-cal-landing/migrations/0001_renewal_warnings.sqlthrough0010_email_template_extras.sqlihnyc-rc-cal-landing/functions/_lib/events.tsihnyc-rc-cal-landing/functions/_lib/renew-link.tsihnyc-rc-cal-landing/functions/cal/programs.ics.tsihnyc-rc-cal-landing/wrangler.toml