fix #46: Al generar asignaturas la IA también genera su sistema de evaluación
Deploy Function / deploy (push) Successful in 25s
Deploy Migrations to Production / deploy (push) Successful in 10s

This commit was merged in pull request #47.
This commit is contained in:
2026-03-04 17:48:23 -06:00
parent 994fb3c7bc
commit d7e232eec7
8 changed files with 167 additions and 20 deletions
+108 -3
View File
@@ -108,6 +108,16 @@ CREATE TYPE "public"."estado_conversacion" AS ENUM (
ALTER TYPE "public"."estado_conversacion" OWNER TO "postgres";
CREATE TYPE "public"."estado_mensaje_ia" AS ENUM (
'PROCESANDO',
'COMPLETADO',
'ERROR'
);
ALTER TYPE "public"."estado_mensaje_ia" OWNER TO "postgres";
CREATE TYPE "public"."estado_tarea_revision" AS ENUM (
'PENDIENTE',
'COMPLETADA',
@@ -523,6 +533,24 @@ CREATE TABLE IF NOT EXISTS "public"."archivos" (
ALTER TABLE "public"."archivos" OWNER TO "postgres";
CREATE TABLE IF NOT EXISTS "public"."asignatura_mensajes_ia" (
"id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
"enviado_por" "uuid" DEFAULT "auth"."uid"() NOT NULL,
"mensaje" "text" NOT NULL,
"campos" "text"[] DEFAULT '{}'::"text"[] NOT NULL,
"respuesta" "text",
"is_refusal" boolean DEFAULT false NOT NULL,
"propuesta" "jsonb",
"estado" "public"."estado_mensaje_ia" DEFAULT 'PROCESANDO'::"public"."estado_mensaje_ia" NOT NULL,
"fecha_creacion" timestamp without time zone DEFAULT "now"() NOT NULL,
"fecha_actualizacion" timestamp without time zone DEFAULT "now"() NOT NULL,
"conversacion_asignatura_id" "uuid" NOT NULL
);
ALTER TABLE "public"."asignatura_mensajes_ia" OWNER TO "postgres";
CREATE TABLE IF NOT EXISTS "public"."asignaturas" (
"id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
"plan_estudio_id" "uuid" NOT NULL,
@@ -546,6 +574,7 @@ CREATE TABLE IF NOT EXISTS "public"."asignaturas" (
"horas_academicas" integer,
"horas_independientes" integer,
"estado" "public"."estado_asignatura" DEFAULT 'borrador'::"public"."estado_asignatura" NOT NULL,
"criterios_de_evaluacion" "jsonb" DEFAULT '[]'::"jsonb" NOT NULL,
CONSTRAINT "asignaturas_ciclo_chk" CHECK ((("numero_ciclo" IS NULL) OR ("numero_ciclo" > 0))),
CONSTRAINT "asignaturas_creditos_check" CHECK (("creditos" >= (0)::numeric)),
CONSTRAINT "asignaturas_horas_academicas_check" CHECK ((("horas_academicas" IS NULL) OR ("horas_academicas" >= 0))),
@@ -675,10 +704,11 @@ ALTER TABLE "public"."estados_plan" OWNER TO "postgres";
CREATE TABLE IF NOT EXISTS "public"."estructuras_asignatura" (
"id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
"nombre" "text" NOT NULL,
"version" "text",
"definicion" "jsonb" DEFAULT '{}'::"jsonb" NOT NULL,
"creado_en" timestamp with time zone DEFAULT "now"() NOT NULL,
"actualizado_en" timestamp with time zone DEFAULT "now"() NOT NULL
"actualizado_en" timestamp with time zone DEFAULT "now"() NOT NULL,
"template_id" "text",
"tipo" "public"."tipo_estructura_plan"
);
@@ -763,6 +793,24 @@ CREATE TABLE IF NOT EXISTS "public"."notificaciones" (
ALTER TABLE "public"."notificaciones" OWNER TO "postgres";
CREATE TABLE IF NOT EXISTS "public"."plan_mensajes_ia" (
"id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
"enviado_por" "uuid" DEFAULT "auth"."uid"() NOT NULL,
"mensaje" "text" NOT NULL,
"campos" "text"[] DEFAULT '{}'::"text"[] NOT NULL,
"respuesta" "text",
"is_refusal" boolean DEFAULT false NOT NULL,
"propuesta" "jsonb",
"estado" "public"."estado_mensaje_ia" DEFAULT 'PROCESANDO'::"public"."estado_mensaje_ia" NOT NULL,
"fecha_creacion" timestamp without time zone DEFAULT "now"() NOT NULL,
"fecha_actualizacion" timestamp without time zone DEFAULT "now"() NOT NULL,
"conversacion_plan_id" "uuid" NOT NULL
);
ALTER TABLE "public"."plan_mensajes_ia" OWNER TO "postgres";
CREATE TABLE IF NOT EXISTS "public"."planes_estudio" (
"id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
"carrera_id" "uuid" NOT NULL,
@@ -789,7 +837,18 @@ CREATE TABLE IF NOT EXISTS "public"."planes_estudio" (
ALTER TABLE "public"."planes_estudio" OWNER TO "postgres";
CREATE OR REPLACE VIEW "public"."plantilla_plan" AS
CREATE OR REPLACE VIEW "public"."plantilla_asignatura" AS
SELECT "asignaturas"."id" AS "asignatura_id",
"struct"."id" AS "estructura_id",
"struct"."template_id"
FROM ("public"."asignaturas"
JOIN "public"."estructuras_asignatura" "struct" ON (("asignaturas"."estructura_id" = "struct"."id")));
ALTER TABLE "public"."plantilla_asignatura" OWNER TO "postgres";
CREATE OR REPLACE VIEW "public"."plantilla_plan" WITH ("security_invoker"='on') AS
SELECT "plan"."id" AS "plan_estudio_id",
"struct"."id" AS "estructura_id",
"struct"."template_id"
@@ -896,6 +955,11 @@ ALTER TABLE ONLY "public"."archivos"
ALTER TABLE ONLY "public"."asignatura_mensajes_ia"
ADD CONSTRAINT "asignatura_mensajes_ia_pkey" PRIMARY KEY ("id");
ALTER TABLE ONLY "public"."asignaturas"
ADD CONSTRAINT "asignaturas_pkey" PRIMARY KEY ("id");
@@ -991,6 +1055,11 @@ ALTER TABLE ONLY "public"."notificaciones"
ALTER TABLE ONLY "public"."plan_mensajes_ia"
ADD CONSTRAINT "plan_mensajes_ia_pkey" PRIMARY KEY ("id");
ALTER TABLE ONLY "public"."planes_estudio"
ADD CONSTRAINT "planes_estudio_pkey" PRIMARY KEY ("id");
@@ -1136,6 +1205,11 @@ ALTER TABLE ONLY "public"."archivos"
ALTER TABLE ONLY "public"."asignatura_mensajes_ia"
ADD CONSTRAINT "asignatura_mensajes_ia_conversacion_asignatura_id_fkey" FOREIGN KEY ("conversacion_asignatura_id") REFERENCES "public"."conversaciones_asignatura"("id") ON DELETE CASCADE;
ALTER TABLE ONLY "public"."asignaturas"
ADD CONSTRAINT "asignaturas_actualizado_por_fkey" FOREIGN KEY ("actualizado_por") REFERENCES "public"."usuarios_app"("id") ON DELETE SET NULL;
@@ -1246,6 +1320,11 @@ ALTER TABLE ONLY "public"."notificaciones"
ALTER TABLE ONLY "public"."plan_mensajes_ia"
ADD CONSTRAINT "plan_mensajes_ia_conversacion_plan_id_fkey" FOREIGN KEY ("conversacion_plan_id") REFERENCES "public"."conversaciones_plan"("id") ON DELETE CASCADE;
ALTER TABLE ONLY "public"."planes_estudio"
ADD CONSTRAINT "planes_estudio_actualizado_por_fkey" FOREIGN KEY ("actualizado_por") REFERENCES "public"."usuarios_app"("id") ON DELETE SET NULL;
@@ -1350,6 +1429,14 @@ ALTER PUBLICATION "supabase_realtime" OWNER TO "postgres";
ALTER PUBLICATION "supabase_realtime" ADD TABLE ONLY "public"."asignaturas";
ALTER PUBLICATION "supabase_realtime" ADD TABLE ONLY "public"."planes_estudio";
@@ -1688,6 +1775,12 @@ GRANT ALL ON TABLE "public"."archivos" TO "service_role";
GRANT ALL ON TABLE "public"."asignatura_mensajes_ia" TO "anon";
GRANT ALL ON TABLE "public"."asignatura_mensajes_ia" TO "authenticated";
GRANT ALL ON TABLE "public"."asignatura_mensajes_ia" TO "service_role";
GRANT ALL ON TABLE "public"."asignaturas" TO "anon";
GRANT ALL ON TABLE "public"."asignaturas" TO "authenticated";
GRANT ALL ON TABLE "public"."asignaturas" TO "service_role";
@@ -1772,12 +1865,24 @@ GRANT ALL ON TABLE "public"."notificaciones" TO "service_role";
GRANT ALL ON TABLE "public"."plan_mensajes_ia" TO "anon";
GRANT ALL ON TABLE "public"."plan_mensajes_ia" TO "authenticated";
GRANT ALL ON TABLE "public"."plan_mensajes_ia" TO "service_role";
GRANT ALL ON TABLE "public"."planes_estudio" TO "anon";
GRANT ALL ON TABLE "public"."planes_estudio" TO "authenticated";
GRANT ALL ON TABLE "public"."planes_estudio" TO "service_role";
GRANT ALL ON TABLE "public"."plantilla_asignatura" TO "anon";
GRANT ALL ON TABLE "public"."plantilla_asignatura" TO "authenticated";
GRANT ALL ON TABLE "public"."plantilla_asignatura" TO "service_role";
GRANT ALL ON TABLE "public"."plantilla_plan" TO "anon";
GRANT ALL ON TABLE "public"."plantilla_plan" TO "authenticated";
GRANT ALL ON TABLE "public"."plantilla_plan" TO "service_role";