A full snapshot of a chapter, course module, course’s settings or course default review config after every save, from the web UI and from agents alike, like page_history for pages. The entity can be restored to any of these. No deleted_at: history is append-only.
| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| agent_call_id | uuid | true | public.agent_changeset_calls | For a change an agent made, the latest call that staged it before it was published; its client_name says which agent. Null for changes made in the web UI. | ||
| author_user_id | uuid | false | public.users | The user who made the change, directly or through an agent. | ||
| change_reason | entity_history_change_reason | false | Whether the entity was saved, deleted or restored from an earlier row. Course settings are never deleted. | |||
| course_id | uuid | false | public.courses | The course the entity belongs to. | ||
| created_at | timestamp with time zone | now() | false | Timestamp when the record was created. | ||
| entity_id | uuid | false | Id of the chapter, module or peer_or_self_review_configs row; the course id for course settings. | |||
| entity_type | content_entity_type | false | Which table entity_id points to, and which snapshot shape snapshot has. | |||
| id | uuid | uuid_generate_v4() | false | public.entity_history | A unique, stable identifier for the record. | |
| restored_from_id | uuid | true | public.entity_history | For a restore, the history row that was restored. | ||
| snapshot | jsonb | false | The entity’s fields after the change, in the snapshot shape agent changesets also use. | |||
| 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 |
|---|---|
| AI agent changesets | How a teacher’s AI agent edits course material through the MCP server without touching what students see. Every agent write is staged in the teacher’s open changeset for the course and reaches students only when the changeset is published; each call is logged with what it changed so that it can be reverted, and saves from the web UI and agents alike leave history. |
| Name | Type | Definition |
|---|---|---|
| entity_history_agent_call_id_fkey | FOREIGN KEY | FOREIGN KEY (agent_call_id) REFERENCES agent_changeset_calls(id) |
| entity_history_author_user_id_fkey | FOREIGN KEY | FOREIGN KEY (author_user_id) REFERENCES users(id) |
| entity_history_author_user_id_not_null | n | NOT NULL author_user_id |
| entity_history_change_reason_not_null | n | NOT NULL change_reason |
| entity_history_course_id_fkey | FOREIGN KEY | FOREIGN KEY (course_id) REFERENCES courses(id) |
| entity_history_course_id_not_null | n | NOT NULL course_id |
| entity_history_created_at_not_null | n | NOT NULL created_at |
| entity_history_entity_id_not_null | n | NOT NULL entity_id |
| entity_history_entity_type_has_history | CHECK | CHECK ((entity_type = ANY (ARRAY[‘chapter’::content_entity_type, ‘module’::content_entity_type, ‘course_settings’::content_entity_type, ‘course_default_review_config’::content_entity_type]))) |
| entity_history_entity_type_not_null | n | NOT NULL entity_type |
| entity_history_id_not_null | n | NOT NULL id |
| entity_history_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| entity_history_restore_has_source | CHECK | CHECK (((change_reason = ‘restored’::entity_history_change_reason) = (restored_from_id IS NOT NULL))) |
| entity_history_restored_from_id_fkey | FOREIGN KEY | FOREIGN KEY (restored_from_id) REFERENCES entity_history(id) |
| entity_history_snapshot_not_null | n | NOT NULL snapshot |
| entity_history_updated_at_not_null | n | NOT NULL updated_at |
| Name | Definition |
|---|---|
| entity_history_pkey | CREATE UNIQUE INDEX entity_history_pkey ON public.entity_history USING btree (id) |
| idx_entity_history_entity | CREATE INDEX idx_entity_history_entity ON public.entity_history USING btree (entity_id, created_at DESC) |
| Name | Definition |
|---|---|
| set_timestamp | CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.entity_history FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp() |
Generated by tbls