fix: apply VFS conversation schema compatibility at backend boot

#26
by Baida07 - opened
Files changed (1) hide show
  1. api/startup_migration.py +12 -0
api/startup_migration.py CHANGED
@@ -36,6 +36,18 @@ _SENSITIVE_TABLES = [
36
 
37
  _RLS_FIX_SQL = """
38
  -- ARCH-F1.5 + SEC-RLS-FIX: RLS GRANT fix — idempotente, sicuro da ri-eseguire.
 
 
 
 
 
 
 
 
 
 
 
 
39
  GRANT USAGE ON SCHEMA public TO anon;
40
  GRANT USAGE ON SCHEMA public TO authenticated;
41
 
 
36
 
37
  _RLS_FIX_SQL = """
38
  -- ARCH-F1.5 + SEC-RLS-FIX: RLS GRANT fix — idempotente, sicuro da ri-eseguire.
39
+ -- Compatibility fix: older Supabase projects created vfs_files without the
40
+ -- conversation namespace used by the VFS router. Keep this safe on every boot.
41
+ DO $$
42
+ BEGIN
43
+ IF to_regclass('public.vfs_files') IS NOT NULL THEN
44
+ ALTER TABLE public.vfs_files
45
+ ADD COLUMN IF NOT EXISTS conversation_id TEXT NOT NULL DEFAULT '';
46
+ CREATE INDEX IF NOT EXISTS vfs_files_conversation_idx
47
+ ON public.vfs_files (conversation_id);
48
+ END IF;
49
+ END $$;
50
+
51
  GRANT USAGE ON SCHEMA public TO anon;
52
  GRANT USAGE ON SCHEMA public TO authenticated;
53