⚡ 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(api,web): add subtasks and task relations
Ivan Bobchenkovc73ef7821f05
diff --git a/apps/api/drizzle/0016_add_task_relation.sql b/apps/api/drizzle/0016_add_task_relation.sqlnew file mode 100644index 000000000..0c95f4cad--- /dev/null+++ b/apps/api/drizzle/0016_add_task_relation.sql@@ -0,0 +1,12 @@+CREATE TABLE "task_relation" (+ "id" text PRIMARY KEY NOT NULL,+ "source_task_id" text NOT NULL,+ "target_task_id" text NOT NULL,+ "relation_type" text NOT NULL,+ "created_at" timestamp DEFAULT now() NOT NULL+);+--> statement-breakpoint+ALTER TABLE "task_relation" ADD CONSTRAINT "task_relation_source_task_id_task_id_fk" FOREIGN KEY ("source_task_id") REFERENCES "public"."task"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint+ALTER TABLE "task_relation" ADD CONSTRAINT "task_relation_target_task_id_task_id_fk" FOREIGN KEY ("target_task_id") REFERENCES "public"."task"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint+CREATE INDEX "task_relation_source_idx" ON "task_relation" USING btree ("source_task_id");--> statement-breakpoint+CREATE INDEX "task_relation_target_idx" ON "task_relation" USING btree ("target_task_id");diff --git a/apps/api/drizzle/meta/0015_snapshot.json b/apps/api/drizzle/meta/0015_snapshot.jsonnew file mode 100644index 000000000..fb975e48f--- /dev/null+++ b/apps/api/drizzle/meta/0015_snapshot.json@@ -0,0 +1,2393 @@+{+ "id": "2f1cbcfc-998f-474d-b027-b538ced42904",+ "prevId": "b2199ce0-8bcf-4961-b656-fa144e41bbb3",+ "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()"+ },+ "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()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "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": {},+ "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": "cascade",+ "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()"+ }+ },+ "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": {}+ }+ },+ "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.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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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.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": true+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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": {}+ }+ },+ "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_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.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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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": {},+ "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()"+ },+ "inviter_id": {+ "name": "inviter_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "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": {}+ }+ },+ "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.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()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "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": {},+ "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": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'info'"+ },+ "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()"+ }+ },+ "indexes": {},+ "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.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()"+ },+ "is_public": {+ "name": "is_public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ }+ },+ "indexes": {},+ "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": {},+ "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()"+ },+ "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+ }+ },+ "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": {}+ }+ },+ "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.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()"+ }+ },+ "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": {+ "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": false,+ "default": "'low'"+ },+ "due_date": {+ "name": "due_date",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "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": "cascade",+ "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": {},+ "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+ },+ "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+ },+ "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": {},+ "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()"+ }+ },+ "indexes": {},+ "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": "cascade",+ "onUpdate": "cascade"+ }+ },+ "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+ },+ "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()"+ },+ "is_anonymous": {+ "name": "is_anonymous",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_email_unique": {+ "name": "user_email_unique",+ "nullsNotDistinct": false,+ "columns": ["email"]+ }+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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": {}+ }+ },+ "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+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "workspace_slug_unique": {+ "name": "workspace_slug_unique",+ "nullsNotDistinct": false,+ "columns": ["slug"]+ }+ },+ "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": {}+ }+}diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.jsonindex 7c77d9bf1..2d0114caf 100644--- a/apps/api/drizzle/meta/_journal.json+++ b/apps/api/drizzle/meta/_journal.json@@ -113,6 +113,13 @@"when": 1773947411304,"tag": "0015_add_comment_and_archival","breakpoints": true+ },+ {+ "idx": 16,+ "version": "7",+ "when": 1773952461673,+ "tag": "0016_add_task_relation",+ "breakpoints": true}]}diff --git a/apps/api/src/database/index.ts b/apps/api/src/database/index.tsindex 1f09684e5..35a026a3a 100644--- a/apps/api/src/database/index.ts+++ b/apps/api/src/database/index.ts@@ -16,6 +16,7 @@ import {notificationTableRelations,projectTableRelations,sessionTableRelations,+ taskRelationTableRelations,taskTableRelations,teamMemberTableRelations,teamTableRelations,@@ -41,6 +42,7 @@ import {notificationTable,projectTable,sessionTable,+ taskRelationTable,taskTable,teamMemberTable,teamTable,@@ -75,6 +77,7 @@ export const schema = {notificationTable,projectTable,sessionTable,+ taskRelationTable,taskTable,teamMemberTable,teamTable,@@ -98,6 +101,7 @@ export const schema = {notificationTableRelations,projectTableRelations,sessionTableRelations,+ taskRelationTableRelations,taskTableRelations,teamMemberTableRelations,teamTableRelations,diff --git a/apps/api/src/database/relations.ts b/apps/api/src/database/relations.tsindex 7e95849ca..9c6dcb182 100644--- a/apps/api/src/database/relations.ts+++ b/apps/api/src/database/relations.ts@@ -14,6 +14,7 @@ import {notificationTable,projectTable,sessionTable,+ taskRelationTable,taskTable,teamMemberTable,teamTable,@@ -143,6 +144,8 @@ export const taskTableRelations = relations(taskTable, ({ one, many }) => ({assets: many(assetTable),labels: many(labelTable),externalLinks: many(externalLinkTable),+ sourceRelations: many(taskRelationTable, { relationName: "sourceTask" }),+ targetRelations: many(taskRelationTable, { relationName: "targetTask" }),}));export const timeEntryTableRelations = relations(timeEntryTable, ({ one }) => ({@@ -271,6 +274,22 @@ export const integrationTableRelations = relations(}),);+export const taskRelationTableRelations = relations(+ taskRelationTable,+ ({ one }) => ({+ sourceTask: one(taskTable, {+ fields: [taskRelationTable.sourceTaskId],+ references: [taskTable.id],+ relationName: "sourceTask",+ }),+ targetTask: one(taskTable, {+ fields: [taskRelationTable.targetTaskId],+ references: [taskTable.id],+ relationName: "targetTask",+ }),+ }),+);+export const externalLinkTableRelations = relations(externalLinkTable,({ one }) => ({diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.tsindex 1866bf558..6c1086d33 100644--- a/apps/api/src/database/schema.ts+++ b/apps/api/src/database/schema.ts@@ -537,6 +537,33 @@ export const commentTable = pgTable(],);+export const taskRelationTable = pgTable(+ "task_relation",+ {+ id: text("id")+ .$defaultFn(() => createId())+ .primaryKey(),+ sourceTaskId: text("source_task_id")+ .notNull()+ .references(() => taskTable.id, {+ onDelete: "cascade",+ onUpdate: "cascade",+ }),+ targetTaskId: text("target_task_id")+ .notNull()+ .references(() => taskTable.id, {+ onDelete: "cascade",+ onUpdate: "cascade",+ }),+ relationType: text("relation_type").notNull(),+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),+ },+ (table) => [+ index("task_relation_source_idx").on(table.sourceTaskId),+ index("task_relation_target_idx").on(table.targetTaskId),+ ],+);+export const apikeyTable = pgTable("apikey",{diff --git a/apps/api/src/index.ts b/apps/api/src/index.tsindex 79f95cf01..f7b4c1b6f 100644--- a/apps/api/src/index.ts+++ b/apps/api/src/index.ts@@ -33,6 +33,7 @@ import { getPublicProject } from "./project/controllers/get-public-project";import search from "./search";import { getPrivateObject } from "./storage/s3";import task from "./task";+import taskRelation from "./task-relation";import timeEntry from "./time-entry";import { getInvitationDetails } from "./utils/check-registration-allowed";import { migrateApiKeyReferenceId } from "./utils/migrate-apikey-reference-id";@@ -391,6 +392,7 @@ const githubIntegrationApi = api.route("/github-integration",githubIntegration,);+const taskRelationApi = api.route("/task-relation", taskRelation);const externalLinkApi = api.route("/external-link", externalLink);const workflowRuleApi = api.route("/workflow-rule", workflowRule);const invitationApi = api.route("/invitation", invitation);@@ -444,6 +446,7 @@ export type AppType =| typeof notificationApi| typeof searchApi| typeof githubIntegrationApi+ | typeof taskRelationApi| typeof externalLinkApi| typeof workflowRuleApi| typeof invitationApidiff --git a/apps/api/src/task-relation/controllers/create-task-relation.ts b/apps/api/src/task-relation/controllers/create-task-relation.tsnew file mode 100644index 000000000..466e3d254--- /dev/null+++ b/apps/api/src/task-relation/controllers/create-task-relation.ts@@ -0,0 +1,85 @@+import { and, eq, or } from "drizzle-orm";+import { HTTPException } from "hono/http-exception";+import db from "../../database";+import { taskRelationTable, taskTable } from "../../database/schema";++async function createTaskRelation({+ sourceTaskId,+ targetTaskId,+ relationType,+}: {+ sourceTaskId: string;+ targetTaskId: string;+ relationType: string;+}) {+ if (sourceTaskId === targetTaskId) {+ throw new HTTPException(400, {+ message: "Cannot create a relation between a task and itself",+ });+ }++ const [sourceTask] = await db+ .select({ id: taskTable.id })+ .from(taskTable)+ .where(eq(taskTable.id, sourceTaskId))+ .limit(1);++ if (!sourceTask) {+ throw new HTTPException(404, { message: "Source task not found" });+ }++ const [targetTask] = await db+ .select({ id: taskTable.id })+ .from(taskTable)+ .where(eq(taskTable.id, targetTaskId))+ .limit(1);++ if (!targetTask) {+ throw new HTTPException(404, { message: "Target task not found" });+ }++ const existing = await db+ .select({ id: taskRelationTable.id })+ .from(taskRelationTable)+ .where(+ and(+ eq(taskRelationTable.relationType, relationType),+ or(+ and(+ eq(taskRelationTable.sourceTaskId, sourceTaskId),+ eq(taskRelationTable.targetTaskId, targetTaskId),+ ),+ and(+ eq(taskRelationTable.sourceTaskId, targetTaskId),+ eq(taskRelationTable.targetTaskId, sourceTaskId),+ ),+ ),+ ),+ )+ .limit(1);++ if (existing.length > 0) {+ throw new HTTPException(409, {+ message: "This relation already exists",+ });+ }++ const [relation] = await db+ .insert(taskRelationTable)+ .values({+ sourceTaskId,+ targetTaskId,+ relationType,+ })+ .returning();++ if (!relation) {+ throw new HTTPException(500, {+ message: "Failed to create task relation",+ });+ }++ return relation;+}++export default createTaskRelation;diff --git a/apps/api/src/task-relation/controllers/delete-task-relation.ts b/apps/api/src/task-relation/controllers/delete-task-relation.tsnew file mode 100644index 000000000..3a027e022--- /dev/null+++ b/apps/api/src/task-relation/controllers/delete-task-relation.ts@@ -0,0 +1,21 @@+import { eq } from "drizzle-orm";+import { HTTPException } from "hono/http-exception";+import db from "../../database";+import { taskRelationTable } from "../../database/schema";++async function deleteTaskRelation(id: string) {+ const [relation] = await db+ .delete(taskRelationTable)+ .where(eq(taskRelationTable.id, id))+ .returning();++ if (!relation) {+ throw new HTTPException(404, {+ message: "Task relation not found",+ });+ }++ return relation;+}++export default deleteTaskRelation;diff --git a/apps/api/src/task-relation/controllers/get-task-relations.ts b/apps/api/src/task-relation/controllers/get-task-relations.tsnew file mode 100644index 000000000..59c7ebfe5--- /dev/null+++ b/apps/api/src/task-relation/controllers/get-task-relations.ts@@ -0,0 +1,70 @@+import { eq, inArray, or } from "drizzle-orm";+import db from "../../database";+import { taskRelationTable, taskTable, userTable } from "../../database/schema";++async function getTaskRelations(taskId: string) {+ const relations = await db+ .select({+ id: taskRelationTable.id,+ sourceTaskId: taskRelationTable.sourceTaskId,+ targetTaskId: taskRelationTable.targetTaskId,+ relationType: taskRelationTable.relationType,+ createdAt: taskRelationTable.createdAt,+ })+ .from(taskRelationTable)+ .where(+ or(+ eq(taskRelationTable.sourceTaskId, taskId),+ eq(taskRelationTable.targetTaskId, taskId),+ ),+ );++ const taskIds = new Set<string>();+ for (const rel of relations) {+ taskIds.add(rel.sourceTaskId);+ taskIds.add(rel.targetTaskId);+ }++ const tasks = new Map<+ string,+ {+ id: string;+ title: string;+ status: string;+ priority: string | null;+ number: number | null;+ projectId: string;+ userId: string | null;+ assigneeName: string | null;+ }+ >();++ if (taskIds.size > 0) {+ const taskRows = await db+ .select({+ id: taskTable.id,+ title: taskTable.title,+ status: taskTable.status,+ priority: taskTable.priority,+ number: taskTable.number,+ projectId: taskTable.projectId,+ userId: taskTable.userId,+ assigneeName: userTable.name,+ })+ .from(taskTable)+ .leftJoin(userTable, eq(taskTable.userId, userTable.id))+ .where(inArray(taskTable.id, [...taskIds]));++ for (const task of taskRows) {+ tasks.set(task.id, task);+ }+ }++ return relations.map((rel) => ({+ ...rel,+ sourceTask: tasks.get(rel.sourceTaskId) ?? null,+ targetTask: tasks.get(rel.targetTaskId) ?? null,+ }));+}++export default getTaskRelations;diff --git a/apps/api/src/task-relation/index.ts b/apps/api/src/task-relation/index.tsnew file mode 100644index 000000000..7ef16306c--- /dev/null+++ b/apps/api/src/task-relation/index.ts@@ -0,0 +1,150 @@+import { eq } from "drizzle-orm";+import { Hono } from "hono";+import { HTTPException } from "hono/http-exception";+import { describeRoute, resolver, validator } from "hono-openapi";+import * as v from "valibot";+import db from "../database";+import { projectTable, taskRelationTable, taskTable } from "../database/schema";+import { validateWorkspaceAccess } from "../utils/validate-workspace-access";+import { workspaceAccess } from "../utils/workspace-access-middleware";+import createTaskRelation from "./controllers/create-task-relation";+import deleteTaskRelation from "./controllers/delete-task-relation";+import getTaskRelations from "./controllers/get-task-relations";++const taskRelationSchema = v.object({+ id: v.string(),+ sourceTaskId: v.string(),+ targetTaskId: v.string(),+ relationType: v.string(),+ createdAt: v.date(),+});++const taskRelation = new Hono<{+ Variables: {+ userId: string;+ };+}>()+ .get(+ "/:taskId",+ describeRoute({+ operationId: "getTaskRelations",+ tags: ["Task Relations"],+ description: "Get all relations for a task",+ responses: {+ 200: {+ description: "Task relations with associated task data",+ content: {+ "application/json": { schema: resolver(v.any()) },+ },+ },+ },+ }),+ validator("param", v.object({ taskId: v.string() })),+ workspaceAccess.fromTaskId("taskId"),+ async (c) => {+ const { taskId } = c.req.valid("param");+ const relations = await getTaskRelations(taskId);+ return c.json(relations);+ },+ )+ .post(+ "/",+ describeRoute({+ operationId: "createTaskRelation",+ tags: ["Task Relations"],+ description: "Create a relation between two tasks",+ responses: {+ 200: {+ description: "Task relation created successfully",+ content: {+ "application/json": { schema: resolver(taskRelationSchema) },+ },+ },+ },+ }),+ validator(+ "json",+ v.object({+ sourceTaskId: v.string(),+ targetTaskId: v.string(),+ relationType: v.picklist(["subtask", "blocks", "related"]),+ }),+ ),+ async (c, next) => {+ const userId = c.get("userId");+ if (!userId) {+ throw new HTTPException(401, { message: "Unauthorized" });+ }+ const { sourceTaskId } = c.req.valid("json");+ const [task] = await db+ .select({ workspaceId: projectTable.workspaceId })+ .from(taskTable)+ .innerJoin(projectTable, eq(taskTable.projectId, projectTable.id))+ .where(eq(taskTable.id, sourceTaskId))+ .limit(1);+ if (!task) {+ throw new HTTPException(404, { message: "Source task not found" });+ }+ await validateWorkspaceAccess(userId, task.workspaceId);+ return next();+ },+ async (c) => {+ const { sourceTaskId, targetTaskId, relationType } = c.req.valid("json");+ const relation = await createTaskRelation({+ sourceTaskId,+ targetTaskId,+ relationType,+ });+ return c.json(relation);+ },+ )+ .delete(+ "/:id",+ describeRoute({+ operationId: "deleteTaskRelation",+ tags: ["Task Relations"],+ description: "Delete a task relation",+ responses: {+ 200: {+ description: "Task relation deleted successfully",+ content: {+ "application/json": { schema: resolver(taskRelationSchema) },+ },+ },+ },+ }),+ validator("param", v.object({ id: v.string() })),+ async (c, next) => {+ const userId = c.get("userId");+ if (!userId) {+ throw new HTTPException(401, { message: "Unauthorized" });+ }+ const { id } = c.req.valid("param");+ const [rel] = await db+ .select({ sourceTaskId: taskRelationTable.sourceTaskId })+ .from(taskRelationTable)+ .where(eq(taskRelationTable.id, id))+ .limit(1);+ if (!rel) {+ throw new HTTPException(404, { message: "Task relation not found" });+ }+ const [task] = await db+ .select({ workspaceId: projectTable.workspaceId })+ .from(taskTable)+ .innerJoin(projectTable, eq(taskTable.projectId, projectTable.id))+ .where(eq(taskTable.id, rel.sourceTaskId))+ .limit(1);+ if (!task) {+ throw new HTTPException(404, { message: "Task not found" });+ }+ await validateWorkspaceAccess(userId, task.workspaceId);+ return next();+ },+ async (c) => {+ const { id } = c.req.valid("param");+ const relation = await deleteTaskRelation(id);+ return c.json(relation);+ },+ );++export default taskRelation;diff --git a/apps/web/src/components/task/task-details-content.tsx b/apps/web/src/components/task/task-details-content.tsxindex 16905ec7d..c7f3dd87c 100644--- a/apps/web/src/components/task/task-details-content.tsx+++ b/apps/web/src/components/task/task-details-content.tsx@@ -10,6 +10,8 @@ import useGetProject from "@/hooks/queries/project/use-get-project";import useGetTask from "@/hooks/queries/task/use-get-task";import type { ExternalLink } from "@/types/external-link";import TaskDescription from "./task-description";+import TaskRelations from "./task-relations";+import TaskSubtasks from "./task-subtasks";import TaskTitle from "./task-title";type TaskDetailsContentProps = {@@ -51,6 +53,20 @@ export default function TaskDetailsContent({/></div>)}+ <div className="mt-4">+ <TaskSubtasks+ taskId={taskId}+ projectId={projectId}+ workspaceId={workspaceId}+ />+ </div>+ <div className="mt-2">+ <TaskRelations+ taskId={taskId}+ projectId={projectId}+ workspaceId={workspaceId}+ />+ </div><span className="text-sm font-medium text-muted-foreground h-[1px] bg-border w-full block shrink-0" /><div className="flex flex-col gap-4"><h1 className="text-md font-semibold">Activity</h1>diff --git a/apps/web/src/components/task/task-relations.tsx b/apps/web/src/components/task/task-relations.tsxnew file mode 100644index 000000000..5c6e1773b--- /dev/null+++ b/apps/web/src/components/task/task-relations.tsx@@ -0,0 +1,322 @@+import { useNavigate } from "@tanstack/react-router";+import {+ ChevronDown,+ ChevronRight,+ Link2,+ Plus,+ Search,+ X,+} from "lucide-react";+import { useMemo, useState } from "react";+import { Button } from "@/components/ui/button";+import {+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+} from "@/components/ui/collapsible";+import {+ Dialog,+ DialogClose,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogPopup,+ DialogTitle,+ DialogTrigger,+} from "@/components/ui/dialog";+import { Input } from "@/components/ui/input";+import useCreateTaskRelation from "@/hooks/mutations/task-relation/use-create-task-relation";+import useDeleteTaskRelation from "@/hooks/mutations/task-relation/use-delete-task-relation";+import { useGetTasks } from "@/hooks/queries/task/use-get-tasks";+import useGetTaskRelations from "@/hooks/queries/task-relation/use-get-task-relations";+import { getColumnIcon } from "@/lib/column";+import { toast } from "@/lib/toast";++type TaskRelationsProps = {+ taskId: string;+ projectId: string;+ workspaceId: string;+};++const relationTypeLabels: Record<string, string> = {+ blocks: "Blocks",+ related: "Related to",+};++export default function TaskRelations({+ taskId,+ projectId,+ workspaceId,+}: TaskRelationsProps) {+ const navigate = useNavigate();+ const [isOpen, setIsOpen] = useState(true);+ const [dialogOpen, setDialogOpen] = useState(false);+ const [searchQuery, setSearchQuery] = useState("");+ const [selectedRelationType, setSelectedRelationType] = useState<+ "blocks" | "related"+ >("related");++ const { data: relations = [] } = useGetTaskRelations(taskId);+ const { data: projectData } = useGetTasks(projectId);+ const createRelation = useCreateTaskRelation();+ const deleteRelation = useDeleteTaskRelation(taskId);++ const nonSubtaskRelations = relations.filter(+ (rel) => rel.relationType !== "subtask",+ );++ const groupedRelations = useMemo(() => {+ const groups: Record<+ string,+ Array<{+ id: string;+ relationType: string;+ task: NonNullable<(typeof nonSubtaskRelations)[number]["sourceTask"]>;+ direction: "source" | "target";+ }>+ > = {};++ for (const rel of nonSubtaskRelations) {+ const isSource = rel.sourceTaskId === taskId;+ const linkedTask = isSource ? rel.targetTask : rel.sourceTask;+ if (!linkedTask) continue;++ const type = rel.relationType;+ if (!groups[type]) {+ groups[type] = [];+ }+ groups[type].push({+ id: rel.id,+ relationType: type,+ task: linkedTask,+ direction: isSource ? "source" : "target",+ });+ }++ return groups;+ }, [nonSubtaskRelations, taskId]);++ const existingRelatedTaskIds = new Set(+ nonSubtaskRelations.flatMap((rel) => [rel.sourceTaskId, rel.targetTaskId]),+ );+ existingRelatedTaskIds.add(taskId);++ const allTasks = useMemo(() => {+ if (!projectData) return [];+ const tasks: Array<{+ id: string;+ title: string;+ number: number | null;+ status: string;+ }> = [];++ if ("columns" in projectData && Array.isArray(projectData.columns)) {+ for (const col of projectData.columns as Array<{+ tasks: Array<{+ id: string;+ title: string;+ number: number | null;+ status: string;+ }>;+ }>) {+ if (col.tasks) {+ for (const t of col.tasks) {+ tasks.push(t);+ }+ }+ }+ }++ return tasks;+ }, [projectData]);++ const filteredTasks = allTasks.filter(+ (t) =>+ !existingRelatedTaskIds.has(t.id) &&+ t.title.toLowerCase().includes(searchQuery.toLowerCase()),+ );++ const handleLinkTask = async (targetTaskId: string) => {+ try {+ await createRelation.mutateAsync({+ sourceTaskId: taskId,+ targetTaskId,+ relationType: selectedRelationType,+ });+ setDialogOpen(false);+ setSearchQuery("");+ } catch {+ toast.error("Failed to link task");+ }+ };++ const handleRemoveRelation = (relationId: string) => {+ deleteRelation.mutate(relationId);+ };++ const handleNavigateToTask = (linkedTaskId: string) => {+ navigate({+ to: "/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId",+ params: { workspaceId, projectId, taskId: linkedTaskId },+ });+ };++ const hasRelations = nonSubtaskRelations.length > 0;++ return (+ <Collapsible open={isOpen} onOpenChange={setIsOpen} className="w-full">+ <div className="flex items-center justify-between">+ <CollapsibleTrigger asChild>+ <Button+ variant="ghost"+ size="sm"+ className="w-full justify-start gap-1 px-0 h-8 hover:bg-transparent"+ >+ {isOpen ? (+ <ChevronDown className="size-4 text-muted-foreground" />+ ) : (+ <ChevronRight className="size-4 text-muted-foreground" />+ )}+ <Link2 className="size-4 text-muted-foreground" />+ <span className="text-sm text-muted-foreground">Relations</span>+ {hasRelations && (+ <span className="text-xs text-muted-foreground ml-1">+ {nonSubtaskRelations.length}+ </span>+ )}+ </Button>+ </CollapsibleTrigger>+ <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>+ <DialogTrigger asChild>+ <Button variant="ghost" size="xs" className="text-muted-foreground">+ <Plus className="size-3.5" />+ </Button>+ </DialogTrigger>+ <DialogPopup className="max-w-md">+ <DialogHeader>+ <DialogTitle>Link task</DialogTitle>+ <DialogDescription>+ Search for a task in this project to create a relation.+ </DialogDescription>+ </DialogHeader>+ <div className="px-6 pb-4 flex flex-col gap-3">+ <div className="flex gap-2">+ <Button+ variant={+ selectedRelationType === "related" ? "default" : "outline"+ }+ size="xs"+ onClick={() => setSelectedRelationType("related")}+ >+ Related+ </Button>+ <Button+ variant={+ selectedRelationType === "blocks" ? "default" : "outline"+ }+ size="xs"+ onClick={() => setSelectedRelationType("blocks")}+ >+ Blocks+ </Button>+ </div>+ <div className="relative">+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground pointer-events-none" />+ <Input+ size="sm"+ placeholder="Search tasks..."+ value={searchQuery}+ onChange={(e: React.ChangeEvent<HTMLInputElement>) =>+ setSearchQuery(e.target.value)+ }+ className="pl-8"+ autoFocus+ />+ </div>+ <div className="max-h-60 overflow-y-auto flex flex-col gap-0.5">+ {filteredTasks.length === 0 && (+ <p className="text-sm text-muted-foreground py-4 text-center">+ No tasks found+ </p>+ )}+ {filteredTasks.map((t) => (+ <button+ key={t.id}+ type="button"+ className="flex items-center gap-2 py-2 px-2 rounded-md hover:bg-accent/50 transition-colors text-left w-full"+ onClick={() => handleLinkTask(t.id)}+ >+ {getColumnIcon(t.status, false)}+ <span className="text-sm truncate flex-1 text-foreground/90">+ {t.title}+ </span>+ {t.number != null && (+ <span className="text-xs text-muted-foreground shrink-0">+ #{t.number}+ </span>+ )}+ </button>+ ))}+ </div>+ </div>+ <DialogFooter variant="bare">+ <DialogClose asChild>+ <Button variant="outline" size="sm">+ Cancel+ </Button>+ </DialogClose>+ </DialogFooter>+ </DialogPopup>+ </Dialog>+ </div>++ <CollapsibleContent>+ {Object.entries(groupedRelations).map(([type, items]) => (+ <div key={type} className="mt-2">+ <p className="text-xs font-medium text-muted-foreground px-2 mb-1">+ {relationTypeLabels[type] || type}+ </p>+ <div className="flex flex-col gap-0.5">+ {items.map((item) => (+ <div+ key={item.id}+ className="group flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-accent/50 transition-colors"+ >+ <button+ type="button"+ className="flex items-center gap-2 flex-1 min-w-0 text-left"+ onClick={() => handleNavigateToTask(item.task.id)}+ >+ {getColumnIcon(item.task.status, false)}+ <span className="text-sm truncate flex-1 text-foreground/90">+ {item.task.title}+ </span>+ {item.task.number != null && (+ <span className="text-xs text-muted-foreground shrink-0">+ #{item.task.number}+ </span>+ )}+ </button>+ <Button+ variant="ghost"+ size="xs"+ className="opacity-0 group-hover:opacity-100 text-muted-foreground h-5 w-5 p-0"+ onClick={() => handleRemoveRelation(item.id)}+ >+ <X className="size-3" />+ </Button>+ </div>+ ))}+ </div>+ </div>+ ))}++ {!hasRelations && (+ <p className="text-xs text-muted-foreground px-2 py-1">+ No related tasks+ </p>+ )}+ </CollapsibleContent>+ </Collapsible>+ );+}diff --git a/apps/web/src/components/task/task-subtasks.tsx b/apps/web/src/components/task/task-subtasks.tsxnew file mode 100644index 000000000..4137d632d--- /dev/null+++ b/apps/web/src/components/task/task-subtasks.tsx@@ -0,0 +1,260 @@+import { useNavigate } from "@tanstack/react-router";+import { ChevronDown, ChevronRight, ListTree, Plus, X } from "lucide-react";+import { useState } from "react";+import { Button } from "@/components/ui/button";+import { Checkbox } from "@/components/ui/checkbox";+import {+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+} from "@/components/ui/collapsible";+import { Input } from "@/components/ui/input";+import useCreateTask from "@/hooks/mutations/task/use-create-task";+import { useUpdateTaskStatus } from "@/hooks/mutations/task/use-update-task-status";+import useCreateTaskRelation from "@/hooks/mutations/task-relation/use-create-task-relation";+import useDeleteTaskRelation from "@/hooks/mutations/task-relation/use-delete-task-relation";+import useGetTaskRelations from "@/hooks/queries/task-relation/use-get-task-relations";+import { getColumnIcon } from "@/lib/column";+import { getPriorityIcon } from "@/lib/priority";+import { toast } from "@/lib/toast";++type TaskSubtasksProps = {+ taskId: string;+ projectId: string;+ workspaceId: string;+};++export default function TaskSubtasks({+ taskId,+ projectId,+ workspaceId,+}: TaskSubtasksProps) {+ const navigate = useNavigate();+ const [isOpen, setIsOpen] = useState(true);+ const [isAdding, setIsAdding] = useState(false);+ const [newTitle, setNewTitle] = useState("");++ const { data: relations = [] } = useGetTaskRelations(taskId);+ const createTask = useCreateTask();+ const createRelation = useCreateTaskRelation();+ const deleteRelation = useDeleteTaskRelation(taskId);+ const updateStatus = useUpdateTaskStatus();++ const subtasks = relations+ .filter(+ (rel) => rel.relationType === "subtask" && rel.sourceTaskId === taskId,+ )+ .map((rel) => ({ relation: rel, task: rel.targetTask }))+ .filter(+ (item): item is typeof item & { task: NonNullable<typeof item.task> } =>+ item.task !== null,+ );++ const completedCount = subtasks.filter(+ (s) => s.task.status === "done",+ ).length;+ const totalCount = subtasks.length;+ const progressPercent =+ totalCount > 0 ? (completedCount / totalCount) * 100 : 0;++ const handleAddSubtask = async () => {+ if (!newTitle.trim()) return;++ try {+ const newTask = await createTask.mutateAsync({+ title: newTitle.trim(),+ description: "",+ projectId,+ status: "to-do",+ priority: "low",+ });++ await createRelation.mutateAsync({+ sourceTaskId: taskId,+ targetTaskId: newTask.id,+ relationType: "subtask",+ });++ setNewTitle("");+ setIsAdding(false);+ } catch {+ toast.error("Failed to create subtask");+ }+ };++ const handleToggleStatus = (subtask: {+ relation: { id: string };+ task: {+ id: string;+ status: string;+ projectId: string;+ title: string;+ number: number | null;+ priority: string | null;+ userId: string | null;+ assigneeName: string | null;+ };+ }) => {+ const newStatus = subtask.task.status === "done" ? "to-do" : "done";+ updateStatus.mutate({+ id: subtask.task.id,+ status: newStatus,+ projectId: subtask.task.projectId,+ title: subtask.task.title,+ number: subtask.task.number,+ description: null,+ priority: subtask.task.priority,+ dueDate: null,+ position: null,+ createdAt: "",+ userId: subtask.task.userId,+ assigneeId: subtask.task.userId,+ assigneeName: subtask.task.assigneeName,+ });+ };++ const handleRemoveSubtask = (relationId: string) => {+ deleteRelation.mutate(relationId);+ };++ const handleNavigateToTask = (subtaskId: string) => {+ navigate({+ to: "/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId",+ params: { workspaceId, projectId, taskId: subtaskId },+ });+ };++ return (+ <Collapsible open={isOpen} onOpenChange={setIsOpen} className="w-full">+ <div className="flex items-center justify-between">+ <CollapsibleTrigger asChild>+ <Button+ variant="ghost"+ size="sm"+ className="w-full justify-start gap-1 px-0 h-8 hover:bg-transparent"+ >+ {isOpen ? (+ <ChevronDown className="size-4 text-muted-foreground" />+ ) : (+ <ChevronRight className="size-4 text-muted-foreground" />+ )}+ <ListTree className="size-4 text-muted-foreground" />+ <span className="text-sm text-muted-foreground">Subtasks</span>+ {totalCount > 0 && (+ <span className="text-xs text-muted-foreground ml-1">+ {completedCount}/{totalCount}+ </span>+ )}+ </Button>+ </CollapsibleTrigger>+ <Button+ variant="ghost"+ size="xs"+ className="text-muted-foreground"+ onClick={() => setIsAdding(true)}+ >+ <Plus className="size-3.5" />+ </Button>+ </div>++ <CollapsibleContent>+ {totalCount > 0 && (+ <div className="mt-2 mb-2">+ <div className="h-1.5 w-full rounded-full bg-input overflow-hidden">+ <div+ className="h-full bg-primary transition-all duration-300"+ style={{ width: `${progressPercent}%` }}+ />+ </div>+ </div>+ )}++ <div className="flex flex-col gap-1 mt-1">+ {subtasks.map((subtask) => (+ <div+ key={subtask.relation.id}+ className="group flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-accent/50 transition-colors"+ >+ <Checkbox+ checked={subtask.task.status === "done"}+ onCheckedChange={() => handleToggleStatus(subtask)}+ />+ <button+ type="button"+ className="flex items-center gap-2 flex-1 min-w-0 text-left"+ onClick={() => handleNavigateToTask(subtask.task.id)}+ >+ {getColumnIcon(subtask.task.status, false)}+ <span+ className={`text-sm truncate flex-1 ${subtask.task.status === "done" ? "line-through text-muted-foreground" : "text-foreground/90"}`}+ >+ {subtask.task.title}+ </span>+ {subtask.task.priority &&+ subtask.task.priority !== "no-priority" && (+ <span className="shrink-0">+ {getPriorityIcon(subtask.task.priority)}+ </span>+ )}+ </button>+ <Button+ variant="ghost"+ size="xs"+ className="opacity-0 group-hover:opacity-100 text-muted-foreground h-5 w-5 p-0"+ onClick={() => handleRemoveSubtask(subtask.relation.id)}+ >+ <X className="size-3" />+ </Button>+ </div>+ ))}+ </div>++ {isAdding && (+ <div className="flex items-center gap-2 mt-2">+ <Input+ size="sm"+ placeholder="Subtask title..."+ value={newTitle}+ onChange={(e: React.ChangeEvent<HTMLInputElement>) =>+ setNewTitle(e.target.value)+ }+ onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {+ if (e.key === "Enter") {+ handleAddSubtask();+ }+ if (e.key === "Escape") {+ setIsAdding(false);+ setNewTitle("");+ }+ }}+ autoFocus+ />+ <Button+ size="xs"+ onClick={handleAddSubtask}+ disabled={!newTitle.trim() || createTask.isPending}+ >+ Add+ </Button>+ <Button+ variant="ghost"+ size="xs"+ onClick={() => {+ setIsAdding(false);+ setNewTitle("");+ }}+ >+ Cancel+ </Button>+ </div>+ )}++ {!isAdding && totalCount === 0 && (+ <p className="text-xs text-muted-foreground px-2 py-1">+ No subtasks yet+ </p>+ )}+ </CollapsibleContent>+ </Collapsible>+ );+}diff --git a/apps/web/src/fetchers/task-relation/create-task-relation.ts b/apps/web/src/fetchers/task-relation/create-task-relation.tsnew file mode 100644index 000000000..4457bb47e--- /dev/null+++ b/apps/web/src/fetchers/task-relation/create-task-relation.ts@@ -0,0 +1,30 @@+import { client } from "@kaneo/libs";++async function createTaskRelation({+ sourceTaskId,+ targetTaskId,+ relationType,+}: {+ sourceTaskId: string;+ targetTaskId: string;+ relationType: "subtask" | "blocks" | "related";+}) {+ const response = await client["task-relation"].$post({+ json: {+ sourceTaskId,+ targetTaskId,+ relationType,+ },+ });++ if (!response.ok) {+ const error = await response.text();+ throw new Error(error);+ }++ const data = await response.json();++ return data;+}++export default createTaskRelation;diff --git a/apps/web/src/fetchers/task-relation/delete-task-relation.ts b/apps/web/src/fetchers/task-relation/delete-task-relation.tsnew file mode 100644index 000000000..ee3a9b621--- /dev/null+++ b/apps/web/src/fetchers/task-relation/delete-task-relation.ts@@ -0,0 +1,18 @@+import { client } from "@kaneo/libs";++async function deleteTaskRelation(id: string) {+ const response = await client["task-relation"][":id"].$delete({+ param: { id },+ });++ if (!response.ok) {+ const error = await response.text();+ throw new Error(error);+ }++ const data = await response.json();++ return data;+}++export default deleteTaskRelation;diff --git a/apps/web/src/fetchers/task-relation/get-task-relations.ts b/apps/web/src/fetchers/task-relation/get-task-relations.tsnew file mode 100644index 000000000..8fac27bef--- /dev/null+++ b/apps/web/src/fetchers/task-relation/get-task-relations.ts@@ -0,0 +1,18 @@+import { client } from "@kaneo/libs";++async function getTaskRelations(taskId: string) {+ const response = await client["task-relation"][":taskId"].$get({+ param: { taskId },+ });++ if (!response.ok) {+ const error = await response.text();+ throw new Error(error);+ }++ const data = await response.json();++ return data;+}++export default getTaskRelations;diff --git a/apps/web/src/hooks/mutations/task-relation/use-create-task-relation.ts b/apps/web/src/hooks/mutations/task-relation/use-create-task-relation.tsnew file mode 100644index 000000000..703a2fd91--- /dev/null+++ b/apps/web/src/hooks/mutations/task-relation/use-create-task-relation.ts@@ -0,0 +1,20 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";+import createTaskRelation from "@/fetchers/task-relation/create-task-relation";++function useCreateTaskRelation() {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: createTaskRelation,+ onSuccess: (_, variables) => {+ queryClient.invalidateQueries({+ queryKey: ["task-relations", variables.sourceTaskId],+ });+ queryClient.invalidateQueries({+ queryKey: ["task-relations", variables.targetTaskId],+ });+ },+ });+}++export default useCreateTaskRelation;diff --git a/apps/web/src/hooks/mutations/task-relation/use-delete-task-relation.ts b/apps/web/src/hooks/mutations/task-relation/use-delete-task-relation.tsnew file mode 100644index 000000000..8f59ac4f8--- /dev/null+++ b/apps/web/src/hooks/mutations/task-relation/use-delete-task-relation.ts@@ -0,0 +1,17 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";+import deleteTaskRelation from "@/fetchers/task-relation/delete-task-relation";++function useDeleteTaskRelation(taskId: string) {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: deleteTaskRelation,+ onSuccess: () => {+ queryClient.invalidateQueries({+ queryKey: ["task-relations", taskId],+ });+ },+ });+}++export default useDeleteTaskRelation;diff --git a/apps/web/src/hooks/queries/task-relation/use-get-task-relations.ts b/apps/web/src/hooks/queries/task-relation/use-get-task-relations.tsnew file mode 100644index 000000000..221a839fe--- /dev/null+++ b/apps/web/src/hooks/queries/task-relation/use-get-task-relations.ts@@ -0,0 +1,12 @@+import { useQuery } from "@tanstack/react-query";+import getTaskRelations from "@/fetchers/task-relation/get-task-relations";++function useGetTaskRelations(taskId: string) {+ return useQuery({+ queryKey: ["task-relations", taskId],+ queryFn: () => getTaskRelations(taskId),+ enabled: !!taskId,+ });+}++export default useGetTaskRelations;