trading-platform-database-v2/ddl/schemas/education/tables/03-modules.sql
rckrdmrd 45e77e9a9c feat: Initial commit - Database schemas and scripts
DDL schemas for Trading Platform:
- User management
- Authentication
- Payments
- Education
- ML predictions
- Trading data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 04:30:23 -06:00

44 lines
1.5 KiB
SQL

-- =====================================================
-- TABLE: education.modules
-- =====================================================
-- Proyecto: OrbiQuant IA (Trading Platform)
-- Módulo: OQI-002 - Education
-- Especificación: ET-EDU-001-database.md
-- =====================================================
CREATE TABLE education.modules (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
-- Relación con curso
course_id UUID NOT NULL REFERENCES education.courses(id) ON DELETE CASCADE,
-- Información básica
title VARCHAR(200) NOT NULL,
description TEXT,
-- Ordenamiento
display_order INTEGER NOT NULL DEFAULT 0,
-- Metadata
duration_minutes INTEGER,
-- Control de acceso
is_locked BOOLEAN DEFAULT false, -- Requiere completar módulos anteriores
unlock_after_module_id UUID REFERENCES education.modules(id) ON DELETE SET NULL,
-- Metadata
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT unique_course_order UNIQUE(course_id, display_order)
);
-- Índices
CREATE INDEX idx_modules_course ON education.modules(course_id);
CREATE INDEX idx_modules_order ON education.modules(course_id, display_order);
-- Comentarios
COMMENT ON TABLE education.modules IS 'Módulos que agrupan lecciones dentro de un curso';
COMMENT ON COLUMN education.modules.is_locked IS 'Si requiere completar módulos anteriores para desbloquearse';
COMMENT ON COLUMN education.modules.unlock_after_module_id IS 'Módulo que debe completarse antes de acceder a este';