Index

public.exercise_task_spec_files

Description

The files an exercise task’s specs reference, as the exercise service declared them: the private spec’s in the editor’s current-state message, each derived spec’s in the response of the endpoint that produced it. The host cannot read a spec blob, so this table is the only thing that tells it a stored file is still in use. Rewritten per task and spec kind whenever that spec is stored, so dropping a file from a spec soft-deletes its row here and eventually makes the upload reapable. The kinds must be tracked apart because a derived spec can name a file the private spec never did – a service may upload during derivation through SpecRequest.upload_url, which is how tmc stores the template students download.

Columns

Name Type Default Nullable Children Parents Comment
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. Set when a save drops the file from the spec.
exercise_task_id uuid false public.exercise_tasks The task whose spec references the file.
file_upload_id uuid false public.file_uploads The referenced file.
id uuid uuid_generate_v4() false A unique, stable identifier for the record.
spec_kind exercise_spec_kind false Which of the task’s three specs references the file.
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.

Constraints

Name Type Definition
exercise_task_spec_files_created_at_not_null n NOT NULL created_at
exercise_task_spec_files_exercise_task_id_fkey FOREIGN KEY FOREIGN KEY (exercise_task_id) REFERENCES exercise_tasks(id)
exercise_task_spec_files_exercise_task_id_not_null n NOT NULL exercise_task_id
exercise_task_spec_files_file_upload_id_fkey FOREIGN KEY FOREIGN KEY (file_upload_id) REFERENCES file_uploads(id)
exercise_task_spec_files_file_upload_id_not_null n NOT NULL file_upload_id
exercise_task_spec_files_id_not_null n NOT NULL id
exercise_task_spec_files_pkey PRIMARY KEY PRIMARY KEY (id)
exercise_task_spec_files_spec_kind_not_null n NOT NULL spec_kind
exercise_task_spec_files_updated_at_not_null n NOT NULL updated_at

Indexes

Name Definition
exercise_task_spec_files_pkey CREATE UNIQUE INDEX exercise_task_spec_files_pkey ON public.exercise_task_spec_files USING btree (id)
idx_exercise_task_spec_files_file_upload CREATE INDEX idx_exercise_task_spec_files_file_upload ON public.exercise_task_spec_files USING btree (file_upload_id) WHERE (deleted_at IS NULL)
idx_exercise_task_spec_files_task CREATE INDEX idx_exercise_task_spec_files_task ON public.exercise_task_spec_files USING btree (exercise_task_id, spec_kind) WHERE (deleted_at IS NULL)

Triggers

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

Relations

er

Generated by tbls