Initial commit: Plataforma de Economía
Features: - React 18 + TypeScript frontend with Vite - Go + Gin backend API - PostgreSQL database - JWT authentication with refresh tokens - User management (admin panel) - Docker containerization - Progress tracking system - 4 economic modules structure Fixed: - Login with username or email - User creation without required email - Database nullable timestamps - API response field naming
This commit is contained in:
44
backend/migrations/001_init.sql
Normal file
44
backend/migrations/001_init.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
-- Enable UUID extension
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
-- Create usuarios table
|
||||
CREATE TABLE IF NOT EXISTS usuarios (
|
||||
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
nombre VARCHAR(255) NOT NULL,
|
||||
rol VARCHAR(50) DEFAULT 'estudiante',
|
||||
creado_en TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||
ultimo_login TIMESTAMP WITH TIME ZONE,
|
||||
activo BOOLEAN DEFAULT true
|
||||
);
|
||||
|
||||
-- Create ejercicios table
|
||||
CREATE TABLE IF NOT EXISTS ejercicios (
|
||||
id SERIAL PRIMARY KEY,
|
||||
modulo_numero INTEGER NOT NULL,
|
||||
titulo VARCHAR(255) NOT NULL,
|
||||
tipo VARCHAR(50) NOT NULL,
|
||||
contenido JSONB NOT NULL,
|
||||
orden INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
-- Create progreso_usuario table
|
||||
CREATE TABLE IF NOT EXISTS progreso_usuario (
|
||||
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
usuario_id UUID NOT NULL REFERENCES usuarios(id) ON DELETE CASCADE,
|
||||
modulo_numero INTEGER NOT NULL,
|
||||
ejercicio_id INTEGER REFERENCES ejercicios(id) ON DELETE SET NULL,
|
||||
completado BOOLEAN DEFAULT false,
|
||||
puntuacion INTEGER DEFAULT 0,
|
||||
intentos INTEGER DEFAULT 0,
|
||||
ultima_vez TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||
respuesta_json JSONB,
|
||||
UNIQUE(usuario_id, modulo_numero, ejercicio_id)
|
||||
);
|
||||
|
||||
-- Create indexes
|
||||
CREATE INDEX IF NOT EXISTS idx_usuarios_email ON usuarios(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_progreso_usuario_usuario ON progreso_usuario(usuario_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_ejercicios_modulo ON ejercicios(modulo_numero, orden);
|
||||
CREATE INDEX IF NOT EXISTS idx_progreso_usuario_ejercicio ON progreso_usuario(usuario_id, ejercicio_id);
|
||||
Reference in New Issue
Block a user