Crear las tablas — copia y pega este SQL
En Supabase ve a SQL Editor → New query y pega todo este código, luego presiona Run:
-- Tabla alumnos
CREATE TABLE alumnos (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
codigo text UNIQUE,
nombre text NOT NULL,
fecha_nacimiento date,
edad integer,
deporte text,
plan text,
nombre_padre text,
celular text,
distrito text,
experiencia text,
nutricion boolean DEFAULT false,
psicologia boolean DEFAULT false,
estado text DEFAULT 'Activo',
created_at timestamptz DEFAULT now()
);
-- Tabla leads CRM
CREATE TABLE leads (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
nombre text NOT NULL,
celular text,
deporte text,
estado text DEFAULT 'Contactado',
edad_hijo integer,
distrito text,
notas text,
created_at timestamptz DEFAULT now()
);
-- Tabla mensualidades
CREATE TABLE mensualidades (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
alumno_id uuid REFERENCES alumnos(id),
monto numeric,
vencimiento date,
pagado boolean DEFAULT false,
fecha_pago date,
created_at timestamptz DEFAULT now()
);
-- Tabla uniformes
CREATE TABLE uniformes (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
alumno_id uuid REFERENCES alumnos(id),
talla text,
estado text DEFAULT 'Pendiente',
fecha_pedido date DEFAULT CURRENT_DATE,
created_at timestamptz DEFAULT now()
);
-- Tabla entrenadores
CREATE TABLE entrenadores (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
nombre text NOT NULL,
area text,
horas_mes integer DEFAULT 0,
estado text DEFAULT 'Activo',
created_at timestamptz DEFAULT now()
);
-- Tabla asistencia
CREATE TABLE asistencia (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
alumno_id uuid REFERENCES alumnos(id),
fecha date DEFAULT CURRENT_DATE,
presente boolean DEFAULT true,
created_at timestamptz DEFAULT now()
);
-- Tabla talentos
CREATE TABLE talentos (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
alumno_id uuid REFERENCES alumnos(id),
tecnica numeric,
fisico numeric,
actitud numeric,
equipo numeric,
mes text,
created_at timestamptz DEFAULT now()
);
-- Habilitar acceso público (para el HTML)
ALTER TABLE alumnos ENABLE ROW LEVEL SECURITY;
ALTER TABLE leads ENABLE ROW LEVEL SECURITY;
ALTER TABLE mensualidades ENABLE ROW LEVEL SECURITY;
ALTER TABLE uniformes ENABLE ROW LEVEL SECURITY;
ALTER TABLE entrenadores ENABLE ROW LEVEL SECURITY;
ALTER TABLE asistencia ENABLE ROW LEVEL SECURITY;
ALTER TABLE talentos ENABLE ROW LEVEL SECURITY;
CREATE POLICY "public_all" ON alumnos FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "public_all" ON leads FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "public_all" ON mensualidades FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "public_all" ON uniformes FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "public_all" ON entrenadores FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "public_all" ON asistencia FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "public_all" ON talentos FOR ALL USING (true) WITH CHECK (true);