Index

public.course_credit_registration_consents

Description

Per (user, course) consent to register completions into the study registry. One consent covers every module of the course. No row means never asked, which is what makes the course-start dialog appear; consent_given = false means asked and declined, which must not re-ask on every page load.

Columns

Name Type Default Nullable Children Parents Comment
asked_at timestamp with time zone now() false When the student was first asked.
consent_given boolean false The current answer. Flipping it stamps the corresponding timestamp and leaves the other one intact, so gave-then-withdrew history survives in the row.
consent_given_at timestamp with time zone true When consent was last given.
consent_withdrawn_at timestamp with time zone true When consent was last withdrawn. Withdrawal stops future submissions and abandons in-flight ones; it cannot un-register anything already in Sisu.
course_id uuid false public.courses The course the consent covers, including all of its modules.
created_at timestamp with time zone now() false Timestamp when the record was created.
deleted_at timestamp with time zone true Timestamp when the record was deleted. If null, the record is not deleted.
id uuid uuid_generate_v4() false A unique, stable identifier for the record.
updated_at timestamp with time zone now() false Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.
user_id uuid false public.users The student who was asked.

Viewpoints

Name Definition
Credit registration How a completed course module becomes a credit in the University of Helsinki study registry. Once the student has consented for the course and holds a student number proven to be theirs, one ledger row per completion is pushed to Sisu through Suotar and polled until the registry confirms the attainment.

Constraints

Name Type Definition
course_credit_registration_consents_asked_at_not_null n NOT NULL asked_at
course_credit_registration_consents_consent_given_not_null n NOT NULL consent_given
course_credit_registration_consents_course_id_fkey FOREIGN KEY FOREIGN KEY (course_id) REFERENCES courses(id)
course_credit_registration_consents_course_id_not_null n NOT NULL course_id
course_credit_registration_consents_created_at_not_null n NOT NULL created_at
course_credit_registration_consents_flag_timestamp CHECK CHECK (
CASE
WHEN consent_given THEN (consent_given_at IS NOT NULL)
ELSE (consent_withdrawn_at IS NOT NULL)
END)
course_credit_registration_consents_id_not_null n NOT NULL id
course_credit_registration_consents_pkey PRIMARY KEY PRIMARY KEY (id)
course_credit_registration_consents_updated_at_not_null n NOT NULL updated_at
course_credit_registration_consents_user_id_fkey FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users(id)
course_credit_registration_consents_user_id_not_null n NOT NULL user_id

Indexes

Name Definition
course_credit_registration_consents_pkey CREATE UNIQUE INDEX course_credit_registration_consents_pkey ON public.course_credit_registration_consents USING btree (id)
uq_course_credit_registration_consents_user_course CREATE UNIQUE INDEX uq_course_credit_registration_consents_user_course ON public.course_credit_registration_consents USING btree (user_id, course_id, deleted_at) NULLS NOT DISTINCT

Triggers

Name Definition
set_timestamp CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.course_credit_registration_consents FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp()

Relations

er

Generated by tbls