a tool for shared writing and social publishing
0

Configure Feed

Select the types of activity you want to include in your feed.

add metadata col to email subscribers

Jared Pereira (May 7, 2026, 5:08 PM EDT) e5e1008c e91aa069

+30
+23
src/email-subscribers/metadata.ts
··· 1 + // Schema for the `metadata` jsonb column on `publication_email_subscribers`. 2 + // 3 + // The column is nullable — most rows have no metadata at all (organic 4 + // signups). Within each variant, only the `source` discriminator is 5 + // required; every other field is optional because different writers 6 + // populate different subsets. 7 + 8 + export type CsvImportProvenance = { 9 + source: "csv_import"; 10 + imported_at?: string; 11 + // Other CSV columns that the import script didn't consume directly 12 + // (e.g. ip_address, signup_source) — kept verbatim so we don't lose 13 + // information from the source list. The subscription date is not 14 + // stored here; it lives on `created_at`/`confirmed_at`. 15 + csv_columns?: Record<string, string>; 16 + }; 17 + 18 + // Discriminated union of known subscriber-row metadata shapes. Extend as 19 + // new sources start writing the column. 20 + export type SubscriberMetadata = CsvImportProvenance; 21 + 22 + // Column-level type — most rows are null. 23 + export type SubscriberMetadataColumn = SubscriberMetadata | null;
+7
supabase/migrations/20260507205333_add_subscriber_metadata.sql
··· 1 + -- Provenance metadata on email subscribers (e.g. csv_import, imported_at, 2 + -- original_subscription_date). The events table already has its own 3 + -- per-event metadata column; this one tags the subscriber row itself so 4 + -- "where did these subscribers come from" is a one-table query. 5 + 6 + alter table "public"."publication_email_subscribers" 7 + add column "metadata" jsonb;