n8n/docs/generated/sqlite-schema/agent_files.md
Robin Braumann d292ca54ea refactor(core): Replace agent knowledge base binary data storage with blob storage (no-changelog)
Moves agent knowledge file bytes off BinaryDataService (N8N_DEFAULT_BINARY_DATA_MODE)
onto the @n8n/blob-storage ByteStore backends already used for agent execution logs,
governed by N8N_EXECUTION_DATA_STORAGE_MODE. Falls back to the local filesystem when
that mode is 'database', since no db-backed byte store exists.

Existing knowledge-file rows are deleted by the migration rather than migrated, as
the feature is at low rollout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 15:57:31 +02:00

2.7 KiB

agent_files

Description

Table Definition
CREATE TABLE "agent_files" ("id" varchar(16) PRIMARY KEY NOT NULL, "agentId" varchar(36) NOT NULL, "fileName" varchar(255) NOT NULL, "mimeType" varchar(255) NOT NULL, "fileSizeBytes" integer NOT NULL, "createdAt" datetime(3) NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), "updatedAt" datetime(3) NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), "storedAt" VARCHAR(2) NOT NULL DEFAULT 'fs' CONSTRAINT "CHK_agent_files_storedAt" CHECK("storedAt" IN ('fs', 's3', 'az')), CONSTRAINT "FK_aca4514cb500494b64356c2e164" FOREIGN KEY ("agentId") REFERENCES "agents" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)

Columns

Name Type Default Nullable Children Parents Comment
agentId varchar(36) false agents
createdAt datetime(3) STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') false
fileName varchar(255) false
fileSizeBytes INTEGER false
id varchar(16) false
mimeType varchar(255) false
storedAt VARCHAR(2) 'fs' false
updatedAt datetime(3) STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') false

Constraints

Name Type Definition
- CHECK CHECK("storedAt" IN ('fs', 's3', 'az'))
- (Foreign key ID: 0) FOREIGN KEY FOREIGN KEY (agentId) REFERENCES agents (id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE
id PRIMARY KEY PRIMARY KEY (id)
sqlite_autoindex_agent_files_1 PRIMARY KEY PRIMARY KEY (id)

Indexes

Name Definition
IDX_45dafc48fe2ce95eac30fc8ffd CREATE INDEX "IDX_45dafc48fe2ce95eac30fc8ffd" ON "agent_files" ("agentId", "createdAt")
IDX_agent_files_agentId_fileName CREATE UNIQUE INDEX "IDX_agent_files_agentId_fileName" ON "agent_files" ("agentId", "fileName")
sqlite_autoindex_agent_files_1 PRIMARY KEY (id)

Relations

erDiagram

"agent_files" }o--|| "agents" : "FOREIGN KEY (agentId) REFERENCES agents (id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE"

"agent_files" {
  varchar_36_ agentId FK
  datetime_3_ createdAt
  varchar_255_ fileName
  INTEGER fileSizeBytes
  varchar_16_ id PK
  varchar_255_ mimeType
  VARCHAR_2_ storedAt
  datetime_3_ updatedAt
}
"agents" {
  varchar_36_ activeVersionId FK
  datetime_3_ createdAt
  varchar_36_ id PK
  TEXT integrations
  varchar_128_ name
  varchar_255_ projectId FK
  TEXT schema
  TEXT skills
  TEXT tools
  datetime_3_ updatedAt
  varchar_36_ versionId
}

Generated by tbls