Index

public.agent_changesets

Description

Unpublished course content changes one user’s AI agent has staged in one course. Every agent write lands in the user’s open changeset for the course; nothing reaches students until the changeset is published, by the agent with the material:publish scope or by the user on the review page. No deleted_at: a changeset ends in a final status instead, and its rows stay as the record of what was staged.

Columns

Name Type Default Nullable Children Parents Comment
course_id uuid false public.courses The course every entity in the changeset belongs to.
created_at timestamp with time zone now() false Timestamp when the record was created.
expires_at timestamp with time zone false When an open changeset expires: 14 days after its last write.
id uuid uuid_generate_v4() false public.agent_changeset_calls public.agent_changeset_entities public.agent_changeset_preview_links A unique, stable identifier for the record.
published_at timestamp with time zone true When the changeset was published. Set exactly when status is published.
revision integer 0 false Incremented by every change to the staged entities. The review page publishes only the revision the user reviewed.
status agent_changeset_status ‘open’::agent_changeset_status false open while it takes writes; published, discarded and expired are final. An open changeset past expires_at stays open here until the next write to the course marks it expired, so it counts as open only while expires_at is in the future.
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 whose agent staged the changes. Only this user can publish or discard the changeset.

Viewpoints

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.

Constraints

Name Type Definition
agent_changesets_course_id_fkey FOREIGN KEY FOREIGN KEY (course_id) REFERENCES courses(id)
agent_changesets_course_id_not_null n NOT NULL course_id
agent_changesets_created_at_not_null n NOT NULL created_at
agent_changesets_expires_at_not_null n NOT NULL expires_at
agent_changesets_id_not_null n NOT NULL id
agent_changesets_pkey PRIMARY KEY PRIMARY KEY (id)
agent_changesets_published_has_published_at CHECK CHECK (((status = ‘published’::agent_changeset_status) = (published_at IS NOT NULL)))
agent_changesets_revision_not_null n NOT NULL revision
agent_changesets_status_not_null n NOT NULL status
agent_changesets_updated_at_not_null n NOT NULL updated_at
agent_changesets_user_id_fkey FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users(id)
agent_changesets_user_id_not_null n NOT NULL user_id

Indexes

Name Definition
agent_changesets_pkey CREATE UNIQUE INDEX agent_changesets_pkey ON public.agent_changesets USING btree (id)
idx_agent_changesets_user_course CREATE INDEX idx_agent_changesets_user_course ON public.agent_changesets USING btree (user_id, course_id, created_at DESC)
uq_agent_changesets_one_open_per_user_and_course CREATE UNIQUE INDEX uq_agent_changesets_one_open_per_user_and_course ON public.agent_changesets USING btree (user_id, course_id) WHERE (status = ‘open’::agent_changeset_status)

Triggers

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

Relations

er

Generated by tbls