-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-setup.sql
More file actions
94 lines (80 loc) · 2.82 KB
/
supabase-setup.sql
File metadata and controls
94 lines (80 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
-- Tabellen erstellen, falls sie noch nicht existieren
CREATE TABLE IF NOT EXISTS public.service_categories (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
sort_order INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS public.services (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
description TEXT,
duration TEXT,
price DECIMAL(10, 2) NOT NULL,
category_id TEXT REFERENCES public.service_categories(id),
sort_order INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Tabelle für Buchungen erstellen, falls sie noch nicht existiert
CREATE TABLE IF NOT EXISTS public.bookings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
booking_date DATE NOT NULL,
booking_time TEXT NOT NULL,
service_id TEXT REFERENCES public.services(id),
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
email TEXT NOT NULL,
phone TEXT NOT NULL,
notes TEXT,
status TEXT NOT NULL DEFAULT 'pending',
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- RLS aktivieren
ALTER TABLE public.service_categories ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.services ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.bookings ENABLE ROW LEVEL SECURITY;
-- Richtlinien für service_categories
CREATE POLICY "Service categories are viewable by everyone"
ON public.service_categories FOR SELECT
USING (true);
CREATE POLICY "Service categories are insertable by authenticated users only"
ON public.service_categories FOR INSERT
TO authenticated
WITH CHECK (true);
CREATE POLICY "Service categories are updatable by authenticated users only"
ON public.service_categories FOR UPDATE
TO authenticated
USING (true);
-- Richtlinien für services
CREATE POLICY "Services are viewable by everyone"
ON public.services FOR SELECT
USING (true);
CREATE POLICY "Services are insertable by authenticated users only"
ON public.services FOR INSERT
TO authenticated
WITH CHECK (true);
CREATE POLICY "Services are updatable by authenticated users only"
ON public.services FOR UPDATE
TO authenticated
USING (true);
-- Richtlinien für bookings
CREATE POLICY "Bookings are insertable by everyone"
ON public.bookings FOR INSERT
TO anon
WITH CHECK (true);
CREATE POLICY "Bookings are viewable by authenticated users only"
ON public.bookings FOR SELECT
TO authenticated
USING (true);
CREATE POLICY "Bookings are updatable by authenticated users only"
ON public.bookings FOR UPDATE
TO authenticated
USING (true);
-- Berechtigungen für anonyme Benutzer
GRANT SELECT ON public.service_categories TO anon;
GRANT SELECT ON public.services TO anon;
GRANT INSERT ON public.bookings TO anon;
-- Berechtigungen für authentifizierte Benutzer
GRANT ALL ON public.service_categories TO authenticated;
GRANT ALL ON public.services TO authenticated;
GRANT ALL ON public.bookings TO authenticated;