mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-22 12:31:57 +02:00
Two tables behind running a catalog workflow on your own schedule. They are split because the keys differ: consent is one grant per (workflow, person), while one person may want several schedules for the same workflow. The subscription hangs off the grant by composite foreign key, so withdrawing consent takes the schedules with it. The scheduler side needed widening to hold them. A job was identified by `(workflowId, nodeId)`, which is what provisioning diffs and deprovisioning deletes by, and a per-person schedule has no node — several people hold their own schedules for the same workflow. `scheduled_job` gains a nullable, opaque `ownerId` that the scheduler only ever pairs with `taskType` and never interprets, so a feature can own jobs without the scheduler learning about the feature. An owner-scoped job deliberately records no `workflowId`: that column is a foreign key onto `workflow_published_version`, so it means "belongs to a published trigger", which these do not. The type makes passing one impossible. It also means nothing in the database removes these jobs when their owner goes, so callers must deprovision explicitly. The column is added with a raw `ALTER TABLE`: on SQLite the schema builder rebuilds the table, and `scheduled_task` cascades from it, so the rebuild would delete every queued occurrence on the instance. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2.9 KiB
2.9 KiB
workflow_subscription
Description
Table Definition
CREATE TABLE "workflow_subscription" ("id" varchar(36) PRIMARY KEY NOT NULL, "workflowId" varchar(36) NOT NULL, "userId" varchar NOT NULL, "cronExpression" varchar(255) NOT NULL, "timezone" varchar(255) NOT NULL, "inputs" text NOT NULL, "enabled" boolean NOT NULL DEFAULT (true), "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')), CONSTRAINT "FK_fbfc34f85307e8b012bccb9009d" FOREIGN KEY ("workflowId", "userId") REFERENCES "workflow_credential_binding" ("workflowId", "userId") ON DELETE CASCADE)
Columns
| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| createdAt | datetime(3) | STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') | false | |||
| cronExpression | varchar(255) | false | ||||
| enabled | boolean | true | false | |||
| id | varchar(36) | false | ||||
| inputs | TEXT | false | ||||
| timezone | varchar(255) | false | ||||
| updatedAt | datetime(3) | STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') | false | |||
| userId | varchar | false | workflow_credential_binding | |||
| workflowId | varchar(36) | false | workflow_credential_binding |
Constraints
| Name | Type | Definition |
|---|---|---|
| - (Foreign key ID: 0) | FOREIGN KEY | FOREIGN KEY (workflowId, userId) REFERENCES workflow_credential_binding (workflowId, userId) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE |
| id | PRIMARY KEY | PRIMARY KEY (id) |
| sqlite_autoindex_workflow_subscription_1 | PRIMARY KEY | PRIMARY KEY (id) |
Indexes
| Name | Definition |
|---|---|
| IDX_acff6aa3959530d3e9c117e99f | CREATE INDEX "IDX_acff6aa3959530d3e9c117e99f" ON "workflow_subscription" ("userId") |
| IDX_fbfc34f85307e8b012bccb9009 | CREATE INDEX "IDX_fbfc34f85307e8b012bccb9009" ON "workflow_subscription" ("workflowId", "userId") |
| sqlite_autoindex_workflow_subscription_1 | PRIMARY KEY (id) |
Relations
erDiagram
"workflow_subscription" }o--|| "workflow_credential_binding" : "FOREIGN KEY (workflowId, userId) REFERENCES workflow_credential_binding (workflowId, userId) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE"
"workflow_subscription" {
datetime_3_ createdAt
varchar_255_ cronExpression
boolean enabled
varchar_36_ id PK
TEXT inputs
varchar_255_ timezone
datetime_3_ updatedAt
varchar userId FK
varchar_36_ workflowId FK
}
"workflow_credential_binding" {
datetime_3_ consentAt
datetime_3_ createdAt
varchar_16_ status
datetime_3_ updatedAt
varchar userId PK
varchar_36_ workflowId PK
}
Generated by tbls