n8n/docs/generated/sqlite-schema/activity_event.md
Arvin Ansari 605247262a
feat(core): Let the agent read past the activity window (no-changelog)
Adds the `activity` tool. `list` reads further back than the window the agent
is handed, or filtered to one kind of event or one resource; `expand` opens a
single entry and returns everything else the log knows about the same
resource. That is the read the deferred `(resourceType, resourceId, id)` index
now exists for, added in its own migration rather than up front.

Expanding never fetches the live resource. `workflows`, `executions` and
`credentials` already do that, with their own permission checks — so an
expansion names the call to make instead, and the entry carries the id to make
it with. A missing id comes back as `notFound` rather than an error: entries
are pruned, so a stale id the agent read from an earlier block is an ordinary
outcome, not a failure.

Closes a scoping hole this feature opened. The window read had no project
filter, so a conversation not bound to a project would have been shown
activity from every project on the instance, including ones the user cannot
open. Reads are now bounded by the conversation's project, or by the user's
accessible projects when there is none, and an entry with no project is
excluded outright — there is no way to prove it is in scope. An expand outside
that scope is indistinguishable from a pruned id.

Keeping deletions visible under that rule needed the writer to change too. A
`workflow-deleted` event fires after the sharing rows that would name its
project are gone, so the project is recalled from the log's own earlier
entries for the same resource; credential updates and deletes do the same.
Without it the entries most worth surfacing would have been silently dropped
by the new filter.

The tool is always loaded when the log is enabled, and absent entirely when it
is not. The activity block names it, so deferring it would price every expand
at search_tools plus load_tool.
2026-08-26 13:52:51 +02:00

3.3 KiB
Generated

activity_event

Description

Table Definition
CREATE TABLE "activity_event" ("id" integer PRIMARY KEY NOT NULL, "category" varchar(32) NOT NULL, "action" varchar(64) NOT NULL, "typeVersion" integer NOT NULL DEFAULT (1), "userId" varchar, "projectId" varchar(36), "resourceType" varchar(32), "resourceId" varchar(36), "resourceName" text, "data" text, "createdAt" datetime(3) NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), CONSTRAINT "FK_29654477f37189453b353d3f46a" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE SET NULL, CONSTRAINT "FK_6bf94d5542661d2e1b9e0c41436" FOREIGN KEY ("projectId") REFERENCES "project" ("id") ON DELETE CASCADE)

Columns

Name Type Default Nullable Children Parents Comment
action varchar(64) false
category varchar(32) false
createdAt datetime(3) STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') false
data TEXT true
id INTEGER false
projectId varchar(36) true project
resourceId varchar(36) true
resourceName TEXT true
resourceType varchar(32) true
typeVersion INTEGER 1 false
userId varchar true user

Constraints

Name Type Definition
- (Foreign key ID: 0) FOREIGN KEY FOREIGN KEY (projectId) REFERENCES project (id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE
- (Foreign key ID: 1) FOREIGN KEY FOREIGN KEY (userId) REFERENCES user (id) ON UPDATE NO ACTION ON DELETE SET NULL MATCH NONE
id PRIMARY KEY PRIMARY KEY (id)

Indexes

Name Definition
IDX_activity_event_project CREATE INDEX "IDX_activity_event_project" ON "activity_event" ("projectId", "id")
IDX_activity_event_resource CREATE INDEX "IDX_activity_event_resource" ON "activity_event" ("resourceType", "resourceId", "id")
IDX_activity_event_user CREATE INDEX "IDX_activity_event_user" ON "activity_event" ("userId", "id")

Relations

erDiagram

"activity_event" }o--o| "project" : "FOREIGN KEY (projectId) REFERENCES project (id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE"
"activity_event" }o--o| "user" : "FOREIGN KEY (userId) REFERENCES user (id) ON UPDATE NO ACTION ON DELETE SET NULL MATCH NONE"

"activity_event" {
  varchar_64_ action
  varchar_32_ category
  datetime_3_ createdAt
  TEXT data
  INTEGER id
  varchar_36_ projectId FK
  varchar_36_ resourceId
  TEXT resourceName
  varchar_32_ resourceType
  INTEGER typeVersion
  varchar userId FK
}
"project" {
  datetime_3_ createdAt
  varchar creatorId FK
  TEXT customTelemetryTags
  varchar_512_ description
  TEXT icon
  varchar_36_ id PK
  varchar_255_ name
  varchar_36_ type
  datetime_3_ updatedAt
}
"user" {
  datetime_3_ createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  varchar id PK
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  TEXT mfaRecoveryCodes
  TEXT mfaSecret
  varchar password
  TEXT personalizationAnswers
  varchar_128_ roleSlug FK
  TEXT settings
  datetime_3_ updatedAt
}

Generated by tbls