Files uploaded to be named in an exercise answer, bound to the uploader and the exercise so a submit can verify the naming. Membership in this table is what scopes the answer upload reaper: the reaper must never consider any other file_uploads row. file_uploads is shared with CMS media, organization images and certificates, which have no binding here, so a reaper widened to file_uploads would silently delete real user data. This narrow scope is a load-bearing safety property, not an optimization. Retention is per origin.
| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| created_at | timestamp with time zone | now() | false | Timestamp when the record was created. The reaper’s retention window is measured from this. | ||
| deleted_at | timestamp with time zone | true | Timestamp when the record was deleted. Set by the reaper, and kept rather than hard-deleted so a submit naming a reaped file can be answered with upload_expired instead of unknown_upload. | |||
| exercise_id | uuid | false | public.exercises | The exercise the file was uploaded for. A submit naming this file for any other exercise is rejected. | ||
| file_upload_id | uuid | false | public.file_uploads | The uploaded file. | ||
| id | uuid | uuid_generate_v4() | false | A unique, stable identifier for the record. | ||
| origin | answer_upload_origin | false | The upload channel that created the row. Selects the reaper’s retention window: one hour for native_client, seven days for iframe. | |||
| 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 user who uploaded the file. A submit by any other user is rejected. |
| Name | Type | Definition |
|---|---|---|
| exercise_answer_uploads_exercise_id_fkey | FOREIGN KEY | FOREIGN KEY (exercise_id) REFERENCES exercises(id) |
| exercise_answer_uploads_file_upload_id_fkey | FOREIGN KEY | FOREIGN KEY (file_upload_id) REFERENCES file_uploads(id) |
| exercise_answer_uploads_origin_not_null | n | NOT NULL origin |
| exercise_answer_uploads_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| exercise_answer_uploads_user_id_fkey | FOREIGN KEY | FOREIGN KEY (user_id) REFERENCES users(id) |
| exercise_service_client_uploads_created_at_not_null | n | NOT NULL created_at |
| exercise_service_client_uploads_exercise_id_not_null | n | NOT NULL exercise_id |
| exercise_service_client_uploads_file_upload_id_not_null | n | NOT NULL file_upload_id |
| exercise_service_client_uploads_id_not_null | n | NOT NULL id |
| exercise_service_client_uploads_updated_at_not_null | n | NOT NULL updated_at |
| exercise_service_client_uploads_user_id_not_null | n | NOT NULL user_id |
| Name | Definition |
|---|---|
| exercise_answer_uploads_pkey | CREATE UNIQUE INDEX exercise_answer_uploads_pkey ON public.exercise_answer_uploads USING btree (id) |
| idx_exercise_answer_uploads_created | CREATE INDEX idx_exercise_answer_uploads_created ON public.exercise_answer_uploads USING btree (created_at) WHERE (deleted_at IS NULL) |
| idx_exercise_answer_uploads_lookup | CREATE INDEX idx_exercise_answer_uploads_lookup ON public.exercise_answer_uploads USING btree (exercise_id, user_id) WHERE (deleted_at IS NULL) |
| uq_exercise_answer_uploads_file_upload_id | CREATE UNIQUE INDEX uq_exercise_answer_uploads_file_upload_id ON public.exercise_answer_uploads USING btree (file_upload_id, deleted_at) NULLS NOT DISTINCT |
| Name | Definition |
|---|---|
| set_timestamp | CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.exercise_answer_uploads FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp() |
Generated by tbls