⚡ 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(projects): add drag-and-drop project reordering
Rojenson Lugo8b88c7d7979b
diff --git a/apps/api/drizzle/0037_tiny_raza.sql b/apps/api/drizzle/0037_tiny_raza.sqlnew file mode 100644index 000000000..1394319dd--- /dev/null+++ b/apps/api/drizzle/0037_tiny_raza.sql@@ -0,0 +1,8 @@+ALTER TABLE "project" ADD COLUMN "position" integer DEFAULT 0 NOT NULL;--> statement-breakpoint+CREATE INDEX "project_workspaceId_position_idx" ON "project" USING btree ("workspace_id","position");--> statement-breakpoint+UPDATE "project" p SET "position" = sub.rn+FROM (+ SELECT "id", row_number() OVER (PARTITION BY "workspace_id" ORDER BY "created_at", "id") - 1 AS rn+ FROM "project"+) sub+WHERE p."id" = sub."id";\ No newline at end of filediff --git a/apps/api/drizzle/meta/0037_snapshot.json b/apps/api/drizzle/meta/0037_snapshot.jsonnew file mode 100644index 000000000..612ca825e--- /dev/null+++ b/apps/api/drizzle/meta/0037_snapshot.json@@ -0,0 +1,3941 @@+{+ "id": "0069b9f8-30bf-42e6-9603-13b0db606552",+ "prevId": "23f5b6df-7eb7-4ca3-936f-594440b532e3",+ "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()"+ },+ "updated_at": {+ "name": "updated_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+ },+ "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": {}+ }+ },+ "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": {+ "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.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": {}+ },+ "asset_createdBy_idx": {+ "name": "asset_createdBy_idx",+ "columns": [+ {+ "expression": "created_by",+ "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.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()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "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.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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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.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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": 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": {+ "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()"+ },+ "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": {}+ },+ "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.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()"+ },+ "updated_at": {+ "name": "updated_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": {+ "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_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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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()"+ },+ "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+ }+ },+ "indexes": {+ "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()"+ },+ "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+ }+ },+ "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_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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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": false,+ "default": "'low'"+ },+ "start_date": {+ "name": "start_date",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "due_date": {+ "name": "due_date",+ "type": "timestamp",+ "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": {+ "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_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": "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": {+ "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+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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": "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+ },+ "locale": {+ "name": "locale",+ "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+ },+ "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+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_email_unique": {+ "name": "user_email_unique",+ "nullsNotDistinct": false,+ "columns": ["email"]+ }+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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()"+ },+ "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": {}+ },+ "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+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "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": {+ "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 d47c8bda2..7e42cfe54 100644--- a/apps/api/drizzle/meta/_journal.json+++ b/apps/api/drizzle/meta/_journal.json@@ -260,6 +260,13 @@"when": 1785921085773,"tag": "0036_strong_pandemic","breakpoints": true+ },+ {+ "idx": 37,+ "version": "7",+ "when": 1786185172966,+ "tag": "0037_tiny_raza",+ "breakpoints": true}]}diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.tsindex 38032a56f..51f591a65 100644--- a/apps/api/src/database/schema.ts+++ b/apps/api/src/database/schema.ts@@ -290,9 +290,14 @@ export const projectTable = pgTable(isPublic: boolean("is_public").default(false),archivedAt: timestamp("archived_at", { mode: "date" }),lastTaskNumber: integer("last_task_number").notNull().default(0),+ position: integer("position").notNull().default(0),},(table) => [unique("project_workspace_id_id_unique").on(table.workspaceId, table.id),+ index("project_workspaceId_position_idx").on(+ table.workspaceId,+ table.position,+ ),],);diff --git a/apps/api/src/project/controllers/create-project.ts b/apps/api/src/project/controllers/create-project.tsindex a18d44cac..cf38021de 100644--- a/apps/api/src/project/controllers/create-project.ts+++ b/apps/api/src/project/controllers/create-project.ts@@ -1,3 +1,4 @@+import { eq, max } from "drizzle-orm";import db from "../../database";import { columnTable, projectTable } from "../../database/schema";@@ -15,6 +16,12 @@ async function createProject(slug: string,) {return db.transaction(async (tx) => {+ // New projects go to the bottom of the workspace's ordering.+ const [{ maxPosition } = { maxPosition: null }] = await tx+ .select({ maxPosition: max(projectTable.position) })+ .from(projectTable)+ .where(eq(projectTable.workspaceId, workspaceId));+const [createdProject] = await tx.insert(projectTable).values({@@ -22,6 +29,7 @@ async function createProject(name,icon,slug,+ position: maxPosition === null ? 0 : maxPosition + 1,}).returning();diff --git a/apps/api/src/project/controllers/get-projects.ts b/apps/api/src/project/controllers/get-projects.tsindex ecb9faf98..46149ee07 100644--- a/apps/api/src/project/controllers/get-projects.ts+++ b/apps/api/src/project/controllers/get-projects.ts@@ -70,6 +70,10 @@ async function getProjects(workspaceId: string, includeArchived = false) {eq(projectTable.workspaceId, workspaceId),isNull(projectTable.archivedAt),),+ orderBy: (project, { asc }) => [+ asc(project.position),+ asc(project.createdAt),+ ],});const statisticsByProject = await getProjectStatistics(diff --git a/apps/api/src/project/controllers/reorder-projects.ts b/apps/api/src/project/controllers/reorder-projects.tsnew file mode 100644index 000000000..6b3f5a379--- /dev/null+++ b/apps/api/src/project/controllers/reorder-projects.ts@@ -0,0 +1,55 @@+import { and, asc, eq, inArray } from "drizzle-orm";+import { HTTPException } from "hono/http-exception";+import db from "../../database";+import { projectTable } from "../../database/schema";++async function reorderProjects(+ workspaceId: string,+ projects: Array<{ id: string; position: number }>,+) {+ const ids = projects.map((project) => project.id);++ // Verify ownership of the whole batch before writing anything, so a smuggled+ // foreign id cannot leave the workspace half-renumbered.+ const owned = ids.length+ ? await db+ .select({ id: projectTable.id })+ .from(projectTable)+ .where(+ and(+ eq(projectTable.workspaceId, workspaceId),+ inArray(projectTable.id, ids),+ ),+ )+ : [];++ const ownedIds = new Set(owned.map((project) => project.id));+ const foreignId = ids.find((id) => !ownedIds.has(id));++ if (foreignId) {+ throw new HTTPException(400, {+ message: `Project ${foreignId} does not belong to this workspace`,+ });+ }++ return db.transaction(async (tx) => {+ for (const project of projects) {+ await tx+ .update(projectTable)+ .set({ position: project.position })+ .where(+ and(+ eq(projectTable.id, project.id),+ eq(projectTable.workspaceId, workspaceId),+ ),+ );+ }++ return tx.query.projectTable.findMany({+ where: eq(projectTable.workspaceId, workspaceId),+ orderBy: [asc(projectTable.position), asc(projectTable.createdAt)],+ });+ });+}++export default reorderProjects;diff --git a/apps/api/src/project/index.ts b/apps/api/src/project/index.tsindex cde07ad78..8270c8d94 100644--- a/apps/api/src/project/index.ts+++ b/apps/api/src/project/index.ts@@ -10,6 +10,7 @@ import createProjectCtrl from "./controllers/create-project";import deleteProjectCtrl from "./controllers/delete-project";import getProjectCtrl from "./controllers/get-project";import getProjectsCtrl from "./controllers/get-projects";+import reorderProjectsCtrl from "./controllers/reorder-projects";import unarchiveProjectCtrl from "./controllers/unarchive-project";import updateProjectCtrl from "./controllers/update-project";@@ -110,6 +111,42 @@ const project = new Hono<{return c.json(projectData);},)+ .put(+ "/reorder",+ describeRoute({+ operationId: "reorderProjects",+ tags: ["Projects"],+ description: "Reorder projects in a workspace",+ responses: {+ 200: {+ description: "Projects reordered successfully",+ content: {+ "application/json": { schema: resolver(v.array(projectSchema)) },+ },+ },+ },+ }),+ validator("query", v.object({ workspaceId: v.string() })),+ validator(+ "json",+ v.object({+ projects: v.array(+ v.object({+ id: v.string(),+ position: v.pipe(v.number(), v.integer()),+ }),+ ),+ }),+ ),+ workspaceAccess.fromQuery(),+ requireWorkspacePermission({ project: ["update"] }),+ async (c) => {+ const workspaceId = c.get("workspaceId");+ const { projects } = c.req.valid("json");+ const reordered = await reorderProjectsCtrl(workspaceId, projects);+ return c.json(reordered);+ },+ ).put("/:id",describeRoute({diff --git a/apps/api/src/schemas.ts b/apps/api/src/schemas.tsindex 68b554db6..a8f989199 100644--- a/apps/api/src/schemas.ts+++ b/apps/api/src/schemas.ts@@ -19,6 +19,7 @@ export const projectSchema = v.object({createdAt: v.date(),isPublic: v.nullable(v.boolean()),archivedAt: v.nullable(v.date()),+ position: v.number(),});export const taskSchema = v.object({diff --git a/apps/web/src/components/nav-projects.tsx b/apps/web/src/components/nav-projects.tsxindex 517b27474..95a39245b 100644--- a/apps/web/src/components/nav-projects.tsx+++ b/apps/web/src/components/nav-projects.tsx@@ -1,14 +1,32 @@+import {+ closestCenter,+ DndContext,+ type DragEndEvent,+ KeyboardSensor,+ MouseSensor,+ TouchSensor,+ useSensor,+ useSensors,+} from "@dnd-kit/core";+import {+ arrayMove,+ SortableContext,+ useSortable,+ verticalListSortingStrategy,+} from "@dnd-kit/sortable";+import { CSS } from "@dnd-kit/utilities";import { useQueryClient } from "@tanstack/react-query";import { useNavigate, useParams } from "@tanstack/react-router";import {ChevronRight,Folder,Forward,+ GripVertical,MoreHorizontal,Settings,Trash2,} from "lucide-react";-import { useState } from "react";+import { type CSSProperties, type ReactNode, useState } from "react";import { useTranslation } from "react-i18next";import {Collapsible,@@ -32,6 +50,7 @@ import {useSidebar,} from "@/components/ui/sidebar";import useDeleteProject from "@/hooks/mutations/project/use-delete-project";+import useReorderProjects from "@/hooks/mutations/project/use-reorder-projects";import useGetProjects from "@/hooks/queries/project/use-get-projects";import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";import { useWorkspacePermission } from "@/hooks/use-workspace-permission";@@ -49,6 +68,55 @@ import {} from "./ui/alert-dialog";import { Button } from "./ui/button";+function SortableProjectItem({+ id,+ canReorder,+ children,+}: {+ id: string;+ canReorder: boolean;+ children: ReactNode;+}) {+ const { t } = useTranslation();+ const {+ attributes,+ listeners,+ setNodeRef,+ transform,+ transition,+ isDragging,+ } = useSortable({ id, disabled: !canReorder });++ const style: CSSProperties = {+ transform: CSS.Transform.toString(transform),+ transition,+ opacity: isDragging ? 0.5 : 1,+ };++ return (+ <SidebarMenuItem ref={setNodeRef} style={style}>+ {canReorder && (+ // Only the handle activates a drag. Spreading the sortable props over+ // the whole item would make it a role="button" tab stop wrapping the+ // menu and dropdown buttons, and would let Enter start a drag.+ <button+ type="button"+ className="absolute top-1.5 end-6 z-10 flex aspect-square w-5 cursor-grab items-center justify-center rounded-lg p-0 text-sidebar-foreground opacity-0 outline-hidden ring-sidebar-ring transition-opacity hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:opacity-100 focus-visible:ring-2 group-data-[collapsible=icon]:hidden group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100"+ onClick={(event) => event.stopPropagation()}+ {...attributes}+ {...listeners}+ >+ <GripVertical className="h-4 w-4" />+ <span className="sr-only">+ {t("workspace:projects.reorderHandle")}+ </span>+ </button>+ )}+ {children}+ </SidebarMenuItem>+ );+}+export function NavProjects() {const { t } = useTranslation();const { isMobile } = useSidebar();@@ -58,9 +126,12 @@ export function NavProjects() {});const queryClient = useQueryClient();const { mutateAsync: deleteProject } = useDeleteProject();- const { canCreateProjects, canDeleteProjects } = useWorkspacePermission();+ const { mutate: reorderProjects } = useReorderProjects();+ const { canCreateProjects, canDeleteProjects, canManageProjects } =+ useWorkspacePermission();const canCreate = canCreateProjects();const canDeleteProject = canDeleteProjects();+ const canReorder = canManageProjects();const navigate = useNavigate();const { workspaceId: currentWorkspaceId, projectId: currentProjectId } =useParams({@@ -91,6 +162,46 @@ export function NavProjects() {});};+ // Distance/delay thresholds keep a tap on the handle from being read as a+ // drag; permission gating lives on the handle and `useSortable`'s `disabled`.+ const sensors = useSensors(+ useSensor(MouseSensor, {+ activationConstraint: { distance: 8 },+ }),+ useSensor(TouchSensor, {+ activationConstraint: { delay: 200, tolerance: 8 },+ }),+ useSensor(KeyboardSensor),+ );++ const handleDragEnd = (event: DragEndEvent) => {+ const { active, over } = event;++ if (!over || active.id === over.id || !projects || !workspace) return;++ const oldIndex = projects.findIndex((project) => project.id === active.id);+ const newIndex = projects.findIndex((project) => project.id === over.id);++ if (oldIndex === -1 || newIndex === -1) return;++ const reordered = arrayMove(projects, oldIndex, newIndex);++ reorderProjects(+ {+ workspaceId: workspace.id,+ projects: reordered.map((project, index) => ({+ id: project.id,+ position: index,+ })),+ },+ {+ onError: () => {+ toast.error(t("workspace:projects.reorderError"));+ },+ },+ );+ };+if (!workspace) return null;return (@@ -109,98 +220,115 @@ export function NavProjects() {<CollapsiblePanel><SidebarGroupContent><SidebarMenu className="gap-0.5">- {projects?.map((project) => {- return (- <SidebarMenuItem key={project.id}>- <SidebarMenuButton- isActive={isCurrentProject(project.id)}- size="default"- className="h-8 gap-0 ps-3.5 text-sm hover:bg-transparent hover:text-sidebar-accent-foreground active:bg-transparent"- onClick={() => handleProjectClick(project)}- >- <span>{project.name}</span>- </SidebarMenuButton>-- <DropdownMenu>- <DropdownMenuTrigger- render={- <button- type="button"- className="absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-lg p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground after:-inset-2 after:absolute md:after:hidden peer-data-[size=sm]/menu-button:top-1 peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 group-data-[collapsible=icon]:hidden group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0"- />- }+ <DndContext+ sensors={sensors}+ collisionDetection={closestCenter}+ onDragEnd={handleDragEnd}+ >+ <SortableContext+ items={projects?.map((project) => project.id) ?? []}+ strategy={verticalListSortingStrategy}+ >+ {projects?.map((project) => {+ return (+ <SortableProjectItem+ key={project.id}+ id={project.id}+ canReorder={canReorder}>- <MoreHorizontal />- <span className="sr-only">- {t("navigation:sidebar.more")}- </span>- </DropdownMenuTrigger>- <DropdownMenuContent- className="w-44 rounded-lg"- side={isMobile ? "bottom" : "right"}- align={isMobile ? "end" : "start"}- >- <DropdownMenuItem- className="h-7 items-start cursor-pointer text-sm"+ <SidebarMenuButton+ isActive={isCurrentProject(project.id)}+ size="default"+ className="h-8 gap-0 ps-3.5 text-sm hover:bg-transparent hover:text-sidebar-accent-foreground active:bg-transparent"onClick={() => handleProjectClick(project)}>- <Folder className="text-muted-foreground" />- <span>- {t("navigation:projectList.viewProject")}- </span>- </DropdownMenuItem>- <DropdownMenuItem- className="h-7 items-start cursor-pointer text-sm"- onClick={() => {- navigator.clipboard.writeText(- `${window.location.origin}/dashboard/workspace/${workspace?.id}/project/${project.id}`,- );- toast.success(- t("navigation:projectList.linkCopied"),- );- }}- >- <Forward className="text-muted-foreground" />- <span>- {t("navigation:projectList.shareProject")}- </span>- </DropdownMenuItem>- <DropdownMenuItem- className="h-7 items-start cursor-pointer text-sm"- onClick={() => {- navigate({- to: "/dashboard/settings/projects/$projectId/general",- params: { projectId: project.id },- });- }}- >- <Settings className="text-muted-foreground" />- <span>- {t("navigation:projectList.projectSettings")}- </span>- </DropdownMenuItem>- {canDeleteProject && (- <>- <DropdownMenuSeparator />+ <span>{project.name}</span>+ </SidebarMenuButton>++ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <button+ type="button"+ className="absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-lg p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground after:-inset-2 after:absolute md:after:hidden peer-data-[size=sm]/menu-button:top-1 peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 group-data-[collapsible=icon]:hidden group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0"+ />+ }+ >+ <MoreHorizontal />+ <span className="sr-only">+ {t("navigation:sidebar.more")}+ </span>+ </DropdownMenuTrigger>+ <DropdownMenuContent+ className="w-44 rounded-lg"+ side={isMobile ? "bottom" : "right"}+ align={isMobile ? "end" : "start"}+ >+ <DropdownMenuItem+ className="h-7 items-start cursor-pointer text-sm"+ onClick={() => handleProjectClick(project)}+ >+ <Folder className="text-muted-foreground" />+ <span>+ {t("navigation:projectList.viewProject")}+ </span>+ </DropdownMenuItem>+ <DropdownMenuItem+ className="h-7 items-start cursor-pointer text-sm"+ onClick={() => {+ navigator.clipboard.writeText(+ `${window.location.origin}/dashboard/workspace/${workspace?.id}/project/${project.id}`,+ );+ toast.success(+ t("navigation:projectList.linkCopied"),+ );+ }}+ >+ <Forward className="text-muted-foreground" />+ <span>+ {t("navigation:projectList.shareProject")}+ </span>+ </DropdownMenuItem><DropdownMenuItem- className="h-7 items-start text-destructive cursor-pointer text-sm"+ className="h-7 items-start cursor-pointer text-sm"onClick={() => {- setProjectToDeleteID(project.id);- setIsDeleteProjectModalOpen(true);+ navigate({+ to: "/dashboard/settings/projects/$projectId/general",+ params: { projectId: project.id },+ });}}>- <Trash2 className="text-destructive" />+ <Settings className="text-muted-foreground" /><span>- {t("navigation:projectList.deleteProject")}+ {t("navigation:projectList.projectSettings")}</span></DropdownMenuItem>- </>- )}- </DropdownMenuContent>- </DropdownMenu>- </SidebarMenuItem>- );- })}+ {canDeleteProject && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ className="h-7 items-start text-destructive cursor-pointer text-sm"+ onClick={() => {+ setProjectToDeleteID(project.id);+ setIsDeleteProjectModalOpen(true);+ }}+ >+ <Trash2 className="text-destructive" />+ <span>+ {t(+ "navigation:projectList.deleteProject",+ )}+ </span>+ </DropdownMenuItem>+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ </SortableProjectItem>+ );+ })}+ </SortableContext>+ </DndContext>{canCreate && (<SidebarMenuItem className="mt-1">diff --git a/apps/web/src/fetchers/project/reorder-projects.ts b/apps/web/src/fetchers/project/reorder-projects.tsnew file mode 100644index 000000000..3f5569e22--- /dev/null+++ b/apps/web/src/fetchers/project/reorder-projects.ts@@ -0,0 +1,20 @@+import { client } from "@kaneo/libs";++async function reorderProjects(+ workspaceId: string,+ projects: Array<{ id: string; position: number }>,+) {+ const response = await client.project.reorder.$put({+ query: { workspaceId },+ json: { projects },+ });++ if (!response.ok) {+ const error = await response.text();+ throw new Error(error);+ }++ return response.json();+}++export default reorderProjects;diff --git a/apps/web/src/hooks/mutations/project/use-reorder-projects.ts b/apps/web/src/hooks/mutations/project/use-reorder-projects.tsnew file mode 100644index 000000000..e1e1b7d5c--- /dev/null+++ b/apps/web/src/hooks/mutations/project/use-reorder-projects.ts@@ -0,0 +1,54 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";+import type getProjects from "@/fetchers/project/get-projects";+import reorderProjects from "@/fetchers/project/reorder-projects";++type ProjectList = Awaited<ReturnType<typeof getProjects>>;++type ReorderProjectsVariables = {+ workspaceId: string;+ projects: Array<{ id: string; position: number }>;+};++function useReorderProjects() {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: ({ workspaceId, projects }: ReorderProjectsVariables) =>+ reorderProjects(workspaceId, projects),+ // Reordering is a pure UI gesture — without an optimistic write the list+ // snaps back to the server order until the refetch lands.+ onMutate: async ({ workspaceId, projects }: ReorderProjectsVariables) => {+ const queryKey = ["projects", workspaceId];+ await queryClient.cancelQueries({ queryKey });++ const previousProjects = queryClient.getQueryData<ProjectList>(queryKey);++ if (previousProjects) {+ const positionById = new Map(+ projects.map(({ id, position }) => [id, position]),+ );++ queryClient.setQueryData<ProjectList>(+ queryKey,+ [...previousProjects].sort(+ (a, b) =>+ (positionById.get(a.id) ?? a.position) -+ (positionById.get(b.id) ?? b.position),+ ),+ );+ }++ return { queryKey, previousProjects };+ },+ onError: (_error, _variables, context) => {+ if (context?.previousProjects) {+ queryClient.setQueryData(context.queryKey, context.previousProjects);+ }+ },+ onSettled: (_data, _error, { workspaceId }) => {+ queryClient.invalidateQueries({ queryKey: ["projects", workspaceId] });+ },+ });+}++export default useReorderProjects;diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsxindex 135d22f8d..57639e335 100644--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx@@ -1,6 +1,23 @@+import {+ closestCenter,+ DndContext,+ type DragEndEvent,+ KeyboardSensor,+ MouseSensor,+ TouchSensor,+ useSensor,+ useSensors,+} from "@dnd-kit/core";+import {+ arrayMove,+ SortableContext,+ useSortable,+ verticalListSortingStrategy,+} from "@dnd-kit/sortable";+import { CSS } from "@dnd-kit/utilities";import { createFileRoute, useNavigate } from "@tanstack/react-router";-import { LayoutGrid, Plus } from "lucide-react";-import { useState } from "react";+import { GripVertical, LayoutGrid, Plus } from "lucide-react";+import { type CSSProperties, type ReactNode, useState } from "react";import { useTranslation } from "react-i18next";import WorkspaceLayout from "@/components/common/workspace-layout";import PageTitle from "@/components/page-title";@@ -27,10 +44,12 @@ import {} from "@/components/ui/table";import icons from "@/constants/project-icons";import { shortcuts } from "@/constants/shortcuts";+import useReorderProjects from "@/hooks/mutations/project/use-reorder-projects";import useGetProjects from "@/hooks/queries/project/use-get-projects";import { useRegisterShortcuts } from "@/hooks/use-keyboard-shortcuts";import { useWorkspacePermission } from "@/hooks/use-workspace-permission";import { formatDateMedium } from "@/lib/format";+import { toast } from "@/lib/toast";export const Route = createFileRoute("/_layout/_authenticated/dashboard/workspace/$workspaceId/",@@ -38,6 +57,63 @@ export const Route = createFileRoute(component: RouteComponent,});+function SortableProjectRow({+ id,+ canReorder,+ onClick,+ children,+}: {+ id: string;+ canReorder: boolean;+ onClick: () => void;+ children: ReactNode;+}) {+ const { t } = useTranslation();+ const {+ attributes,+ listeners,+ setNodeRef,+ transform,+ transition,+ isDragging,+ } = useSortable({ id });++ const style: CSSProperties = {+ transform: CSS.Transform.toString(transform),+ transition,+ opacity: isDragging ? 0.5 : 1,+ };++ return (+ <TableRow+ ref={setNodeRef}+ style={style}+ className="group/row cursor-pointer"+ onClick={onClick}+ >+ <TableCell className="w-8 py-3 pe-0">+ {canReorder && (+ // The row itself navigates on click, so only the handle activates a+ // drag.+ <button+ type="button"+ className="flex cursor-grab items-center text-muted-foreground opacity-0 transition-opacity focus-visible:opacity-100 group-hover/row:opacity-100 hover:text-foreground"+ onClick={(event) => event.stopPropagation()}+ {...attributes}+ {...listeners}+ >+ <GripVertical className="h-4 w-4" />+ <span className="sr-only">+ {t("workspace:projects.reorderHandle")}+ </span>+ </button>+ )}+ </TableCell>+ {children}+ </TableRow>+ );+}+function RouteComponent() {const { t } = useTranslation();const [isCreateProjectOpen, setIsCreateProjectOpen] = useState(false);@@ -46,8 +122,48 @@ function RouteComponent() {const { data: projects, isLoading } = useGetProjects({workspaceId,});- const { canCreateProjects } = useWorkspacePermission();+ const { mutate: reorderProjects } = useReorderProjects();+ const { canCreateProjects, canManageProjects } = useWorkspacePermission();const canCreate = canCreateProjects();+ const canReorder = canManageProjects();++ const sensors = useSensors(+ useSensor(MouseSensor, {+ activationConstraint: { distance: 8 },+ }),+ useSensor(TouchSensor, {+ activationConstraint: { delay: 200, tolerance: 8 },+ }),+ useSensor(KeyboardSensor),+ );++ const handleDragEnd = (event: DragEndEvent) => {+ const { active, over } = event;++ if (!over || active.id === over.id || !projects) return;++ const oldIndex = projects.findIndex((project) => project.id === active.id);+ const newIndex = projects.findIndex((project) => project.id === over.id);++ if (oldIndex === -1 || newIndex === -1) return;++ const reordered = arrayMove(projects, oldIndex, newIndex);++ reorderProjects(+ {+ workspaceId,+ projects: reordered.map((project, index) => ({+ id: project.id,+ position: index,+ })),+ },+ {+ onError: () => {+ toast.error(t("workspace:projects.reorderError"));+ },+ },+ );+ };const handleCreateProject = () => {if (!canCreate) return;@@ -92,6 +208,7 @@ function RouteComponent() {<Table><TableHeader><TableRow>+ <TableHead className="w-8" /><TableHead className="text-foreground font-medium">{t("workspace:projects.title")}</TableHead>@@ -109,6 +226,7 @@ function RouteComponent() {<TableBody>{[1, 2, 3].map((i) => (<TableRow key={i}>+ <TableCell className="w-8 py-3 pe-0" /><TableCell className="py-3"><div className="flex items-center gap-3"><Skeleton className="h-5 w-5" />@@ -203,85 +321,99 @@ function RouteComponent() {) : null}>- <Table>- <TableHeader className="p-4">- <TableRow>- <TableHead className="text-foreground font-medium">- {t("workspace:projects.title")}- </TableHead>- <TableHead className="text-foreground font-medium">- {t("workspace:projects.progress")}- </TableHead>- <TableHead className="text-foreground font-medium">- {t("workspace:projects.dueDate")}- </TableHead>- <TableHead className="text-foreground font-medium">- {t("workspace:projects.status")}- </TableHead>- </TableRow>- </TableHeader>- <TableBody>- {projects?.map((project) => {- if (!project || !project.id || !project.statistics) return null;+ <DndContext+ sensors={sensors}+ collisionDetection={closestCenter}+ onDragEnd={handleDragEnd}+ >+ <Table>+ <TableHeader className="p-4">+ <TableRow>+ <TableHead className="w-8" />+ <TableHead className="text-foreground font-medium">+ {t("workspace:projects.title")}+ </TableHead>+ <TableHead className="text-foreground font-medium">+ {t("workspace:projects.progress")}+ </TableHead>+ <TableHead className="text-foreground font-medium">+ {t("workspace:projects.dueDate")}+ </TableHead>+ <TableHead className="text-foreground font-medium">+ {t("workspace:projects.status")}+ </TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ <SortableContext+ items={projects?.map((project) => project.id) ?? []}+ strategy={verticalListSortingStrategy}+ >+ {projects?.map((project) => {+ if (!project || !project.id || !project.statistics)+ return null;- const IconComponent =- icons[project.icon as keyof typeof icons] || icons.Layout;+ const IconComponent =+ icons[project.icon as keyof typeof icons] || icons.Layout;- const getStatusText = () => {- if (project.statistics.totalTasks === 0)- return t("workspace:projects.projectStatus.notStarted");- if (project.statistics.completionPercentage === 100)- return t("workspace:projects.projectStatus.complete");- return t("workspace:projects.projectStatus.inProgress");- };+ const getStatusText = () => {+ if (project.statistics.totalTasks === 0)+ return t("workspace:projects.projectStatus.notStarted");+ if (project.statistics.completionPercentage === 100)+ return t("workspace:projects.projectStatus.complete");+ return t("workspace:projects.projectStatus.inProgress");+ };- const getStatusVariant = () => {- if (project.statistics.totalTasks === 0) return "secondary";- if (project.statistics.completionPercentage === 100)- return "default";- return "outline";- };+ const getStatusVariant = () => {+ if (project.statistics.totalTasks === 0) return "secondary";+ if (project.statistics.completionPercentage === 100)+ return "default";+ return "outline";+ };- return (- <TableRow- key={project.id}- className="cursor-pointer"- onClick={() => handleProjectClick(project.id)}- >- <TableCell className="py-3">- <div className="flex items-center gap-3">- <IconComponent className="w-5 h-5 text-muted-foreground" />- <span className="font-medium">{project.name}</span>- </div>- </TableCell>- <TableCell className="py-3">- <div className="flex items-center gap-2">- <Progress- value={project.statistics.completionPercentage}- className="w-16 h-2"- />- <span className="text-sm text-muted-foreground">- {project.statistics.completionPercentage}%- </span>- </div>- </TableCell>- <TableCell className="py-3">- <span className="text-sm text-muted-foreground">- {project.statistics.dueDate- ? formatDateMedium(project.statistics.dueDate)- : t("workspace:projects.noDueDate")}- </span>- </TableCell>- <TableCell className="py-3">- <Badge variant={getStatusVariant()}>- {getStatusText()}- </Badge>- </TableCell>- </TableRow>- );- })}- </TableBody>- </Table>+ return (+ <SortableProjectRow+ key={project.id}+ id={project.id}+ canReorder={canReorder}+ onClick={() => handleProjectClick(project.id)}+ >+ <TableCell className="py-3">+ <div className="flex items-center gap-3">+ <IconComponent className="w-5 h-5 text-muted-foreground" />+ <span className="font-medium">{project.name}</span>+ </div>+ </TableCell>+ <TableCell className="py-3">+ <div className="flex items-center gap-2">+ <Progress+ value={project.statistics.completionPercentage}+ className="w-16 h-2"+ />+ <span className="text-sm text-muted-foreground">+ {project.statistics.completionPercentage}%+ </span>+ </div>+ </TableCell>+ <TableCell className="py-3">+ <span className="text-sm text-muted-foreground">+ {project.statistics.dueDate+ ? formatDateMedium(project.statistics.dueDate)+ : t("workspace:projects.noDueDate")}+ </span>+ </TableCell>+ <TableCell className="py-3">+ <Badge variant={getStatusVariant()}>+ {getStatusText()}+ </Badge>+ </TableCell>+ </SortableProjectRow>+ );+ })}+ </SortableContext>+ </TableBody>+ </Table>+ </DndContext></WorkspaceLayout><CreateProjectModaldiff --git a/i18n/de-DE.json b/i18n/de-DE.jsonindex 0db14a99d..d4ae49fc9 100644--- a/i18n/de-DE.json+++ b/i18n/de-DE.json@@ -1956,6 +1956,8 @@"inProgress": "In Bearbeitung"},"noDueDate": "Kein Fälligkeitsdatum",+ "reorderHandle": "Projekt neu anordnen",+ "reorderError": "Projekte konnten nicht neu angeordnet werden","emptyDescriptionReadOnly": "In diesem Workspace gibt es noch keine Projekte. Bitte einen Admin, eines zu erstellen."},"search": {diff --git a/i18n/el-GR.json b/i18n/el-GR.jsonindex 543cc2ee2..a2d316d4d 100644--- a/i18n/el-GR.json+++ b/i18n/el-GR.json@@ -1956,6 +1956,8 @@"inProgress": "Σε εξέλιξη"},"noDueDate": "Χωρίς ημερομηνία λήξης",+ "reorderHandle": "Αναδιάταξη έργου",+ "reorderError": "Η αναδιάταξη των έργων απέτυχε","emptyDescriptionReadOnly": "Δεν υπάρχουν ακόμα έργα σε αυτόν τον χώρο εργασίας. Ζητήστε από έναν διαχειριστή να δημιουργήσει ένα."},"search": {diff --git a/i18n/en-US.json b/i18n/en-US.jsonindex 39251f051..d8220ee71 100644--- a/i18n/en-US.json+++ b/i18n/en-US.json@@ -1956,7 +1956,9 @@"complete": "Complete","inProgress": "In progress"},- "noDueDate": "No due date"+ "noDueDate": "No due date",+ "reorderHandle": "Reorder project",+ "reorderError": "Failed to reorder projects"},"search": {"pageTitle": "Search",diff --git a/i18n/es-ES.json b/i18n/es-ES.jsonindex 61358dde4..7cfac0062 100644--- a/i18n/es-ES.json+++ b/i18n/es-ES.json@@ -1956,6 +1956,8 @@"inProgress": "En progreso"},"noDueDate": "Sin fecha de vencimiento",+ "reorderHandle": "Reordenar proyecto",+ "reorderError": "No se pudieron reordenar los proyectos","emptyDescriptionReadOnly": "Todavía no hay proyectos en este espacio de trabajo. Pide a un admin que cree uno."},"search": {diff --git a/i18n/fr-FR.json b/i18n/fr-FR.jsonindex 53a01bbe2..d6627f47b 100644--- a/i18n/fr-FR.json+++ b/i18n/fr-FR.json@@ -1956,7 +1956,9 @@"complete": "Terminé","inProgress": "En cours"},- "noDueDate": "Pas de date d'échéance"+ "noDueDate": "Pas de date d'échéance",+ "reorderHandle": "Réorganiser le projet",+ "reorderError": "Échec de la réorganisation des projets"},"search": {"pageTitle": "Rechercher",diff --git a/i18n/hi-IN.json b/i18n/hi-IN.jsonindex 72e39b9ec..07dda8e87 100644--- a/i18n/hi-IN.json+++ b/i18n/hi-IN.json@@ -1956,7 +1956,9 @@"complete": "पूर्ण","inProgress": "प्रगति में"},- "noDueDate": "कोई नियत तारीख नहीं"+ "noDueDate": "कोई नियत तारीख नहीं",+ "reorderHandle": "प्रोजेक्ट का क्रम बदलें",+ "reorderError": "प्रोजेक्ट का क्रम बदलने में विफल"},"search": {"pageTitle": "खोजें",diff --git a/i18n/id-ID.json b/i18n/id-ID.jsonindex 7980a1103..c1241ff9e 100644--- a/i18n/id-ID.json+++ b/i18n/id-ID.json@@ -1956,7 +1956,9 @@"complete": "Selesai","inProgress": "Sedang berjalan"},- "noDueDate": "Tanpa tenggat"+ "noDueDate": "Tanpa tenggat",+ "reorderHandle": "Ubah urutan proyek",+ "reorderError": "Gagal mengubah urutan proyek"},"search": {"pageTitle": "Cari",diff --git a/i18n/it-IT.json b/i18n/it-IT.jsonindex 93e623220..c1616ebce 100644--- a/i18n/it-IT.json+++ b/i18n/it-IT.json@@ -1956,7 +1956,9 @@"complete": "Completato","inProgress": "In corso"},- "noDueDate": "Nessuna scadenza"+ "noDueDate": "Nessuna scadenza",+ "reorderHandle": "Riordina progetto",+ "reorderError": "Impossibile riordinare i progetti"},"search": {"pageTitle": "Cerca",diff --git a/i18n/ko-KR.json b/i18n/ko-KR.jsonindex 2dbc1be16..6068b6090 100644--- a/i18n/ko-KR.json+++ b/i18n/ko-KR.json@@ -1956,6 +1956,8 @@"inProgress": "진행 중"},"noDueDate": "마감일 없음",+ "reorderHandle": "프로젝트 순서 변경",+ "reorderError": "프로젝트 순서를 변경하지 못했습니다","emptyDescriptionReadOnly": "이 워크스페이스에 아직 프로젝트가 없습니다. 관리자에게 프로젝트 생성을 요청하세요."},"search": {diff --git a/i18n/mk-MK.json b/i18n/mk-MK.jsonindex 8afe66e83..d61646adf 100644--- a/i18n/mk-MK.json+++ b/i18n/mk-MK.json@@ -1956,6 +1956,8 @@"inProgress": "Во тек"},"noDueDate": "Без краен рок",+ "reorderHandle": "Прередување на проектот",+ "reorderError": "Прередувањето на проектите не успеа","emptyDescriptionReadOnly": "Сè уште нема проекти во овој работен простор. Замоли администратор да креира еден."},"search": {diff --git a/i18n/nl-NL.json b/i18n/nl-NL.jsonindex 643578338..ea5ea80ae 100644--- a/i18n/nl-NL.json+++ b/i18n/nl-NL.json@@ -1956,6 +1956,8 @@"inProgress": "In behandeling"},"noDueDate": "Geen einddatum",+ "reorderHandle": "Project opnieuw ordenen",+ "reorderError": "Projecten opnieuw ordenen mislukt","emptyDescriptionReadOnly": "Er zijn nog geen projecten in deze werkruimte. Vraag een beheerder om er een aan te maken."},"search": {diff --git a/i18n/pt-BR.json b/i18n/pt-BR.jsonindex d343aad9e..d88989273 100644--- a/i18n/pt-BR.json+++ b/i18n/pt-BR.json@@ -1956,7 +1956,9 @@"complete": "Concluído","inProgress": "Em andamento"},- "noDueDate": "Sem data de vencimento"+ "noDueDate": "Sem data de vencimento",+ "reorderHandle": "Reordenar projeto",+ "reorderError": "Falha ao reordenar os projetos"},"search": {"pageTitle": "Buscar",diff --git a/i18n/ru-RU.json b/i18n/ru-RU.jsonindex 083005268..dab8534f9 100644--- a/i18n/ru-RU.json+++ b/i18n/ru-RU.json@@ -2024,6 +2024,8 @@"inProgress": "В работе"},"noDueDate": "Без срока",+ "reorderHandle": "Изменить порядок проекта",+ "reorderError": "Не удалось изменить порядок проектов","emptyDescriptionReadOnly": "В этой рабочей области пока нет проектов. Попросите администратора создать проект."},"search": {diff --git a/i18n/schema.json b/i18n/schema.jsonindex 9ff0acfb5..0f2cb6996 100644--- a/i18n/schema.json+++ b/i18n/schema.json@@ -7732,6 +7732,12 @@},"noDueDate": {"type": "string"+ },+ "reorderHandle": {+ "type": "string"+ },+ "reorderError": {+ "type": "string"}},"required": [@@ -7746,7 +7752,9 @@"emptyDescription","emptyDescriptionReadOnly","projectStatus",- "noDueDate"+ "noDueDate",+ "reorderHandle",+ "reorderError"]},"search": {diff --git a/i18n/tr-TR.json b/i18n/tr-TR.jsonindex 1664e8853..bc1ad802e 100644--- a/i18n/tr-TR.json+++ b/i18n/tr-TR.json@@ -1956,7 +1956,9 @@"complete": "Tamamlandı","inProgress": "Devam ediyor"},- "noDueDate": "Bitiş tarihi yok"+ "noDueDate": "Bitiş tarihi yok",+ "reorderHandle": "Projeyi yeniden sırala",+ "reorderError": "Projeler yeniden sıralanamadı"},"search": {"pageTitle": "Ara",diff --git a/i18n/uk-UA.json b/i18n/uk-UA.jsonindex 5589a0672..58efffa37 100644--- a/i18n/uk-UA.json+++ b/i18n/uk-UA.json@@ -1968,6 +1968,8 @@"inProgress": "В роботі"},"noDueDate": "Без дати завершення",+ "reorderHandle": "Змінити порядок проєкту",+ "reorderError": "Не вдалося змінити порядок проєктів","emptyDescriptionReadOnly": "У цьому робочому просторі ще немає проєктів. Попросіть адміністратора створити проєкт."},"search": {diff --git a/i18n/vi-VN.json b/i18n/vi-VN.jsonindex 379d85df6..6e4faac5c 100644--- a/i18n/vi-VN.json+++ b/i18n/vi-VN.json@@ -1956,7 +1956,9 @@"complete": "Hoàn thành","inProgress": "Đang thực hiện"},- "noDueDate": "Không có ngày đến hạn"+ "noDueDate": "Không có ngày đến hạn",+ "reorderHandle": "Sắp xếp lại dự án",+ "reorderError": "Không thể sắp xếp lại dự án"},"search": {"pageTitle": "Tìm kiếm",diff --git a/i18n/zh-CN.json b/i18n/zh-CN.jsonindex 8a7b4bd2d..c431ad908 100644--- a/i18n/zh-CN.json+++ b/i18n/zh-CN.json@@ -1956,7 +1956,9 @@"complete": "已完成","inProgress": "进行中"},- "noDueDate": "无截止日期"+ "noDueDate": "无截止日期",+ "reorderHandle": "重新排序项目",+ "reorderError": "重新排序项目失败"},"search": {"pageTitle": "搜索",diff --git a/tests/api-integration/project-reorder.test.ts b/tests/api-integration/project-reorder.test.tsnew file mode 100644index 000000000..030437b01--- /dev/null+++ b/tests/api-integration/project-reorder.test.ts@@ -0,0 +1,160 @@+import { beforeEach, describe, expect, it } from "vitest";+import { schema } from "../../apps/api/src/database";+import { createApp } from "../../apps/api/src/index";+import { mockAuthenticatedSession } from "./helpers/auth";+import { resetTestDatabase } from "./helpers/database";+import {+ createProjectFixture,+ createWorkspaceMember,+} from "./helpers/fixtures";++type ProjectListEntry = typeof schema.projectTable.$inferSelect;++async function listProjects(workspaceId: string) {+ const { app } = createApp();+ const response = await app.request(`/api/project?workspaceId=${workspaceId}`);+ return (await response.json()) as ProjectListEntry[];+}++function reorderRequest(+ workspaceId: string,+ projects: Array<{ id: string; position: number }>,+) {+ const { app } = createApp();+ return app.request(`/api/project/reorder?workspaceId=${workspaceId}`, {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ projects }),+ });+}++describe("API integration: project reorder", () => {+ beforeEach(async () => {+ await resetTestDatabase();+ });++ it("persists the new order across a re-fetch", async () => {+ const member = await createWorkspaceMember({ role: "admin" });+ const { project: first } = await createProjectFixture({+ workspaceId: member.workspace.id,+ name: "First",+ });+ const { project: second } = await createProjectFixture({+ workspaceId: member.workspace.id,+ name: "Second",+ });++ mockAuthenticatedSession(member.user);++ const response = await reorderRequest(member.workspace.id, [+ { id: second.id, position: 0 },+ { id: first.id, position: 1 },+ ]);++ expect(response.status).toBe(200);++ const projects = await listProjects(member.workspace.id);+ expect(projects.map((project) => project.id)).toEqual([+ second.id,+ first.id,+ ]);+ });++ it("rejects a project that belongs to another workspace", async () => {+ const member = await createWorkspaceMember({ role: "admin" });+ const outsider = await createWorkspaceMember({ role: "admin" });++ const { project: first } = await createProjectFixture({+ workspaceId: member.workspace.id,+ name: "First",+ });+ const { project: second } = await createProjectFixture({+ workspaceId: member.workspace.id,+ name: "Second",+ });+ const { project: foreign } = await createProjectFixture({+ workspaceId: outsider.workspace.id,+ });++ mockAuthenticatedSession(member.user);++ // A caller with legitimate access to their own workspace must not be able+ // to smuggle a foreign project id into the batch.+ const response = await reorderRequest(member.workspace.id, [+ { id: second.id, position: 0 },+ { id: first.id, position: 1 },+ { id: foreign.id, position: 2 },+ ]);++ expect(response.status).toBe(400);++ // The rejected batch must not have applied partially: the two legitimate+ // ids come before the foreign one, so a per-row loop would already have+ // renumbered them by the time it failed.+ const projects = await listProjects(member.workspace.id);+ expect(projects.map((project) => project.id)).toEqual([+ first.id,+ second.id,+ ]);+ });++ it("rejects a fractional position", async () => {+ const member = await createWorkspaceMember({ role: "admin" });+ const { project } = await createProjectFixture({+ workspaceId: member.workspace.id,+ });++ mockAuthenticatedSession(member.user);++ const response = await reorderRequest(member.workspace.id, [+ { id: project.id, position: 1.5 },+ ]);++ expect(response.status).toBe(400);+ });++ it("rejects a member without project update permission", async () => {+ const viewer = await createWorkspaceMember({ role: "viewer" });+ const { project } = await createProjectFixture({+ workspaceId: viewer.workspace.id,+ });++ mockAuthenticatedSession(viewer.user);++ const response = await reorderRequest(viewer.workspace.id, [+ { id: project.id, position: 0 },+ ]);++ expect(response.status).toBe(403);+ });++ it("places a newly created project at the end of the order", async () => {+ const member = await createWorkspaceMember({ role: "admin" });+ await createProjectFixture({+ workspaceId: member.workspace.id,+ name: "Existing",+ });++ mockAuthenticatedSession(member.user);+ const { app } = createApp();++ const response = await app.request(+ `/api/project?workspaceId=${member.workspace.id}`,+ {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ name: "Newest",+ workspaceId: member.workspace.id,+ icon: "Folder",+ slug: "newest",+ }),+ },+ );++ expect(response.status).toBe(200);++ const projects = await listProjects(member.workspace.id);+ expect(projects.at(-1)?.name).toBe("Newest");+ });+});