Inicio
Configurar Base de Datos
Para comenzar, necesitás configurar la conexión a Supabase. Si aún no tenés un proyecto, seguí las instrucciones debajo.
Pasos previos en Supabase
- Creá un proyecto en supabase.com
- Copiá la URL del proyecto y la clave anónima (anon key)
- Ejecutá el SQL que aparece abajo en el SQL Editor de Supabase
- Ingresá los datos de conexión aquí
SQL para crear las tablas
-- =============================================
-- CEBAS Asistencia - Esquema de Base de Datos
-- Ejecutar en SQL Editor de Supabase
-- =============================================
-- Cursos
CREATE TABLE IF NOT EXISTS courses (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Materias
CREATE TABLE IF NOT EXISTS subjects (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Alumnos
CREATE TABLE IF NOT EXISTS students (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
apellido TEXT NOT NULL,
nombre TEXT NOT NULL,
dni TEXT NOT NULL,
course_id UUID REFERENCES courses(id) ON DELETE CASCADE,
status TEXT DEFAULT 'activo' CHECK (status IN ('activo', 'inactivo')),
fecha_ingreso DATE DEFAULT CURRENT_DATE,
fecha_egreso DATE,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Horarios
CREATE TABLE IF NOT EXISTS schedule (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
course_id UUID REFERENCES courses(id) ON DELETE CASCADE,
subject_id UUID REFERENCES subjects(id) ON DELETE SET NULL,
day_of_week SMALLINT NOT NULL CHECK (day_of_week BETWEEN 1 AND 5),
hour_slot SMALLINT NOT NULL CHECK (hour_slot BETWEEN 1 AND 8),
start_time TIME NOT NULL,
end_time TIME NOT NULL,
is_recess BOOLEAN DEFAULT FALSE,
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(course_id, day_of_week, hour_slot)
);
-- Asistencia
CREATE TABLE IF NOT EXISTS attendance (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
student_id UUID REFERENCES students(id) ON DELETE CASCADE,
schedule_id UUID REFERENCES schedule(id) ON DELETE CASCADE,
date DATE NOT NULL,
present BOOLEAN DEFAULT FALSE,
hora_entrada TIME,
hora_salida TIME,
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(student_id, schedule_id, date)
);
-- Feriados
CREATE TABLE IF NOT EXISTS holidays (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
date DATE NOT NULL UNIQUE,
description TEXT,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Ausencias de docentes
CREATE TABLE IF NOT EXISTS teacher_absences (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
subject_id UUID REFERENCES subjects(id) ON DELETE CASCADE,
course_id UUID REFERENCES courses(id) ON DELETE CASCADE,
date DATE NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(subject_id, course_id, date)
);
-- Políticas RLS (habilitar acceso anónimo para simplificar)
ALTER TABLE courses ENABLE ROW LEVEL SECURITY;
ALTER TABLE subjects ENABLE ROW LEVEL SECURITY;
ALTER TABLE students ENABLE ROW LEVEL SECURITY;
ALTER TABLE schedule ENABLE ROW LEVEL SECURITY;
ALTER TABLE attendance ENABLE ROW LEVEL SECURITY;
ALTER TABLE holidays ENABLE ROW LEVEL SECURITY;
ALTER TABLE teacher_absences ENABLE ROW LEVEL SECURITY;
-- Permitir acceso completo con anon key
CREATE POLICY "Allow all on courses" ON courses FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow all on subjects" ON subjects FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow all on students" ON students FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow all on schedule" ON schedule FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow all on attendance" ON attendance FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow all on holidays" ON holidays FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow all on teacher_absences" ON teacher_absences FOR ALL USING (true) WITH CHECK (true);
-- =============================================
-- MIGRACIÓN: Si ya tenés las tablas creadas, ejecutá esto aparte
-- =============================================
ALTER TABLE attendance ADD COLUMN IF NOT EXISTS hora_entrada TIME;
ALTER TABLE attendance ADD COLUMN IF NOT EXISTS hora_salida TIME;
-- Justificaciones (ausencias justificadas)
CREATE TABLE IF NOT EXISTS justifications (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
student_id UUID REFERENCES students(id) ON DELETE CASCADE,
date DATE NOT NULL,
justificacion TEXT NOT NULL DEFAULT '',
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(student_id, date)
);
ALTER TABLE justifications ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Allow all on justifications" ON justifications FOR ALL USING (true) WITH CHECK (true);
-- Turno (mañana/vespertino) para cursos
ALTER TABLE courses ADD COLUMN IF NOT EXISTS turno TEXT DEFAULT 'mañana' CHECK (turno IN ('mañana', 'vespertino'));
Bienvenido al Sistema de Asistencia
Seleccioná una opción del menú para comenzar.
Tomar Asistencia
Registrar la presencia de alumnos
Alumnos
Gestionar el listado de alumnos
Reportes
Ver informes de inasistencias
Cursos
Materias
Feriados
Ausencias de Docentes
Conexión a Base de Datos
Desconectado