-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsupabase-setup.sql
More file actions
73 lines (62 loc) · 2.47 KB
/
supabase-setup.sql
File metadata and controls
73 lines (62 loc) · 2.47 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
-- Script simplificado para crear tabla de voluntarios en Supabase
-- Ejecutar este script completo en el SQL Editor de Supabase
-- 1. Crear la tabla
CREATE TABLE volunteers (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
phone TEXT,
city TEXT,
experience TEXT,
interests TEXT,
availability TEXT,
message TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- 2. Crear índices para mejor rendimiento
CREATE INDEX idx_volunteers_email ON volunteers(email);
CREATE INDEX idx_volunteers_city ON volunteers(city);
-- 3. Habilitar Row Level Security
ALTER TABLE volunteers ENABLE ROW LEVEL SECURITY;
-- 4. Crear política para permitir inserciones desde el formulario web
CREATE POLICY "Enable insert for all users" ON volunteers
FOR INSERT
WITH CHECK (true);
-- 5. Crear política para permitir lecturas solo para usuarios autenticados (opcional)
CREATE POLICY "Enable read for authenticated users only" ON volunteers
FOR SELECT
USING (auth.role() = 'authenticated');
-- ============================================
-- TABLA: python_route_registrations
-- ============================================
-- 1. Crear tabla para registros de Python Route
CREATE TABLE python_route_registrations (
id SERIAL PRIMARY KEY,
email TEXT NOT NULL,
name TEXT NOT NULL,
phone TEXT,
age INT,
province TEXT NOT NULL,
exact_location TEXT,
group_type TEXT NOT NULL,
workshop_interest TEXT NOT NULL,
programming_experience TEXT NOT NULL,
newsletter_consent BOOLEAN DEFAULT false,
data_protection_accepted BOOLEAN DEFAULT false,
additional_comments TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- 2. Crear índices para mejor rendimiento
CREATE INDEX idx_python_route_email ON python_route_registrations(email);
CREATE INDEX idx_python_route_province ON python_route_registrations(province);
CREATE INDEX idx_python_route_created_at ON python_route_registrations(created_at);
-- 3. Habilitar Row Level Security
ALTER TABLE python_route_registrations ENABLE ROW LEVEL SECURITY;
-- 4. Crear política para permitir inserciones desde el formulario web
CREATE POLICY "Enable insert for all users" ON python_route_registrations
FOR INSERT
WITH CHECK (true);
-- 5. Crear política para permitir lecturas solo para usuarios autenticados (opcional)
CREATE POLICY "Enable read for authenticated users only" ON python_route_registrations
FOR SELECT
USING (auth.role() = 'authenticated');