Schema audit · types/supabase.ts vs prod
Snapshot 2026-05-26. Origine: ops/quality-followup-2026-05-26.md · P2-5.
Sintesi
| Categoria | # |
|---|---|
| ✅ Allineate | 4 |
| 🔴 In drift (Row ≠ prod) | 17 |
| ⚠️ Solo in prod (mancano nei types) | 72 |
| ⚠️ Solo nei types | 21 |
| TOTALE | 114 |
Strategia: si riallinea types → prod rigenerando il file via
supabase gen types. Eccezioni di rename inverso (modifica prod per matchare il frontend) solo dove ha senso (es.oauth_connectionsriconciliato nel decisions-log v53). NON si rinominano colonne in prod alla cieca: rischio rottura RLS/edge functions/codice non-frontend.
🔴 Tabelle in DRIFT (17)
| Tabella | Prod | Types | Solo prod (➕ da aggiungere nei types) | Solo types (➖ rimosse o da creare) |
|---|---|---|---|---|
api_keys |
11 | 9 | created_by_user_id, expires_at, is_active, key_hash, key_prefix, scopes |
active, allowed_domains, key, submissions_count |
booking_services |
19 | 12 | buffer_minutes_override, category, cover_image_url, custom_fields, deposit_chf, deposit_required, display_order, duration_minutes, is_active, opening_hours_override, price_chf, sector_role |
active, duration_min, price, sector_specific_fields, sort_order |
booking_settings |
18 | 13 | advance_booking_days, buffer_minutes, cancellation_hours, deposit_amount_chf, deposit_percentage, no_show_fee_chf, reminder_template, require_deposit, send_confirmation, send_followup_review, send_reminder_24h, widget_color, widget_position |
buffer_min, closed_days, default_timezone, embed_colors_json, gdpr_disclaimer, max_advance_days, min_advance_hours, webhook_url |
booking_slots |
11 | 9 | booked_count, capacity, is_blocked, resource_id, slot_end, slot_start |
created_by, end_at, start_at, team_member_id |
booking_team_calendars |
10 | 10 | display_order, is_active, opening_hours, resource_color, resource_name, service_ids |
color, disabled, display_name, external_sync_provider, external_sync_url, updated_at |
deals |
26 | 20 | call_script, closed_at, closed_won, contact_phone, crm_contact_id, currency, last_activity_at, lead_id, loss_reason, metadata, next_activity_at, owner_user_id, pipeline_id, source, source_campaign, stage_id, title, value_chf |
city, feedback_discovery, feedback_trattativa, lead_link, motivo, phone, sector, stage, status, utm, value, website |
form_submissions |
14 | 11 | fields, ip_country, is_spam, page_id, processed, user_agent |
message, metadata, status |
leads |
26 | 25 | assigned_to_user_id, audit_summary, contact_linkedin, contact_name, contact_phone, contact_role, country, industry, last_outreach_at, metadata, outreach_count, reply_received, score |
audit_data, business_details, call_attempts, call_notes, call_status, detected_sector, inevitability_score, last_call_at, lead_source, next_call_at, pattern_id, phone |
notification_preferences |
18 | 16 | email_digest_enabled, notify_booking_cancellation, notify_booking_new |
notify_email_opened |
oauth_connections |
17 | 16 | is_active |
— |
push_subscriptions |
9 | 7 | last_used_at, p256dh_key, user_agent |
p256dh |
smtp_configs |
22 | 29 | — | signature_image_url, signature_linkedin, signature_name, signature_phone, signature_tagline, signature_title, signature_website |
social_posts |
28 | 26 | content_item_id, hashtags, post_external_id |
post_id |
subscriptions |
14 | 11 | billing_cycle, billing_period, current_period_start |
— |
team_members |
7 | 6 | invited_by |
— |
webhook_events |
13 | 10 | processed_at, retry_count, signature_verified |
— |
workspaces |
29 | 23 | billing_email, country_code, default_settings, primary_language, region_code, setup_fee_paid, stripe_customer_id |
slug |
⚠️ Solo in prod, MANCANO nei types (72)
Probabili migration applicate via MCP senza rigenerare i types.
| Tabella | Cols in prod |
|---|---|
agent_decisions |
22 |
agent_runs |
14 |
ai_generation_jobs |
18 |
ai_visibility_checks |
16 |
ai_visibility_results |
12 |
audit_log_gdpr_art9 |
12 |
autonomy_promotions |
18 |
contact_events |
7 |
content_brand_memory |
16 |
content_calendar_events |
11 |
content_generations |
12 |
content_items |
24 |
crm_activity_timeline |
12 |
crm_contacts |
29 |
crm_loyalty_transactions |
8 |
crm_message_threads |
9 |
crm_messages |
18 |
crm_segments |
11 |
cro_audits |
7 |
customer_value_v |
12 |
design_reviews |
9 |
email_accounts |
25 |
email_labels |
7 |
email_log |
15 |
email_messages |
23 |
email_threads |
18 |
entity_interactions |
14 |
entity_memory |
10 |
entity_patterns |
9 |
entity_profile |
12 |
external_integration_events |
10 |
external_widget_configs |
10 |
failed_webhooks |
17 |
founder_emails |
3 |
knowledge_packs |
20 |
legal_acceptances |
10 |
model_ab_tests |
27 |
monthly_workspace_costs |
8 |
nucleo_events |
15 |
patient_pseudo_map |
7 |
planet_goals |
24 |
planet_registry |
13 |
prelaunch_signups |
8 |
reach_audits |
8 |
reach_google_connections |
15 |
referrals |
12 |
reflection_schedules |
20 |
sales_commissions_rules |
10 |
sales_email_sequences |
16 |
sales_outreach_log |
20 |
sales_pipeline_stages |
12 |
sales_pipeline_templates |
10 |
sales_pipelines |
8 |
sales_quotas |
12 |
sales_seller_subaccounts |
16 |
sales_territories |
10 |
sector_default_services |
9 |
site_assets |
14 |
site_block_translations |
6 |
site_blocks |
8 |
site_constitutions |
8 |
site_pages |
15 |
site_subdomains |
5 |
site_versions |
6 |
sites |
16 |
tier_caps |
7 |
usage_counters |
15 |
workspace_external_integrations |
18 |
workspace_home_prefs |
4 |
workspace_insights |
22 |
workspace_planet_autonomy |
4 |
workspace_token_usage |
5 |
⚠️ Solo nei types, MANCANO in prod (21)
Tabelle dichiarate nei types ma non più in prod (cancellate? Da indagare).
| Tabella | Cols nei types |
|---|---|
ab_tests |
12 |
ai_activity_log |
12 |
ai_conversations |
6 |
ai_goals |
17 |
ai_notifications |
12 |
ai_reports |
14 |
analytics_metrics |
10 |
bookings_legacy_backup |
10 |
brand_intelligence |
10 |
business_documents |
11 |
business_expenses |
13 |
business_templates |
11 |
daily_kpi |
22 |
daily_strategy |
10 |
dashboard_config |
9 |
geography_strategy |
8 |
outreach_log |
21 |
patterns |
10 |
revenue_events |
15 |
review_data |
13 |
team_invites |
7 |
✅ Tabelle pulite (4)
Espandi
| Tabella | Cols |
|---|---|
bookings |
31 |
onboarding_ai_log |
12 |
sector_macros |
7 |
sectors |
15 |
Prossimi passi (ordine consigliato)
- Backup:
cp frontend/multiverbe-app/src/types/supabase.ts{,.backup-2026-05-26}. - Rigenerazione types da prod:
supabase gen types typescript --project-id yqhixdqipojvgzfadufo --schema public > frontend/multiverbe-app/src/types/supabase.ts. - Build frontend:
pnpm --filter multiverbe-dashboard run build— emergono i TS errors. Tipicamente: oggetti che leggono colonne con nomi vecchi. - Fix codice frontend in PR a batch per dominio (auth, sales, crm, content, ecc.). Tipica fix: rename camelCase → snake_case corretto del nome attuale prod.
- Flip drift detector da advisory a hard gate appena tutte le drift sono chiuse.
Note tecniche
- Per tabelle "solo in prod": basta la rigenerazione dei types (zero rischio frontend, perché il codice non le usa ancora).
- Per drift su tabelle USATE (es.
agent_runsse ha cambiato schema): la rigenerazione rompe la build → fix codice obbligato. - Per drift su tabelle non USATE in frontend ma in api/ (vercel serverless):
api/**non è tipizzato in CI (vediproject_api_esbuild_local_validation), quindi la rigenerazione non emerge — controllare manualmente congrepse servono fix.