Files
webshop/shop/supabase/migrations/20260624100000_create_companies_table.sql
DanielS 4e86ad7a9d
All checks were successful
Staging Build / build (push) Successful in 2m44s
Rename companies to partners and update UI
2026-06-24 22:29:51 +02:00

32 lines
950 B
SQL

-- Migration: companies table + company_id in users
-- 1. Tabelle companies erstellen
CREATE TABLE IF NOT EXISTS public.partners (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
-- RLS aktivieren
ALTER TABLE public.companies ENABLE ROW LEVEL SECURITY;
-- Policies
DROP POLICY IF EXISTS "Admins und Partner lesen Partner" ON public.partners;
DROP POLICY IF EXISTS "Service role kann alles" ON public.partners;
CREATE POLICY "Admins und Partner lesen Partner"
ON public.partners FOR SELECT
USING (auth.role() = 'authenticated');
CREATE POLICY "Service role kann alles"
ON public.partners FOR ALL
USING (true)
WITH CHECK (true);
-- 2. company_id zu public.users hinzufügen
ALTER TABLE public.users
ADD COLUMN IF NOT EXISTS partner_id UUID REFERENCES public.partners(id) ON DELETE SET NULL;
-- Reload Schema Cache
NOTIFY pgrst, 'reload schema';