-2

I need to create a custom admin tool, where I create tables and RLS rules outside the Supabase admin dashboard.

Is this possible?

Ken White
  • 123,280
  • 14
  • 225
  • 444
Solsiden
  • 673
  • 1
  • 7
  • 22

2 Answers2

1

You can use any database interaction tool to do this. I am using a nodejs database migration tool in one of my project along with a nodejs postgres client and I'm able to create tables, enable RLS and write policies with this. You can see all the files doing these tasks in my project here.

Andrew Smith
  • 1,224
  • 6
  • 9
0

Found out in the documentation for RLS, and in combination with the SQL editor (https://supabase.com/docs/guides/auth/row-level-security)

Wrap this bit in a database function with parameters

-- 1. Create table
create table profiles (
  id uuid references auth.users,
  avatar_url text
);

-- 2. Enable RLS
alter table profiles
  enable row level security;

-- 3. Create Policy
create policy "Public profiles are viewable by everyone."
  on profiles for select using (
    true
  );

Then call the function with rpc call

Solsiden
  • 673
  • 1
  • 7
  • 22