Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(admin): deliver signed instance audit webhooks

Tin2504c6567d1f
diff --git a/apps/api/drizzle/0072_instance_webhooks.sql b/apps/api/drizzle/0072_instance_webhooks.sql
new file mode 100644
index 000000000..3840f7641
--- /dev/null
+++ b/apps/api/drizzle/0072_instance_webhooks.sql
@@ -0,0 +1,24 @@
+CREATE TABLE "instance_webhook_delivery" (
+ "id" text PRIMARY KEY NOT NULL,
+ "webhook_id" text NOT NULL,
+ "payload" jsonb NOT NULL,
+ "state" text DEFAULT 'pending' NOT NULL,
+ "attempts" integer DEFAULT 0 NOT NULL,
+ "status_code" integer,
+ "error_code" text,
+ "next_attempt_at" timestamp DEFAULT (now() AT TIME ZONE 'utc') NOT NULL,
+ "created_at" timestamp DEFAULT (now() AT TIME ZONE 'utc') NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE "instance_webhook" (
+ "id" text PRIMARY KEY NOT NULL,
+ "url" text NOT NULL,
+ "categories" text[] NOT NULL,
+ "enabled" boolean DEFAULT true NOT NULL,
+ "signing_secret" text NOT NULL,
+ "created_at" timestamp DEFAULT (now() AT TIME ZONE 'utc') NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "instance_webhook_delivery" ADD CONSTRAINT "instance_webhook_delivery_webhook_id_instance_webhook_id_fk" FOREIGN KEY ("webhook_id") REFERENCES "public"."instance_webhook"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "instance_webhook_delivery_due_idx" ON "instance_webhook_delivery" USING btree ("state","next_attempt_at");--> statement-breakpoint
+CREATE INDEX "instance_webhook_delivery_history_idx" ON "instance_webhook_delivery" USING btree ("webhook_id","created_at" DESC NULLS LAST,"id" DESC NULLS LAST);
\ No newline at end of file
diff --git a/apps/api/drizzle/meta/0072_snapshot.json b/apps/api/drizzle/meta/0072_snapshot.json
new file mode 100644
index 000000000..e25d3b654
--- /dev/null
+++ b/apps/api/drizzle/meta/0072_snapshot.json
@@ -0,0 +1,5964 @@
+{
+ "id": "da7ed7c3-b6eb-4652-90f2-6f900d417fa0",
+ "prevId": "7ab4105f-964e-425f-a551-43895baf6683",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.activity": {
+ "name": "activity",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_data": {
+ "name": "event_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_user_name": {
+ "name": "external_user_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_user_avatar": {
+ "name": "external_user_avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_source": {
+ "name": "external_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_url": {
+ "name": "external_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "activity_task_id_idx": {
+ "name": "activity_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "activity_userId_idx": {
+ "name": "activity_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "activity_createdAt_idx": {
+ "name": "activity_createdAt_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "activity_task_id_task_id_fk": {
+ "name": "activity_task_id_task_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "activity_user_id_user_id_fk": {
+ "name": "activity_user_id_user_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "activity_task_external_source_external_url_unique": {
+ "name": "activity_task_external_source_external_url_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "task_id",
+ "external_source",
+ "external_url"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.admin_audit_log": {
+ "name": "admin_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_type": {
+ "name": "target_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_label": {
+ "name": "target_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "admin_audit_log_createdAt_idx": {
+ "name": "admin_audit_log_createdAt_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "admin_audit_log_actorUserId_idx": {
+ "name": "admin_audit_log_actorUserId_idx",
+ "columns": [
+ {
+ "expression": "actor_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "admin_audit_log_target_idx": {
+ "name": "admin_audit_log_target_idx",
+ "columns": [
+ {
+ "expression": "target_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "admin_audit_log_actor_user_id_user_id_fk": {
+ "name": "admin_audit_log_actor_user_id_user_id_fk",
+ "tableFrom": "admin_audit_log",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 86400000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 10
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_userId_idx": {
+ "name": "apikey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "apikey_reference_id_user_id_fk": {
+ "name": "apikey_reference_id_user_id_fk",
+ "tableFrom": "apikey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reference_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "apikey_user_id_user_id_fk": {
+ "name": "apikey_user_id_user_id_fk",
+ "tableFrom": "apikey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.asset": {
+ "name": "asset",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "activity_id": {
+ "name": "activity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "object_key": {
+ "name": "object_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'image'"
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'description'"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "asset_workspaceId_idx": {
+ "name": "asset_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_projectId_idx": {
+ "name": "asset_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_taskId_idx": {
+ "name": "asset_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_activityId_idx": {
+ "name": "asset_activityId_idx",
+ "columns": [
+ {
+ "expression": "activity_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_createdBy_idx": {
+ "name": "asset_createdBy_idx",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_draft_expiry_idx": {
+ "name": "asset_draft_expiry_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"asset\".\"task_id\" is null and \"asset\".\"surface\" in ('draft', 'draft-pending')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "asset_workspace_id_workspace_id_fk": {
+ "name": "asset_workspace_id_workspace_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_project_id_project_id_fk": {
+ "name": "asset_project_id_project_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_task_id_task_id_fk": {
+ "name": "asset_task_id_task_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_activity_id_activity_id_fk": {
+ "name": "asset_activity_id_activity_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "activity",
+ "columnsFrom": [
+ "activity_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_created_by_user_id_fk": {
+ "name": "asset_created_by_user_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "asset_object_key_unique": {
+ "name": "asset_object_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "object_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_event": {
+ "name": "billing_event",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_reminder_sent": {
+ "name": "billing_reminder_sent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reminder_type": {
+ "name": "reminder_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "billing_reminder_sent_workspaceId_idx": {
+ "name": "billing_reminder_sent_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "billing_reminder_sent_userId_idx": {
+ "name": "billing_reminder_sent_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "billing_reminder_sent_user_id_user_id_fk": {
+ "name": "billing_reminder_sent_user_id_user_id_fk",
+ "tableFrom": "billing_reminder_sent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "billing_reminder_sent_workspace_id_workspace_id_fk": {
+ "name": "billing_reminder_sent_workspace_id_workspace_id_fk",
+ "tableFrom": "billing_reminder_sent",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "billing_reminder_sent_user_type_unique": {
+ "name": "billing_reminder_sent_user_type_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "reminder_type"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.calendar_feed": {
+ "name": "calendar_feed",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_ids": {
+ "name": "label_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "time_zone": {
+ "name": "time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "calendar_feed_project_id_idx": {
+ "name": "calendar_feed_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "calendar_feed_project_id_project_id_fk": {
+ "name": "calendar_feed_project_id_project_id_fk",
+ "tableFrom": "calendar_feed",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "calendar_feed_token_unique": {
+ "name": "calendar_feed_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.column": {
+ "name": "column",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_final": {
+ "name": "is_final",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "column_projectId_idx": {
+ "name": "column_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "column_project_id_project_id_fk": {
+ "name": "column_project_id_project_id_fk",
+ "tableFrom": "column",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.comment": {
+ "name": "comment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "comment_task_idx": {
+ "name": "comment_task_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "comment_user_idx": {
+ "name": "comment_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "comment_task_id_task_id_fk": {
+ "name": "comment_task_id_task_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "comment_user_id_user_id_fk": {
+ "name": "comment_user_id_user_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field_definition": {
+ "name": "custom_field_definition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "required": {
+ "name": "required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_value": {
+ "name": "default_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "options": {
+ "name": "options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hidden_options": {
+ "name": "hidden_options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "custom_field_def_projectId_idx": {
+ "name": "custom_field_def_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "custom_field_definition_project_id_project_id_fk": {
+ "name": "custom_field_definition_project_id_project_id_fk",
+ "tableFrom": "custom_field_definition",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field_value": {
+ "name": "custom_field_value",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "custom_field_value_taskId_idx": {
+ "name": "custom_field_value_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "custom_field_value_fieldId_idx": {
+ "name": "custom_field_value_fieldId_idx",
+ "columns": [
+ {
+ "expression": "field_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "custom_field_value_task_id_task_id_fk": {
+ "name": "custom_field_value_task_id_task_id_fk",
+ "tableFrom": "custom_field_value",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "custom_field_value_field_id_custom_field_definition_id_fk": {
+ "name": "custom_field_value_field_id_custom_field_definition_id_fk",
+ "tableFrom": "custom_field_value",
+ "tableTo": "custom_field_definition",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_value_task_field_unique": {
+ "name": "custom_field_value_task_field_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "task_id",
+ "field_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.data_migration": {
+ "name": "data_migration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.device_code": {
+ "name": "device_code",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "device_code": {
+ "name": "device_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_polled_at": {
+ "name": "last_polled_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "polling_interval": {
+ "name": "polling_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "device_code_device_code_uidx": {
+ "name": "device_code_device_code_uidx",
+ "columns": [
+ {
+ "expression": "device_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "device_code_user_code_uidx": {
+ "name": "device_code_user_code_uidx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "device_code_user_id_idx": {
+ "name": "device_code_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "device_code_user_id_user_id_fk": {
+ "name": "device_code_user_id_user_id_fk",
+ "tableFrom": "device_code",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.external_link": {
+ "name": "external_link",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_id": {
+ "name": "integration_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "external_link_taskId_idx": {
+ "name": "external_link_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_integrationId_idx": {
+ "name": "external_link_integrationId_idx",
+ "columns": [
+ {
+ "expression": "integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_externalId_idx": {
+ "name": "external_link_externalId_idx",
+ "columns": [
+ {
+ "expression": "external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_resourceType_idx": {
+ "name": "external_link_resourceType_idx",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_deferred_issue_idx": {
+ "name": "external_link_deferred_issue_idx",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"external_link\".\"resource_type\" = 'issue' AND \"external_link\".\"metadata\" LIKE '%\"deferredIssueEdit\":%'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "external_link_task_id_task_id_fk": {
+ "name": "external_link_task_id_task_id_fk",
+ "tableFrom": "external_link",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "external_link_integration_id_integration_id_fk": {
+ "name": "external_link_integration_id_integration_id_fk",
+ "tableFrom": "external_link",
+ "tableTo": "integration",
+ "columnsFrom": [
+ "integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_import": {
+ "name": "github_import",
+ "schema": "",
+ "columns": {
+ "integration_id": {
+ "name": "integration_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "github_import_integration_id_integration_id_fk": {
+ "name": "github_import_integration_id_integration_id_fk",
+ "tableFrom": "github_import",
+ "tableTo": "integration",
+ "columnsFrom": [
+ "integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_integration": {
+ "name": "github_integration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_owner": {
+ "name": "repository_owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_name": {
+ "name": "repository_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installation_id": {
+ "name": "installation_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "github_integration_project_id_project_id_fk": {
+ "name": "github_integration_project_id_project_id_fk",
+ "tableFrom": "github_integration",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "github_integration_project_id_unique": {
+ "name": "github_integration_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.import_run": {
+ "name": "import_run",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "include_comments": {
+ "name": "include_comments",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "projects": {
+ "name": "projects",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heartbeat_at": {
+ "name": "heartbeat_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "import_run_workspace_created_idx": {
+ "name": "import_run_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_run_workspace_id_workspace_id_fk": {
+ "name": "import_run_workspace_id_workspace_id_fk",
+ "tableFrom": "import_run",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "import_run_user_id_user_id_fk": {
+ "name": "import_run_user_id_user_id_fk",
+ "tableFrom": "import_run",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.instance_role": {
+ "name": "instance_role",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "instance_role_name_unique": {
+ "name": "instance_role_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.instance_settings": {
+ "name": "instance_settings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "'instance'"
+ },
+ "instance_name": {
+ "name": "instance_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_enabled": {
+ "name": "registration_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "password_registration_enabled": {
+ "name": "password_registration_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "require_email_verification": {
+ "name": "require_email_verification",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_role_id": {
+ "name": "default_role_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_creation_restricted": {
+ "name": "workspace_creation_restricted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "disabled_integrations": {
+ "name": "disabled_integrations",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "instance_settings_default_role_id_instance_role_id_fk": {
+ "name": "instance_settings_default_role_id_instance_role_id_fk",
+ "tableFrom": "instance_settings",
+ "tableTo": "instance_role",
+ "columnsFrom": [
+ "default_role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.instance_webhook_delivery": {
+ "name": "instance_webhook_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "webhook_id": {
+ "name": "webhook_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "instance_webhook_delivery_due_idx": {
+ "name": "instance_webhook_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "instance_webhook_delivery_history_idx": {
+ "name": "instance_webhook_delivery_history_idx",
+ "columns": [
+ {
+ "expression": "webhook_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "instance_webhook_delivery_webhook_id_instance_webhook_id_fk": {
+ "name": "instance_webhook_delivery_webhook_id_instance_webhook_id_fk",
+ "tableFrom": "instance_webhook_delivery",
+ "tableTo": "instance_webhook",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.instance_webhook": {
+ "name": "instance_webhook",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "categories": {
+ "name": "categories",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "signing_secret": {
+ "name": "signing_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.integration": {
+ "name": "integration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "integration_projectId_idx": {
+ "name": "integration_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "integration_type_idx": {
+ "name": "integration_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_project_id_project_id_fk": {
+ "name": "integration_project_id_project_id_fk",
+ "tableFrom": "integration",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_project_type_unique": {
+ "name": "integration_project_type_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "type"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.invitation": {
+ "name": "invitation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_access": {
+ "name": "project_access",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'all'"
+ },
+ "project_ids": {
+ "name": "project_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ }
+ },
+ "indexes": {
+ "invitation_workspaceId_idx": {
+ "name": "invitation_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitation_email_idx": {
+ "name": "invitation_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitation_inviterId_idx": {
+ "name": "invitation_inviterId_idx",
+ "columns": [
+ {
+ "expression": "inviter_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitation_workspace_id_workspace_id_fk": {
+ "name": "invitation_workspace_id_workspace_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "invitation_inviter_id_user_id_fk": {
+ "name": "invitation_inviter_id_user_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "user",
+ "columnsFrom": [
+ "inviter_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.job_lease": {
+ "name": "job_lease",
+ "schema": "",
+ "columns": {
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner": {
+ "name": "owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.label": {
+ "name": "label",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "deletion_started_at": {
+ "name": "deletion_started_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "label_task_id_idx": {
+ "name": "label_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "label_workspace_id_idx": {
+ "name": "label_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "label_workspace_cascade_idx": {
+ "name": "label_workspace_cascade_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"label\".\"task_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "label_workspace_name_unique": {
+ "name": "label_workspace_name_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"label\".\"task_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "label_task_id_task_id_fk": {
+ "name": "label_task_id_task_id_fk",
+ "tableFrom": "label",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "label_workspace_id_workspace_id_fk": {
+ "name": "label_workspace_id_workspace_id_fk",
+ "tableFrom": "label",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_task_name_unique": {
+ "name": "label_task_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "task_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mcp_oauth_state": {
+ "name": "mcp_oauth_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "mcp_oauth_state_kind_key_uidx": {
+ "name": "mcp_oauth_state_kind_key_uidx",
+ "columns": [
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mcp_oauth_state_expiresAt_idx": {
+ "name": "mcp_oauth_state_expiresAt_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'info'"
+ },
+ "event_data": {
+ "name": "event_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_read": {
+ "name": "is_read",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_userId_idx": {
+ "name": "notification_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_role": {
+ "name": "workspace_role",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permission": {
+ "name": "permission",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "workspace_role_workspaceId_idx": {
+ "name": "workspace_role_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_role_role_idx": {
+ "name": "workspace_role_role_idx",
+ "columns": [
+ {
+ "expression": "role",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_role_workspace_id_workspace_id_fk": {
+ "name": "workspace_role_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_role",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project": {
+ "name": "project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'Layout'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "is_public": {
+ "name": "is_public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_task_number": {
+ "name": "last_task_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "background_object_key": {
+ "name": "background_object_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "background_mime_type": {
+ "name": "background_mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "background_version": {
+ "name": "background_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "project_background_object_key_idx": {
+ "name": "project_background_object_key_idx",
+ "columns": [
+ {
+ "expression": "background_object_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"project\".\"background_object_key\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_workspaceId_position_idx": {
+ "name": "project_workspaceId_position_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_workspace_id_workspace_id_fk": {
+ "name": "project_workspace_id_workspace_id_fk",
+ "tableFrom": "project",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_workspace_id_id_unique": {
+ "name": "project_workspace_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_team_id": {
+ "name": "active_team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impersonated_by": {
+ "name": "impersonated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oidc_sid": {
+ "name": "oidc_sid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "session_oidcSid_idx": {
+ "name": "session_oidcSid_idx",
+ "columns": [
+ {
+ "expression": "oidc_sid",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.storage_cleanup": {
+ "name": "storage_cleanup",
+ "schema": "",
+ "columns": {
+ "object_key": {
+ "name": "object_key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_relation": {
+ "name": "task_relation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "source_task_id": {
+ "name": "source_task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_task_id": {
+ "name": "target_task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relation_type": {
+ "name": "relation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "task_relation_source_idx": {
+ "name": "task_relation_source_idx",
+ "columns": [
+ {
+ "expression": "source_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_relation_target_idx": {
+ "name": "task_relation_target_idx",
+ "columns": [
+ {
+ "expression": "target_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_relation_source_task_id_task_id_fk": {
+ "name": "task_relation_source_task_id_task_id_fk",
+ "tableFrom": "task_relation",
+ "tableTo": "task",
+ "columnsFrom": [
+ "source_task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_relation_target_task_id_task_id_fk": {
+ "name": "task_relation_target_task_id_task_id_fk",
+ "tableFrom": "task_relation",
+ "tableTo": "task",
+ "columnsFrom": [
+ "target_task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_reminder_sent": {
+ "name": "task_reminder_sent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reminder_type": {
+ "name": "reminder_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "task_reminder_sent_taskId_idx": {
+ "name": "task_reminder_sent_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_reminder_sent_task_id_task_id_fk": {
+ "name": "task_reminder_sent_task_id_task_id_fk",
+ "tableFrom": "task_reminder_sent",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "task_reminder_sent_task_type_unique": {
+ "name": "task_reminder_sent_task_type_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "task_id",
+ "reminder_type"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task": {
+ "name": "task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "assignee_id": {
+ "name": "assignee_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'to-do'"
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'low'"
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recurrence": {
+ "name": "recurrence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "task_projectId_idx": {
+ "name": "task_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_project_scheduled_id_idx": {
+ "name": "task_project_scheduled_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"task\".\"start_date\" is not null or \"task\".\"due_date\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_dueDate_idx": {
+ "name": "task_dueDate_idx",
+ "columns": [
+ {
+ "expression": "due_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_assigneeId_idx": {
+ "name": "task_assigneeId_idx",
+ "columns": [
+ {
+ "expression": "assignee_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_columnId_idx": {
+ "name": "task_columnId_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_project_id_project_id_fk": {
+ "name": "task_project_id_project_id_fk",
+ "tableFrom": "task",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_assignee_id_user_id_fk": {
+ "name": "task_assignee_id_user_id_fk",
+ "tableFrom": "task",
+ "tableTo": "user",
+ "columnsFrom": [
+ "assignee_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "task_column_id_column_id_fk": {
+ "name": "task_column_id_column_id_fk",
+ "tableFrom": "task",
+ "tableTo": "column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "task_project_number_unique": {
+ "name": "task_project_number_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "number"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_count": {
+ "name": "member_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "team_workspaceId_idx": {
+ "name": "team_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_workspace_id_workspace_id_fk": {
+ "name": "team_workspace_id_workspace_id_fk",
+ "tableFrom": "team",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_member": {
+ "name": "team_member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "membership_key": {
+ "name": "membership_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "teamMember_teamId_idx": {
+ "name": "teamMember_teamId_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "teamMember_userId_idx": {
+ "name": "teamMember_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_member_team_id_team_id_fk": {
+ "name": "team_member_team_id_team_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_member_user_id_user_id_fk": {
+ "name": "team_member_user_id_user_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "team_member_membership_key_unique": {
+ "name": "team_member_membership_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "membership_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.time_entry": {
+ "name": "time_entry",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "time_entry_taskId_idx": {
+ "name": "time_entry_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "time_entry_userId_idx": {
+ "name": "time_entry_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "time_entry_task_id_task_id_fk": {
+ "name": "time_entry_task_id_task_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "time_entry_user_id_user_id_fk": {
+ "name": "time_entry_user_id_user_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.trial_grant": {
+ "name": "trial_grant",
+ "schema": "",
+ "columns": {
+ "email_hash": {
+ "name": "email_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "is_anonymous": {
+ "name": "is_anonymous",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "banned": {
+ "name": "banned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "ban_reason": {
+ "name": "ban_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ban_expires": {
+ "name": "ban_expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_verification_required": {
+ "name": "email_verification_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_avatar": {
+ "name": "user_avatar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "user_avatar_userId_idx": {
+ "name": "user_avatar_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_avatar_user_id_user_id_fk": {
+ "name": "user_avatar_user_id_user_id_fk",
+ "tableFrom": "user_avatar",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_avatar_user_id_unique": {
+ "name": "user_avatar_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_preference": {
+ "name": "user_notification_preference",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_enabled": {
+ "name": "email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_enabled": {
+ "name": "ntfy_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_server_url": {
+ "name": "ntfy_server_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ntfy_topic": {
+ "name": "ntfy_topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ntfy_token": {
+ "name": "ntfy_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gotify_enabled": {
+ "name": "gotify_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "gotify_server_url": {
+ "name": "gotify_server_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gotify_token": {
+ "name": "gotify_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_enabled": {
+ "name": "webhook_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "webhook_url": {
+ "name": "webhook_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_secret": {
+ "name": "webhook_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_assignment_enabled": {
+ "name": "task_assignment_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "task_comment_enabled": {
+ "name": "task_comment_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "task_status_change_enabled": {
+ "name": "task_status_change_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "due_date_reminder_enabled": {
+ "name": "due_date_reminder_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "due_date_reminder_lead_time_minutes": {
+ "name": "due_date_reminder_lead_time_minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1440
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_notification_preference_user_id_user_id_fk": {
+ "name": "user_notification_preference_user_id_user_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_preference_user_id_unique": {
+ "name": "user_notification_preference_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_workspace_project": {
+ "name": "user_notification_workspace_project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_rule_id": {
+ "name": "workspace_rule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "user_notification_workspace_project_ruleId_idx": {
+ "name": "user_notification_workspace_project_ruleId_idx",
+ "columns": [
+ {
+ "expression": "workspace_rule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_notification_workspace_project_projectId_idx": {
+ "name": "user_notification_workspace_project_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_notification_workspace_project_workspaceId_projectId_idx": {
+ "name": "user_notification_workspace_project_workspaceId_projectId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "unwp_workspaceId_workspaceRuleId_idx": {
+ "name": "unwp_workspaceId_workspaceRuleId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_rule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_notification_workspace_project_workspace_id_workspace_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_workspace_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_project_workspace_id_workspace_rule_id_user_notification_workspace_rule_workspace_id_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_workspace_rule_id_user_notification_workspace_rule_workspace_id_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "user_notification_workspace_rule",
+ "columnsFrom": [
+ "workspace_id",
+ "workspace_rule_id"
+ ],
+ "columnsTo": [
+ "workspace_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_project_workspace_id_project_id_project_workspace_id_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_project_id_project_workspace_id_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "project",
+ "columnsFrom": [
+ "workspace_id",
+ "project_id"
+ ],
+ "columnsTo": [
+ "workspace_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_workspace_project_rule_project_unique": {
+ "name": "user_notification_workspace_project_rule_project_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_rule_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_workspace_rule": {
+ "name": "user_notification_workspace_rule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "email_enabled": {
+ "name": "email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_enabled": {
+ "name": "ntfy_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "gotify_enabled": {
+ "name": "gotify_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "webhook_enabled": {
+ "name": "webhook_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "project_mode": {
+ "name": "project_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'all'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "user_notification_workspace_rule_userId_idx": {
+ "name": "user_notification_workspace_rule_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_notification_workspace_rule_workspaceId_idx": {
+ "name": "user_notification_workspace_rule_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_notification_workspace_rule_user_id_user_id_fk": {
+ "name": "user_notification_workspace_rule_user_id_user_id_fk",
+ "tableFrom": "user_notification_workspace_rule",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_rule_workspace_id_workspace_id_fk": {
+ "name": "user_notification_workspace_rule_workspace_id_workspace_id_fk",
+ "tableFrom": "user_notification_workspace_rule",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_workspace_rule_user_workspace_unique": {
+ "name": "user_notification_workspace_rule_user_workspace_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "workspace_id"
+ ]
+ },
+ "user_notification_workspace_rule_workspace_id_id_unique": {
+ "name": "user_notification_workspace_rule_workspace_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workflow_rule": {
+ "name": "workflow_rule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "workflow_rule_projectId_idx": {
+ "name": "workflow_rule_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workflow_rule_columnId_idx": {
+ "name": "workflow_rule_columnId_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workflow_rule_project_id_project_id_fk": {
+ "name": "workflow_rule_project_id_project_id_fk",
+ "tableFrom": "workflow_rule",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "workflow_rule_column_id_column_id_fk": {
+ "name": "workflow_rule_column_id_column_id_fk",
+ "tableFrom": "workflow_rule",
+ "tableTo": "column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace": {
+ "name": "workspace",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_by": {
+ "name": "archived_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "workspace_archived_by_user_id_fk": {
+ "name": "workspace_archived_by_user_id_fk",
+ "tableFrom": "workspace",
+ "tableTo": "user",
+ "columnsFrom": [
+ "archived_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_slug_unique": {
+ "name": "workspace_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_billing": {
+ "name": "workspace_billing",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "founding_free": {
+ "name": "founding_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creem_customer_id": {
+ "name": "creem_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creem_subscription_id": {
+ "name": "creem_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creem_product_id": {
+ "name": "creem_product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "billing_interval": {
+ "name": "billing_interval",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seats": {
+ "name": "seats",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "workspace_billing_workspaceId_idx": {
+ "name": "workspace_billing_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_billing_workspace_id_workspace_id_fk": {
+ "name": "workspace_billing_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_billing",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_billing_workspace_id_unique": {
+ "name": "workspace_billing_workspace_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id"
+ ]
+ },
+ "workspace_billing_creem_subscription_id_unique": {
+ "name": "workspace_billing_creem_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "creem_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_access": {
+ "name": "workspace_member_access",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_access": {
+ "name": "project_access",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'all'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "workspace_member_access_userId_idx": {
+ "name": "workspace_member_access_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_access_workspace_id_workspace_id_fk": {
+ "name": "workspace_member_access_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_member_access",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_access_user_id_user_id_fk": {
+ "name": "workspace_member_access_user_id_user_id_fk",
+ "tableFrom": "workspace_member_access",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_member_access_workspace_user_unique": {
+ "name": "workspace_member_access_workspace_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_project": {
+ "name": "workspace_member_project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "workspace_member_project_projectId_idx": {
+ "name": "workspace_member_project_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_project_user_id_user_id_fk": {
+ "name": "workspace_member_project_user_id_user_id_fk",
+ "tableFrom": "workspace_member_project",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_project_workspace_id_project_id_project_workspace_id_id_fk": {
+ "name": "workspace_member_project_workspace_id_project_id_project_workspace_id_id_fk",
+ "tableFrom": "workspace_member_project",
+ "tableTo": "project",
+ "columnsFrom": [
+ "workspace_id",
+ "project_id"
+ ],
+ "columnsTo": [
+ "workspace_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_member_project_workspace_user_project_unique": {
+ "name": "workspace_member_project_workspace_user_project_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "user_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member": {
+ "name": "workspace_member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "workspace_member_workspaceId_idx": {
+ "name": "workspace_member_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_member_userId_idx": {
+ "name": "workspace_member_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_workspace_id_workspace_id_fk": {
+ "name": "workspace_member_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_user_id_user_id_fk": {
+ "name": "workspace_member_user_id_user_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json
index 623095711..9828a2b67 100644
--- a/apps/api/drizzle/meta/_journal.json
+++ b/apps/api/drizzle/meta/_journal.json
@@ -505,6 +505,13 @@
"when": 1793128646236,
"tag": "0071_instance_settings",
"breakpoints": true
+ },
+ {
+ "idx": 72,
+ "version": "7",
+ "when": 1793129069447,
+ "tag": "0072_instance_webhooks",
+ "breakpoints": true
}
]
}
diff --git a/apps/api/src/admin/audit/record-admin-action.ts b/apps/api/src/admin/audit/record-admin-action.ts
index d5c661a68..0352c3430 100644
--- a/apps/api/src/admin/audit/record-admin-action.ts
+++ b/apps/api/src/admin/audit/record-admin-action.ts
@@ -1,6 +1,7 @@
import { sql } from "drizzle-orm";
import db, { schema } from "../../database";
import type { DbOrTx } from "../../project-access/db-or-tx";
+import { enqueueAuditWebhooks } from "../webhooks/enqueue-audit-webhooks";
import { sanitizeAuditMetadata } from "./sanitize-audit-metadata";
const MAX_USER_AGENT_LENGTH = 512;
@@ -25,7 +26,10 @@ export type AdminActionInput = {
export async function recordAdminAction(
input: AdminActionInput,
database: DbOrTx = db,
-) {
+): Promise<void> {
+ if (database === db) {
+ return db.transaction((tx) => recordAdminAction(input, tx));
+ }
const actorId = input.actorUserId;
const actor = (column: "id" | "name" | "email") =>
actorId
@@ -35,20 +39,24 @@ export async function recordAdminAction(
? (sanitizeAuditMetadata(input.metadata) as Record<string, unknown>)
: null;
- await database.insert(schema.adminAuditLogTable).values({
- // Resolved in the insert so a concurrently deleted actor yields NULL
- // instead of a foreign key error.
- actorUserId: actor("id"),
- actorName: actor("name"),
- actorEmail: actor("email"),
- action: input.action,
- targetType: input.targetType,
- targetId: input.targetId ?? null,
- targetLabel: input.targetLabel ?? null,
- metadata,
- ipAddress: input.ipAddress ?? null,
- userAgent: input.userAgent?.slice(0, MAX_USER_AGENT_LENGTH) ?? null,
- });
+ const [entry] = await database
+ .insert(schema.adminAuditLogTable)
+ .values({
+ // Resolved in the insert so a concurrently deleted actor yields NULL
+ // instead of a foreign key error.
+ actorUserId: actor("id"),
+ actorName: actor("name"),
+ actorEmail: actor("email"),
+ action: input.action,
+ targetType: input.targetType,
+ targetId: input.targetId ?? null,
+ targetLabel: input.targetLabel ?? null,
+ metadata,
+ ipAddress: input.ipAddress ?? null,
+ userAgent: input.userAgent?.slice(0, MAX_USER_AGENT_LENGTH) ?? null,
+ })
+ .returning({ id: schema.adminAuditLogTable.id });
+ if (entry) await enqueueAuditWebhooks(database, entry.id);
}
export default recordAdminAction;
diff --git a/apps/api/src/admin/index.ts b/apps/api/src/admin/index.ts
index 42123e6c7..c4163eb8a 100644
--- a/apps/api/src/admin/index.ts
+++ b/apps/api/src/admin/index.ts
@@ -24,6 +24,7 @@ import restoreWorkspace from "./controllers/restore-workspace";
import transferWorkspaceOwnership from "./controllers/transfer-workspace-ownership";
import updateWorkspaceMemberRole from "./controllers/update-workspace-member-role";
import adminRoleRoutes from "./role-routes";
+import adminWebhookRoutes from "./webhook-routes";
import adminSettingsRoutes from "./settings-routes";
import { getUserAccess } from "./roles/get-instance-access";
import { instanceAccessSchema } from "./roles/schema";
@@ -543,6 +544,7 @@ const admin = apiRouter()
.route("/users", adminUserAccountRoutes)
.route("/roles", adminRoleRoutes)
.route("/settings", adminSettingsRoutes)
+ .route("/webhooks", adminWebhookRoutes)
.route("/", adminUserSecurityRoutes);
export default admin;
diff --git a/apps/api/src/admin/webhook-routes.ts b/apps/api/src/admin/webhook-routes.ts
new file mode 100644
index 000000000..fe80a98e0
--- /dev/null
+++ b/apps/api/src/admin/webhook-routes.ts
@@ -0,0 +1,183 @@
+import {
+ apiRouter,
+ createRoute,
+ errorResponse,
+ jsonResponse,
+ z,
+} from "../openapi";
+import { requireUserSession } from "../utils/require-user-session";
+import { adminAuditRequest } from "./audit/admin-audit-request";
+import { requireInstancePermission } from "./roles/require-instance-permission";
+import { createWebhook } from "./webhooks/create-webhook";
+import { deleteWebhook } from "./webhooks/delete-webhook";
+import { listWebhookDeliveries } from "./webhooks/list-webhook-deliveries";
+import { listWebhooks } from "./webhooks/list-webhooks";
+import { rotateWebhookSecret } from "./webhooks/rotate-webhook-secret";
+import {
+ deliverySchema,
+ queuedSchema,
+ webhookInput,
+ webhookListSchema,
+ webhookParam,
+ webhookSchema,
+ webhookSecretSchema,
+} from "./webhooks/schema";
+import { testWebhook } from "./webhooks/test-webhook";
+import { updateWebhook } from "./webhooks/update-webhook";
+
+const common = {
+ tags: ["Admin"],
+ middleware: [
+ requireUserSession,
+ requireInstancePermission("instance:settings"),
+ ],
+};
+const errors = {
+ 401: errorResponse("Authentication required"),
+ 403: errorResponse("The caller lacks instance:settings or used an API key"),
+ 404: errorResponse("Webhook not found"),
+};
+const body = {
+ required: true,
+ content: { "application/json": { schema: webhookInput } },
+};
+const description =
+ "Requires the instance:settings instance permission and a user session. API keys are rejected.";
+const list = createRoute({
+ ...common,
+ method: "get",
+ path: "/",
+ operationId: "listInstanceWebhooks",
+ summary: "List instance webhooks",
+ description: `Returns configuration without signing secrets. ${description}`,
+ responses: {
+ ...errors,
+ 200: jsonResponse("Instance webhooks", webhookListSchema),
+ },
+});
+const create = createRoute({
+ ...common,
+ method: "post",
+ path: "/",
+ operationId: "createInstanceWebhook",
+ summary: "Create an instance webhook",
+ description: `The signing secret is returned once. URLs must resolve to public addresses (HTTPS in production). ${description}`,
+ request: { body },
+ responses: {
+ ...errors,
+ 201: jsonResponse(
+ "Created webhook and one-time secret",
+ webhookSecretSchema,
+ ),
+ 400: errorResponse("Invalid URL or categories"),
+ 409: errorResponse("Set NOTIFICATION_SECRET_ENCRYPTION_KEY first"),
+ },
+});
+const update = createRoute({
+ ...common,
+ method: "put",
+ path: "/{webhookId}",
+ operationId: "updateInstanceWebhook",
+ summary: "Update an instance webhook",
+ description,
+ request: { params: webhookParam, body },
+ responses: {
+ ...errors,
+ 200: jsonResponse("Updated webhook", webhookSchema),
+ 400: errorResponse("Invalid URL or categories"),
+ },
+});
+const remove = createRoute({
+ ...common,
+ method: "delete",
+ path: "/{webhookId}",
+ operationId: "deleteInstanceWebhook",
+ summary: "Delete an instance webhook",
+ description,
+ request: { params: webhookParam },
+ responses: {
+ ...errors,
+ 200: jsonResponse("Deleted webhook id", queuedSchema),
+ },
+});
+const rotate = createRoute({
+ ...common,
+ method: "post",
+ path: "/{webhookId}/rotate-secret",
+ operationId: "rotateInstanceWebhookSecret",
+ summary: "Rotate a webhook signing secret",
+ description: `Returns the new secret once. Queued deliveries use the new secret. ${description}`,
+ request: { params: webhookParam },
+ responses: {
+ ...errors,
+ 200: jsonResponse("Webhook and one-time secret", webhookSecretSchema),
+ 409: errorResponse("Set NOTIFICATION_SECRET_ENCRYPTION_KEY first"),
+ },
+});
+const test = createRoute({
+ ...common,
+ method: "post",
+ path: "/{webhookId}/test",
+ operationId: "testInstanceWebhook",
+ summary: "Queue a test webhook delivery",
+ description: `Queues a webhook.test event regardless of selected categories. ${description}`,
+ request: { params: webhookParam },
+ responses: {
+ ...errors,
+ 202: jsonResponse("Queued delivery id", queuedSchema),
+ 409: errorResponse("Webhook is disabled"),
+ },
+});
+const history = createRoute({
+ ...common,
+ method: "get",
+ path: "/{webhookId}/deliveries",
+ operationId: "listInstanceWebhookDeliveries",
+ summary: "List recent webhook deliveries",
+ description: `The latest 20 deliveries, without payloads, URLs, secrets or response bodies. ${description}`,
+ request: { params: webhookParam },
+ responses: {
+ ...errors,
+ 200: jsonResponse("Recent deliveries", z.array(deliverySchema)),
+ },
+});
+
+export default apiRouter()
+ .openapi(list, async (c) => c.json(await listWebhooks(), 200))
+ .openapi(create, async (c) =>
+ c.json(await createWebhook(c.req.valid("json"), adminAuditRequest(c)), 201),
+ )
+ .openapi(update, async (c) =>
+ c.json(
+ await updateWebhook(
+ c.req.valid("param").webhookId,
+ c.req.valid("json"),
+ adminAuditRequest(c),
+ ),
+ 200,
+ ),
+ )
+ .openapi(remove, async (c) =>
+ c.json(
+ await deleteWebhook(c.req.valid("param").webhookId, adminAuditRequest(c)),
+ 200,
+ ),
+ )
+ .openapi(rotate, async (c) =>
+ c.json(
+ await rotateWebhookSecret(
+ c.req.valid("param").webhookId,
+ adminAuditRequest(c),
+ ),
+ 200,
+ ),
+ )
+ .openapi(test, async (c) =>
+ c.json(
+ await testWebhook(c.req.valid("param").webhookId, adminAuditRequest(c)),
+ 202,
+ ),
+ )
+ .openapi(history, async (c) =>
+ c.json(await listWebhookDeliveries(c.req.valid("param").webhookId), 200),
+ );
diff --git a/apps/api/src/admin/webhooks/audit-webhook-payload.ts b/apps/api/src/admin/webhooks/audit-webhook-payload.ts
new file mode 100644
index 000000000..0bff00d6a
--- /dev/null
+++ b/apps/api/src/admin/webhooks/audit-webhook-payload.ts
@@ -0,0 +1,13 @@
+export type AuditWebhookPayload = {
+ id: string;
+ action: string;
+ actorUserId: string | null;
+ actorName: string | null;
+ actorEmail: string | null;
+ targetType: string;
+ targetId: string | null;
+ targetLabel: string | null;
+ metadata: Record<string, unknown> | null;
+ ipAddress: string | null;
+ createdAt: string;
+};
diff --git a/apps/api/src/admin/webhooks/categories.ts b/apps/api/src/admin/webhooks/categories.ts
new file mode 100644
index 000000000..3c1984485
--- /dev/null
+++ b/apps/api/src/admin/webhooks/categories.ts
@@ -0,0 +1,10 @@
+export const WEBHOOK_CATEGORIES = [
+ "user",
+ "session",
+ "api_key",
+ "workspace",
+ "role",
+ "instance",
+ "email",
+ "webhook",
+] as const;
diff --git a/apps/api/src/admin/webhooks/claim-webhook-delivery.ts b/apps/api/src/admin/webhooks/claim-webhook-delivery.ts
new file mode 100644
index 000000000..f320df9a6
--- /dev/null
+++ b/apps/api/src/admin/webhooks/claim-webhook-delivery.ts
@@ -0,0 +1,62 @@
+import { and, asc, eq, gte, lt, lte, sql } from "drizzle-orm";
+import db, { schema } from "../../database";
+
+import { pruneWebhookDeliveries } from "./prune-webhook-deliveries";
+
+export const MAX_WEBHOOK_ATTEMPTS = 3;
+
+/** A short database lease keeps API instances from sending the same job. */
+export async function claimWebhookDelivery() {
+ const delivery = schema.instanceWebhookDeliveryTable;
+ const webhook = schema.instanceWebhookTable;
+ const now = new Date();
+ // A process may have stopped during its final attempt.
+ const interrupted = await db
+ .update(delivery)
+ .set({ state: "failed", errorCode: "interrupted" })
+ .where(
+ and(
+ eq(delivery.state, "pending"),
+ gte(delivery.attempts, MAX_WEBHOOK_ATTEMPTS),
+ lte(
+ delivery.nextAttemptAt,
+ sql`(clock_timestamp() AT TIME ZONE 'utc')`,
+ ),
+ ),
+ )
+ .returning({ webhookId: delivery.webhookId });
+ for (const id of new Set(interrupted.map((job) => job.webhookId))) {
+ await pruneWebhookDeliveries(db, id);
+ }
+ return db.transaction(async (tx) => {
+ const [job] = await tx
+ .select({
+ delivery,
+ url: webhook.url,
+ signingSecret: webhook.signingSecret,
+ })
+ .from(delivery)
+ .innerJoin(webhook, eq(delivery.webhookId, webhook.id))
+ .where(
+ and(
+ eq(delivery.state, "pending"),
+ lt(delivery.attempts, MAX_WEBHOOK_ATTEMPTS),
+ lte(
+ delivery.nextAttemptAt,
+ sql`(clock_timestamp() AT TIME ZONE 'utc')`,
+ ),
+ eq(webhook.enabled, true),
+ ),
+ )
+ .orderBy(asc(delivery.nextAttemptAt), asc(delivery.id))
+ .limit(1)
+ .for("update", { of: delivery, skipLocked: true });
+ if (!job) return null;
+ const attempts = job.delivery.attempts + 1;
+ await tx
+ .update(delivery)
+ .set({ attempts, nextAttemptAt: new Date(now.getTime() + 60_000) })
+ .where(eq(delivery.id, job.delivery.id));
+ return { ...job, delivery: { ...job.delivery, attempts } };
+ });
+}
diff --git a/apps/api/src/admin/webhooks/create-webhook.ts b/apps/api/src/admin/webhooks/create-webhook.ts
new file mode 100644
index 000000000..c919c9469
--- /dev/null
+++ b/apps/api/src/admin/webhooks/create-webhook.ts
@@ -0,0 +1,38 @@
+import db, { schema } from "../../database";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+import { recordAdminAction } from "../audit/record-admin-action";
+import { newSigningSecret } from "./new-signing-secret";
+import { publicWebhook } from "./public-webhook";
+import type { WebhookInput } from "./schema";
+import { validateWebhookUrl } from "./validate-webhook-url";
+
+export async function createWebhook(
+ input: WebhookInput,
+ audit: AdminAuditRequest,
+) {
+ const url = await validateWebhookUrl(input.url);
+ const { secret, encrypted } = newSigningSecret();
+ const webhook = await db.transaction(async (tx) => {
+ const [row] = await tx
+ .insert(schema.instanceWebhookTable)
+ .values({
+ ...input,
+ url,
+ categories: [...new Set(input.categories)],
+ signingSecret: encrypted,
+ })
+ .returning();
+ if (!row) throw new Error("Webhook insert failed");
+ await recordAdminAction(
+ {
+ ...audit,
+ action: "webhook.created",
+ targetType: "webhook",
+ targetId: row.id,
+ },
+ tx,
+ );
+ return publicWebhook(row);
+ });
+ return { webhook, secret };
+}
diff --git a/apps/api/src/admin/webhooks/delete-webhook.ts b/apps/api/src/admin/webhooks/delete-webhook.ts
new file mode 100644
index 000000000..f42516b8d
--- /dev/null
+++ b/apps/api/src/admin/webhooks/delete-webhook.ts
@@ -0,0 +1,25 @@
+import { eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
+import db, { schema } from "../../database";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+import { recordAdminAction } from "../audit/record-admin-action";
+
+export async function deleteWebhook(id: string, audit: AdminAuditRequest) {
+ return db.transaction(async (tx) => {
+ const [row] = await tx
+ .delete(schema.instanceWebhookTable)
+ .where(eq(schema.instanceWebhookTable.id, id))
+ .returning({ id: schema.instanceWebhookTable.id });
+ if (!row) throw new HTTPException(404, { message: "Webhook not found" });
+ await recordAdminAction(
+ {
+ ...audit,
+ action: "webhook.deleted",
+ targetType: "webhook",
+ targetId: id,
+ },
+ tx,
+ );
+ return row;
+ });
+}
diff --git a/apps/api/src/admin/webhooks/enqueue-audit-webhooks.ts b/apps/api/src/admin/webhooks/enqueue-audit-webhooks.ts
new file mode 100644
index 000000000..70466d668
--- /dev/null
+++ b/apps/api/src/admin/webhooks/enqueue-audit-webhooks.ts
@@ -0,0 +1,21 @@
+import { sql } from "drizzle-orm";
+import type { DbOrTx } from "../../project-access/db-or-tx";
+
+/** Runs in the audit transaction: workers cannot see deliveries until commit. */
+export async function enqueueAuditWebhooks(database: DbOrTx, auditId: string) {
+ await database.execute(sql`
+ INSERT INTO instance_webhook_delivery (id, webhook_id, payload)
+ SELECT gen_random_uuid()::text, w.id,
+ jsonb_build_object(
+ 'id', a.id, 'action', a.action, 'actorUserId', a.actor_user_id,
+ 'actorName', a.actor_name, 'actorEmail', a.actor_email,
+ 'targetType', a.target_type, 'targetId', a.target_id,
+ 'targetLabel', a.target_label, 'metadata', a.metadata,
+ 'ipAddress', a.ip_address,
+ 'createdAt', to_char(a.created_at, 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')
+ )
+ FROM admin_audit_log a CROSS JOIN instance_webhook w
+ WHERE a.id = ${auditId} AND w.enabled
+ AND split_part(a.action, '.', 1) = ANY(w.categories)
+ `);
+}
diff --git a/apps/api/src/admin/webhooks/list-webhook-deliveries.ts b/apps/api/src/admin/webhooks/list-webhook-deliveries.ts
new file mode 100644
index 000000000..76fa4e1eb
--- /dev/null
+++ b/apps/api/src/admin/webhooks/list-webhook-deliveries.ts
@@ -0,0 +1,22 @@
+import { desc, eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import { requireWebhook } from "./require-webhook";
+
+export async function listWebhookDeliveries(id: string) {
+ await requireWebhook(id);
+ const rows = await db
+ .select()
+ .from(schema.instanceWebhookDeliveryTable)
+ .where(eq(schema.instanceWebhookDeliveryTable.webhookId, id))
+ .orderBy(
+ desc(schema.instanceWebhookDeliveryTable.createdAt),
+ desc(schema.instanceWebhookDeliveryTable.id),
+ )
+ .limit(20);
+ return rows.map(({ payload, nextAttemptAt: _, webhookId: __, ...row }) => ({
+ ...row,
+ eventId: payload.id,
+ action: payload.action,
+ createdAt: row.createdAt.toISOString(),
+ }));
+}
diff --git a/apps/api/src/admin/webhooks/list-webhooks.ts b/apps/api/src/admin/webhooks/list-webhooks.ts
new file mode 100644
index 000000000..cbdd94f01
--- /dev/null
+++ b/apps/api/src/admin/webhooks/list-webhooks.ts
@@ -0,0 +1,16 @@
+import { desc } from "drizzle-orm";
+import db, { schema } from "../../database";
+import { publicWebhook } from "./public-webhook";
+
+export async function listWebhooks() {
+ const rows = await db
+ .select()
+ .from(schema.instanceWebhookTable)
+ .orderBy(desc(schema.instanceWebhookTable.createdAt));
+ return {
+ webhooks: rows.map(publicWebhook),
+ signingConfigured: Boolean(
+ process.env.NOTIFICATION_SECRET_ENCRYPTION_KEY?.trim(),
+ ),
+ };
+}
diff --git a/apps/api/src/admin/webhooks/new-signing-secret.ts b/apps/api/src/admin/webhooks/new-signing-secret.ts
new file mode 100644
index 000000000..adfb6f783
--- /dev/null
+++ b/apps/api/src/admin/webhooks/new-signing-secret.ts
@@ -0,0 +1,14 @@
+import { randomBytes } from "node:crypto";
+import { HTTPException } from "hono/http-exception";
+import { encryptSecret } from "../../notification-preferences/secrets";
+
+export function newSigningSecret() {
+ if (!process.env.NOTIFICATION_SECRET_ENCRYPTION_KEY?.trim()) {
+ throw new HTTPException(409, {
+ message:
+ "Set NOTIFICATION_SECRET_ENCRYPTION_KEY to create or rotate webhook secrets.",
+ });
+ }
+ const secret = randomBytes(32).toString("base64url");
+ return { secret, encrypted: encryptSecret(secret)! };
+}
diff --git a/apps/api/src/admin/webhooks/prune-webhook-deliveries.ts b/apps/api/src/admin/webhooks/prune-webhook-deliveries.ts
new file mode 100644
index 000000000..15736d8b9
--- /dev/null
+++ b/apps/api/src/admin/webhooks/prune-webhook-deliveries.ts
@@ -0,0 +1,18 @@
+import { sql } from "drizzle-orm";
+import type { DbOrTx } from "../../project-access/db-or-tx";
+
+export async function pruneWebhookDeliveries(
+ database: DbOrTx,
+ webhookId: string,
+) {
+ // Keep the newest 20 finished deliveries; queued jobs are never pruned.
+ await database.execute(sql`
+ DELETE FROM instance_webhook_delivery
+ WHERE webhook_id = ${webhookId} AND state <> 'pending'
+ AND id NOT IN (
+ SELECT id FROM instance_webhook_delivery
+ WHERE webhook_id = ${webhookId} AND state <> 'pending'
+ ORDER BY created_at DESC, id DESC LIMIT 20
+ )
+ `);
+}
diff --git a/apps/api/src/admin/webhooks/public-webhook.ts b/apps/api/src/admin/webhooks/public-webhook.ts
new file mode 100644
index 000000000..03e143432
--- /dev/null
+++ b/apps/api/src/admin/webhooks/public-webhook.ts
@@ -0,0 +1,11 @@
+import type { instanceWebhookTable } from "../../database/schema";
+
+export function publicWebhook(row: typeof instanceWebhookTable.$inferSelect) {
+ return {
+ id: row.id,
+ url: row.url,
+ categories: row.categories,
+ enabled: row.enabled,
+ createdAt: row.createdAt.toISOString(),
+ };
+}
diff --git a/apps/api/src/admin/webhooks/require-webhook.ts b/apps/api/src/admin/webhooks/require-webhook.ts
new file mode 100644
index 000000000..b64ef307e
--- /dev/null
+++ b/apps/api/src/admin/webhooks/require-webhook.ts
@@ -0,0 +1,13 @@
+import { eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
+import db, { schema } from "../../database";
+import type { DbOrTx } from "../../project-access/db-or-tx";
+
+export async function requireWebhook(id: string, database: DbOrTx = db) {
+ const [webhook] = await database
+ .select()
+ .from(schema.instanceWebhookTable)
+ .where(eq(schema.instanceWebhookTable.id, id));
+ if (!webhook) throw new HTTPException(404, { message: "Webhook not found" });
+ return webhook;
+}
diff --git a/apps/api/src/admin/webhooks/rotate-webhook-secret.ts b/apps/api/src/admin/webhooks/rotate-webhook-secret.ts
new file mode 100644
index 000000000..118f20ec6
--- /dev/null
+++ b/apps/api/src/admin/webhooks/rotate-webhook-secret.ts
@@ -0,0 +1,32 @@
+import { eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
+import db, { schema } from "../../database";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+import { recordAdminAction } from "../audit/record-admin-action";
+import { newSigningSecret } from "./new-signing-secret";
+import { publicWebhook } from "./public-webhook";
+
+export async function rotateWebhookSecret(
+ id: string,
+ audit: AdminAuditRequest,
+) {
+ const { secret, encrypted } = newSigningSecret();
+ return db.transaction(async (tx) => {
+ const [row] = await tx
+ .update(schema.instanceWebhookTable)
+ .set({ signingSecret: encrypted })
+ .where(eq(schema.instanceWebhookTable.id, id))
+ .returning();
+ if (!row) throw new HTTPException(404, { message: "Webhook not found" });
+ await recordAdminAction(
+ {
+ ...audit,
+ action: "webhook.secret_rotated",
+ targetType: "webhook",
+ targetId: id,
+ },
+ tx,
+ );
+ return { webhook: publicWebhook(row), secret };
+ });
+}
diff --git a/apps/api/src/admin/webhooks/schema.ts b/apps/api/src/admin/webhooks/schema.ts
new file mode 100644
index 000000000..6f36890a1
--- /dev/null
+++ b/apps/api/src/admin/webhooks/schema.ts
@@ -0,0 +1,44 @@
+import { z } from "../../openapi";
+
+import { WEBHOOK_CATEGORIES } from "./categories";
+
+export const webhookInput = z.object({
+ url: z.url().max(2048),
+ categories: z
+ .array(z.enum(WEBHOOK_CATEGORIES))
+ .min(1)
+ .max(WEBHOOK_CATEGORIES.length),
+ enabled: z.boolean(),
+});
+export type WebhookInput = z.infer<typeof webhookInput>;
+export const webhookParam = z.object({ webhookId: z.string().min(1) });
+export const webhookSchema = webhookInput
+ .extend({
+ id: z.string(),
+ createdAt: z.iso.datetime(),
+ })
+ .openapi("InstanceWebhook");
+export const webhookSecretSchema = z
+ .object({ webhook: webhookSchema, secret: z.string() })
+ .openapi("InstanceWebhookSecret");
+export const webhookListSchema = z
+ .object({
+ webhooks: z.array(webhookSchema),
+ signingConfigured: z.boolean(),
+ })
+ .openapi("InstanceWebhookList");
+export const deliverySchema = z
+ .object({
+ id: z.string(),
+ action: z.string(),
+ eventId: z.string(),
+ state: z.enum(["pending", "succeeded", "failed"]),
+ attempts: z.number().int(),
+ statusCode: z.number().int().nullable(),
+ errorCode: z.string().nullable(),
+ createdAt: z.iso.datetime(),
+ })
+ .openapi("InstanceWebhookDelivery");
+export const queuedSchema = z
+ .object({ id: z.string() })
+ .openapi("InstanceWebhookQueued");
diff --git a/apps/api/src/admin/webhooks/send-webhook-delivery.ts b/apps/api/src/admin/webhooks/send-webhook-delivery.ts
new file mode 100644
index 000000000..a000ffc9e
--- /dev/null
+++ b/apps/api/src/admin/webhooks/send-webhook-delivery.ts
@@ -0,0 +1,77 @@
+import { createHmac } from "node:crypto";
+import { and, eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import { decryptSecret } from "../../notification-preferences/secrets";
+import {
+ OutboundRequestError,
+ sendOutboundRequest,
+} from "../../utils/outbound-request";
+import { pruneWebhookDeliveries } from "./prune-webhook-deliveries";
+import {
+ claimWebhookDelivery,
+ MAX_WEBHOOK_ATTEMPTS,
+} from "./claim-webhook-delivery";
+
+export async function sendWebhookDelivery() {
+ const job = await claimWebhookDelivery();
+ if (!job) return false;
+ const { delivery, url, signingSecret } = job;
+ let statusCode: number | null = null;
+ let errorCode: string | null = null;
+ let retryable = false;
+ try {
+ const secret = decryptSecret(signingSecret);
+ if (!secret) throw new Error("Missing signing secret");
+ const body = JSON.stringify(delivery.payload);
+ const timestamp = Math.floor(Date.now() / 1000).toString();
+ const signature = createHmac("sha256", secret)
+ .update(`${timestamp}.${body}`)
+ .digest("hex");
+ statusCode = (await sendOutboundRequest(
+ url,
+ {
+ body,
+ headers: {
+ "content-type": "application/json",
+ "x-kaneo-timestamp": timestamp,
+ "x-kaneo-signature": `sha256=${signature}`,
+ "x-kaneo-delivery": delivery.id,
+ },
+ },
+ { publicDestination: true, readStatus: true, timeoutMs: 5_000 },
+ )) as number;
+ } catch (error) {
+ // Neither an untrusted response body nor an error containing a URL is kept.
+ errorCode =
+ error instanceof OutboundRequestError ? error.reason : "signing";
+ statusCode =
+ error instanceof OutboundRequestError ? (error.status ?? null) : null;
+ retryable =
+ errorCode === "network" ||
+ errorCode === "timeout" ||
+ (errorCode === "http" &&
+ (statusCode === 408 || statusCode === 429 || (statusCode ?? 0) >= 500));
+ }
+ const retry =
+ errorCode !== null && retryable && delivery.attempts < MAX_WEBHOOK_ATTEMPTS;
+ const table = schema.instanceWebhookDeliveryTable;
+ await db
+ .update(table)
+ .set({
+ state: retry ? "pending" : errorCode ? "failed" : "succeeded",
+ statusCode,
+ errorCode,
+ nextAttemptAt: new Date(
+ Date.now() + (delivery.attempts === 1 ? 5_000 : 30_000),
+ ),
+ })
+ .where(
+ and(
+ eq(table.id, delivery.id),
+ eq(table.state, "pending"),
+ eq(table.attempts, delivery.attempts),
+ ),
+ );
+ await pruneWebhookDeliveries(db, delivery.webhookId);
+ return true;
+}
diff --git a/apps/api/src/admin/webhooks/start-webhook-worker.ts b/apps/api/src/admin/webhooks/start-webhook-worker.ts
new file mode 100644
index 000000000..91bc01c16
--- /dev/null
+++ b/apps/api/src/admin/webhooks/start-webhook-worker.ts
@@ -0,0 +1,25 @@
+import { sendWebhookDelivery } from "./send-webhook-delivery";
+
+export function startWebhookWorker() {
+ let running: Promise<unknown> | null = null;
+ const tick = () => {
+ if (running) return;
+ running = Promise.all(
+ Array.from({ length: 5 }, () => sendWebhookDelivery()),
+ )
+ .catch(() => {
+ // Database errors may embed payloads and encrypted secrets.
+ console.error("Instance webhook delivery worker failed");
+ })
+ .finally(() => {
+ running = null;
+ });
+ };
+ const timer = setInterval(tick, 1_000);
+ timer.unref();
+ tick();
+ return async () => {
+ clearInterval(timer);
+ await running;
+ };
+}
diff --git a/apps/api/src/admin/webhooks/test-webhook.ts b/apps/api/src/admin/webhooks/test-webhook.ts
new file mode 100644
index 000000000..8e19cb2a7
--- /dev/null
+++ b/apps/api/src/admin/webhooks/test-webhook.ts
@@ -0,0 +1,33 @@
+import { createId } from "@paralleldrive/cuid2";
+import { HTTPException } from "hono/http-exception";
+import db, { schema } from "../../database";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+import { requireWebhook } from "./require-webhook";
+
+export async function testWebhook(id: string, audit: AdminAuditRequest) {
+ const webhook = await requireWebhook(id);
+ if (!webhook.enabled)
+ throw new HTTPException(409, {
+ message: "Enable the webhook before sending a test.",
+ });
+ const [row] = await db
+ .insert(schema.instanceWebhookDeliveryTable)
+ .values({
+ webhookId: id,
+ payload: {
+ id: createId(),
+ action: "webhook.test",
+ actorUserId: audit.actorUserId,
+ actorName: null,
+ actorEmail: null,
+ targetType: "webhook",
+ targetId: id,
+ targetLabel: null,
+ metadata: null,
+ ipAddress: null,
+ createdAt: new Date().toISOString(),
+ },
+ })
+ .returning({ id: schema.instanceWebhookDeliveryTable.id });
+ return row!;
+}
diff --git a/apps/api/src/admin/webhooks/update-webhook.ts b/apps/api/src/admin/webhooks/update-webhook.ts
new file mode 100644
index 000000000..23f2f0ea8
--- /dev/null
+++ b/apps/api/src/admin/webhooks/update-webhook.ts
@@ -0,0 +1,47 @@
+import { and, eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
+import db, { schema } from "../../database";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+import { recordAdminAction } from "../audit/record-admin-action";
+import { pruneWebhookDeliveries } from "./prune-webhook-deliveries";
+import { publicWebhook } from "./public-webhook";
+import type { WebhookInput } from "./schema";
+import { validateWebhookUrl } from "./validate-webhook-url";
+
+export async function updateWebhook(
+ id: string,
+ input: WebhookInput,
+ audit: AdminAuditRequest,
+) {
+ const url = await validateWebhookUrl(input.url);
+ return db.transaction(async (tx) => {
+ const [row] = await tx
+ .update(schema.instanceWebhookTable)
+ .set({ ...input, url, categories: [...new Set(input.categories)] })
+ .where(eq(schema.instanceWebhookTable.id, id))
+ .returning();
+ if (!row) throw new HTTPException(404, { message: "Webhook not found" });
+ if (!input.enabled) {
+ await tx
+ .update(schema.instanceWebhookDeliveryTable)
+ .set({ state: "failed", errorCode: "disabled" })
+ .where(
+ and(
+ eq(schema.instanceWebhookDeliveryTable.webhookId, id),
+ eq(schema.instanceWebhookDeliveryTable.state, "pending"),
+ ),
+ );
+ }
+ if (!input.enabled) await pruneWebhookDeliveries(tx, id);
+ await recordAdminAction(
+ {
+ ...audit,
+ action: "webhook.updated",
+ targetType: "webhook",
+ targetId: id,
+ },
+ tx,
+ );
+ return publicWebhook(row);
+ });
+}
diff --git a/apps/api/src/admin/webhooks/validate-webhook-url.ts b/apps/api/src/admin/webhooks/validate-webhook-url.ts
new file mode 100644
index 000000000..05dc954c4
--- /dev/null
+++ b/apps/api/src/admin/webhooks/validate-webhook-url.ts
@@ -0,0 +1,25 @@
+import { HTTPException } from "hono/http-exception";
+import { assertPublicDestination } from "../../utils/assert-public-destination";
+
+export async function validateWebhookUrl(value: string) {
+ const url = new URL(value);
+ if (
+ !["http:", "https:"].includes(url.protocol) ||
+ (process.env.NODE_ENV === "production" && url.protocol !== "https:") ||
+ url.username ||
+ url.password ||
+ url.hash
+ ) {
+ throw new HTTPException(400, {
+ message: "Use an HTTPS URL without credentials or a fragment.",
+ });
+ }
+ try {
+ await assertPublicDestination(value, "Webhook");
+ } catch {
+ throw new HTTPException(400, {
+ message: "Webhook URL must resolve to a public address.",
+ });
+ }
+ return url.href;
+}
diff --git a/apps/api/src/database/index.ts b/apps/api/src/database/index.ts
index dd87134c7..2a3c46ccc 100644
--- a/apps/api/src/database/index.ts
+++ b/apps/api/src/database/index.ts
@@ -43,6 +43,8 @@ import {
adminAuditLogTable,
instanceRoleTable,
instanceSettingsTable,
+ instanceWebhookTable,
+ instanceWebhookDeliveryTable,
apikeyTable,
assetTable,
billingEventTable,
@@ -96,6 +98,8 @@ export const schema = {
adminAuditLogTable,
instanceRoleTable,
instanceSettingsTable,
+ instanceWebhookTable,
+ instanceWebhookDeliveryTable,
assetTable,
activityTable,
apikeyTable,
diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.ts
index d6b8a7418..6d83345ca 100644
--- a/apps/api/src/database/schema.ts
+++ b/apps/api/src/database/schema.ts
@@ -13,6 +13,8 @@ import {
unique,
uniqueIndex,
} from "drizzle-orm/pg-core";
+import type { WEBHOOK_CATEGORIES } from "../admin/webhooks/categories";
+import type { AuditWebhookPayload } from "../admin/webhooks/audit-webhook-payload";
import type { GitHubImportState } from "../github-integration/import-state";
import type { ImportRunProject } from "../import/import-run-project";
import type { TaskRecurrence } from "../task/recurrence/schema";
@@ -179,6 +181,59 @@ export const adminAuditLogTable = pgTable(
],
);
+export const instanceWebhookTable = pgTable("instance_webhook", {
+ id: text("id")
+ .$defaultFn(() => createId())
+ .primaryKey(),
+ url: text("url").notNull(),
+ categories: text("categories")
+ .array()
+ .$type<(typeof WEBHOOK_CATEGORIES)[number][]>()
+ .notNull(),
+ enabled: boolean("enabled").default(true).notNull(),
+ signingSecret: text("signing_secret").notNull(),
+ createdAt: timestamp("created_at", { mode: "date" })
+ .default(utcNow)
+ .notNull(),
+});
+
+export const instanceWebhookDeliveryTable = pgTable(
+ "instance_webhook_delivery",
+ {
+ id: text("id")
+ .$defaultFn(() => createId())
+ .primaryKey(),
+ webhookId: text("webhook_id")
+ .notNull()
+ .references(() => instanceWebhookTable.id, { onDelete: "cascade" }),
+ payload: jsonb("payload").$type<AuditWebhookPayload>().notNull(),
+ state: text("state")
+ .$type<"pending" | "succeeded" | "failed">()
+ .default("pending")
+ .notNull(),
+ attempts: integer("attempts").default(0).notNull(),
+ statusCode: integer("status_code"),
+ errorCode: text("error_code"),
+ nextAttemptAt: timestamp("next_attempt_at", { mode: "date" })
+ .default(utcNow)
+ .notNull(),
+ createdAt: timestamp("created_at", { mode: "date" })
+ .default(utcNow)
+ .notNull(),
+ },
+ (table) => [
+ index("instance_webhook_delivery_due_idx").on(
+ table.state,
+ table.nextAttemptAt,
+ ),
+ index("instance_webhook_delivery_history_idx").on(
+ table.webhookId,
+ table.createdAt.desc(),
+ table.id.desc(),
+ ),
+ ],
+);
+
// Custom instance roles. Users hold them by name in their comma-separated
// `user.role`, next to the built-in `admin` and `user` roles.
export const instanceRoleTable = pgTable("instance_role", {
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 0695b8c62..370c2bdf0 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -1,3 +1,4 @@
+import { startWebhookWorker } from "./admin/webhooks/start-webhook-worker";
import integrationSync from "./integration-sync";
import { syncWorkspaceAccess } from "./ws/workspace-access";
import { drainPasswordResetDeliveries } from "./utils/password-reset-delivery";
@@ -1081,6 +1082,7 @@ export async function startServer(
);
injectWebSocket(server);
+ const stopWebhookWorker = startWebhookWorker();
const gracefulShutdown = async () => {
if (shuttingDown) return;
@@ -1088,6 +1090,7 @@ export async function startServer(
console.log("🛑 Shutting down gracefully...");
shutdownScheduler();
+ await stopWebhookWorker();
await shutdownWebSocketAdapter();
server.close();
const [, signInEmailsDrained] = await Promise.all([
diff --git a/apps/api/src/utils/outbound-request.ts b/apps/api/src/utils/outbound-request.ts
index 329166bd3..920f0c0e1 100644
--- a/apps/api/src/utils/outbound-request.ts
+++ b/apps/api/src/utils/outbound-request.ts
@@ -60,6 +60,7 @@ export async function sendOutboundRequest(
init: Pick<RequestInit, "headers" | "body">,
options: {
readJson?: boolean;
+ readStatus?: boolean;
publicDestination?: boolean;
timeoutMs?: number;
} = {},
@@ -96,7 +97,7 @@ export async function sendOutboundRequest(
if (!response.ok || !options.readJson) {
void response.body?.cancel().catch(() => {});
if (!response.ok) throw new OutboundRequestError("http", response.status);
- return undefined;
+ return options.readStatus ? response.status : undefined;
}
return readSmallJson(response);
};
diff --git a/apps/docs/openapi.json b/apps/docs/openapi.json
index dae21fad5..a0552a399 100644
--- a/apps/docs/openapi.json
+++ b/apps/docs/openapi.json
@@ -6714,6 +6714,146 @@
"integrationProviders"
]
},
+ "InstanceWebhookList": {
+ "type": "object",
+ "properties": {
+ "webhooks": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/InstanceWebhook"
+ }
+ },
+ "signingConfigured": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "webhooks",
+ "signingConfigured"
+ ]
+ },
+ "InstanceWebhook": {
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ },
+ "categories": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "enum": [
+ "user",
+ "session",
+ "api_key",
+ "workspace",
+ "role",
+ "instance",
+ "email",
+ "webhook"
+ ]
+ },
+ "minItems": 1,
+ "maxItems": 8
+ },
+ "enabled": {
+ "type": "boolean"
+ },
+ "id": {
+ "type": "string"
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ "required": [
+ "url",
+ "categories",
+ "enabled",
+ "id",
+ "createdAt"
+ ]
+ },
+ "InstanceWebhookSecret": {
+ "type": "object",
+ "properties": {
+ "webhook": {
+ "$ref": "#/components/schemas/InstanceWebhook"
+ },
+ "secret": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "webhook",
+ "secret"
+ ]
+ },
+ "InstanceWebhookQueued": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id"
+ ]
+ },
+ "InstanceWebhookDelivery": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "action": {
+ "type": "string"
+ },
+ "eventId": {
+ "type": "string"
+ },
+ "state": {
+ "type": "string",
+ "enum": [
+ "pending",
+ "succeeded",
+ "failed"
+ ]
+ },
+ "attempts": {
+ "type": "integer"
+ },
+ "statusCode": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "errorCode": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "createdAt": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ "required": [
+ "id",
+ "action",
+ "eventId",
+ "state",
+ "attempts",
+ "statusCode",
+ "errorCode",
+ "createdAt"
+ ]
+ },
"AdminApiKeyList": {
"type": "object",
"properties": {
@@ -28112,6 +28252,581 @@
}
}
},
+ "/admin/webhooks": {
+ "get": {
+ "tags": [
+ "Admin"
+ ],
+ "operationId": "listInstanceWebhooks",
+ "summary": "List instance webhooks",
+ "description": "Returns configuration without signing secrets. Requires the instance:settings instance permission and a user session. API keys are rejected.",
+ "responses": {
+ "200": {
+ "description": "Instance webhooks",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InstanceWebhookList"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Authentication required",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "The caller lacks instance:settings or used an API key",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Webhook not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "429": {
+ "$ref": "#/components/responses/ApiKeyRateLimited"
+ }
+ }
+ },
+ "post": {
+ "tags": [
+ "Admin"
+ ],
+ "operationId": "createInstanceWebhook",
+ "summary": "Create an instance webhook",
+ "description": "The signing secret is returned once. URLs must resolve to public addresses (HTTPS in production). Requires the instance:settings instance permission and a user session. API keys are rejected.",
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ },
+ "categories": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "enum": [
+ "user",
+ "session",
+ "api_key",
+ "workspace",
+ "role",
+ "instance",
+ "email",
+ "webhook"
+ ]
+ },
+ "minItems": 1,
+ "maxItems": 8
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "url",
+ "categories",
+ "enabled"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "201": {
+ "description": "Created webhook and one-time secret",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InstanceWebhookSecret"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid URL or categories",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Authentication required",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "The caller lacks instance:settings or used an API key",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Webhook not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "Set NOTIFICATION_SECRET_ENCRYPTION_KEY first",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "429": {
+ "$ref": "#/components/responses/ApiKeyRateLimited"
+ }
+ }
+ }
+ },
+ "/admin/webhooks/{webhookId}": {
+ "put": {
+ "tags": [
+ "Admin"
+ ],
+ "operationId": "updateInstanceWebhook",
+ "summary": "Update an instance webhook",
+ "description": "Requires the instance:settings instance permission and a user session. API keys are rejected.",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string",
+ "minLength": 1
+ },
+ "required": true,
+ "name": "webhookId",
+ "in": "path"
+ }
+ ],
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ },
+ "categories": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "enum": [
+ "user",
+ "session",
+ "api_key",
+ "workspace",
+ "role",
+ "instance",
+ "email",
+ "webhook"
+ ]
+ },
+ "minItems": 1,
+ "maxItems": 8
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "url",
+ "categories",
+ "enabled"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Updated webhook",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InstanceWebhook"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid URL or categories",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Authentication required",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "The caller lacks instance:settings or used an API key",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Webhook not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "429": {
+ "$ref": "#/components/responses/ApiKeyRateLimited"
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "Admin"
+ ],
+ "operationId": "deleteInstanceWebhook",
+ "summary": "Delete an instance webhook",
+ "description": "Requires the instance:settings instance permission and a user session. API keys are rejected.",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string",
+ "minLength": 1
+ },
+ "required": true,
+ "name": "webhookId",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Deleted webhook id",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InstanceWebhookQueued"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Authentication required",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "The caller lacks instance:settings or used an API key",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Webhook not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "429": {
+ "$ref": "#/components/responses/ApiKeyRateLimited"
+ }
+ }
+ }
+ },
+ "/admin/webhooks/{webhookId}/rotate-secret": {
+ "post": {
+ "tags": [
+ "Admin"
+ ],
+ "operationId": "rotateInstanceWebhookSecret",
+ "summary": "Rotate a webhook signing secret",
+ "description": "Returns the new secret once. Queued deliveries use the new secret. Requires the instance:settings instance permission and a user session. API keys are rejected.",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string",
+ "minLength": 1
+ },
+ "required": true,
+ "name": "webhookId",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Webhook and one-time secret",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InstanceWebhookSecret"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Authentication required",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "The caller lacks instance:settings or used an API key",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Webhook not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "Set NOTIFICATION_SECRET_ENCRYPTION_KEY first",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "429": {
+ "$ref": "#/components/responses/ApiKeyRateLimited"
+ }
+ }
+ }
+ },
+ "/admin/webhooks/{webhookId}/test": {
+ "post": {
+ "tags": [
+ "Admin"
+ ],
+ "operationId": "testInstanceWebhook",
+ "summary": "Queue a test webhook delivery",
+ "description": "Queues a webhook.test event regardless of selected categories. Requires the instance:settings instance permission and a user session. API keys are rejected.",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string",
+ "minLength": 1
+ },
+ "required": true,
+ "name": "webhookId",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "202": {
+ "description": "Queued delivery id",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InstanceWebhookQueued"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Authentication required",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "The caller lacks instance:settings or used an API key",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Webhook not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "Webhook is disabled",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "429": {
+ "$ref": "#/components/responses/ApiKeyRateLimited"
+ }
+ }
+ }
+ },
+ "/admin/webhooks/{webhookId}/deliveries": {
+ "get": {
+ "tags": [
+ "Admin"
+ ],
+ "operationId": "listInstanceWebhookDeliveries",
+ "summary": "List recent webhook deliveries",
+ "description": "The latest 20 deliveries, without payloads, URLs, secrets or response bodies. Requires the instance:settings instance permission and a user session. API keys are rejected.",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string",
+ "minLength": 1
+ },
+ "required": true,
+ "name": "webhookId",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Recent deliveries",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/InstanceWebhookDelivery"
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Authentication required",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "The caller lacks instance:settings or used an API key",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Webhook not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiError"
+ }
+ }
+ }
+ },
+ "429": {
+ "$ref": "#/components/responses/ApiKeyRateLimited"
+ }
+ }
+ }
+ },
"/admin/users/{userId}/sessions": {
"get": {
"operationId": "listAdminUserSessions",
diff --git a/tests/api-integration/admin-instance-webhooks.test.ts b/tests/api-integration/admin-instance-webhooks.test.ts
new file mode 100644
index 000000000..43ec1e2ab
--- /dev/null
+++ b/tests/api-integration/admin-instance-webhooks.test.ts
@@ -0,0 +1,450 @@
+import { createHmac } from "node:crypto";
+import { createServer, type Server, type IncomingHttpHeaders } from "node:http";
+import { eq } from "drizzle-orm";
+import {
+ afterEach,
+ beforeEach,
+ describe,
+ expect,
+ it,
+ vi,
+} from "vite-plus/test";
+import { auth } from "../../apps/api/src/auth";
+import db, { schema } from "../../apps/api/src/database";
+import { createApp } from "../../apps/api/src/index";
+import { recordAdminAction } from "../../apps/api/src/admin/audit/record-admin-action";
+import { sendWebhookDelivery } from "../../apps/api/src/admin/webhooks/send-webhook-delivery";
+import { claimWebhookDelivery } from "../../apps/api/src/admin/webhooks/claim-webhook-delivery";
+import {
+ insertInstanceRole,
+ signInWithRole,
+ adminApi,
+} from "./helpers/admin/instance-roles";
+import { readAuditLog } from "./helpers/admin/read-audit-log";
+import { resetTestDatabase } from "./helpers/database";
+
+let server: Server;
+let url: string;
+let status: number;
+let requests: { body: string; headers: IncomingHttpHeaders }[];
+let admin: Awaited<ReturnType<typeof signInWithRole>>;
+let app: ReturnType<typeof createApp>["app"];
+const table = schema.instanceWebhookDeliveryTable;
+
+beforeEach(async () => {
+ await resetTestDatabase();
+ vi.stubEnv(
+ "NOTIFICATION_SECRET_ENCRYPTION_KEY",
+ "test-only-webhook-encryption-key",
+ );
+ vi.stubEnv("KANEO_ALLOW_PRIVATE_WEBHOOK_DESTINATIONS", "true");
+ ({ app } = createApp());
+ admin = await signInWithRole(app, "admin");
+ requests = [];
+ status = 204;
+ server = createServer((req, res) => {
+ let body = "";
+ req.on("data", (chunk) => {
+ body += chunk.toString();
+ });
+ req.on("end", () => {
+ requests.push({ body, headers: req.headers });
+ res.writeHead(status);
+ res.end(status === 204 ? undefined : "untrusted-secret-response-body");
+ });
+ });
+ await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
+ const address = server.address();
+ if (!address || typeof address === "string")
+ throw new Error("No receiver address");
+ url = `http://127.0.0.1:${address.port}/events`;
+});
+afterEach(async () => {
+ server.closeAllConnections();
+ await new Promise<void>((resolve) => server.close(() => resolve()));
+ vi.unstubAllEnvs();
+});
+
+async function create(categories = ["user"], enabled = true) {
+ const response = await admin.api("/webhooks", {
+ method: "POST",
+ body: { url, categories, enabled },
+ });
+ expect(response.status, await response.clone().text()).toBe(201);
+ return response.json() as Promise<{
+ webhook: { id: string };
+ secret: string;
+ }>;
+}
+async function due() {
+ await db.update(table).set({ nextAttemptAt: new Date(0) });
+}
+async function record(
+ action = "user.updated",
+ database: Parameters<typeof recordAdminAction>[1] = db,
+) {
+ await recordAdminAction(
+ {
+ actorUserId: admin.userId,
+ action,
+ targetType: "user",
+ targetId: "target",
+ metadata: {
+ name: "Changed",
+ password: "must-not-stream",
+ token: "must-not-stream",
+ },
+ ipAddress: "203.0.113.2",
+ },
+ database,
+ );
+}
+
+describe("instance webhook administration", () => {
+ it("gates every endpoint by session and instance:settings, rejecting API keys", async () => {
+ const { webhook } = await create();
+ const plain = await signInWithRole(app, "user");
+ const { key } = await auth.api.createApiKey({
+ body: { userId: admin.userId },
+ });
+ const routes = [
+ ["GET", "/webhooks"],
+ ["POST", "/webhooks"],
+ ["PUT", `/webhooks/${webhook.id}`],
+ ["DELETE", `/webhooks/${webhook.id}`],
+ ["POST", `/webhooks/${webhook.id}/rotate-secret`],
+ ["POST", `/webhooks/${webhook.id}/test`],
+ ["GET", `/webhooks/${webhook.id}/deliveries`],
+ ];
+ for (const [method, path] of routes) {
+ for (const [api, expected] of [
+ [adminApi(app, {}), 401],
+ [plain.api, 403],
+ [adminApi(app, { "x-api-key": key }), 403],
+ [adminApi(app, { authorization: `Bearer ${key}` }), 403],
+ ] as const) {
+ expect(
+ (
+ await api(path!, {
+ method,
+ ...(method === "POST" || method === "PUT"
+ ? { body: { url, categories: ["user"], enabled: true } }
+ : {}),
+ })
+ ).status,
+ `${method} ${path}`,
+ ).toBe(expected);
+ }
+ }
+ await insertInstanceRole("webhooks-manager", ["instance:settings"]);
+ const manager = await signInWithRole(app, "webhooks-manager");
+ expect((await manager.api("/webhooks")).status).toBe(200);
+ expect(
+ (
+ await manager.api(`/webhooks/${webhook.id}`, {
+ method: "PUT",
+ body: { url, categories: ["instance"], enabled: false },
+ })
+ ).status,
+ ).toBe(200);
+ });
+
+ it("shows secrets once, encrypts storage, and audits create/update/rotate/delete without secrets", async () => {
+ const { webhook, secret } = await create();
+ const [stored] = await db.select().from(schema.instanceWebhookTable);
+ expect(stored?.signingSecret).toMatch(/^enc:v1:/);
+ expect(stored?.signingSecret).not.toContain(secret);
+ const rotated = await admin.api(`/webhooks/${webhook.id}/rotate-secret`, {
+ method: "POST",
+ });
+ expect(rotated.status).toBe(200);
+ const next = (await rotated.json()) as { secret: string };
+ expect(next.secret).not.toBe(secret);
+ const updated = await admin.api(`/webhooks/${webhook.id}`, {
+ method: "PUT",
+ body: { url, categories: ["email"], enabled: false },
+ });
+ expect(updated.status).toBe(200);
+ expect(await updated.text()).not.toContain("secret");
+ const list = await admin.api("/webhooks");
+ const text = await list.text();
+ expect(text).not.toContain(secret);
+ expect(text).not.toContain(next.secret);
+ expect(text).not.toContain("signingSecret");
+ expect(
+ (await admin.api(`/webhooks/${webhook.id}/test`, { method: "POST" }))
+ .status,
+ ).toBe(409);
+ expect(
+ (await admin.api(`/webhooks/${webhook.id}`, { method: "DELETE" })).status,
+ ).toBe(200);
+ expect(await db.select().from(table)).toEqual([]);
+ const audit = await readAuditLog();
+ expect(audit.map((row) => row.action).sort()).toEqual([
+ "webhook.created",
+ "webhook.deleted",
+ "webhook.secret_rotated",
+ "webhook.updated",
+ ]);
+ expect(JSON.stringify(audit)).not.toContain(secret);
+ expect(JSON.stringify(audit)).not.toContain(next.secret);
+ expect(JSON.stringify(audit)).not.toContain(url);
+ for (const [method, suffix] of [
+ ["PUT", ""],
+ ["DELETE", ""],
+ ["POST", "/rotate-secret"],
+ ["POST", "/test"],
+ ["GET", "/deliveries"],
+ ]) {
+ const missing = await admin.api(`/webhooks/${webhook.id}${suffix}`, {
+ method,
+ ...(method === "PUT"
+ ? { body: { url, categories: ["user"], enabled: true } }
+ : {}),
+ });
+ expect(missing.status).toBe(404);
+ }
+ });
+
+ it("requires encryption configuration and validates categories and destinations on create and edit", async () => {
+ const { webhook } = await create();
+ vi.stubEnv("NOTIFICATION_SECRET_ENCRYPTION_KEY", "");
+ expect(
+ (
+ await admin.api("/webhooks", {
+ method: "POST",
+ body: { url, categories: ["user"], enabled: true },
+ })
+ ).status,
+ ).toBe(409);
+ expect(
+ (
+ await admin.api(`/webhooks/${webhook.id}/rotate-secret`, {
+ method: "POST",
+ })
+ ).status,
+ ).toBe(409);
+ expect(await (await admin.api("/webhooks")).json()).toMatchObject({
+ signingConfigured: false,
+ });
+ vi.stubEnv("KANEO_ALLOW_PRIVATE_WEBHOOK_DESTINATIONS", "");
+ const invalid = [
+ "http://127.0.0.1/events",
+ "https://10.0.0.1",
+ "https://[::1]",
+ "http://localhost",
+ "https://169.254.169.254/latest",
+ "https://user:[email protected]/events",
+ "file:///etc/passwd",
+ ];
+ for (const destination of invalid) {
+ for (const [method, path] of [
+ ["POST", "/webhooks"],
+ ["PUT", `/webhooks/${webhook.id}`],
+ ]) {
+ const response = await admin.api(path!, {
+ method,
+ body: { url: destination, categories: ["user"], enabled: true },
+ });
+ expect(response.status, destination).toBe(400);
+ }
+ }
+ for (const categories of [[], ["unknown"]]) {
+ expect(
+ (
+ await admin.api("/webhooks", {
+ method: "POST",
+ body: { url, categories, enabled: true },
+ })
+ ).status,
+ ).toBe(400);
+ }
+ vi.stubEnv("NODE_ENV", "production");
+ expect(
+ (
+ await admin.api(`/webhooks/${webhook.id}`, {
+ method: "PUT",
+ body: { url: "http://8.8.8.8", categories: ["user"], enabled: true },
+ })
+ ).status,
+ ).toBe(400);
+ });
+});
+
+describe("instance webhook delivery", () => {
+ it("signs the exact sanitized payload, routes categories, and omits payloads from history", async () => {
+ const { webhook, secret } = await create();
+ await create(["email"]);
+ await create(["user"], false);
+ await record();
+ expect(await sendWebhookDelivery()).toBe(true);
+ expect(await sendWebhookDelivery()).toBe(false);
+ expect(requests).toHaveLength(1);
+ const received = requests[0]!;
+ expect(received.headers["x-kaneo-signature"]).toBe(
+ `sha256=${createHmac("sha256", secret).update(`${received.headers["x-kaneo-timestamp"]}.${received.body}`).digest("hex")}`,
+ );
+ expect(JSON.parse(received.body)).toMatchObject({
+ action: "user.updated",
+ actorUserId: admin.userId,
+ actorName: "admin",
+ actorEmail: admin.email,
+ targetId: "target",
+ ipAddress: "203.0.113.2",
+ metadata: { name: "Changed" },
+ });
+ expect(received.body).not.toContain("must-not-stream");
+ expect(received.body).not.toContain("userAgent");
+ expect(received.body).not.toContain(secret);
+ const history = await admin.api(`/webhooks/${webhook.id}/deliveries`);
+ expect(history.status).toBe(200);
+ const entries = await history.json();
+ expect(entries).toEqual([
+ expect.objectContaining({
+ action: "user.updated",
+ state: "succeeded",
+ attempts: 1,
+ statusCode: 204,
+ errorCode: null,
+ }),
+ ]);
+ expect(JSON.stringify(entries)).not.toContain("payload");
+ expect(JSON.stringify(entries)).not.toContain(admin.email);
+ });
+
+ it("enqueues after commit and discards rolled-back audit entries", async () => {
+ await create();
+ await db.transaction(async (tx) => {
+ await record("user.updated", tx);
+ expect(await sendWebhookDelivery()).toBe(false);
+ expect(requests).toHaveLength(0);
+ });
+ expect(await sendWebhookDelivery()).toBe(true);
+ await expect(
+ db.transaction(async (tx) => {
+ await record("user.deleted", tx);
+ throw new Error("rollback");
+ }),
+ ).rejects.toThrow("rollback");
+ expect(await sendWebhookDelivery()).toBe(false);
+ expect(requests).toHaveLength(1);
+ });
+
+ it("delivers better-auth audit hooks and test events even when the category is unselected", async () => {
+ const { webhook } = await create();
+ const target = await signInWithRole(app, "user");
+ const response = await app.request("/api/auth/admin/update-user", {
+ method: "POST",
+ headers: {
+ "content-type": "application/json",
+ origin: "http://localhost:5173",
+ cookie: admin.cookies,
+ },
+ body: JSON.stringify({
+ userId: target.userId,
+ data: { name: "Renamed" },
+ }),
+ });
+ expect(response.status).toBe(200);
+ expect(await sendWebhookDelivery()).toBe(true);
+ expect(JSON.parse(requests[0]!.body).action).toBe("user.updated");
+ expect(
+ (await admin.api(`/webhooks/${webhook.id}/test`, { method: "POST" }))
+ .status,
+ ).toBe(202);
+ expect(await sendWebhookDelivery()).toBe(true);
+ expect(JSON.parse(requests[1]!.body).action).toBe("webhook.test");
+ expect(await sendWebhookDelivery()).toBe(false);
+ });
+
+ it("keeps actions successful when a receiver is down, retries with backoff, and stops after three attempts", async () => {
+ await create(["instance"]);
+ status = 503;
+ const saved = await admin.api("/settings", {
+ method: "PATCH",
+ body: { instanceName: "Webhook outage" },
+ });
+ expect(saved.status).toBe(200);
+ expect(requests).toHaveLength(0);
+ for (let attempt = 1; attempt <= 3; attempt++) {
+ expect(await sendWebhookDelivery()).toBe(true);
+ const [job] = await db.select().from(table);
+ expect(job).toMatchObject({
+ attempts: attempt,
+ statusCode: 503,
+ errorCode: "http",
+ state: attempt === 3 ? "failed" : "pending",
+ });
+ expect(job!.nextAttemptAt.getTime()).toBeGreaterThan(Date.now());
+ expect(await sendWebhookDelivery()).toBe(false);
+ await due();
+ }
+ expect(await sendWebhookDelivery()).toBe(false);
+ expect(requests).toHaveLength(3);
+ expect(
+ new Set(requests.map((r) => r.headers["x-kaneo-delivery"])).size,
+ ).toBe(1);
+ expect(JSON.stringify(await db.select().from(table))).not.toContain(
+ "untrusted-secret-response-body",
+ );
+ });
+
+ it("claims across workers once, recovers an expired lease, and bounds interrupted attempts", async () => {
+ await create();
+ await record();
+ const jobs = await Promise.all(
+ Array.from({ length: 8 }, () => claimWebhookDelivery()),
+ );
+ expect(jobs.filter(Boolean)).toHaveLength(1);
+ expect(await sendWebhookDelivery()).toBe(false);
+ await due();
+ expect(await sendWebhookDelivery()).toBe(true);
+ expect(requests).toHaveLength(1);
+ await record();
+ for (let attempt = 0; attempt < 3; attempt++) {
+ expect(await claimWebhookDelivery()).not.toBeNull();
+ await due();
+ }
+ expect(await claimWebhookDelivery()).toBeNull();
+ const rows = await db.select().from(table);
+ expect(rows).toContainEqual(
+ expect.objectContaining({
+ state: "failed",
+ attempts: 3,
+ errorCode: "interrupted",
+ }),
+ );
+ });
+
+ it("uses rotated secrets, cancels disabled jobs, and retains only 20 completed deliveries", async () => {
+ const { webhook } = await create();
+ await record();
+ const rotated = (await (
+ await admin.api(`/webhooks/${webhook.id}/rotate-secret`, {
+ method: "POST",
+ })
+ ).json()) as { secret: string };
+ await sendWebhookDelivery();
+ expect(requests[0]!.headers["x-kaneo-signature"]).toBe(
+ `sha256=${createHmac("sha256", rotated.secret).update(`${requests[0]!.headers["x-kaneo-timestamp"]}.${requests[0]!.body}`).digest("hex")}`,
+ );
+ for (let i = 0; i < 22; i++) {
+ await record();
+ await sendWebhookDelivery();
+ }
+ expect(await db.select().from(table)).toHaveLength(20);
+ await record();
+ expect(
+ (
+ await admin.api(`/webhooks/${webhook.id}`, {
+ method: "PUT",
+ body: { url, categories: ["user"], enabled: false },
+ })
+ ).status,
+ ).toBe(200);
+ expect(await sendWebhookDelivery()).toBe(false);
+ expect(
+ await db.select().from(table).where(eq(table.state, "pending")),
+ ).toEqual([]);
+ });
+});