Sub / supabase /INSTALL_SIMULATION_RUNS.sql
Himankpro's picture
Upload 93 files
3a6c182 verified
Raw History Blame Contribute Delete
1.79 kB
-- =============================================================================
-- Fix: PGRST205 "Could not find the table 'public.simulation_runs' in the schema cache"
-- =============================================================================
-- 1. Open Supabase Dashboard β†’ your project β†’ SQL Editor β†’ New query.
-- 2. Paste and run this entire script.
-- 3. If the API still errors after ~1 minute, run the last line alone to reload PostgREST.
-- 4. Create Storage bucket "reports" (private) under Storage if you use report files.
-- =============================================================================
create table if not exists public.simulation_runs (
id uuid primary key,
user_id text not null,
backend_task_id text,
report_id text,
status text not null default 'pending',
requirement_preview text,
report_storage_path text,
report_public_url text,
simulation_id text,
project_id text,
error_message text,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create index if not exists simulation_runs_user_id_idx on public.simulation_runs (user_id);
create index if not exists simulation_runs_status_idx on public.simulation_runs (status);
alter table public.simulation_runs enable row level security;
drop policy if exists "simulation_runs_select_own" on public.simulation_runs;
create policy "simulation_runs_select_own"
on public.simulation_runs for select
to authenticated
using (auth.uid()::text = user_id);
-- If the table exists but REST still returns PGRST205, wait ~1 min or pause/resume the project
-- in Dashboard β†’ Settings. (Uncomment below only if your project supports it.)
-- select pg_notify('pgrst', 'reload schema');