Database Schema
PostgreSQL 17.6.1 (Supabase-managed) — Tables, relationships, and migrations
Last updated: Nov 4, 2026
On This Page
Schema Overview
Supabase Database
├── public (LIVE production data layer - 41 tables, 13 views as of Oct 30, 2026; core ones below)
│ ├── customer_profile # User accounts + subscription
│ ├── items # Inventory management
│ ├── actions # Bookings (pickup/redelivery)
│ ├── inventory_events # Item movement audit trail
│ ├── booking_events # Booking lifecycle audit trail
│ ├── claims # Insurance claims
│ └── service_areas # Serviceable ZIP codes
│
├── sv (supporting helpers - 13 tables; customer mirrors are EMPTY)
│ ├── customer_profile # Empty mirror (0 rows); live data is public
│ ├── items # Empty mirror (0 rows)
│ ├── actions # Empty mirror (0 rows)
│ ├── inventory_events # Empty mirror (0 rows)
│ ├── ops_tasks # Operations tasks
│ ├── item_embeddings # Vector embeddings for search
│ ├── staff # Staff access control
│ ├── container_catalog # Container types
│ ├── referrals # Referral program
│ ├── account_ledger # Financial transactions
│ ├── pre_customers # Pre-signup leads
│ ├── signup_anomalies # Error tracking
│ └── webhook_events # Empty (0 rows); live log is billing
│
├── billing (Stripe integration)
│ └── webhook_events # Webhook idempotency log
│
├── auth (Supabase-managed)
│ └── users # Authentication (magic links)
│
└── storage (Supabase-managed)
└── buckets # File storage (item-photos)
Current Status
| Schema | Status | Notes |
|---|---|---|
public | ACTIVE PRODUCTION | The live v2 data layer: customer tables, 35 fn_v2_* SECURITY DEFINER write RPCs (the portal’s only mutation path), 9 v_v2_* read-model views, and referral_codes (W4). 0 paying external members; 1 active subscription (the founder’s), verified against live Stripe Sep 11, 2026 |
sv | SUPPORTING | Internal helpers, not the customer data home: staff (access control), container_catalog, pre_customers (leads; since Oct 29, 2026 each row carries promo_slug, promo_source and utm_*), and internal core functions (e.g. sv.fn_v2_booking_cancel_core, sv.fn_v2_item_revert_core). The customer-facing tables mirrored here remain empty — a full public→sv data migration was never executed and is not planned |
billing | ACTIVE | Stripe webhook idempotency log (webhook_events) |
Migrations: all 121 applied to production (head 20261030190000_seasonal_plans); local and remote match one for one, verified Oct 30, 2026 at 19:02 EDT with supabase migration list --remote. The four Oct 19 migrations were applied by the founder on Oct 24, 2026, shortly before 21:58 EDT (see Migration History). pgTAP suite runs locally only — the pgTAP extension is not installed on prod.
Custody predicate (F13, Jul 2026): fn_v2_item_in_custody is the single shared definition of “in Storage Valet’s hands” (stored, or scheduled with scheduled_kind = 'delivery'). Both the capacity meter and the insurance-coverage meter derive from it — any new meter or disposition feature must reuse it, never re-implement the filter.
Coverage override & four-reader contract (F13.1, Jul 15, 2026): customer_profile.insurance_cap_cents_override lets ops raise a member’s coverage cap above the plan default; the effective cap is always coalesce(override, plans.insurance_cap_cents) (customer UPDATE revoked, all overrides NULL today). The cap is resolved in exactly four places — v_v2_insurance_coverage, fn_v2_read_meter_preview, sv.fn_v2_meter_thresholds_check, fn_v2_ops_booking_detail — and a cap change must update all four together. Threshold crossings (plans.meter_warn_threshold_pct, 80%) persist to meter_threshold_state and log an inventory_events row (meter_threshold_crossed). customer_profile.is_internal flags internal accounts; member/MRR aggregates filter is_internal = false at the read-model.
Ops missing-dimensions counts (F1, Jul 17, 2026): fn_v2_ops_booking_detail returns two distinct measurement-gap counts. items_missing_dims is manifest-scoped — the active manifest items on this booking whose cubic_feet is null; it is the visit work-prompt telling ops exactly what to measure at the appointment. account_items_missing_dims is an additive, account-wide count of every unmeasured item the member owns — the backfill signal, independent of any single visit. Migration 20260717170000.
Scheduled-in space preview (F4, Jul 19, 2026): v_v2_insurance_coverage grew append-only from 14 to 16 columns — scheduled_in_cubic_feet (known cubic feet of pickup-scheduled items; unmeasured items contribute nothing) and scheduled_in_has_unmeasured (true when any pickup-scheduled item has no dimensions yet — the dominant case, since ops measures at pickup). Cap logic is untouched; the four-reader contract is unaffected. Migration 20260719210000_f4_coverage_scheduled_in.
Entity Relationship Diagram
┌──────────────────────┐
│ auth.users │ (Supabase-managed)
│ ───────────────── │
│ id (PK) │
│ email │
└──────────┬───────────┘
│ 1:1
▼
┌──────────────────────────────────────────────────┐
│ public.customer_profile │
│ ───────────────────────────────────────────── │
│ user_id (PK, FK → auth.users) │
│ email, stripe_customer_id, subscription_id │
│ subscription_status, last_payment_at │
│ full_name, phone, delivery_address (jsonb) │
│ out_of_service_area, needs_manual_refund │
└───────────┬──────────────────────────────────────┘
│ 1:N
▼
┌────────────────────────────────────────────┐
│ public.items │
│ ─────────────────────────────────────── │
│ id (PK), user_id (FK) │
│ label, description, category │
│ status (home|in_transit|stored|scheduled) │
│ scheduled_kind (pickup|delivery) │
│ active_booking_id (FK → actions) │
│ photo_paths[], qr_code (UNIQUE) │
│ weight_lbs, dimensions, cubic_feet │
│ physical_locked_at, archived_at, tags[] │
└────────┬──────────────────┬────────────────┘
│ 1:N │ 1:N
▼ ▼
┌────────────────────┐ ┌──────────────────────────┐
│ inventory_events │ │ public.booking_items │
│ ─────────────── │ │ ───────────────────── │
│ id, item_id (FK) │ │ action_id (FK), item_id │
│ event_type │ │ role (direction) │
│ event_data │ │ is_active │
│ created_at │ └─────────┬────────────────┘
└────────────────────┘ │ N:1
▼
┌──────────────────────────┐
│ public.actions (booking) │
│ ───────────────────── │
│ id, user_id (FK) │
│ service_type, status │
│ visit_kind │
│ scheduler_provider │
│ external_booking_id │
│ scheduled_start/end │
└─────────┬────────────────┘
│ 1:N
▼
┌──────────────────────┐
│ booking_events │
│ ─────────────────── │
│ id, action_id (FK) │
│ event_type │
│ metadata, created_at│
└──────────────────────┘
Core Tables
customer_profile
Purpose: User account and subscription data (1:1 with auth.users)
| Column | Type | Description |
|---|---|---|
user_id | UUID (PK, FK) | Links to auth.users |
email | TEXT (UNIQUE) | Customer email |
stripe_customer_id | TEXT (UNIQUE) | Stripe customer ID |
subscription_id | TEXT | Active subscription ID |
subscription_status | ENUM | inactive, active, past_due, canceled, trialing, etc. |
last_payment_at | TIMESTAMPTZ | Latest successful payment ($0 trial-activation invoices excluded) |
current_period_end | TIMESTAMPTZ | Billing period anchor (webhook-maintained); feeds the next_billing_label derivation in v_v2_membership for active members (B3, Jun 15, 2026) |
full_name | TEXT | Customer name |
phone | TEXT | Contact phone |
delivery_address | JSONB | {street, unit, city, state, zip} |
out_of_service_area | BOOLEAN | Soft gate for out-of-area |
Protected Columns
Users CANNOT update subscription_status, stripe_customer_id, subscription_id directly.
items
Purpose: Customer inventory with multi-photo support
| Column | Type | Description |
|---|---|---|
id | UUID (PK) | Item identifier |
user_id | UUID (FK) | Owner |
label | TEXT (NOT NULL) | Item name |
description | TEXT (NOT NULL) | Item description |
category | TEXT | Optional category |
status | ENUM | home, in_transit, stored, scheduled |
photo_paths | TEXT[] | Multi-photo array (1-5) |
qr_code | TEXT (UNIQUE) | Format: SV-YYYY-NNNNNN |
cubic_feet | NUMERIC (GENERATED) | Auto-calculated |
tags | TEXT[] | Searchable keywords |
scheduled_kind | TEXT | pickup or delivery while status = 'scheduled'; the read layer derives Pickup Scheduled / Return Scheduled from it |
active_booking_id | UUID (FK) | The active booking for a scheduled item; cleared on completion or cancel |
archived_at | TIMESTAMPTZ | Soft delete (“Remove from Inventory”, allowed only while At Home) |
actions
Purpose: Bookings (visits): service requests for pickup, redelivery (customer-facing “return”) and container delivery. Per-item membership and direction live in booking_items.
| Column | Type | Description |
|---|---|---|
id | UUID (PK) | Action identifier |
user_id | UUID (FK) | Customer |
service_type | ENUM | pickup, redelivery, container_delivery |
status | ENUM | pending_items, pending_confirmation, confirmed, in_progress, completed, canceled |
pickup_item_ids | UUID[] | Items to pick up |
delivery_item_ids | UUID[] | Items to deliver |
visit_kind | TEXT | Derived summary: pickup, delivery or mixed |
scheduler_provider | TEXT | google (native Google Calendar, DEC-0001) on every booking |
external_booking_id | TEXT | The “SV Bookings” Google Calendar event ID |
scheduled_start | TIMESTAMPTZ | Booking start time |
The array columns pickup_item_ids and delivery_item_ids and the calendly_event_uri column remain in the schema; booking_items is the per-item source of truth, and no booking carries a Calendly event (verified Oct 19, 2026).
booking_items
Purpose: Links items to a booking, one row per item
| Column | Type | Description |
|---|---|---|
action_id | UUID (FK) | The booking |
item_id | UUID (FK) | The item |
role | TEXT | Per-item direction on this visit |
is_active | BOOLEAN | False once the item is removed from the booking |
service_areas
Purpose: Serviceable ZIP codes
| Column | Type | Description |
|---|---|---|
zip | TEXT (PK) | ZIP code |
city | TEXT | City name |
state | TEXT | State code |
Billing Tables
billing.webhook_events
Purpose: Stripe webhook idempotency log
| Column | Type | Description |
|---|---|---|
id | BIGSERIAL (PK) | Auto-increment ID |
event_id | TEXT (UNIQUE) | Stripe event.id (idempotency key) |
event_type | TEXT | e.g., checkout.session.completed |
payload | JSONB | Full Stripe event object |
processed_at | TIMESTAMPTZ | Processing completion |
Donations and Seasonal Plans (built, dark)
In production, switched off
Both features are in the production database behind the flags donations and seasonal_plans, and neither is visible to members. Verified Oct 30, 2026 at 19:08 EDT: both flags off with no change logged; 2 partner rows, inactive, with no legal details; no donation request, line, run or receipt; no plan; no outbox row; no donated item. The founder decides when each flag is turned on (Technology › Feature flags).
Flags and the notification outbox (portal foundation, Oct 29, 2026)
| Object | Holds | Access |
|---|---|---|
feature_flags | Launch gates: key, enabled, description, who changed it and when. Two rows, donations and seasonal_plans, seeded off | Service role reads only. Changed through fn_v2_staff_feature_set (staff at AAL2, logged, ops alerted) or a migration. Members read key and enabled through fn_v2_read_feature_flags() |
feature_flag_events | Append-only log of every flag change: key, new and previous value, who, optional note | Service role reads only |
notification_outbox | Queued member email, one row per event key, recipient and channel (email): template type, frozen payload, status (queued, sending, retry, sent, failed), attempts (at most 3), last status code | Service role only. Posted to send-email by sv-v2-notification-sweep; retry rules in Technology › Transactional Email |
Donations
Purpose: a member asks to donate items that are In Storage; staff approve, run the trip to a partner charity, hand the items off and attach the partner’s signed receipt. The item stays stored through request, review and scheduling. Donation state lives in its own tables, and the item leaves custody only at hand-off. Migrations: 20261030170000_donations_db1 (sv-db #44), 20261030180000 and 20261030180100 (sv-db #45).
| Table | Holds | Access |
|---|---|---|
donation_partners | Partner charities: name, legal name, EIN, address, drop-off notes, contact, receipt method (sv_prepared_signed or partner_direct), active. Two rows are seeded, inactive and by name only | No member policy. Members see active partners (name, blurb, logo) through the view v_v2_donation_partner, the one SECURITY DEFINER view |
donation_partner_rules | What a partner accepts, by category: minimum condition, size and weight limits, season. Shown to reviewers, not enforced | Staff functions only |
donation_requests | One row per member submission: partner preference (or Match me), the time the member agreed to share their name and email, a note | Owner reads; writes by function |
donation_request_items | One row per item on a request, called a line: condition (new, like_new, good), state (requested, approved, declined, scheduled, withdrawn, handed_off, refused), assigned partner, run, reasons, current receipt | Owner reads; in the realtime publication; writes by function. A partial unique index allows one open line (requested, approved or scheduled) per item |
donation_runs, donation_run_items | A trip to one partner (draft, loading, departed, closed, cancelled) and the items on it (added, pulled, handed_off, refused, removed), with the shelf each was pulled from | Staff functions only |
donation_receipts, donation_receipt_items | One acknowledgment per donor per run, with a frozen snapshot of what it states (donor, partner, items, hand-off date, a no-goods-or-services line), linked to the exact lines. A correction inserts a new row that supersedes the old one | Owner reads; staff insert through a function; no update or delete for any API role |
Storage bucket donation-receipts | The signed PDF at <user id>/<receipt id>.pdf. Private, PDF only, 10 MB; signed links last 1 hour | The owner reads a file that has a receipt row; staff at AAL2 insert and read; no update or delete policy |
Existing objects changed:
itemsgains the statusdonated, the columnsdonated_at,donation_partner_idanddonation_partner_name, and the checkchk_items_donated_shape(a donated item is archived with no booking and no shelf; every other item carries no donation data).chk_items_archive_eligibilityis amended to allow it, and the item label reads Donated.custody_eventsgains the typedonatedand a nullablemetadatacolumn that carries the partner and the run.v_v2_item_eligibilitygainscan_donateanddonation_state, and an open donation line turns off scheduling for the item.fn_v2_booking_attach_itemsrefuses such an item withSV_DONATION_PENDING, for an active item and for a planned follow-up item, under the same member lock the request takes, so a request and a booking cannot both win.- New view
v_v2_item_donated(security_invoker, owner scoped): the member’s donated items with partner name, date and receipt id.
Member functions (SECURITY DEFINER, empty search_path, granted to authenticated): fn_v2_donation_request refuses with SV_FEATURE_OFF while the flag is off, takes up to 50 items and is idempotent. fn_v2_donation_withdraw and fn_v2_read_donations are not gated by the flag, so a paused launch never strands an item. A withdraw is allowed until the run departs.
Staff functions (17, named fn_v2_staff_donation_*): review, partner save, partner rule set and remove, run create, add and remove, pull, depart, hand off, refuse, close, cancel, receipt attach, and three reads (queue, runs, partners). Each begins with the staff and AAL2 check (AAL1 staff get SV_STEP_UP_REQUIRED) and none is gated by the flag, so staff can finish work in flight. Each write is idempotent, by a client event id or, for a receipt attach, by the receipt id. A hand-off needs the run departed, the item pulled and still In Storage with no booking or planned visit, the partner matching, and the member’s sharing consent. Attaching a receipt for a partner on the default receipt method (sv_prepared_signed) needs the partner’s legal name and EIN on record, otherwise it raises SV_DONATION_PARTNER_INCOMPLETE.
Money and billing: a donation writes nothing to the service ledger and changes no billing. Checks: the 20-minute reconciler (sv-v2-reconcile) reports donation rule violations without repairing them, and the ops monitor reports a run still open 24 hours after departing and handed-off items with no receipt after 7 days, each once.
Seasonal plans
Purpose: a non-binding plan with a date and a reminder. A plan changes no item, booking, calendar window or service ledger. Migration: 20261030190000_seasonal_plans (sv-db #46).
| Table | Holds | Access |
|---|---|---|
member_plans | One row per plan: title (1 to 80 characters), direction (pickup or delivery; members see Pickup or Return), target_date, remind_days (1 to 60, default 14), status (active or dismissed, with dismissed_at and a reason, member or nothing_left) | Owner reads; writes by function |
member_plan_items | The item ids taken when the plan was created or changed. A snapshot that does not follow a collection, so deleting a collection cannot break a plan | Owner reads; composite foreign keys keep a plan to its owner’s items |
Functions (SECURITY DEFINER, empty search_path, anon and PUBLIC revoked, all idempotent): fn_v2_plan_create and fn_v2_plan_update refuse with SV_FEATURE_OFF while the flag is off; fn_v2_plan_dismiss and fn_v2_read_plans do not. fn_v2_plan_reminder_sweep is callable by the service role and cron only. Limits: 20 active plans per member, 100 items per plan, and a date inside the 18-month booking horizon (SV_HORIZON_EXCEEDED).
State is never stored. fn_v2_read_plans works out Not booked, Partly booked, Booked, Done or nothing left on every read, from the plan’s items and their active bookings in the plan’s direction, so a plan reads Booked the instant a booking exists. Reminder: the job sv-v2-plan-reminder (see Scheduled Jobs) queues one plan_reminder outbox row per plan under the event key plan:<plan id>:<target date> once the target date less the reminder lead has arrived and an item is still unbooked. A moved date is a new key, so it earns a new reminder. A plan whose items are all gone (removed or donated) dismisses itself.
Database Functions
update_subscription_status()
Purpose: Update billing-protected columns from webhooks
Type: SECURITY DEFINER (bypasses RLS)
SELECT update_subscription_status( p_user_id := 'user-uuid', p_status := 'active', p_subscription_id := 'sub_123', p_last_payment_at := now() );
log_booking_event()
Purpose: Insert booking events from edge functions
Type: SECURITY DEFINER
Callers: only the legacy calendly-webhook function (kept until sv-website#30); the v2 booking path does not use it.
SELECT log_booking_event(
p_action_id := 'action-uuid',
p_event_type := 'calendly_webhook',
p_metadata := '{"event_uri": "..."}'::jsonb
);
fn_v2_assert_entitled() — v2 Entitlement Gate (Jun 10, 2026)
Purpose: Single entitlement authority for the v2 RPCs. Migration 20260610061949_v2_entitlement_gate adds a server-side membership assertion to the two RPCs that grow stored inventory.
Type: SECURITY DEFINER
- Gated (members only):
fn_v2_item_create, andfn_v2_booking_attach_itemsonly when the call adds pickup items - Never gated: login, reads, delivery-only bookings, cancel/revert, reschedule, confirm of an existing commitment — customers can always recover their inventory
- Entitled =
subscription_status IN ('active','trialing','past_due'); otherwise raisesSV_NOT_ENTITLED(errcodeP0001) - Staff bypass:
sv.staffidentities (ops/QA) are exempt
RLS Policies
Staff access requires a second factor (Jul 20, 2026)
Four security migrations shipped Jul 20, 2026 and are applied in production:
20260720100000_revoke_client_dml_public_sv— closed the client-write bypass.anon/authenticatednow hold onlySELECT, REFERENCES, TRIGGERonpublic; every write goes through thefn_v2_*SECURITY DEFINER RPCs.20260720100001_neutralize_agent_role— contained an unaccounted login credential:agent_roleis nowNOLOGINwith grants, schemaUSAGEand the 24ALTER DEFAULT PRIVILEGESentries all removed. The default-privilege clearance matters — revoking current grants alone would have re-granted on the nextCREATE TABLE.20260720100002_backfill_hollow_ledger_entries— data backfill.20260720110000_aal2_staff_rls— staff RLS now requires AAL2.sv.is_staff()= membership and an MFA-stepped-up session; all policies referencing it inherit the requirement. Before this, ansv.staffrow exposed every customer's bookings,service_address,booking_eventsandbooking_itemsfor reading with no second factor.
Do not gate public.is_staff() on AAL2. It is the
identity predicate — the portal calls it to decide whether to show the ops route and offer
MFA step-up, and it renders the 404 surface when it returns false. Gating it would 404 a staff member
at AAL1, hide the Verify button, and permanently lock out the only staff account. It deliberately no
longer delegates to sv.is_staff(); both functions carry a COMMENT ON FUNCTION
recording this.
New tables, views and sequences must state their grants explicitly in the same migration (Supabase stopped auto-granting Data API access to new public objects on Oct 30, 2026); see Technology, Database Migrations.
Local/prod grant parity is enforced by supabase/seed.sql, which now fails the reset if a
client DML grant reappears. Any grant-changing migration must regenerate the seed in the same
commit — otherwise a local rebuild silently reopens what the migration closed.
Client writes are revoked (since Jul 20, 2026). anon and authenticated hold no INSERT, UPDATE or DELETE on public or sv. Customers read their own rows under RLS and every write goes through the fn_v2_* SECURITY DEFINER RPCs (the one exception is the photo upload to bucket item-photos).
customer_profile
- ✓ Owner can SELECT own profile
- ✗ Owner CANNOT write directly; profile edits go through
fn_v2_*RPCs - ✗ Owner CANNOT update billing fields
items
- ✓ Owner can SELECT own items
- ✗ Owner CANNOT INSERT/UPDATE/DELETE directly; item writes go through
fn_v2_*RPCs
actions
- ✓ Owner can SELECT own actions (or staff can view all)
- ✗ Owner CANNOT INSERT/UPDATE/DELETE directly; booking, cancel and revert go through
fn_v2_*RPCs - ✗ Status moves to confirmed/completed are ops-only RPCs
service_areas
- ✓ RLS enabled — authenticated users can SELECT (lookup table)
- ✗ No INSERT/UPDATE/DELETE for users
sv.staff
- ✓ RLS enabled —
service_roleonly (no direct user access)
inventory_events
- ✓ Owner can SELECT events for their items
- ✗ Owner CANNOT insert (system-only via service_role)
booking_events
- ✓ Owner can SELECT events for their own bookings (via action ownership JOIN)
- ✓ Staff can SELECT all booking events
- ✗ Orphan events (
action_id IS NULL) are only visible to staff - ✗ Owner CANNOT insert (system-only via service_role)
Common Queries
Get user items for dashboard
SELECT * FROM items WHERE user_id = auth.uid() ORDER BY created_at DESC;
Search items
SELECT * FROM items
WHERE user_id = auth.uid()
AND status = 'stored'
AND (
label ILIKE '%keyword%'
OR description ILIKE '%keyword%'
OR 'keyword' = ANY(tags)
);
Get pending bookings
SELECT * FROM actions
WHERE user_id = auth.uid()
AND status IN ('pending_items', 'pending_confirmation')
ORDER BY scheduled_start ASC;
Scheduled Jobs (pg_cron)
Production cron.job holds 6 jobs, verified Oct 30, 2026 at 19:08 EDT. Times are UTC unless a row says otherwise.
| Job | Schedule | Runs | State |
|---|---|---|---|
sv-ops-monitor | */15 * * * * (every 15 minutes) | fn_v2_ops_monitor(): alerts ops if the reconcile job stops running or Stripe webhook events sit unprocessed. Since Oct 28, 2026 (sv-db #34) it also emails “NEW MEMBER (backstop)” for a membership the immediate stripe-webhook alert missed, and an unconverted-lead notice for an in-area lead 2 to 48 hours old with no membership; public.ops_signup_alerts is the ledger that keeps it to one email per member. Since Oct 29, 2026 it also reports notification outbox rows that are stalled (due for more than 30 minutes without an attempt, or posted more than 30 minutes ago with no answer) or failed, each failed row once. Since Oct 30, 2026 (sv-db #45) it reports a donation run still open 24 hours after departing and handed-off items with no receipt after 7 days, each once | Active |
sv-v2-reconcile | */20 * * * * (every 20 minutes) | fn_v2_reconcile(): item and booking invariant checks; alerts ops on a violation. Since Oct 30, 2026 (sv-db #45) it also reports donation rule violations, report only: an open donation item that is not stored, or is booked or planned; a scheduled line without its one live run item; a donated item without a hand-off, or with an open line or a booking | Active |
sv-v2-reminder | 5 * * * * (hourly at :05) | fn_v2_reminder_sweep(): booking reminder emails | Active |
sv-v2-notification-sweep | 4-59/5 * * * * (every 5 minutes, at minutes 4, 9, … 59) | fn_v2_notification_sweep(): posts due notification_outbox rows to send-email, resolves the answers, retries transient failures (10 and then 60 minutes later, three attempts in all) and raises an ops alert for a row that fails. A 400 from send-email is final. Rules: Transactional Email | Active |
sv-v2-plan-reminder | 12 14,15 * * * (14:12 and 15:12 UTC; the command runs only when the New York hour is 10, so it acts at 10:12 a.m. New York in both EDT and EST) | fn_v2_plan_reminder_sweep(): queues one plan_reminder outbox row per active plan per target date once the reminder window has opened and an item is still unbooked; dismisses a plan whose items are all gone. Does nothing while the seasonal_plans flag is off | Active; a no-op while the flag is off |
sv-v2-trial-nudges | 7,17,27,37,47,57 14-17 * * * (every 10 minutes, 14:07 to 17:57 UTC; sends only 10:00 to 11:59 New York time) | fn_v2_trial_nudge_sweep(): getting-started emails for trialing members (day 3, day 10, charge notice) | Paused on purpose (active = false) |
Why sv-v2-trial-nudges is paused (founder ruling, Oct 24, 2026): Mary’s items are physically held by Storage Valet but still recorded At Home, so the sweep would treat her as a member with nothing stored and send her the “nothing with us yet” emails. The job resumes once her first item is recorded In Storage (through the staff intake in /ops). Leave it paused until then.
Migration History
Total: 121 local migrations, all 121 applied to production (head 20261030190000_seasonal_plans; sv-db main 517cb1a). No migration is pending. Verified Oct 30, 2026 at 19:02 EDT.
Key migrations include:
0001_init— Core schema0004_phase1_inventory_enhancements— Multi-photo, status, batch ops0005_create_sv_schema— Create sv domain schema20251112000005_billing_status_tracking— Payment timestamps20251201062222_create_service_areas_table— Service areas20260107000001— Billing v2 trial columns20260129000001— Enable RLS on service_areas20260202000001—fn_revert_orphaned_scheduledguardrail (dropped Jun 29, 2026 by DEC-021; the v2 equivalent isfn_v2_reconcile)20260202000002— Deprecatebilling.customers20260204000001–05— v1 ops dashboard:sv.v_ops_actionsview,get_ops_actionsRPC, staff RLS hardening (view and RPC dropped Jun 29, 2026 by migration20260629120000, DEC-021)20260211000001— Track A: Harden actions UPDATE/DELETE RLS (restore status constraint), fix booking_events cross-tenant leak20260211000002— Track A: Capture 3 missing RPCs in migration history (check_stripe_webhook_event,insert_stripe_webhook_event,get_user_id_by_email)20260211000003— Track A:is_valid_zip_code()STABLE table-backed function20260211000004— Track A: Drop stalebooking_events_read_policy(P0 leak closure) and duplicatep_actions_owner_insert20260215000001— Drop duplicateupdate_subscription_status(subscription_status_enum)overload (P0 stripe-webhook fix)20260227000001— Drop deprecatedupsert_billing_customerfunction (legacy helper forbilling.customers, no longer referenced)20260304000001— Drop deprecatedbilling.customerstable (redundant withcustomer_profile.stripe_customer_id)20260526223235— Harden security advisors (pinsearch_path, revoke EXECUTE from PUBLIC)20260529130001–200001— v2 backend train (applied prod Jun 9): additive schema,plansseed,fn_v2_*RPC suite, Stripe helpers,v_v2_*read-model views,fn_v2_item_revert, reconcile cron, realtime publication20260531142114— Enable RLS onbilling.webhook_events20260610040905—customer_profilegrant lockdown (column-scoped UPDATE; billing fields locked)20260610041336— Insurance possession-split (insured-now / scheduled-in)20260610061949— Server-side entitlement gate (fn_v2_assert_entitled; pickups/creates gated, deliveries never)20260610215009— Operational-minimum data-capture floors + coherence-constraint VALIDATE20260612233000— P0:release_stripe_webhook_event_v2(claim release on webhook failure)20260614120000— B3:current_period_endcolumn +next_billing_labelderivation inv_v2_membership
Oct 19 Migrations (applied Oct 24, 2026)
Written Oct 19, 2026 and applied by the founder on Oct 24, 2026, shortly before 21:58 EDT. No migration is pending.
20261019112000_trial_nudges— getting-started emails for trialing members (day 3, day 10 and the charge notice): tablestrial_nudgesandemail_optouts,fn_v2_trial_nudge_sweep,fn_v2_trial_nudge_candidates,fn_v2_email_optout, and the cron jobsv-v2-trial-nudges, which is paused on purpose (see Scheduled Jobs)20261019160000_custody_locations_ledger— item QR labels and chain of custody, M1 of 2:storage_locations(staff-only shelf and floor codes), the append-only staff-onlycustody_eventsledger, the custody check onitems.storage_location, QR immutability, the staff scan and label RPCs and the restatedfn_v2_booking_complete; dropsp_inventory_events_owner_insert20261019160100_ops_intake— custody M2 of 2: staff intake, recording an item already in Storage Valet’s hands into storage at a location (an existing At Home item, or a new item staff create on the member’s account); unique indexux_actions_recorded_intake_day(one recorded intake visit per household per New York day) and the staff photo policies onstorage.objects20261019160200_past_visit_lines— Past visits list the items completed on each visit (PV-1);v_v2_booking_linenow runs withsecurity_invoker = true
In production since the push: 16 new fn_v2_* functions and three “Staff …” policies on storage.objects. The staff /ops pages that use the custody tables merge tonight, Oct 24: sv-portal-2026 #88 (locations and household label sheets), #89 (scan, put here, store here) and #87 (new item for a household). sv-db ./security/check-drift.sh lists the new objects as drift until its baseline is updated.
Booking horizon, signup alerts and campaign tracking
20261011170000_far_ahead_planned_visits— 18-month booking horizon enforced in the database (SV_HORIZON_EXCEEDED) and planned follow-up visits (booking_planned_items); see DEC-03020261028220000_ops_monitor_signup_backstop(sv-db #34, Oct 28, 2026) —public.ops_signup_alertsledger (RLS on, service role only) and the new-member and unconverted-lead backstop infn_v2_ops_monitor(): a 5-minute grace after the profile is written, then “NEW MEMBER (backstop)” ifstripe-webhookdid not already record the alert; internal accounts skipped, at most 10 notices per kind per run20261029013900_lead_campaign_attribution(sv-db #36) —promo_slug,promo_source,utm_source,utm_medium,utm_campaignonsv.pre_customers(first touch kept as a set, over-long values dropped, no backfill);upsert_pre_customertakes five optional parameters; viewsv.v_ops_campaign_resultscounts leads, in-area leads, members and live members per campaign with internal accounts excluded; staff read it throughfn_v2_ops_campaign_results()(staff plus MFA)
Portal foundation, donations and seasonal plans (Oct 29 to 30, 2026)
20261029035912_portal_foundation— feature flags (feature_flags,feature_flag_events,fn_v2_staff_feature_set,fn_v2_read_feature_flags) and the notification outbox with its sweep job, among other portal changes. Applied Oct 29, 2026; see Donations and Seasonal Plans20261030170000_donations_db1(sv-db #44) — donations, member side: enums,donation_partners,donation_partner_rules,donation_requests,donation_request_items, the viewv_v2_donation_partner,fn_v2_donation_request,fn_v2_donation_withdrawandfn_v2_read_donations;fn_v2_booking_attach_itemsandv_v2_item_eligibilityrestated with theSV_DONATION_PENDINGguard. Two partners seeded, inactive, by name only20261030180000_donations_db2a_donated_status(sv-db #45) — adds thedonateditem status, in its own file because a new enum value cannot be used in the transaction that adds it20261030180100_donations_db2b_runs_receipts(sv-db #45) — donations, staff side: runs, run items, receipts and thedonation-receiptsbucket, the 17 staff functions, the terminal donated state onitems, the viewv_v2_item_donated, the reconciler and ops-monitor checks, and the outbox producers for the donation emails20261030190000_seasonal_plans(sv-db #46) —member_plans,member_plan_items, four member functions,fn_v2_plan_reminder_sweepand the cron jobsv-v2-plan-reminder. Applied at 16:05 EDT
Full migration list: ~/code/sv-db/supabase/migrations/