diff --git a/backend/scripts/regen-schema.ts b/backend/scripts/regen-schema.ts index ed0ad24cc0..811aa63b0a 100644 --- a/backend/scripts/regen-schema.ts +++ b/backend/scripts/regen-schema.ts @@ -223,10 +223,8 @@ async function generateSQLFiles(pg: SupabaseDirectClient) { for (const policy of tableInfo.policies) { content += `DROP POLICY IF EXISTS "${policy.policy_name}" ON ${tableInfo.tableName};\n` content += `CREATE POLICY "${policy.policy_name}" ON ${tableInfo.tableName} ` - if (policy.role && policy.role !== 'public') - content += `TO ${policy.role} ` if (policy.command) content += `FOR ${policy.command} ` - + if (policy.role) content += `TO ${policy.role} ` if (policy.expression) content += `USING (${policy.expression}) ` if (policy.with_check) content += `WITH CHECK (${policy.with_check})` content += ';\n\n' diff --git a/backend/supabase/contract_embeddings.sql b/backend/supabase/contract_embeddings.sql index 4ee740689e..ab473671fe 100644 --- a/backend/supabase/contract_embeddings.sql +++ b/backend/supabase/contract_embeddings.sql @@ -11,7 +11,7 @@ alter table contract_embeddings enable row level security; drop policy if exists "admin write access" on contract_embeddings; -create policy "admin write access" on contract_embeddings to service_role for all; +create policy "admin write access" on contract_embeddings for all to service_role; drop policy if exists "public read" on contract_embeddings; diff --git a/backend/supabase/dashboard_groups.sql b/backend/supabase/dashboard_groups.sql index 48af744485..b97f79827a 100644 --- a/backend/supabase/dashboard_groups.sql +++ b/backend/supabase/dashboard_groups.sql @@ -17,9 +17,9 @@ alter table dashboard_groups enable row level security; drop policy if exists "Enable read access for admin" on dashboard_groups; -create policy "Enable read access for admin" on dashboard_groups to service_role for +create policy "Enable read access for admin" on dashboard_groups for select - using (true); + to service_role using (true); -- Indexes drop index if exists dashboard_groups_pkey; diff --git a/backend/supabase/dashboards.sql b/backend/supabase/dashboards.sql index f27b7f5d72..745f6b6ce0 100644 --- a/backend/supabase/dashboards.sql +++ b/backend/supabase/dashboards.sql @@ -26,9 +26,9 @@ alter table dashboards enable row level security; drop policy if exists "Enable read access for admin" on dashboards; -create policy "Enable read access for admin" on dashboards to service_role for +create policy "Enable read access for admin" on dashboards for select - using (true); + to service_role using (true); -- Indexes drop index if exists dashboards_pkey; diff --git a/backend/supabase/group_embeddings.sql b/backend/supabase/group_embeddings.sql index 729c07d5f5..b049a53ed8 100644 --- a/backend/supabase/group_embeddings.sql +++ b/backend/supabase/group_embeddings.sql @@ -15,7 +15,7 @@ alter table group_embeddings enable row level security; drop policy if exists "admin write access" on group_embeddings; -create policy "admin write access" on group_embeddings to service_role for all; +create policy "admin write access" on group_embeddings for all to service_role; drop policy if exists "public read" on group_embeddings; diff --git a/backend/supabase/group_invites.sql b/backend/supabase/group_invites.sql index 34ebbb10e0..e08e6b2f76 100644 --- a/backend/supabase/group_invites.sql +++ b/backend/supabase/group_invites.sql @@ -48,9 +48,9 @@ alter table group_invites enable row level security; drop policy if exists "Enable read access for admin" on group_invites; -create policy "Enable read access for admin" on group_invites to service_role for +create policy "Enable read access for admin" on group_invites for select - using (true); + to service_role using (true); -- Indexes drop index if exists group_invites_pkey; diff --git a/backend/supabase/manalinks.sql b/backend/supabase/manalinks.sql index 9cce08cbbe..4fe95dffdd 100644 --- a/backend/supabase/manalinks.sql +++ b/backend/supabase/manalinks.sql @@ -15,9 +15,9 @@ alter table manalinks enable row level security; drop policy if exists "Enable read access for admin" on manalinks; -create policy "Enable read access for admin" on manalinks to service_role for +create policy "Enable read access for admin" on manalinks for select - using (true); + to service_role using (true); -- Indexes drop index if exists manalinks_pkey; diff --git a/backend/supabase/market_ads.sql b/backend/supabase/market_ads.sql index 5716eb4262..8cd4689c3c 100644 --- a/backend/supabase/market_ads.sql +++ b/backend/supabase/market_ads.sql @@ -19,7 +19,7 @@ alter table market_ads enable row level security; drop policy if exists "admin write access" on market_ads; -create policy "admin write access" on market_ads to service_role for all; +create policy "admin write access" on market_ads for all to service_role; drop policy if exists "public read" on market_ads; diff --git a/backend/supabase/old_post_comments.sql b/backend/supabase/old_post_comments.sql index a2e9c0feff..e564aa5688 100644 --- a/backend/supabase/old_post_comments.sql +++ b/backend/supabase/old_post_comments.sql @@ -30,9 +30,9 @@ alter table old_post_comments enable row level security; drop policy if exists "auth read" on old_post_comments; -create policy "auth read" on old_post_comments to service_role for +create policy "auth read" on old_post_comments for select - using (true); + to service_role using (true); drop policy if exists "user can insert" on old_post_comments; diff --git a/backend/supabase/old_posts.sql b/backend/supabase/old_posts.sql index 05502359c8..0934fb061e 100644 --- a/backend/supabase/old_posts.sql +++ b/backend/supabase/old_posts.sql @@ -35,9 +35,9 @@ alter table old_posts enable row level security; drop policy if exists "admin read" on old_posts; -create policy "admin read" on old_posts to service_role for +create policy "admin read" on old_posts for select - using (true); + to service_role using (true); -- Indexes drop index if exists posts_pkey; diff --git a/backend/supabase/topic_embeddings.sql b/backend/supabase/topic_embeddings.sql index 527884b1f4..a2a8933248 100644 --- a/backend/supabase/topic_embeddings.sql +++ b/backend/supabase/topic_embeddings.sql @@ -11,7 +11,7 @@ alter table topic_embeddings enable row level security; drop policy if exists "admin write access" on topic_embeddings; -create policy "admin write access" on topic_embeddings to service_role for all; +create policy "admin write access" on topic_embeddings for all to service_role; drop policy if exists "public read" on topic_embeddings; diff --git a/backend/supabase/user_contract_metrics.sql b/backend/supabase/user_contract_metrics.sql index 56b4173a4a..5bde2b26ca 100644 --- a/backend/supabase/user_contract_metrics.sql +++ b/backend/supabase/user_contract_metrics.sql @@ -26,9 +26,9 @@ select drop policy if exists "read for admin" on user_contract_metrics; -create policy "read for admin" on user_contract_metrics to service_role for +create policy "read for admin" on user_contract_metrics for select - using (true); + to service_role using (true); -- Indexes drop index if exists user_contract_metrics_pkey; diff --git a/backend/supabase/user_embeddings.sql b/backend/supabase/user_embeddings.sql index 2d8ed9a15e..c46ab7b2c5 100644 --- a/backend/supabase/user_embeddings.sql +++ b/backend/supabase/user_embeddings.sql @@ -13,7 +13,7 @@ alter table user_embeddings enable row level security; drop policy if exists "admin write access" on user_embeddings; -create policy "admin write access" on user_embeddings to service_role for all; +create policy "admin write access" on user_embeddings for all to service_role; drop policy if exists "public read" on user_embeddings;