Files uploaded through POST /api/v0/files/{exercise_service_slug}, the route a teacher’s CMS editor and the playground upload through. Membership here is what scopes the abandoned-spec-upload reaper: the reaper must never consider any other file_uploads row. file_uploads is shared with CMS media, organization images, certificates and answer files, none of which are recorded 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. Only uploads made after this table existed are recorded, so files uploaded earlier are never reaped – the leak is closed going forward rather than retroactively.
| 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. If null, the record is not deleted. Set by the reaper when it retires the upload, which keeps the row as an audit trail of what was reclaimed. | |||
| exercise_service_slug | varchar(255) | false | The slug the file was uploaded under, kept for diagnosing what produced an abandoned upload. Not a foreign key: the playground uploads under the reserved slug “playground”, which names no exercise service, and a service can be deleted without invalidating the record of its uploads. | |||
| file_upload_id | uuid | false | public.file_uploads | The uploaded file. | ||
| 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. | ||
| uploaded_by_user | uuid | true | public.users | The uploader, when the route authenticated one. Null for an upload authorized by an upload claim instead of a session. |
| Name | Type | Definition |
|---|---|---|
| exercise_spec_uploads_created_at_not_null | n | NOT NULL created_at |
| exercise_spec_uploads_exercise_service_slug_not_null | n | NOT NULL exercise_service_slug |
| exercise_spec_uploads_file_upload_id_fkey | FOREIGN KEY | FOREIGN KEY (file_upload_id) REFERENCES file_uploads(id) |
| exercise_spec_uploads_file_upload_id_not_null | n | NOT NULL file_upload_id |
| exercise_spec_uploads_id_not_null | n | NOT NULL id |
| exercise_spec_uploads_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| exercise_spec_uploads_updated_at_not_null | n | NOT NULL updated_at |
| exercise_spec_uploads_uploaded_by_user_fkey | FOREIGN KEY | FOREIGN KEY (uploaded_by_user) REFERENCES users(id) |
| Name | Definition |
|---|---|
| exercise_spec_uploads_pkey | CREATE UNIQUE INDEX exercise_spec_uploads_pkey ON public.exercise_spec_uploads USING btree (id) |
| idx_exercise_spec_uploads_created | CREATE INDEX idx_exercise_spec_uploads_created ON public.exercise_spec_uploads USING btree (created_at) WHERE (deleted_at IS NULL) |
| uq_exercise_spec_uploads_file_upload_id | CREATE UNIQUE INDEX uq_exercise_spec_uploads_file_upload_id ON public.exercise_spec_uploads USING btree (file_upload_id, deleted_at) NULLS NOT DISTINCT |
| Name | Definition |
|---|---|
| set_timestamp | CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.exercise_spec_uploads FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp() |
Generated by tbls