This commit is contained in:
2026-04-02 14:29:36 +02:00
parent a270deb2db
commit 039fa0bc80
54 changed files with 4944 additions and 170 deletions

View File

@@ -0,0 +1,37 @@
-- Profiles table (extends Supabase auth.users)
create table profiles (
id uuid primary key references auth.users(id) on delete cascade,
display_name text,
locale text not null default 'en',
currency text not null default 'EUR',
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
alter table profiles enable row level security;
create policy "Users can read own profile"
on profiles for select
using (id = auth.uid());
create policy "Users can update own profile"
on profiles for update
using (id = auth.uid())
with check (id = auth.uid());
create policy "Users can insert own profile"
on profiles for insert
with check (id = auth.uid());
-- Auto-create profile on user signup
create or replace function handle_new_user()
returns trigger as $$
begin
insert into profiles (id) values (new.id);
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row execute function handle_new_user();