Skip to content

Commit

Permalink
fix role generated syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sipec committed Jul 31, 2024
1 parent a9712e3 commit f5330eb
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 22 deletions.
4 changes: 1 addition & 3 deletions backend/scripts/regen-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion backend/supabase/contract_embeddings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions backend/supabase/dashboard_groups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions backend/supabase/dashboards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion backend/supabase/group_embeddings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions backend/supabase/group_invites.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions backend/supabase/manalinks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion backend/supabase/market_ads.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions backend/supabase/old_post_comments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions backend/supabase/old_posts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion backend/supabase/topic_embeddings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions backend/supabase/user_contract_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion backend/supabase/user_embeddings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit f5330eb

Please sign in to comment.