Supabase backup
This commit is contained in:
committed by
github-actions[bot]
parent
4c3724f06c
commit
fef340e8e8
+80
-80
File diff suppressed because one or more lines are too long
+77
-26
@@ -59,13 +59,6 @@ CREATE EXTENSION IF NOT EXISTS "pgcrypto" WITH SCHEMA "extensions";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE EXTENSION IF NOT EXISTS "pgjwt" WITH SCHEMA "extensions";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE EXTENSION IF NOT EXISTS "supabase_vault" WITH SCHEMA "vault";
|
CREATE EXTENSION IF NOT EXISTS "supabase_vault" WITH SCHEMA "vault";
|
||||||
|
|
||||||
|
|
||||||
@@ -514,6 +507,61 @@ $$;
|
|||||||
|
|
||||||
ALTER FUNCTION "public"."validar_numero_ciclo_asignatura"() OWNER TO "postgres";
|
ALTER FUNCTION "public"."validar_numero_ciclo_asignatura"() OWNER TO "postgres";
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION "public"."validar_prerrequisito_asignatura"() RETURNS "trigger"
|
||||||
|
LANGUAGE "plpgsql"
|
||||||
|
AS $$
|
||||||
|
declare
|
||||||
|
v_plan uuid;
|
||||||
|
v_ciclo integer;
|
||||||
|
begin
|
||||||
|
|
||||||
|
if new.prerrequisito_asignatura_id is null then
|
||||||
|
return new;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
select
|
||||||
|
plan_estudio_id,
|
||||||
|
numero_ciclo
|
||||||
|
into
|
||||||
|
v_plan,
|
||||||
|
v_ciclo
|
||||||
|
from public.asignaturas
|
||||||
|
where id = new.prerrequisito_asignatura_id;
|
||||||
|
|
||||||
|
if not found then
|
||||||
|
raise exception
|
||||||
|
'La asignatura prerrequisito no existe';
|
||||||
|
end if;
|
||||||
|
|
||||||
|
if v_plan <> new.plan_estudio_id then
|
||||||
|
raise exception
|
||||||
|
'El prerrequisito debe pertenecer al mismo plan de estudio';
|
||||||
|
end if;
|
||||||
|
|
||||||
|
if new.numero_ciclo is null then
|
||||||
|
raise exception
|
||||||
|
'La asignatura debe tener numero_ciclo definido';
|
||||||
|
end if;
|
||||||
|
|
||||||
|
if v_ciclo is null then
|
||||||
|
raise exception
|
||||||
|
'El prerrequisito debe tener numero_ciclo definido';
|
||||||
|
end if;
|
||||||
|
|
||||||
|
if v_ciclo >= new.numero_ciclo then
|
||||||
|
raise exception
|
||||||
|
'El prerrequisito debe pertenecer a un ciclo menor';
|
||||||
|
end if;
|
||||||
|
|
||||||
|
return new;
|
||||||
|
|
||||||
|
end;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER FUNCTION "public"."validar_prerrequisito_asignatura"() OWNER TO "postgres";
|
||||||
|
|
||||||
SET default_tablespace = '';
|
SET default_tablespace = '';
|
||||||
|
|
||||||
SET default_table_access_method = "heap";
|
SET default_table_access_method = "heap";
|
||||||
@@ -578,11 +626,13 @@ CREATE TABLE IF NOT EXISTS "public"."asignaturas" (
|
|||||||
"asignatura_hash" "text" GENERATED ALWAYS AS ("encode"(SUBSTRING("extensions"."digest"(("id")::"text", 'sha512'::"text") FROM 1 FOR 12), 'hex'::"text")) STORED,
|
"asignatura_hash" "text" GENERATED ALWAYS AS ("encode"(SUBSTRING("extensions"."digest"(("id")::"text", 'sha512'::"text") FROM 1 FOR 12), 'hex'::"text")) STORED,
|
||||||
"estado" "public"."estado_asignatura" DEFAULT 'borrador'::"public"."estado_asignatura" NOT NULL,
|
"estado" "public"."estado_asignatura" DEFAULT 'borrador'::"public"."estado_asignatura" NOT NULL,
|
||||||
"criterios_de_evaluacion" "jsonb" DEFAULT '[]'::"jsonb" NOT NULL,
|
"criterios_de_evaluacion" "jsonb" DEFAULT '[]'::"jsonb" NOT NULL,
|
||||||
|
"prerrequisito_asignatura_id" "uuid",
|
||||||
CONSTRAINT "asignaturas_ciclo_chk" CHECK ((("numero_ciclo" IS NULL) OR ("numero_ciclo" > 0))),
|
CONSTRAINT "asignaturas_ciclo_chk" CHECK ((("numero_ciclo" IS NULL) OR ("numero_ciclo" > 0))),
|
||||||
CONSTRAINT "asignaturas_creditos_check" CHECK (("creditos" >= (0)::numeric)),
|
CONSTRAINT "asignaturas_creditos_check" CHECK (("creditos" >= (0)::numeric)),
|
||||||
CONSTRAINT "asignaturas_horas_academicas_check" CHECK ((("horas_academicas" IS NULL) OR ("horas_academicas" >= 0))),
|
CONSTRAINT "asignaturas_horas_academicas_check" CHECK ((("horas_academicas" IS NULL) OR ("horas_academicas" >= 0))),
|
||||||
CONSTRAINT "asignaturas_horas_independientes_check" CHECK ((("horas_independientes" IS NULL) OR ("horas_independientes" >= 0))),
|
CONSTRAINT "asignaturas_horas_independientes_check" CHECK ((("horas_independientes" IS NULL) OR ("horas_independientes" >= 0))),
|
||||||
CONSTRAINT "asignaturas_orden_celda_chk" CHECK ((("orden_celda" IS NULL) OR ("orden_celda" >= 0)))
|
CONSTRAINT "asignaturas_orden_celda_chk" CHECK ((("orden_celda" IS NULL) OR ("orden_celda" >= 0))),
|
||||||
|
CONSTRAINT "asignaturas_prerrequisito_self_check" CHECK ((("prerrequisito_asignatura_id" IS NULL) OR ("prerrequisito_asignatura_id" <> "id")))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -1132,6 +1182,10 @@ CREATE INDEX "asignaturas_plan_linea_ciclo_idx" ON "public"."asignaturas" USING
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE INDEX "asignaturas_prerrequisito_idx" ON "public"."asignaturas" USING "btree" ("prerrequisito_asignatura_id");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX "bibliografia_asignatura_idx" ON "public"."bibliografia_asignatura" USING "btree" ("asignatura_id");
|
CREATE INDEX "bibliografia_asignatura_idx" ON "public"."bibliografia_asignatura" USING "btree" ("asignatura_id");
|
||||||
|
|
||||||
|
|
||||||
@@ -1200,6 +1254,10 @@ CREATE OR REPLACE TRIGGER "trg_validar_numero_ciclo_asignatura" BEFORE INSERT OR
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE TRIGGER "trg_validar_prerrequisito_asignatura" BEFORE INSERT OR UPDATE OF "prerrequisito_asignatura_id", "numero_ciclo", "plan_estudio_id" ON "public"."asignaturas" FOR EACH ROW EXECUTE FUNCTION "public"."validar_prerrequisito_asignatura"();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE ONLY "public"."archivos"
|
ALTER TABLE ONLY "public"."archivos"
|
||||||
ADD CONSTRAINT "archivos_subido_por_fkey" FOREIGN KEY ("subido_por") REFERENCES "public"."usuarios_app"("id") ON DELETE SET NULL;
|
ADD CONSTRAINT "archivos_subido_por_fkey" FOREIGN KEY ("subido_por") REFERENCES "public"."usuarios_app"("id") ON DELETE SET NULL;
|
||||||
|
|
||||||
@@ -1235,6 +1293,11 @@ ALTER TABLE ONLY "public"."asignaturas"
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE ONLY "public"."asignaturas"
|
||||||
|
ADD CONSTRAINT "asignaturas_prerrequisito_asignatura_id_fkey" FOREIGN KEY ("prerrequisito_asignatura_id") REFERENCES "public"."asignaturas"("id") ON DELETE SET NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE ONLY "public"."bibliografia_asignatura"
|
ALTER TABLE ONLY "public"."bibliografia_asignatura"
|
||||||
ADD CONSTRAINT "bibliografia_asignatura_asignatura_id_fkey" FOREIGN KEY ("asignatura_id") REFERENCES "public"."asignaturas"("id") ON DELETE CASCADE;
|
ADD CONSTRAINT "bibliografia_asignatura_asignatura_id_fkey" FOREIGN KEY ("asignatura_id") REFERENCES "public"."asignaturas"("id") ON DELETE CASCADE;
|
||||||
|
|
||||||
@@ -1652,24 +1715,6 @@ GRANT USAGE ON SCHEMA "public" TO "service_role";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1753,6 +1798,12 @@ GRANT ALL ON FUNCTION "public"."validar_numero_ciclo_asignatura"() TO "service_r
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GRANT ALL ON FUNCTION "public"."validar_prerrequisito_asignatura"() TO "anon";
|
||||||
|
GRANT ALL ON FUNCTION "public"."validar_prerrequisito_asignatura"() TO "authenticated";
|
||||||
|
GRANT ALL ON FUNCTION "public"."validar_prerrequisito_asignatura"() TO "service_role";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user