⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
feat(admin): add DB-backed instance settings
Tin6e9aaa4695c2
diff --git a/apps/api/drizzle/0071_instance_settings.sql b/apps/api/drizzle/0071_instance_settings.sqlnew file mode 100644index 000000000..35aa0de91--- /dev/null+++ b/apps/api/drizzle/0071_instance_settings.sql@@ -0,0 +1,14 @@+CREATE TABLE "instance_settings" (+ "id" text PRIMARY KEY DEFAULT 'instance' NOT NULL,+ "instance_name" text,+ "registration_enabled" boolean DEFAULT true NOT NULL,+ "password_registration_enabled" boolean DEFAULT true NOT NULL,+ "require_email_verification" boolean DEFAULT false NOT NULL,+ "default_role_id" text,+ "workspace_creation_restricted" boolean DEFAULT false NOT NULL,+ "disabled_integrations" text[] DEFAULT '{}' NOT NULL,+ "updated_at" timestamp DEFAULT (now() AT TIME ZONE 'utc') NOT NULL+);+--> statement-breakpoint+ALTER TABLE "user" ADD COLUMN "email_verification_required" boolean DEFAULT false NOT NULL;--> statement-breakpoint+ALTER TABLE "instance_settings" ADD CONSTRAINT "instance_settings_default_role_id_instance_role_id_fk" FOREIGN KEY ("default_role_id") REFERENCES "public"."instance_role"("id") ON DELETE restrict ON UPDATE no action;\ No newline at end of filediff --git a/apps/api/drizzle/meta/0071_snapshot.json b/apps/api/drizzle/meta/0071_snapshot.jsonnew file mode 100644index 000000000..f3d5acaaf--- /dev/null+++ b/apps/api/drizzle/meta/0071_snapshot.json@@ -0,0 +1,5779 @@+{+ "id": "7ab4105f-964e-425f-a551-43895baf6683",+ "prevId": "5280db1b-84ba-447d-8990-095baa17d4f4",+ "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.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 filediff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.jsonindex 594aaeaf0..623095711 100644--- a/apps/api/drizzle/meta/_journal.json+++ b/apps/api/drizzle/meta/_journal.json@@ -498,6 +498,13 @@"when": 1793128577982,"tag": "0070_instance_roles","breakpoints": true+ },+ {+ "idx": 71,+ "version": "7",+ "when": 1793128646236,+ "tag": "0071_instance_settings",+ "breakpoints": true}]}diff --git a/apps/api/src/admin/controllers/create-user.ts b/apps/api/src/admin/controllers/create-user.tsindex 8857bd71e..c3e304a98 100644--- a/apps/api/src/admin/controllers/create-user.ts+++ b/apps/api/src/admin/controllers/create-user.ts@@ -2,6 +2,7 @@ import { eq, sql } from "drizzle-orm";import db from "../../database";import { userTable } from "../../database/schema";import { ApiError } from "../../errors/api-error";+import { readStoredSettings } from "../../instance-settings/read-stored-settings";import { isCloud } from "../../utils/is-cloud";import { isDisposableEmail } from "../../utils/is-disposable-email";import type { AdminAuditRequest } from "../audit/admin-audit-request";@@ -15,7 +16,8 @@ import { createsPasswordAccounts } from "../users/password-sign-in";type CreateUserInput = {name: string;email: string;- role: string;+ /** Defaults to the instance's default role. */+ role?: string;};export type PasswordSetupEmail =@@ -46,11 +48,12 @@ async function createUser(input: CreateUserInput, audit: AdminAuditRequest) {"Use a permanent email address. Disposable addresses cannot create accounts.",});}- const withPassword = createsPasswordAccounts();+ const withPassword = await createsPasswordAccounts();const actor = await getUserAccess(audit.actorUserId ?? "");const userId = await db.transaction(async (tx) => {- await assertAssignableRole(input.role, actor, tx);+ const role = input.role ?? (await readStoredSettings(tx)).defaultRole;+ await assertAssignableRole(role, actor, tx);const [existing] = await tx.select({ id: userTable.id }).from(userTable)@@ -60,7 +63,7 @@ async function createUser(input: CreateUserInput, audit: AdminAuditRequest) {const [created] = await tx.insert(userTable)- .values({ name, email, role: input.role, emailVerified: !withPassword })+ .values({ name, email, role, emailVerified: !withPassword }).onConflictDoNothing({ target: userTable.email }).returning({ id: userTable.id });if (!created) throw emailTaken();@@ -74,7 +77,7 @@ async function createUser(input: CreateUserInput, audit: AdminAuditRequest) {targetLabel: email,metadata: {name,- role: input.role,+ role,signIn: withPassword ? "password_link" : "single_sign_on",},},diff --git a/apps/api/src/admin/controllers/delete-instance-role.ts b/apps/api/src/admin/controllers/delete-instance-role.tsindex ca007cb18..dc2e74eb3 100644--- a/apps/api/src/admin/controllers/delete-instance-role.ts+++ b/apps/api/src/admin/controllers/delete-instance-role.ts@@ -1,6 +1,10 @@import { count, eq, sql } from "drizzle-orm";import db from "../../database";-import { instanceRoleTable, userTable } from "../../database/schema";+import {+ instanceRoleTable,+ instanceSettingsTable,+ userTable,+} from "../../database/schema";import { ApiError } from "../../errors/api-error";import type { AdminAuditRequest } from "../audit/admin-audit-request";import { recordAdminAction } from "../audit/record-admin-action";@@ -22,6 +26,19 @@ async function deleteInstanceRole(roleId: string, audit: AdminAuditRequest) {});}+ const [defaultFor] = await tx+ .select({ id: instanceSettingsTable.id })+ .from(instanceSettingsTable)+ .where(eq(instanceSettingsTable.defaultRoleId, roleId))+ .limit(1);+ if (defaultFor) {+ throw new ApiError(409, {+ code: "ROLE_IS_DEFAULT",+ message:+ "New users get this role. Choose another default role in instance settings first.",+ });+ }+await tx.delete(instanceRoleTable).where(eq(instanceRoleTable.id, roleId));await recordAdminAction({diff --git a/apps/api/src/admin/controllers/get-admin-settings.ts b/apps/api/src/admin/controllers/get-admin-settings.tsnew file mode 100644index 000000000..83d7126ab--- /dev/null+++ b/apps/api/src/admin/controllers/get-admin-settings.ts@@ -0,0 +1,3 @@+import { readAdminSettings } from "../settings/read-admin-settings";++export default readAdminSettings;diff --git a/apps/api/src/admin/controllers/get-overview.ts b/apps/api/src/admin/controllers/get-overview.tsindex 45f646d3e..2fc066e79 100644--- a/apps/api/src/admin/controllers/get-overview.ts+++ b/apps/api/src/admin/controllers/get-overview.ts@@ -1,5 +1,6 @@import { and, count, desc, eq, exists, gte, sql } from "drizzle-orm";import db, { schema } from "../../database";+import { getInstanceSettings } from "../../instance-settings/get-instance-settings";import { instanceAdminRoleSql } from "../../utils/instance-admin-role";import { notBannedCondition } from "../../utils/user-ban";import { configurationWarnings } from "../overview/configuration-warnings";@@ -115,7 +116,7 @@ export default async function getOverview() {},warnings: configurationWarnings(services,- process.env.DISABLE_REGISTRATION !== "true",+ (await getInstanceSettings()).registrationEnabled,users.enabledAdmins,),};diff --git a/apps/api/src/admin/controllers/get-system-status.ts b/apps/api/src/admin/controllers/get-system-status.tsindex febb4f077..2f48c681e 100644--- a/apps/api/src/admin/controllers/get-system-status.ts+++ b/apps/api/src/admin/controllers/get-system-status.ts@@ -1,17 +1,19 @@import { readAppVersion } from "../../app-version";+import { getInstanceSettings } from "../../instance-settings/get-instance-settings";import { describeAuth } from "../system/describe-auth";import { getServiceStatus } from "../system/get-service-status";import { listIntegrationProviders } from "../system/list-integration-providers";async function getSystemStatus() {- const [services, integrations] = await Promise.all([+ const [services, integrations, instance] = await Promise.all([getServiceStatus(),listIntegrationProviders(3_000),+ getInstanceSettings().catch(() => undefined),]);return {...services,version: readAppVersion(),- auth: describeAuth(),+ auth: describeAuth(instance),integrations,};}diff --git a/apps/api/src/admin/controllers/update-admin-settings.ts b/apps/api/src/admin/controllers/update-admin-settings.tsnew file mode 100644index 000000000..615361ec5--- /dev/null+++ b/apps/api/src/admin/controllers/update-admin-settings.ts@@ -0,0 +1,150 @@+import { isSmtpConfigured } from "@kaneo/email";+import { eq } from "drizzle-orm";+import db from "../../database";+import {+ instanceRoleTable,+ instanceSettingsTable,+} from "../../database/schema";+import { ApiError } from "../../errors/api-error";+import { invalidateInstanceSettings } from "../../instance-settings/get-instance-settings";+import {+ INSTANCE_SETTINGS_ID,+ readStoredSettings,+} from "../../instance-settings/read-stored-settings";+import { resolveInstanceSettings } from "../../instance-settings/resolve-instance-settings";+import { integrationPlugins } from "../../plugins";+import type { AdminAuditRequest } from "../audit/admin-audit-request";+import { recordAdminAction } from "../audit/record-admin-action";+import { assertAssignableRole } from "../roles/assert-assignable-role";+import { getUserAccess } from "../roles/get-instance-access";+import { readAdminSettings } from "../settings/read-admin-settings";+import type { UpdateInstanceSettingsInput } from "../settings/schema";++// Setting names go in values, not keys: the audit sanitizer drops keys that+// look like credentials, such as `passwordRegistrationEnabled`.+type Change = { setting: string; from: unknown; to: unknown };++function badRequest(code: string, message: string) {+ return new ApiError(400, { code, message });+}++function assertKnownIntegrations(types: string[]) {+ const known = new Set(integrationPlugins.map((plugin) => plugin.type));+ if (types.some((type) => !known.has(type))) {+ throw badRequest("UNKNOWN_INTEGRATION", "Unknown integration provider.");+ }+}++/** Save the changed settings and record which ones changed. */+async function updateAdminSettings(+ input: UpdateInstanceSettingsInput,+ audit: AdminAuditRequest,+) {+ const locked = resolveInstanceSettings(+ await readStoredSettings(),+ process.env,+ ).lockedByEnv;+ for (const key of locked) {+ if (input[key] !== undefined) {+ throw new ApiError(409, {+ code: "SETTING_LOCKED_BY_ENV",+ message: "An environment variable sets this option.",+ });+ }+ }+ if (input.requireEmailVerification === true && !isSmtpConfigured()) {+ throw badRequest(+ "EMAIL_DELIVERY_NOT_CONFIGURED",+ "Email verification needs SMTP to be configured.",+ );+ }+ if (input.defaultRole === "admin") {+ throw badRequest(+ "ADMIN_DEFAULT_ROLE",+ "New users can't become administrators by default.",+ );+ }+ const disabledIntegrations = input.disabledIntegrations+ ? [...new Set(input.disabledIntegrations)].sort()+ : undefined;+ if (disabledIntegrations) assertKnownIntegrations(disabledIntegrations);+ const instanceName =+ input.instanceName === undefined ? undefined : input.instanceName || null;++ const actor = await getUserAccess(audit.actorUserId ?? "");+ await db.transaction(async (tx) => {+ await tx+ .insert(instanceSettingsTable)+ .values({ id: INSTANCE_SETTINGS_ID })+ .onConflictDoNothing();+ await tx+ .select({ id: instanceSettingsTable.id })+ .from(instanceSettingsTable)+ .where(eq(instanceSettingsTable.id, INSTANCE_SETTINGS_ID))+ .for("update");+ const current = await readStoredSettings(tx);++ let defaultRoleId: string | null | undefined;+ if (input.defaultRole !== undefined) {+ // Share-locks the role so it can't be renamed or deleted first, and+ // stops anyone from handing new accounts permissions they lack.+ await assertAssignableRole(input.defaultRole, actor, tx);+ if (input.defaultRole === "user") {+ defaultRoleId = null;+ } else {+ const [role] = await tx+ .select({ id: instanceRoleTable.id })+ .from(instanceRoleTable)+ .where(eq(instanceRoleTable.name, input.defaultRole))+ .limit(1);+ defaultRoleId = role?.id ?? null;+ }+ }++ const next = {+ instanceName,+ registrationEnabled: input.registrationEnabled,+ passwordRegistrationEnabled: input.passwordRegistrationEnabled,+ requireEmailVerification: input.requireEmailVerification,+ defaultRole: input.defaultRole,+ workspaceCreationRestricted: input.workspaceCreationRestricted,+ disabledIntegrations,+ };+ const changes: Change[] = [];+ for (const [setting, to] of Object.entries(next)) {+ if (to === undefined) continue;+ const from = current[setting as keyof typeof current];+ if (JSON.stringify(from) !== JSON.stringify(to))+ changes.push({ setting, from, to });+ }+ if (changes.length === 0) return;++ await tx+ .update(instanceSettingsTable)+ .set({+ instanceName,+ registrationEnabled: input.registrationEnabled,+ passwordRegistrationEnabled: input.passwordRegistrationEnabled,+ requireEmailVerification: input.requireEmailVerification,+ defaultRoleId,+ workspaceCreationRestricted: input.workspaceCreationRestricted,+ disabledIntegrations,+ })+ .where(eq(instanceSettingsTable.id, INSTANCE_SETTINGS_ID));+ await recordAdminAction(+ {+ ...audit,+ action: "instance.settings_updated",+ targetType: "instance",+ targetId: null,+ targetLabel: null,+ metadata: { changes },+ },+ tx,+ );+ });+ invalidateInstanceSettings();+ return readAdminSettings();+}++export default updateAdminSettings;diff --git a/apps/api/src/admin/controllers/update-instance-role.ts b/apps/api/src/admin/controllers/update-instance-role.tsindex f2bf86f04..5d0c26fc2 100644--- a/apps/api/src/admin/controllers/update-instance-role.ts+++ b/apps/api/src/admin/controllers/update-instance-role.ts@@ -6,6 +6,7 @@ import { eq, sql } from "drizzle-orm";import db from "../../database";import { instanceRoleTable, userTable } from "../../database/schema";import type { AdminAuditRequest } from "../audit/admin-audit-request";+import { invalidateInstanceSettings } from "../../instance-settings/get-instance-settings";import { recordAdminAction } from "../audit/record-admin-action";import { assertRoleNameAvailable } from "../roles/assert-role-name-available";import { findInstanceRole } from "../roles/find-instance-role";@@ -22,7 +23,7 @@ async function updateInstanceRole(input: UpdateInstanceRoleInput,audit: AdminAuditRequest,) {- return db.transaction(async (tx) => {+ const updated = await db.transaction(async (tx) => {const current = await lockInstanceRole(roleId, tx);const renamed = input.name !== current.name;if (renamed) await assertRoleNameAvailable(input.name, tx, roleId);@@ -67,6 +68,9 @@ async function updateInstanceRole(if (!role) throw new Error("Instance role disappeared during update");return role;});+ // The cached default role is held by name.+ invalidateInstanceSettings();+ return updated;}export default updateInstanceRole;diff --git a/apps/api/src/admin/index.ts b/apps/api/src/admin/index.tsindex 728b24e26..42123e6c7 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 adminSettingsRoutes from "./settings-routes";import { getUserAccess } from "./roles/get-instance-access";import { instanceAccessSchema } from "./roles/schema";import adminUserAccountRoutes from "./user-account-routes";@@ -541,6 +542,7 @@ const admin = apiRouter().route("/users", adminUserRoutes).route("/users", adminUserAccountRoutes).route("/roles", adminRoleRoutes)+ .route("/settings", adminSettingsRoutes).route("/", adminUserSecurityRoutes);export default admin;diff --git a/apps/api/src/admin/schema.ts b/apps/api/src/admin/schema.tsindex e36f1dfc9..2aea4b08f 100644--- a/apps/api/src/admin/schema.ts+++ b/apps/api/src/admin/schema.ts@@ -96,7 +96,10 @@ export const createAdminUserBody = z.object({description:"The new user's email address. They sign in with it and receive their password link there.",}),- role: instanceRoleName.default("user"),+ role: instanceRoleName.optional().openapi({+ description:+ "Instance role, as for updates. Defaults to the instance's default role for new users.",+ }),});export const updateAdminUserBody = zdiff --git a/apps/api/src/admin/settings-routes.ts b/apps/api/src/admin/settings-routes.tsnew file mode 100644index 000000000..1aa0b2bee--- /dev/null+++ b/apps/api/src/admin/settings-routes.ts@@ -0,0 +1,80 @@+import {+ apiRouter,+ createRoute,+ errorResponse,+ jsonResponse,+} from "../openapi";+import { requireUserSession } from "../utils/require-user-session";+import { adminAuditRequest } from "./audit/admin-audit-request";+import getAdminSettings from "./controllers/get-admin-settings";+import updateAdminSettings from "./controllers/update-admin-settings";+import { requireInstancePermission } from "./roles/require-instance-permission";+import {+ instanceSettingsSchema,+ updateInstanceSettingsBody,+} from "./settings/schema";++const forbidden = errorResponse(+ "The caller lacks the instance permission or used an API key",+);++const getSettingsRoute = createRoute({+ method: "get",+ operationId: "getInstanceSettings",+ path: "/",+ tags: ["Admin"],+ summary: "Get instance settings",+ description:+ "Read the instance-wide settings, which ones an environment variable locks, and the choices for the default role and integrations. Requires the `instance:settings` instance permission; API keys are rejected.",+ middleware: [+ requireUserSession,+ requireInstancePermission("instance:settings"),+ ] as const,+ responses: {+ 200: jsonResponse("Instance settings", instanceSettingsSchema),+ 403: forbidden,+ },+});++const updateSettingsRoute = createRoute({+ method: "patch",+ operationId: "updateInstanceSettings",+ path: "/",+ tags: ["Admin"],+ summary: "Update instance settings",+ description:+ "Change one or more instance-wide settings. Other API instances apply a change within a few seconds. Requires the `instance:settings` instance permission; API keys are rejected.",+ middleware: [+ requireUserSession,+ requireInstancePermission("instance:settings"),+ ] as const,+ request: {+ body: {+ required: true,+ content: { "application/json": { schema: updateInstanceSettingsBody } },+ },+ },+ responses: {+ 200: jsonResponse("The saved settings", instanceSettingsSchema),+ 400: errorResponse(+ "Invalid value, `admin` as the default role, an unknown role or integration, or email verification without SMTP",+ ),+ 403: errorResponse(+ "The caller lacks the instance permission, used an API key, or chose a default role with permissions they lack",+ ),+ 409: errorResponse(+ "An environment variable locks the setting (code SETTING_LOCKED_BY_ENV)",+ ),+ },+});++const adminSettingsRoutes = apiRouter()+ .openapi(getSettingsRoute, async (c) => c.json(await getAdminSettings(), 200))+ .openapi(updateSettingsRoute, async (c) =>+ c.json(+ await updateAdminSettings(c.req.valid("json"), adminAuditRequest(c)),+ 200,+ ),+ );++export default adminSettingsRoutes;diff --git a/apps/api/src/admin/settings/read-admin-settings.ts b/apps/api/src/admin/settings/read-admin-settings.tsnew file mode 100644index 000000000..e4bc683b0--- /dev/null+++ b/apps/api/src/admin/settings/read-admin-settings.ts@@ -0,0 +1,40 @@+import { isSmtpConfigured } from "@kaneo/email";+import { asc } from "drizzle-orm";+import db from "../../database";+import { instanceRoleTable } from "../../database/schema";+import { readStoredSettings } from "../../instance-settings/read-stored-settings";+import { resolveInstanceSettings } from "../../instance-settings/resolve-instance-settings";+import { integrationPlugins } from "../../plugins";++function instanceUrl() {+ return process.env.KANEO_CLIENT_URL?.trim() || null;+}++/** The settings page: saved values with environment overrides applied. */+export async function readAdminSettings() {+ const [stored, roles] = await Promise.all([+ readStoredSettings(),+ db+ .select({ name: instanceRoleTable.name })+ .from(instanceRoleTable)+ .orderBy(asc(instanceRoleTable.name)),+ ]);+ const effective = resolveInstanceSettings(stored, process.env);+ return {+ instanceName: stored.instanceName,+ instanceUrl: instanceUrl(),+ registrationEnabled: effective.registrationEnabled,+ passwordRegistrationEnabled: effective.passwordRegistrationEnabled,+ requireEmailVerification: effective.requireEmailVerification,+ defaultRole: effective.defaultRole,+ workspaceCreationRestricted: effective.workspaceCreationRestricted,+ disabledIntegrations: effective.disabledIntegrations,+ lockedByEnv: effective.lockedByEnv,+ emailDeliveryConfigured: isSmtpConfigured(),+ roles: roles.map((role) => role.name),+ integrationProviders: integrationPlugins.map(({ type, name }) => ({+ type,+ name,+ })),+ };+}diff --git a/apps/api/src/admin/settings/schema.ts b/apps/api/src/admin/settings/schema.tsnew file mode 100644index 000000000..2ec9fbde5--- /dev/null+++ b/apps/api/src/admin/settings/schema.ts@@ -0,0 +1,74 @@+import { z } from "../../openapi";++const ENV_LOCKABLE = [+ "registrationEnabled",+ "passwordRegistrationEnabled",+ "workspaceCreationRestricted",+] as const;++export const updateInstanceSettingsBody = z+ .object({+ instanceName: z.string().trim().max(60).nullable().optional().openapi({+ description:+ "Shown in page titles and email headers and subjects. Empty or null restores Kaneo.",+ }),+ registrationEnabled: z.boolean().optional().openapi({+ description:+ "When false, only people with a valid invitation can create an account. Locked when `DISABLE_REGISTRATION=true`.",+ }),+ passwordRegistrationEnabled: z.boolean().optional().openapi({+ description:+ "When false, new accounts must use a social or OIDC provider. Locked when `DISABLE_PASSWORD_REGISTRATION=true`.",+ }),+ requireEmailVerification: z.boolean().optional().openapi({+ description:+ "New password sign-ups must confirm their email before they can sign in. Requires email delivery.",+ }),+ defaultRole: z.string().min(1).max(64).optional().openapi({+ description:+ "Instance role for new users: `user` or a custom role name, never `admin`. You can only choose a role whose permissions you have.",+ }),+ workspaceCreationRestricted: z.boolean().optional().openapi({+ description:+ "Only administrators can create workspaces. Locked when `DISABLE_WORKSPACE_CREATION=true`.",+ }),+ disabledIntegrations: z.array(z.string()).max(32).optional().openapi({+ description:+ "Integration provider types to turn off. Their connections stop syncing and delivering, and projects can't connect them.",+ }),+ })+ .refine((body) => Object.values(body).some((value) => value !== undefined), {+ message: "Nothing to update",+ });++export type UpdateInstanceSettingsInput = z.infer<+ typeof updateInstanceSettingsBody+>;++export const instanceSettingsSchema = z+ .object({+ instanceName: z.string().nullable().openapi({+ description: "The saved name, or null for the default Kaneo.",+ }),+ instanceUrl: z.string().nullable().openapi({+ description: "The web app URL from `KANEO_CLIENT_URL`. Read-only.",+ }),+ registrationEnabled: z.boolean(),+ passwordRegistrationEnabled: z.boolean(),+ requireEmailVerification: z.boolean(),+ defaultRole: z.string(),+ workspaceCreationRestricted: z.boolean(),+ disabledIntegrations: z.array(z.string()),+ lockedByEnv: z.array(z.enum(ENV_LOCKABLE)).openapi({+ description:+ "Settings an environment variable forces. Their values here are the effective ones.",+ }),+ emailDeliveryConfigured: z.boolean(),+ roles: z.array(z.string()).openapi({+ description: "Custom instance roles that can be the default role.",+ }),+ integrationProviders: z.array(+ z.object({ type: z.string(), name: z.string() }),+ ),+ })+ .openapi("InstanceSettings");diff --git a/apps/api/src/admin/system/describe-auth.ts b/apps/api/src/admin/system/describe-auth.tsindex 718ae3e31..a34d214c7 100644--- a/apps/api/src/admin/system/describe-auth.ts+++ b/apps/api/src/admin/system/describe-auth.ts@@ -1,4 +1,9 @@import { isSmtpConfigured } from "@kaneo/email";+import {+ DEFAULT_STORED_SETTINGS,+ type InstanceSettings,+ resolveInstanceSettings,+} from "../../instance-settings/resolve-instance-settings";import { resolveFileSecret } from "../../utils/file-secret";import { getGithubSsoOAuthCredentials } from "../../utils/github-sso-env";import { credentialSetStatus } from "./credential-set-status";@@ -34,11 +39,15 @@ function customOAuthEndpoint() {* Which sign-in paths this instance offers. Only booleans and display names* leave here: never client ids, secrets, or provider URLs.*/-export function describeAuth() {+export function describeAuth(+ instance: InstanceSettings = resolveInstanceSettings(+ DEFAULT_STORED_SETTINGS,+ process.env,+ ),+) {const disableLoginForm = process.env.DISABLE_LOGIN_FORM === "true";- const disableRegistration = process.env.DISABLE_REGISTRATION === "true";- const disablePasswordRegistration =- process.env.DISABLE_PASSWORD_REGISTRATION === "true";+ const disableRegistration = !instance.registrationEnabled;+ const disablePasswordRegistration = !instance.passwordRegistrationEnabled;const github = getGithubSsoOAuthCredentials();const providers: AuthProvider[] = [{@@ -89,7 +98,7 @@ export function describeAuth() {!disableRegistration &&!disablePasswordRegistration &&!disableLoginForm,- workspaceCreation: process.env.DISABLE_WORKSPACE_CREATION !== "true",+ workspaceCreation: !instance.workspaceCreationRestricted,providers,};}diff --git a/apps/api/src/admin/users/password-sign-in.ts b/apps/api/src/admin/users/password-sign-in.tsindex 1d2526820..b4670158f 100644--- a/apps/api/src/admin/users/password-sign-in.ts+++ b/apps/api/src/admin/users/password-sign-in.ts@@ -1,3 +1,5 @@+import { getInstanceSettings } from "../../instance-settings/get-instance-settings";+// Read at call time so tests can stub the environment./** Local password sign-in is turned off entirely. */@@ -9,9 +11,9 @@ export function isPasswordSignInDisabled() {* Whether a new account gets a link to choose a password. When password sign-in* or password registration is off, accounts are created for single sign-on.*/-export function createsPasswordAccounts() {+export async function createsPasswordAccounts() {return (!isPasswordSignInDisabled() &&- process.env.DISABLE_PASSWORD_REGISTRATION !== "true"+ (await getInstanceSettings()).passwordRegistrationEnabled);}diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.tsindex 0bed156dd..4c85cff8c 100644--- a/apps/api/src/auth.ts+++ b/apps/api/src/auth.ts@@ -10,6 +10,7 @@ import { apiKey } from "@better-auth/api-key";import {isSmtpConfigured,OTP_EXPIRY_SECONDS,+ setBrandNameResolver,sendMagicLinkEmail,sendOtpEmail,sendPasswordResetEmail,@@ -55,6 +56,12 @@ import {} from "./backchannel-logout/sign-in-session-id";import db, { schema } from "./database";import { authDatabaseAdapter } from "./database/auth-adapter";+import {+ emailVerificationContext,+ signUpNeedsVerification,+} from "./instance-settings/email-verification-gate";+import { getInstanceSettings } from "./instance-settings/get-instance-settings";+import { readStoredSettings } from "./instance-settings/read-stored-settings";import { lockedSessionRevocation } from "./utils/locked-session-revocation";import { publishEvent } from "./events";import { applyInvitationProjectAccess } from "./project-access/apply-invitation-project-access";@@ -134,16 +141,17 @@ import { authCaptchaPaths, verifyTurnstile } from "./utils/verify-turnstile";config();+setBrandNameResolver(async () => (await getInstanceSettings()).instanceName);+const githubSso = getGithubSsoOAuthCredentials();-const isRegistrationDisabled = process.env.DISABLE_REGISTRATION === "true";-const isPasswordRegistrationDisabled =+// Only the environment can be read at startup. The database setting is+// enforced when the user row is created (`assertUserRegistrationAllowed`).+const isPasswordRegistrationDisabledByEnv =process.env.DISABLE_PASSWORD_REGISTRATION === "true";const isLoginFormDisabled = process.env.DISABLE_LOGIN_FORM === "true";const isEmailOtpSignInDisabled =process.env.DISABLE_EMAIL_OTP_SIGN_IN === "true";-const isWorkspaceCreationDisabled =- process.env.DISABLE_WORKSPACE_CREATION === "true";const apiUrl = process.env.KANEO_API_URL || "http://localhost:1337";const clientUrl = process.env.KANEO_CLIENT_URL || "http://localhost:5173";@@ -208,12 +216,13 @@ function isEmailCodeSignInAvailable() {);}-// Reads env at call time (not module scope) so tests can stub it.+// Reads settings at call time (not module scope) so tests can change them.async function shouldDeliverSignInEmail(email: string) {- if (process.env.DISABLE_PASSWORD_REGISTRATION === "true") {+ const settings = await getInstanceSettings();+ if (!settings.passwordRegistrationEnabled) {return userExistsByEmail(email);}- if (process.env.DISABLE_REGISTRATION === "true") {+ if (!settings.registrationEnabled) {// Mirror `assertUserRegistrationAllowed`: the first non-guest user can// always complete initial instance setup.if (!(await hasRegisteredUsers())) {@@ -314,6 +323,13 @@ export const auth = betterAuth({input: true,required: false,},+ emailVerificationRequired: {+ type: "boolean",+ input: false,+ required: false,+ defaultValue: false,+ returned: false,+ },},deleteUser: {enabled: true,@@ -394,7 +410,7 @@ export const auth = betterAuth({: []),lastLoginMethod(),magicLink({- disableSignUp: isPasswordRegistrationDisabled,+ disableSignUp: isPasswordRegistrationDisabledByEnv,sendMagicLink: async ({ email, url }, ctx) => {const requestContext = getEmailRequestContext(ctx?.request?.headers ?? ctx?.headers,@@ -418,7 +434,7 @@ export const auth = betterAuth({: [emailOTP({expiresIn: OTP_EXPIRY_SECONDS,- disableSignUp: isPasswordRegistrationDisabled,+ disableSignUp: isPasswordRegistrationDisabledByEnv,async sendVerificationOTP({ email, otp, type }, ctx) {if (type === "sign-in") {const requestContext = getEmailRequestContext(@@ -515,7 +531,8 @@ export const auth = betterAuth({},},},- // When `DISABLE_WORKSPACE_CREATION` is set, only instance admins+ // When workspace creation is restricted (instance setting or+ // `DISABLE_WORKSPACE_CREATION`), only instance admins// (role list includes "admin") may create workspaces — mirrors the// implicit-exemption shape of `DISABLE_REGISTRATION` above. This// check runs before any workspace membership exists, so only the@@ -525,15 +542,15 @@ export const auth = betterAuth({//// Read the current instance role rather than a session's user snapshot,// which can predate first-user promotion or an administrator's changes.- allowUserToCreateOrganization: isWorkspaceCreationDisabled- ? async (user) => {- const [freshUser] = await db- .select({ role: schema.userTable.role })- .from(schema.userTable)- .where(eq(schema.userTable.id, user.id));- return hasInstanceAdminRole(freshUser?.role);- }- : true,+ allowUserToCreateOrganization: async (user) => {+ if (!(await getInstanceSettings()).workspaceCreationRestricted)+ return true;+ const [freshUser] = await db+ .select({ role: schema.userTable.role })+ .from(schema.userTable)+ .where(eq(schema.userTable.id, user.id));+ return hasInstanceAdminRole(freshUser?.role);+ },// Better Auth defaults this to `true`, which blocks any user whose email// is not verified from accepting/rejecting an invitation. Kaneo does not// verify emails on signup (and guest/anonymous users are unverified by@@ -790,6 +807,18 @@ export const auth = betterAuth({ctx?.headers?.get("x-invitation-id"),},);+ if ((user as Partial<UserWithAnonymous>).isAnonymous) return;+ // Every sign-up path (password, email code, OAuth/OIDC) gets the+ // default role. better-auth's admin endpoint sets its own role.+ if (ctx?.path === "/admin/create-user") return;+ return {+ data: {+ role: (await readStoredSettings()).defaultRole,+ ...((await signUpNeedsVerification(ctx?.path))+ ? { emailVerificationRequired: true }+ : {}),+ },+ };},after: async (user) => {// The anonymous() plugin creates ephemeral users for guest@@ -838,7 +867,11 @@ export const auth = betterAuth({before: createAuthMiddleware(async (ctx,- ): Promise<void | Awaited<ReturnType<typeof deleteNativeWorkspace>>> => {+ ): Promise<+ | void+ | Awaited<ReturnType<typeof deleteNativeWorkspace>>+ | Awaited<ReturnType<typeof emailVerificationContext>>+ > => {// Runs before provider hooks can turn a key into its owner's session.await assertNativeAuthApiKeyAllowed(ctx);let organizationViewer: {@@ -996,19 +1029,22 @@ export const auth = betterAuth({}}+ const verification = await emailVerificationContext(ctx);+const isSignUpPath =ctx.path === "/sign-up/email" ||ctx.path.startsWith("/callback/") ||ctx.path.startsWith("/sign-in/social");if (!isSignUpPath) {- return;+ return verification;}const isInstanceAdminSetup = !(await hasRegisteredUsers());+ const settings = await getInstanceSettings();if (ctx.path === "/sign-up/email") {- if (isPasswordRegistrationDisabled && !isInstanceAdminSetup) {+ if (!settings.passwordRegistrationEnabled && !isInstanceAdminSetup) {throw new APIError("FORBIDDEN", {code: "PASSWORD_REGISTRATION_DISABLED",message:@@ -1028,8 +1064,8 @@ export const auth = betterAuth({}}- if (!isRegistrationDisabled || isInstanceAdminSetup) {- return;+ if (settings.registrationEnabled || isInstanceAdminSetup) {+ return verification;}const email =@@ -1051,6 +1087,7 @@ export const auth = betterAuth({});}}+ return verification;},),after: createAuthMiddleware(async (ctx) => {diff --git a/apps/api/src/config/index.ts b/apps/api/src/config/index.tsindex 19a756c08..b7868438c 100644--- a/apps/api/src/config/index.ts+++ b/apps/api/src/config/index.ts@@ -1,3 +1,4 @@+import { getInstanceSettings } from "../instance-settings/get-instance-settings";import { apiRouter, createRoute, jsonResponse } from "../openapi";import getSettings from "../utils/get-settings";import { configSchema } from "./response";@@ -11,15 +12,15 @@ const getConfigRoute = createRoute({tags: ["Config"],summary: "Get config",description:- "Public instance settings: which sign-in methods, registration paths, and features are enabled.",+ "Public instance settings: the instance name, which sign-in methods, registration paths, integrations, and features are enabled.",security: [],responses: {200: jsonResponse("Application settings", configSchema),},});-const config = apiRouter().openapi(getConfigRoute, (c) =>- c.json(getSettings(), 200),+const config = apiRouter().openapi(getConfigRoute, async (c) =>+ c.json(getSettings(await getInstanceSettings()), 200),);export default config;diff --git a/apps/api/src/config/response.ts b/apps/api/src/config/response.tsindex 538bf7887..4f19809b0 100644--- a/apps/api/src/config/response.ts+++ b/apps/api/src/config/response.ts@@ -4,10 +4,17 @@ import { MANAGED_PROFILE_FIELDS } from "../utils/custom-oauth-env";export const configSchema = z.object({isCloud: z.boolean(),+ instanceName: z.string().openapi({+ description: "Name shown in page titles and emails. Defaults to Kaneo.",+ }),disableRegistration: z.boolean(),disablePasswordRegistration: z.boolean(),disableEmailOtpSignIn: z.boolean(),disableWorkspaceCreation: z.boolean(),+ disabledIntegrations: z.array(z.string()).openapi({+ description:+ "Integration provider types an administrator turned off, such as `slack`.",+ }),isDemoMode: z.boolean(),hasSmtp: z.boolean(),hasImageUploads: z.boolean().openapi({diff --git a/apps/api/src/database/index.ts b/apps/api/src/database/index.tsindex 0b5be1a12..dd87134c7 100644--- a/apps/api/src/database/index.ts+++ b/apps/api/src/database/index.ts@@ -42,6 +42,7 @@ import {activityTable,adminAuditLogTable,instanceRoleTable,+ instanceSettingsTable,apikeyTable,assetTable,billingEventTable,@@ -94,6 +95,7 @@ export const schema = {accountTable,adminAuditLogTable,instanceRoleTable,+ instanceSettingsTable,assetTable,activityTable,apikeyTable,diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.tsindex 99e3893b4..d6b8a7418 100644--- a/apps/api/src/database/schema.ts+++ b/apps/api/src/database/schema.ts@@ -51,6 +51,10 @@ export const userTable = pgTable("user", {banned: boolean("banned").default(false),banReason: text("ban_reason"),banExpires: timestamp("ban_expires", { mode: "date" }),+ // Set on password sign-ups while the instance requires email verification.+ emailVerificationRequired: boolean("email_verification_required")+ .default(false)+ .notNull(),});export const sessionTable = pgTable(@@ -195,6 +199,36 @@ export const instanceRoleTable = pgTable("instance_role", {.notNull(),});+// A single row (id "instance"). Without it, every setting has its default.+export const instanceSettingsTable = pgTable("instance_settings", {+ id: text("id").primaryKey().default("instance"),+ instanceName: text("instance_name"),+ registrationEnabled: boolean("registration_enabled").default(true).notNull(),+ passwordRegistrationEnabled: boolean("password_registration_enabled")+ .default(true)+ .notNull(),+ requireEmailVerification: boolean("require_email_verification")+ .default(false)+ .notNull(),+ defaultRoleId: text("default_role_id").references(+ () => instanceRoleTable.id,+ {+ onDelete: "restrict",+ },+ ),+ workspaceCreationRestricted: boolean("workspace_creation_restricted")+ .default(false)+ .notNull(),+ disabledIntegrations: text("disabled_integrations")+ .array()+ .notNull()+ .default(sql`'{}'`),+ updatedAt: timestamp("updated_at", { mode: "date" })+ .default(utcNow)+ .$onUpdate(() => new Date())+ .notNull(),+});+export const verificationTable = pgTable("verification",{diff --git a/apps/api/src/index.ts b/apps/api/src/index.tsindex 8d2f56e11..c22dab81c 100644--- a/apps/api/src/index.ts+++ b/apps/api/src/index.ts@@ -66,7 +66,7 @@ import notification from "./notification";import notificationPreferences from "./notification-preferences";import oauth from "./oauth";import { createRoute, errorResponse, jsonResponse, z } from "./openapi";-import { initializePlugins } from "./plugins";+import { initializePlugins, integrationPlugins } from "./plugins";import { migrateGitHubIntegration } from "./plugins/github/migration";import project from "./project";import { assertProjectAccess } from "./project-access/assert-project-access";@@ -90,6 +90,7 @@ import getAvatar from "./user/controllers/get-avatar";import { apiKeyRejection } from "./utils/api-key-rejection";import { applyApiKeyHeaders } from "./utils/apply-api-key-headers";import { authenticateApiRequest } from "./utils/authenticate-api-request";+import { requireIntegrationProviderEnabled } from "./instance-settings/require-integration-provider-enabled";import {authorizeAssetAccess,isPublicAsset,@@ -826,6 +827,11 @@ export function createApp() {);const searchApi = api.route("/search", search);const integrationSyncApi = api.route("/integration-sync", integrationSync);+ // Inbound provider webhooks are mounted earlier and answer on their own;+ // their work is skipped through `activeIntegrationCondition`.+ for (const { type } of integrationPlugins) {+ api.use(`/${type}-integration/*`, requireIntegrationProviderEnabled(type));+ }const githubIntegrationApi = api.route("/github-integration",githubIntegration,diff --git a/apps/api/src/instance-settings/email-verification-gate.ts b/apps/api/src/instance-settings/email-verification-gate.tsnew file mode 100644index 000000000..622fc4c2b--- /dev/null+++ b/apps/api/src/instance-settings/email-verification-gate.ts@@ -0,0 +1,63 @@+import { eq } from "drizzle-orm";+import db from "../database";+import { userTable } from "../database/schema";+import { hasRegisteredUsers } from "../utils/instance-bootstrap";+import { getInstanceSettings } from "./get-instance-settings";+import { sendSignUpVerificationEmail } from "./send-sign-up-verification-email";++type AuthRequest = { path: string; body?: { email?: unknown } | null };++/**+ * Whether a new password sign-up must confirm its email before signing in.+ * The first account sets the instance up, so it is never held back.+ */+export async function signUpNeedsVerification(path: string | undefined) {+ return (+ path === "/sign-up/email" &&+ (await getInstanceSettings()).requireEmailVerification &&+ (await hasRegisteredUsers())+ );+}++async function signInNeedsVerification(email: unknown) {+ if (typeof email !== "string") return false;+ if (!(await getInstanceSettings()).requireEmailVerification) return false;+ const [user] = await db+ .select({+ required: userTable.emailVerificationRequired,+ verified: userTable.emailVerified,+ })+ .from(userTable)+ .where(eq(userTable.email, email.trim().toLowerCase()))+ .limit(1);+ return Boolean(user?.required && !user.verified);+}++/**+ * A better-auth `before` hook result that turns on its email verification for+ * this request only: sign-up skips the session and emails a link, and password+ * sign-in of an unconfirmed sign-up is refused with a fresh link. better-auth+ * reads these options per request, and the shared options stay untouched.+ */+export async function emailVerificationContext(ctx: AuthRequest) {+ const required =+ ctx.path === "/sign-up/email"+ ? await signUpNeedsVerification(ctx.path)+ : ctx.path === "/sign-in/email" &&+ (await signInNeedsVerification(ctx.body?.email));+ if (!required) return undefined;+ return {+ context: {+ context: {+ options: {+ emailAndPassword: { requireEmailVerification: true },+ emailVerification: {+ sendOnSignUp: true,+ sendOnSignIn: true,+ sendVerificationEmail: sendSignUpVerificationEmail,+ },+ },+ },+ },+ };+}diff --git a/apps/api/src/instance-settings/get-instance-settings.ts b/apps/api/src/instance-settings/get-instance-settings.tsnew file mode 100644index 000000000..c371d7efa--- /dev/null+++ b/apps/api/src/instance-settings/get-instance-settings.ts@@ -0,0 +1,32 @@+import { readStoredSettings } from "./read-stored-settings";+import {+ type InstanceSettings,+ resolveInstanceSettings,+ type StoredInstanceSettings,+} from "./resolve-instance-settings";++// Other API instances pick up a change within this window; Redis stays optional.+const CACHE_MS = 5_000;++let cached: {+ expiresAt: number;+ value: Promise<StoredInstanceSettings>;+} | null = null;++/** The effective instance settings. Environment variables win over the database. */+export async function getInstanceSettings(): Promise<InstanceSettings> {+ const now = Date.now();+ if (!cached || cached.expiresAt <= now) {+ const value = readStoredSettings();+ cached = { expiresAt: now + CACHE_MS, value };+ // Don't keep a failed read around.+ value.catch(() => {+ if (cached?.value === value) cached = null;+ });+ }+ return resolveInstanceSettings(await cached.value, process.env);+}++export function invalidateInstanceSettings() {+ cached = null;+}diff --git a/apps/api/src/instance-settings/read-stored-settings.ts b/apps/api/src/instance-settings/read-stored-settings.tsnew file mode 100644index 000000000..c522d66a6--- /dev/null+++ b/apps/api/src/instance-settings/read-stored-settings.ts@@ -0,0 +1,37 @@+import { eq } from "drizzle-orm";+import db from "../database";+import { instanceRoleTable, instanceSettingsTable } from "../database/schema";+import type { DbOrTx } from "../project-access/db-or-tx";+import {+ DEFAULT_STORED_SETTINGS,+ type StoredInstanceSettings,+} from "./resolve-instance-settings";++export const INSTANCE_SETTINGS_ID = "instance";++export async function readStoredSettings(+ tx: DbOrTx = db,+): Promise<StoredInstanceSettings & { defaultRoleId: string | null }> {+ const [row] = await tx+ .select({+ instanceName: instanceSettingsTable.instanceName,+ registrationEnabled: instanceSettingsTable.registrationEnabled,+ passwordRegistrationEnabled:+ instanceSettingsTable.passwordRegistrationEnabled,+ requireEmailVerification: instanceSettingsTable.requireEmailVerification,+ defaultRoleId: instanceSettingsTable.defaultRoleId,+ defaultRole: instanceRoleTable.name,+ workspaceCreationRestricted:+ instanceSettingsTable.workspaceCreationRestricted,+ disabledIntegrations: instanceSettingsTable.disabledIntegrations,+ })+ .from(instanceSettingsTable)+ .leftJoin(+ instanceRoleTable,+ eq(instanceRoleTable.id, instanceSettingsTable.defaultRoleId),+ )+ .where(eq(instanceSettingsTable.id, INSTANCE_SETTINGS_ID))+ .limit(1);+ if (!row) return { ...DEFAULT_STORED_SETTINGS, defaultRoleId: null };+ return { ...row, defaultRole: row.defaultRole ?? "user" };+}diff --git a/apps/api/src/instance-settings/require-integration-provider-enabled.ts b/apps/api/src/instance-settings/require-integration-provider-enabled.tsnew file mode 100644index 000000000..d19759cf7--- /dev/null+++ b/apps/api/src/instance-settings/require-integration-provider-enabled.ts@@ -0,0 +1,24 @@+import type { Context, Next } from "hono";+import { ApiError } from "../errors/api-error";+import { getInstanceSettings } from "./get-instance-settings";++const READ_OR_REMOVE = new Set(["GET", "HEAD", "OPTIONS", "DELETE"]);++/**+ * While a provider is turned off, projects can still see and remove their+ * connection, but can't connect, change, or import through it.+ */+export function requireIntegrationProviderEnabled(type: string) {+ return async function requireProviderEnabled(c: Context, next: Next) {+ if (+ !READ_OR_REMOVE.has(c.req.method) &&+ (await getInstanceSettings()).disabledIntegrations.includes(type)+ ) {+ throw new ApiError(403, {+ code: "INTEGRATION_PROVIDER_DISABLED",+ message: "An administrator turned this integration off.",+ });+ }+ return next();+ };+}diff --git a/apps/api/src/instance-settings/resolve-instance-settings.ts b/apps/api/src/instance-settings/resolve-instance-settings.tsnew file mode 100644index 000000000..39a28beae--- /dev/null+++ b/apps/api/src/instance-settings/resolve-instance-settings.ts@@ -0,0 +1,68 @@+export const DEFAULT_INSTANCE_NAME = "Kaneo";++/** What the `instance_settings` row holds, with defaults for a missing row. */+export type StoredInstanceSettings = {+ instanceName: string | null;+ registrationEnabled: boolean;+ passwordRegistrationEnabled: boolean;+ requireEmailVerification: boolean;+ /** Custom role name, or `user` when no default role is set. */+ defaultRole: string;+ workspaceCreationRestricted: boolean;+ disabledIntegrations: string[];+};++/** Settings an environment variable can force. */+export type EnvLockedSetting =+ | "registrationEnabled"+ | "passwordRegistrationEnabled"+ | "workspaceCreationRestricted";++export type InstanceSettings = Omit<StoredInstanceSettings, "instanceName"> & {+ instanceName: string;+ /** Settings forced by an environment variable, which wins over the database. */+ lockedByEnv: EnvLockedSetting[];+};++export const DEFAULT_STORED_SETTINGS: StoredInstanceSettings = {+ instanceName: null,+ registrationEnabled: true,+ passwordRegistrationEnabled: true,+ requireEmailVerification: false,+ defaultRole: "user",+ workspaceCreationRestricted: false,+ disabledIntegrations: [],+};++type Env = Record<string, string | undefined>;++/**+ * Apply environment overrides. Only `"true"` locks a setting: deployments that+ * set these variables to `"false"` keep the database value.+ */+export function resolveInstanceSettings(+ stored: StoredInstanceSettings,+ env: Env,+): InstanceSettings {+ const registrationLocked = env.DISABLE_REGISTRATION === "true";+ const passwordLocked = env.DISABLE_PASSWORD_REGISTRATION === "true";+ const workspaceLocked = env.DISABLE_WORKSPACE_CREATION === "true";+ const lockedByEnv: EnvLockedSetting[] = [];+ if (registrationLocked) lockedByEnv.push("registrationEnabled");+ if (passwordLocked) lockedByEnv.push("passwordRegistrationEnabled");+ if (workspaceLocked) lockedByEnv.push("workspaceCreationRestricted");++ return {+ ...stored,+ instanceName: stored.instanceName?.trim() || DEFAULT_INSTANCE_NAME,+ registrationEnabled: registrationLocked+ ? false+ : stored.registrationEnabled,+ passwordRegistrationEnabled: passwordLocked+ ? false+ : stored.passwordRegistrationEnabled,+ workspaceCreationRestricted:+ workspaceLocked || stored.workspaceCreationRestricted,+ lockedByEnv,+ };+}diff --git a/apps/api/src/instance-settings/send-sign-up-verification-email.ts b/apps/api/src/instance-settings/send-sign-up-verification-email.tsnew file mode 100644index 000000000..a5348f2e3--- /dev/null+++ b/apps/api/src/instance-settings/send-sign-up-verification-email.ts@@ -0,0 +1,40 @@+import { sendEmailVerificationEmail } from "@kaneo/email";+import { accountEmailSubject } from "../admin/users/account-email-subjects";++type Recipient = { email: string; name?: string | null; locale?: unknown };++function signInUrl() {+ const base = process.env.KANEO_CLIENT_URL || "http://localhost:5173";+ return `${base.replace(/\/$/, "")}/auth/sign-in`;+}++/**+ * Email the link better-auth built for a password sign-up. After confirming,+ * the person lands on the web sign-in page instead of the API's root.+ */+export async function sendSignUpVerificationEmail({+ user,+ url,+}: {+ user: Recipient;+ url: string;+}) {+ const link = new URL(url);+ link.searchParams.set("callbackURL", signInUrl());+ const locale = typeof user.locale === "string" ? user.locale : null;+ try {+ await sendEmailVerificationEmail(+ user.email,+ accountEmailSubject("verification", locale),+ {+ verificationLink: link.toString(),+ userName: user.name ?? undefined,+ locale,+ requestedBy: "sign-up",+ },+ );+ } catch {+ // The account stays; signing in with the password sends a new link.+ console.error("Sign-up verification email could not be sent");+ }+}diff --git a/apps/api/src/plugins/active-integration-condition.ts b/apps/api/src/plugins/active-integration-condition.tsindex de8abb1be..f13dd5a4d 100644--- a/apps/api/src/plugins/active-integration-condition.ts+++ b/apps/api/src/plugins/active-integration-condition.ts@@ -1,14 +1,24 @@-import { and, eq } from "drizzle-orm";+import { and, eq, type SQLWrapper, sql } from "drizzle-orm";import { integrationTable } from "../database/schema";import { projectInActiveWorkspace } from "../workspace/archive/active-workspace-sql";+/** True unless an administrator turned this integration provider off. */+export function integrationProviderEnabled(type: SQLWrapper) {+ return sql<boolean>`not exists (+ select 1 from "instance_settings" as "provider_settings"+ where ${type} = any("provider_settings"."disabled_integrations")+ )`;+}+/*** An integration acts (webhooks in or out, syncs, reminders) only while it is- * enabled and its workspace is not archived.+ * enabled, its workspace is not archived, and its provider is not turned off.+ * Read in SQL so every API instance sees a change at once.*/export function activeIntegrationCondition() {return and(eq(integrationTable.isActive, true),projectInActiveWorkspace(integrationTable.projectId),+ integrationProviderEnabled(integrationTable.type),);}diff --git a/apps/api/src/utils/check-registration-allowed.ts b/apps/api/src/utils/check-registration-allowed.tsindex 39cc18ace..1083de820 100644--- a/apps/api/src/utils/check-registration-allowed.ts+++ b/apps/api/src/utils/check-registration-allowed.ts@@ -1,6 +1,7 @@import { and, eq, gt, isNull } from "drizzle-orm";import db from "../database";import { invitationTable, userTable, workspaceTable } from "../database/schema";+import { getInstanceSettings } from "../instance-settings/get-instance-settings";type RegistrationCheckResult = {allowed: boolean;@@ -21,9 +22,7 @@ export async function checkRegistrationAllowed(invitationId?: string,options?: { allowInvitationByEmail?: boolean; emailVerified?: boolean },): Promise<RegistrationCheckResult> {- const isRegistrationDisabled = process.env.DISABLE_REGISTRATION === "true";-- if (!isRegistrationDisabled) {+ if ((await getInstanceSettings()).registrationEnabled) {return {allowed: true,reason: "Registration is enabled",diff --git a/apps/api/src/utils/get-settings.ts b/apps/api/src/utils/get-settings.tsindex 42fcfac4b..b577f6551 100644--- a/apps/api/src/utils/get-settings.ts+++ b/apps/api/src/utils/get-settings.ts@@ -1,6 +1,11 @@import { isSmtpConfigured } from "@kaneo/email";import { config } from "dotenv-mono";import { isBillingEnabled } from "../billing/config";+import {+ DEFAULT_STORED_SETTINGS,+ type InstanceSettings,+ resolveInstanceSettings,+} from "../instance-settings/resolve-instance-settings";import { isStorageConfigured } from "../storage/s3";import {parseCustomOAuthAccountUrl,@@ -12,14 +17,20 @@ import { isCloud } from "./is-cloud";config();-function getSettings() {+function getSettings(+ instance: InstanceSettings = resolveInstanceSettings(+ DEFAULT_STORED_SETTINGS,+ process.env,+ ),+) {return {isCloud: isCloud(),- disableRegistration: process.env.DISABLE_REGISTRATION === "true",- disablePasswordRegistration:- process.env.DISABLE_PASSWORD_REGISTRATION === "true",+ instanceName: instance.instanceName,+ disableRegistration: !instance.registrationEnabled,+ disablePasswordRegistration: !instance.passwordRegistrationEnabled,disableEmailOtpSignIn: process.env.DISABLE_EMAIL_OTP_SIGN_IN === "true",- disableWorkspaceCreation: process.env.DISABLE_WORKSPACE_CREATION === "true",+ disableWorkspaceCreation: instance.workspaceCreationRestricted,+ disabledIntegrations: instance.disabledIntegrations,isDemoMode: process.env.DEMO_MODE === "true",hasSmtp: isSmtpConfigured(),hasImageUploads: isStorageConfigured(),@@ -33,12 +44,12 @@ function getSettings() {hasCustomOAuth:Boolean(process.env.CUSTOM_OAUTH_CLIENT_ID) &&Boolean(resolveFileSecret("CUSTOM_OAUTH_CLIENT_SECRET")),- hasGuestAccess: [- "DISABLE_GUEST_ACCESS",- "DISABLE_REGISTRATION",- "DISABLE_PASSWORD_REGISTRATION",- "DISABLE_LOGIN_FORM",- ].every((key) => process.env[key] !== "true"),+ // Mirrors `isGuestAccessAvailable`.+ hasGuestAccess:+ process.env.DISABLE_GUEST_ACCESS !== "true" &&+ process.env.DISABLE_LOGIN_FORM !== "true" &&+ instance.registrationEnabled &&+ instance.passwordRegistrationEnabled,disableLoginForm: process.env.DISABLE_LOGIN_FORM === "true",customOAuthName: process.env.CUSTOM_OAUTH_NAME?.trim() || null,customOAuthAutoLogin: process.env.CUSTOM_OAUTH_AUTO_LOGIN === "true",diff --git a/apps/api/src/utils/registration-policy.ts b/apps/api/src/utils/registration-policy.tsindex fc0f96517..5b0b9defc 100644--- a/apps/api/src/utils/registration-policy.ts+++ b/apps/api/src/utils/registration-policy.ts@@ -1,4 +1,5 @@import { APIError } from "better-auth/api";+import { getInstanceSettings } from "../instance-settings/get-instance-settings";import {checkRegistrationAllowed,userExistsByEmail,@@ -37,14 +38,19 @@ export async function assertEmailCodeRecipientAllowed(throw disposableEmailError();}-export async function assertGuestRegistrationAllowed(): Promise<void> {+/** Guests are self-registered accounts, so any registration limit hides them. */+export async function isGuestAccessAvailable(): Promise<boolean> {if (process.env.DISABLE_GUEST_ACCESS === "true" ||- process.env.DISABLE_REGISTRATION === "true" ||- process.env.DISABLE_PASSWORD_REGISTRATION === "true" ||- process.env.DISABLE_LOGIN_FORM === "true" ||- !(await hasRegisteredUsers())- ) {+ process.env.DISABLE_LOGIN_FORM === "true"+ )+ return false;+ const settings = await getInstanceSettings();+ return settings.registrationEnabled && settings.passwordRegistrationEnabled;+}++export async function assertGuestRegistrationAllowed(): Promise<void> {+ if (!(await isGuestAccessAvailable()) || !(await hasRegisteredUsers())) {throw new APIError("FORBIDDEN", {code: "GUEST_ACCESS_DISABLED",message: "Guest access is unavailable on this instance.",@@ -67,7 +73,7 @@ export async function assertUserRegistrationAllowed(if (!(await hasRegisteredUsers())) return;if (isCloud() && isDisposableEmail(user.email)) throw disposableEmailError();if (- process.env.DISABLE_PASSWORD_REGISTRATION === "true" &&+ !(await getInstanceSettings()).passwordRegistrationEnabled &&!isOAuthCallbackPath(context?.path)) {throw new APIError("FORBIDDEN", {diff --git a/packages/email/src/brand.ts b/packages/email/src/brand.tsnew file mode 100644index 000000000..3d8be3f1d--- /dev/null+++ b/packages/email/src/brand.ts@@ -0,0 +1,30 @@+const DEFAULT_BRAND = "Kaneo";++let resolveName: () => Promise<string | null | undefined> = async () => null;+let current = DEFAULT_BRAND;++/** Let the API supply the instance name shown in email headers and subjects. */+export function setBrandNameResolver(+ resolver: () => Promise<string | null | undefined>,+) {+ resolveName = resolver;+}++/** Refresh the instance name before an email is rendered. */+export async function loadBrandName() {+ try {+ current = (await resolveName())?.trim() || DEFAULT_BRAND;+ } catch {+ // Keep the last known name when settings can't be read.+ }+}++export function brandName() {+ return current;+}++export function brandSubject(subject: string) {+ return current === DEFAULT_BRAND+ ? subject+ : subject.replaceAll(DEFAULT_BRAND, current);+}diff --git a/packages/email/src/components/email-shell.tsx b/packages/email/src/components/email-shell.tsxindex 973f5d598..9a7520459 100644--- a/packages/email/src/components/email-shell.tsx+++ b/packages/email/src/components/email-shell.tsx@@ -1,5 +1,6 @@import { Column, Container, Head, Html, Img, Preview } from "react-email";import React from "react";+import { brandName } from "../brand";import { Row } from "./row";import { emailAsset } from "./assets";import { themeCss } from "./theme";@@ -56,7 +57,7 @@ export function EmailShell({/></Column><Column className="k-text" style={wordmark}>- Kaneo+ {brandName()}</Column></Row>{children}diff --git a/packages/email/src/components/security-reasons.ts b/packages/email/src/components/security-reasons.tsindex 3d1e77333..9de0ccf01 100644--- a/packages/email/src/components/security-reasons.ts+++ b/packages/email/src/components/security-reasons.ts@@ -15,6 +15,19 @@ export const signInReason: Record<EmailLocale, Reason> = {`因為有人要求登入 ${instance},所以寄送至 ${email}。`,};+export const signUpReason: Record<EmailLocale, Reason> = {+ en: (email, instance = "Kaneo") =>+ `Sent to ${email} because someone created an account on ${instance} with this address.`,+ de: (email, instance = "Kaneo") =>+ `Gesendet an ${email}, weil jemand mit dieser Adresse ein Konto bei ${instance} erstellt hat.`,+ vi: (email, instance = "Kaneo") =>+ `Đã gửi đến ${email} vì có người đã tạo tài khoản trên ${instance} bằng địa chỉ này.`,+ ja: (email, instance = "Kaneo") =>+ `このアドレスで ${instance} のアカウントが作成されたため、${email} に送信しました。`,+ "zh-tw": (email, instance = "Kaneo") =>+ `因為有人使用這個地址在 ${instance} 建立了帳號,所以寄送至 ${email}。`,+};+export const passwordResetReason: Record<EmailLocale, Reason> = {en: (email, instance = "Kaneo") =>`Sent to ${email} because someone asked to reset the password on ${instance}.`,diff --git a/packages/email/src/index.tsx b/packages/email/src/index.tsxindex f70a0437d..b8ddba325 100644--- a/packages/email/src/index.tsx+++ b/packages/email/src/index.tsx@@ -1,3 +1,4 @@+export { setBrandNameResolver } from "./brand";export { OTP_EXPIRY_SECONDS } from "./otp-expiry";export {type EmailResult,diff --git a/packages/email/src/send-email.tsx b/packages/email/src/send-email.tsxindex 1cb6892d0..0817f9ee0 100644--- a/packages/email/src/send-email.tsx+++ b/packages/email/src/send-email.tsx@@ -1,7 +1,8 @@import type { ReactElement } from "react";-import { render } from "react-email";+import { render as renderEmail } from "react-email";import { config } from "dotenv-mono";import * as nodemailer from "nodemailer";+import { brandSubject, loadBrandName } from "./brand";import { instanceHost } from "./components/instance-host";import { getSmtpTransportOptions, isSmtpConfigured } from "./smtp-config";import { getSmtpErrorDetails } from "./smtp-error-details";@@ -33,6 +34,11 @@ config();const transporter = nodemailer.createTransport(getSmtpTransportOptions());+async function render(template: ReactElement) {+ await loadBrandName();+ return renderEmail(template);+}+export const sendMagicLinkEmail = async (to: string,subject: string,@@ -45,7 +51,7 @@ export const sendMagicLinkEmail = async (await transporter.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html: emailTemplate,});} catch (error) {@@ -65,7 +71,7 @@ export const sendOtpEmail = async (await transporter.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html: emailTemplate,});} catch (error) {@@ -91,7 +97,7 @@ export const sendPasswordResetEmail = async (await transporter.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html: emailTemplate,});} catch (error) {@@ -123,7 +129,7 @@ export const sendWorkspaceInvitationEmail = async (await transporter.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html: emailTemplate,});return { success: true };@@ -147,7 +153,7 @@ export const sendNotificationEmail = async (await transporter.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html: emailTemplate,});return { success: true };@@ -169,7 +175,7 @@ export const sendTrialReminderEmail = async (await transporter.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html: emailTemplate,});} catch (error) {@@ -195,7 +201,7 @@ async function sendAdministratorEmail(await transporter.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html,});return { success: true };@@ -255,7 +261,7 @@ export const sendTestEmail = async (await testTransport.sendMail({from: process.env.SMTP_FROM,to,- subject,+ subject: brandSubject(subject),html: emailTemplate,});return { success: true };diff --git a/packages/email/src/templates/email-verification.tsx b/packages/email/src/templates/email-verification.tsxindex b7bcc586d..c1a4c6644 100644--- a/packages/email/src/templates/email-verification.tsx+++ b/packages/email/src/templates/email-verification.tsx@@ -6,7 +6,10 @@ import { EmailNote } from "../components/email-note";import { EmailShell } from "../components/email-shell";import { FallbackLink } from "../components/fallback-link";import { footerLinks } from "../components/footer-links";-import { administratorReason } from "../components/security-reasons";+import {+ administratorReason,+ signUpReason,+} from "../components/security-reasons";import { emailHtmlLang, resolveEmailLocale } from "./resolve-locale";void React;@@ -17,6 +20,8 @@ export type EmailVerificationEmailProps = {locale?: string | null;email?: string;instance?: string;+ /** Who asked for the email. Defaults to an administrator. */+ requestedBy?: "administrator" | "sign-up";};const messages = {@@ -85,6 +90,7 @@ const EmailVerificationEmail = ({locale,email,instance,+ requestedBy = "administrator",}: EmailVerificationEmailProps) => {const emailLocale = resolveEmailLocale(locale);const copy = messages[emailLocale];@@ -104,7 +110,11 @@ const EmailVerificationEmail = ({<EmailFootertitle={copy.footer}reason={- email ? administratorReason[emailLocale](email, instance) : undefined+ ? (requestedBy === "sign-up" ? signUpReason : administratorReason)[+ emailLocale+ ](email, instance)+ : undefined}links={footerLinks(emailLocale)}/>diff --git a/tests/api-integration/mocks/email.ts b/tests/api-integration/mocks/email.tsindex 15634e3c9..d4d58b335 100644--- a/tests/api-integration/mocks/email.ts+++ b/tests/api-integration/mocks/email.ts@@ -69,3 +69,7 @@ export async function verifySmtpConnection(): Promise<SmtpVerification> {return { status: "not_configured" };}++export function setBrandNameResolver(+ _resolver: () => Promise<string | null | undefined>,+): void {}