Append-only audit trail for the credit registration ledger. There is no retention sweep here, so anything stored survives the 90-day suotar_api_calls window; every Suotar payload written to details is scrubbed at write time, but only best-effort — email addresses, student-number-shaped digit runs, access tokens and the known person fields are removed, while a personal name quoted in a free-text error message is deliberately left in place because the study registry holds it anyway. Treat this table as holding personal data, not as a guaranteed personal-data-free store.
| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| actor_user_id | uuid | true | public.users | The acting user, set for admin_action and student_action events. | ||
| created_at | timestamp with time zone | now() | false | Timestamp when the record was created. | ||
| credit_registration_id | uuid | false | public.credit_registrations | The ledger row this event belongs to. Also the reference that replaces the identifiers removed from details, since the ledger row holds the real snapshot values. | ||
| deleted_at | timestamp with time zone | true | Timestamp when the record was deleted. Exists for convention and for personal data erasure; events are not soft-deleted in normal operation. | |||
| details | jsonb | true | Scrubbed per-item Suotar exchange, shaped {“request”: <the item we sent>, “response”: <the result or error we got>}. Both sides, because the admin drill-down renders them side by side and inferring the request afterwards is guesswork the moment anything is retried. Either key may be absent for non-Suotar events. Passed through scrub_suotar_body at every write site, never at read time. | |||
| error_code | credit_registration_error_code | true | The error code that caused this event, when there was one. | |||
| from_state | credit_registration_state | true | State before the change, for state_changed events. | |||
| id | uuid | uuid_generate_v4() | false | A unique, stable identifier for the record. | ||
| kind | credit_registration_event_kind | false | What kind of event this is. | |||
| message | text | true | Human-readable description, scrubbed of personal data before storage. | |||
| request_item_id | varchar(255) | true | The requestItemId this row went out under in the Suotar call behind the event. A fresh UUID per call, so this and suotar_api_calls.request_item_ids are the only way to find the row in either side’s log. | |||
| suotar_answer | suotar_answer | true | Whether Suotar answered this row, set by the registrar for every suotar_response event. Backfilled rows older than the 90-day suotar_api_calls sweep read refused even when they were unanswered, since the call reference that told them apart is gone. | |||
| suotar_answered_at | timestamp with time zone | true | When Suotar’s answer or refusal arrived, taken by the registrar. The timeline sorts on this where set, since events written in one transaction share created_at. NULL like suotar_endpoint. | |||
| suotar_api_call_id | uuid | true | public.suotar_api_calls | The batch call this event came out of, if any. | ||
| suotar_endpoint | suotar_endpoint | true | The Suotar endpoint whose answer or refusal this event records. Kept here because suotar_api_calls rows are swept after 90 days. NULL for events not about a Suotar exchange, and for older events whose call row was already swept. | |||
| suotar_requested_at | timestamp with time zone | true | When the request this event records left for Suotar, taken by the registrar. NULL like suotar_endpoint. | |||
| to_state | credit_registration_state | true | State after the change, for state_changed events. | |||
| 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. |
| Name | Definition |
|---|---|
| Credit registration | How a completed course module becomes a credit in the University of Helsinki study registry. Enrolment on the course is itself the student’s consent to register the credit; once a student number is proven to be theirs, one ledger row per completion is pushed to Sisu through Suotar and polled until the registry confirms the attainment. |
| Name | Type | Definition |
|---|---|---|
| credit_registration_events_actor_user_id_fkey | FOREIGN KEY | FOREIGN KEY (actor_user_id) REFERENCES users(id) |
| credit_registration_events_created_at_not_null | n | NOT NULL created_at |
| credit_registration_events_credit_registration_id_fkey | FOREIGN KEY | FOREIGN KEY (credit_registration_id) REFERENCES credit_registrations(id) ON DELETE RESTRICT |
| credit_registration_events_credit_registration_id_not_null | n | NOT NULL credit_registration_id |
| credit_registration_events_id_not_null | n | NOT NULL id |
| credit_registration_events_kind_not_null | n | NOT NULL kind |
| credit_registration_events_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| credit_registration_events_suotar_api_call_id_fkey | FOREIGN KEY | FOREIGN KEY (suotar_api_call_id) REFERENCES suotar_api_calls(id) ON DELETE SET NULL |
| credit_registration_events_updated_at_not_null | n | NOT NULL updated_at |
| Name | Definition |
|---|---|
| credit_registration_events_pkey | CREATE UNIQUE INDEX credit_registration_events_pkey ON public.credit_registration_events USING btree (id) |
| idx_credit_registration_events_api_call | CREATE INDEX idx_credit_registration_events_api_call ON public.credit_registration_events USING btree (suotar_api_call_id) WHERE (suotar_api_call_id IS NOT NULL) |
| idx_credit_registration_events_error_code | CREATE INDEX idx_credit_registration_events_error_code ON public.credit_registration_events USING btree (error_code, created_at DESC) WHERE (error_code IS NOT NULL) |
| idx_credit_registration_events_kind_created | CREATE INDEX idx_credit_registration_events_kind_created ON public.credit_registration_events USING btree (kind, created_at DESC) |
| idx_credit_registration_events_registration | CREATE INDEX idx_credit_registration_events_registration ON public.credit_registration_events USING btree (credit_registration_id, created_at DESC) |
| idx_credit_registration_events_request_item_id | CREATE INDEX idx_credit_registration_events_request_item_id ON public.credit_registration_events USING btree (request_item_id) WHERE (request_item_id IS NOT NULL) |
| Name | Definition |
|---|---|
| set_timestamp | CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.credit_registration_events FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp() |
Generated by tbls