SSG SCHWEIZ

Datenbankverbindung

Einmalige Einrichtung — danach läuft alles online für alle Benutzer.

Schritt 1 — SQL ausführen
Supabase → SQL Editor → einfügen → Run
create table if not exists users(id uuid default gen_random_uuid() primary key,company text,name text,email text unique,pw_hash text,role text default 'firma',approved boolean default false,created_at timestamptz default now()); create table if not exists deliveries(id uuid default gen_random_uuid() primary key,user_id uuid,company text,date text,material text,time text,qty text,vehicle text,forklift text default 'nein',notes text default '',status text default 'pending',created_at timestamptz default now(),updated_at timestamptz default now()); create table if not exists posts(id uuid default gen_random_uuid() primary key,user_id uuid,company text,subject text,body text,category text default 'info',created_at timestamptz default now()); create table if not exists change_requests(id uuid default gen_random_uuid() primary key,delivery_id uuid,user_id uuid,company text,reason text,proposed jsonb,status text default 'pending',created_at timestamptz default now()); create table if not exists backups(id uuid default gen_random_uuid() primary key,tag text,data jsonb,created_at timestamptz default now()); create table if not exists audit_log(id uuid default gen_random_uuid() primary key,user_email text,action text,details text,created_at timestamptz default now()); create table if not exists baustellen(id uuid default gen_random_uuid() primary key,name text,ort text default '',created_at timestamptz default now()); alter table deliveries add column if not exists baustelle text default ''; alter table baustellen enable row level security; do $$ begin if not exists(select 1 from pg_policies where tablename='baustellen' and policyname='all') then create policy "all" on baustellen for all using(true) with check(true);end if;end $$; alter table users enable row level security;alter table deliveries enable row level security;alter table posts enable row level security;alter table change_requests enable row level security;alter table audit_log enable row level security;alter table backups enable row level security; do $$ begin if not exists(select 1 from pg_policies where tablename='users' and policyname='all') then create policy "all" on users for all using(true) with check(true);end if;if not exists(select 1 from pg_policies where tablename='deliveries' and policyname='all') then create policy "all" on deliveries for all using(true) with check(true);end if;if not exists(select 1 from pg_policies where tablename='posts' and policyname='all') then create policy "all" on posts for all using(true) with check(true);end if;if not exists(select 1 from pg_policies where tablename='change_requests' and policyname='all') then create policy "all" on change_requests for all using(true) with check(true);end if;if not exists(select 1 from pg_policies where tablename='backups' and policyname='all') then create policy "all" on backups for all using(true) with check(true);end if;if not exists(select 1 from pg_policies where tablename='audit_log' and policyname='all') then create policy "all" on audit_log for all using(true) with check(true);end if;end $$;
Schritt 2 — API verbinden
Settings → API Keys → Werte kopieren
SSG SCHWEIZ
SSG Lieferverwaltung
Verbinde...