Database Migrations
Address Table — 10 Missing Columns
The addresses table was missing columns that addressService.ts was trying to insert. This caused address save to hang on “Saving…”.
Added via SQL migration on supabase-ricoya:
| Column | Type | Default |
|---|---|---|
| name | text | |
| address_line1 | text | |
| address_line2 | text | |
| city | text | |
| state | text | |
| zip_code | text | |
| country | text | Honduras |
| is_default | boolean | false |
| map_thumbnail | text | |
| updated_at | timestamptz |
RLS Policy — order_items_insert_own
Customers could not insert items for their own orders because the order_items table only had admin insert policies.
Added policy: order_items_insert_own — allows customers to insert items for orders where orders.user_id matches their auth UID.
Auth Token Refresh
Fixed 401 errors on page reload in src/lib/apiClient.ts:
waitForSessionwas returning stale cached token- Added
forceRefreshparam that callssupabase.auth.refreshSession()