mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-19 16:55:02 +02:00
`projectId` was nullable, and a null one made the row unreadable: every read filters on that column, so an unattributed entry was written and then never surfaced to anyone. The column is now NOT NULL, and `ActivityEventInput` requires it. The nullable column existed for one case, and that case turns out to be fixable. `workflow-deleted` reaches a listener after the workflow row and its `shared_workflow` rows have cascaded away, so the project cannot be looked up at that point. But it can be captured before the delete: `workflow.service.ts` already resolves the workflow, already calls `ownershipService`, and already runs a `beforeWorkflowDeleted` hook whose stated purpose is capturing rows the delete is about to cascade away. Enriching the event is upstream work, tracked on the relay ticket. Instance-level credentials are not an exception either. `instance_credential_- assignment` maps a use slot to an ordinary credential that lives in a project; what is instance-level is the assignment, not the credential. Two test changes follow. The project-cascade test now writes to two projects and asserts only the deleted one's entries go, since it can no longer lean on an unattributed row surviving. And a new test confirms the column rejects an entry with no project.
3.2 KiB
Generated
3.2 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) NOT NULL, "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) | false | 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_user | CREATE INDEX "IDX_activity_event_user" ON "activity_event" ("userId", "id") |
Relations
erDiagram
"activity_event" }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