⚡ 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(account): change avatar and delete account
Andrej384eb005c71f
diff --git a/apps/api/drizzle/0040_clear_eternals.sql b/apps/api/drizzle/0040_clear_eternals.sqlnew file mode 100644index 000000000..c6cc167a0--- /dev/null+++ b/apps/api/drizzle/0040_clear_eternals.sql@@ -0,0 +1,22 @@+CREATE TABLE "user_avatar" (+ "id" text PRIMARY KEY NOT NULL,+ "user_id" text NOT NULL,+ "mime_type" text NOT NULL,+ "size" integer NOT NULL,+ "data" "bytea" NOT NULL,+ "created_at" timestamp DEFAULT now() NOT NULL,+ "updated_at" timestamp DEFAULT now() NOT NULL,+ CONSTRAINT "user_avatar_user_id_unique" UNIQUE("user_id")+);+--> statement-breakpoint+ALTER TABLE "activity" DROP CONSTRAINT IF EXISTS "activity_user_id_user_id_fk";+--> statement-breakpoint+ALTER TABLE "task" DROP CONSTRAINT IF EXISTS "task_assignee_id_user_id_fk";+--> statement-breakpoint+ALTER TABLE "time_entry" DROP CONSTRAINT IF EXISTS "time_entry_user_id_user_id_fk";+--> statement-breakpoint+ALTER TABLE "user_avatar" ADD CONSTRAINT "user_avatar_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint+CREATE INDEX "user_avatar_userId_idx" ON "user_avatar" USING btree ("user_id");--> statement-breakpoint+ALTER TABLE "activity" ADD CONSTRAINT "activity_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint+ALTER TABLE "task" ADD CONSTRAINT "task_assignee_id_user_id_fk" FOREIGN KEY ("assignee_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint+ALTER TABLE "time_entry" ADD CONSTRAINT "time_entry_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE cascade;\ No newline at end of filediff --git a/apps/api/drizzle/0041_famous_cable.sql b/apps/api/drizzle/0041_famous_cable.sqlnew file mode 100644index 000000000..ada03b2bf--- /dev/null+++ b/apps/api/drizzle/0041_famous_cable.sql@@ -0,0 +1,5 @@+CREATE TABLE "trial_grant" (+ "email_hash" text PRIMARY KEY NOT NULL,+ "trial_ends_at" timestamp NOT NULL,+ "created_at" timestamp DEFAULT now() NOT NULL+);diff --git a/apps/api/drizzle/meta/0040_snapshot.json b/apps/api/drizzle/meta/0040_snapshot.jsonnew file mode 100644index 000000000..b5d95424b--- /dev/null+++ b/apps/api/drizzle/meta/0040_snapshot.json@@ -0,0 +1,4143 @@+{+ "id": "be3b55c3-33cd-4872-aa4d-b60bafead072",+ "prevId": "45193339-f83e-45d4-8b3c-b210cd25239a",+ "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": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "activity_task_external_source_external_url_unique": {+ "name": "activity_task_external_source_external_url_unique",+ "nullsNotDistinct": false,+ "columns": ["task_id", "external_source", "external_url"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.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.billing_reminder_sent": {+ "name": "billing_reminder_sent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reminder_type": {+ "name": "reminder_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "trial_ends_at": {+ "name": "trial_ends_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "billing_reminder_sent_workspaceId_idx": {+ "name": "billing_reminder_sent_workspaceId_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "billing_reminder_sent_userId_idx": {+ "name": "billing_reminder_sent_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "billing_reminder_sent_user_id_user_id_fk": {+ "name": "billing_reminder_sent_user_id_user_id_fk",+ "tableFrom": "billing_reminder_sent",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "billing_reminder_sent_workspace_id_workspace_id_fk": {+ "name": "billing_reminder_sent_workspace_id_workspace_id_fk",+ "tableFrom": "billing_reminder_sent",+ "tableTo": "workspace",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "billing_reminder_sent_user_type_unique": {+ "name": "billing_reminder_sent_user_type_unique",+ "nullsNotDistinct": false,+ "columns": ["user_id", "reminder_type"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.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": "set null",+ "onUpdate": "cascade"+ },+ "task_column_id_column_id_fk": {+ "name": "task_column_id_column_id_fk",+ "tableFrom": "task",+ "tableTo": "column",+ "columnsFrom": ["column_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "task_project_number_unique": {+ "name": "task_project_number_unique",+ "nullsNotDistinct": false,+ "columns": ["project_id", "number"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team": {+ "name": "team",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "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": "set null",+ "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_avatar": {+ "name": "user_avatar",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mime_type": {+ "name": "mime_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "bytea",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_avatar_userId_idx": {+ "name": "user_avatar_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_avatar_user_id_user_id_fk": {+ "name": "user_avatar_user_id_user_id_fk",+ "tableFrom": "user_avatar",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_avatar_user_id_unique": {+ "name": "user_avatar_user_id_unique",+ "nullsNotDistinct": false,+ "columns": ["user_id"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_notification_preference": {+ "name": "user_notification_preference",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_enabled": {+ "name": "email_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "ntfy_enabled": {+ "name": "ntfy_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "ntfy_server_url": {+ "name": "ntfy_server_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ntfy_topic": {+ "name": "ntfy_topic",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ntfy_token": {+ "name": "ntfy_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "gotify_enabled": {+ "name": "gotify_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "gotify_server_url": {+ "name": "gotify_server_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "gotify_token": {+ "name": "gotify_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "webhook_enabled": {+ "name": "webhook_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "webhook_url": {+ "name": "webhook_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "webhook_secret": {+ "name": "webhook_secret",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_assignment_enabled": {+ "name": "task_assignment_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "task_comment_enabled": {+ "name": "task_comment_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "task_status_change_enabled": {+ "name": "task_status_change_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "due_date_reminder_enabled": {+ "name": "due_date_reminder_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "due_date_reminder_lead_time_minutes": {+ "name": "due_date_reminder_lead_time_minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1440+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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/0041_snapshot.json b/apps/api/drizzle/meta/0041_snapshot.jsonnew file mode 100644index 000000000..9e577ad9f--- /dev/null+++ b/apps/api/drizzle/meta/0041_snapshot.json@@ -0,0 +1,4175 @@+{+ "id": "6ed5db76-6409-4440-81ab-7a38f6832db9",+ "prevId": "be3b55c3-33cd-4872-aa4d-b60bafead072",+ "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": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "activity_task_external_source_external_url_unique": {+ "name": "activity_task_external_source_external_url_unique",+ "nullsNotDistinct": false,+ "columns": ["task_id", "external_source", "external_url"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.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.billing_reminder_sent": {+ "name": "billing_reminder_sent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reminder_type": {+ "name": "reminder_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "trial_ends_at": {+ "name": "trial_ends_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "billing_reminder_sent_workspaceId_idx": {+ "name": "billing_reminder_sent_workspaceId_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "billing_reminder_sent_userId_idx": {+ "name": "billing_reminder_sent_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "billing_reminder_sent_user_id_user_id_fk": {+ "name": "billing_reminder_sent_user_id_user_id_fk",+ "tableFrom": "billing_reminder_sent",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "billing_reminder_sent_workspace_id_workspace_id_fk": {+ "name": "billing_reminder_sent_workspace_id_workspace_id_fk",+ "tableFrom": "billing_reminder_sent",+ "tableTo": "workspace",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "billing_reminder_sent_user_type_unique": {+ "name": "billing_reminder_sent_user_type_unique",+ "nullsNotDistinct": false,+ "columns": ["user_id", "reminder_type"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.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": "set null",+ "onUpdate": "cascade"+ },+ "task_column_id_column_id_fk": {+ "name": "task_column_id_column_id_fk",+ "tableFrom": "task",+ "tableTo": "column",+ "columnsFrom": ["column_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "task_project_number_unique": {+ "name": "task_project_number_unique",+ "nullsNotDistinct": false,+ "columns": ["project_id", "number"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team": {+ "name": "team",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "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": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.trial_grant": {+ "name": "trial_grant",+ "schema": "",+ "columns": {+ "email_hash": {+ "name": "email_hash",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "trial_ends_at": {+ "name": "trial_ends_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user": {+ "name": "user",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "locale": {+ "name": "locale",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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_avatar": {+ "name": "user_avatar",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mime_type": {+ "name": "mime_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "bytea",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_avatar_userId_idx": {+ "name": "user_avatar_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_avatar_user_id_user_id_fk": {+ "name": "user_avatar_user_id_user_id_fk",+ "tableFrom": "user_avatar",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_avatar_user_id_unique": {+ "name": "user_avatar_user_id_unique",+ "nullsNotDistinct": false,+ "columns": ["user_id"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_notification_preference": {+ "name": "user_notification_preference",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_enabled": {+ "name": "email_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "ntfy_enabled": {+ "name": "ntfy_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "ntfy_server_url": {+ "name": "ntfy_server_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ntfy_topic": {+ "name": "ntfy_topic",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ntfy_token": {+ "name": "ntfy_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "gotify_enabled": {+ "name": "gotify_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "gotify_server_url": {+ "name": "gotify_server_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "gotify_token": {+ "name": "gotify_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "webhook_enabled": {+ "name": "webhook_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "webhook_url": {+ "name": "webhook_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "webhook_secret": {+ "name": "webhook_secret",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_assignment_enabled": {+ "name": "task_assignment_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "task_comment_enabled": {+ "name": "task_comment_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "task_status_change_enabled": {+ "name": "task_status_change_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "due_date_reminder_enabled": {+ "name": "due_date_reminder_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "due_date_reminder_lead_time_minutes": {+ "name": "due_date_reminder_lead_time_minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1440+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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 9a2ca8b88..447ea6d7d 100644--- a/apps/api/drizzle/meta/_journal.json+++ b/apps/api/drizzle/meta/_journal.json@@ -281,6 +281,20 @@"when": 1786478671279,"tag": "0039_gorgeous_jack_power","breakpoints": true+ },+ {+ "idx": 40,+ "version": "7",+ "when": 1786555508802,+ "tag": "0040_clear_eternals",+ "breakpoints": true+ },+ {+ "idx": 41,+ "version": "7",+ "when": 1786557281986,+ "tag": "0041_famous_cable",+ "breakpoints": true}]}diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.tsindex 8fd581e40..569b9fd9b 100644--- a/apps/api/src/auth.ts+++ b/apps/api/src/auth.ts@@ -34,9 +34,14 @@ import type { AccessControl } from "better-auth/plugins/access";import type { UserWithAnonymous } from "better-auth/plugins/anonymous";import { config } from "dotenv-mono";import { count, eq, sql } from "drizzle-orm";+import {+ findBillableWorkspaces,+ formatBillableWorkspacesMessage,+} from "./billing/controllers/find-billable-workspaces";import { syncWorkspaceSeats } from "./billing/controllers/sync-seats";import db, { schema } from "./database";import { publishEvent } from "./events";+import deleteAccountData from "./user/controllers/delete-account-data";import { checkRegistrationAllowed } from "./utils/check-registration-allowed";import { checkWorkspaceName } from "./utils/check-workspace-name";import { mapCustomOAuthProfileToUser } from "./utils/custom-oauth-profile";@@ -222,6 +227,12 @@ export const auth = betterAuth({required: false,},},+ deleteUser: {+ enabled: true,+ beforeDelete: async (user) => {+ await deleteAccountData(user.id);+ },+ },},account: {accountLinking: {@@ -423,6 +434,16 @@ export const auth = betterAuth({ownerId: user.id,});},+ beforeDeleteOrganization: async ({ organization }) => {+ const billable = await findBillableWorkspaces([organization.id]);+ if (billable.length > 0) {+ throw new APIError("CONFLICT", {+ message: formatBillableWorkspacesMessage(+ billable.map((workspace) => workspace.name),+ ),+ });+ }+ },afterAddMember: async ({ member }) => {if (member?.organizationId) {void syncWorkspaceSeats(member.organizationId).catch((error) => {diff --git a/apps/api/src/billing/controllers/find-billable-workspaces.ts b/apps/api/src/billing/controllers/find-billable-workspaces.tsnew file mode 100644index 000000000..eddee1efd--- /dev/null+++ b/apps/api/src/billing/controllers/find-billable-workspaces.ts@@ -0,0 +1,41 @@+import { eq, inArray } from "drizzle-orm";+import db from "../../database";+import { workspaceBillingTable, workspaceTable } from "../../database/schema";+import { isBillingEnabled } from "../config";+import { hasBillableSubscription } from "../subscription-state";++export async function findBillableWorkspaces(workspaceIds: string[]) {+ if (!isBillingEnabled() || workspaceIds.length === 0) {+ return [];+ }++ const rows = await db+ .select({+ workspaceId: workspaceBillingTable.workspaceId,+ name: workspaceTable.name,+ creemSubscriptionId: workspaceBillingTable.creemSubscriptionId,+ status: workspaceBillingTable.status,+ })+ .from(workspaceBillingTable)+ .innerJoin(+ workspaceTable,+ eq(workspaceTable.id, workspaceBillingTable.workspaceId),+ )+ .where(inArray(workspaceBillingTable.workspaceId, workspaceIds));++ return rows+ .filter(hasBillableSubscription)+ .map((row) => ({ workspaceId: row.workspaceId, name: row.name }));+}++export function formatBillableWorkspacesMessage(names: string[]) {+ const quoted = names.map((name) => `"${name}"`);+ const list =+ quoted.length === 1+ ? quoted[0]+ : `${quoted.slice(0, -1).join(", ")} and ${quoted[quoted.length - 1]}`;++ return `${list} still ${names.length === 1 ? "has" : "have"} an active subscription. Cancel it in billing settings before deleting.`;+}++export default findBillableWorkspaces;diff --git a/apps/api/src/billing/controllers/get-workspace-billing.ts b/apps/api/src/billing/controllers/get-workspace-billing.tsindex d03b8a6c1..63cba1ace 100644--- a/apps/api/src/billing/controllers/get-workspace-billing.ts+++ b/apps/api/src/billing/controllers/get-workspace-billing.ts@@ -2,11 +2,14 @@ import { and, eq, isNotNull, min } from "drizzle-orm";import { HTTPException } from "hono/http-exception";import db from "../../database";import {+ trialGrantTable,+ userTable,workspaceBillingTable,workspaceTable,workspaceUserTable,} from "../../database/schema";import { foundingCutoff, isBillingEnabled, trialDays } from "../config";+import { hashTrialEmail } from "../trial-identity";const ACTIVE_STATUSES = new Set(["active",@@ -19,8 +22,12 @@ export async function resolveTrialEndsAt(workspaceId: string,): Promise<Date | null> {const [owner] = await db- .select({ userId: workspaceUserTable.userId })+ .select({+ userId: workspaceUserTable.userId,+ email: userTable.email,+ }).from(workspaceUserTable)+ .innerJoin(userTable, eq(userTable.id, workspaceUserTable.userId)).where(and(eq(workspaceUserTable.workspaceId, workspaceId),@@ -48,11 +55,36 @@ export async function resolveTrialEndsAt(if (earlier?.trialEndsAt) {return new Date(earlier.trialEndsAt);}++ return claimTrial(owner.email);}return new Date(Date.now() + trialDays() * 24 * 60 * 60 * 1000);}+async function claimTrial(email: string): Promise<Date> {+ const emailHash = hashTrialEmail(email);+ const trialEndsAt = new Date(Date.now() + trialDays() * 24 * 60 * 60 * 1000);++ const [claimed] = await db+ .insert(trialGrantTable)+ .values({ emailHash, trialEndsAt })+ .onConflictDoNothing({ target: trialGrantTable.emailHash })+ .returning({ trialEndsAt: trialGrantTable.trialEndsAt });++ if (claimed) {+ return claimed.trialEndsAt;+ }++ const [granted] = await db+ .select({ trialEndsAt: trialGrantTable.trialEndsAt })+ .from(trialGrantTable)+ .where(eq(trialGrantTable.emailHash, emailHash))+ .limit(1);++ return granted?.trialEndsAt ?? trialEndsAt;+}+export async function getOrCreateWorkspaceBilling(workspaceId: string) {const [existing] = await db.select()diff --git a/apps/api/src/billing/subscription-state.ts b/apps/api/src/billing/subscription-state.tsnew file mode 100644index 000000000..4520213bb--- /dev/null+++ b/apps/api/src/billing/subscription-state.ts@@ -0,0 +1,16 @@+const BILLABLE_STATUSES = new Set(["active", "trialing", "past_due"]);++export type SubscriptionState = {+ creemSubscriptionId: string | null;+ status: string | null;+};++export function hasBillableSubscription(+ billing: SubscriptionState | null | undefined,+) {+ if (!billing?.creemSubscriptionId) {+ return false;+ }++ return BILLABLE_STATUSES.has(billing.status ?? "");+}diff --git a/apps/api/src/billing/trial-identity.ts b/apps/api/src/billing/trial-identity.tsnew file mode 100644index 000000000..576347843--- /dev/null+++ b/apps/api/src/billing/trial-identity.ts@@ -0,0 +1,21 @@+import { createHash } from "node:crypto";++const PLUS_TAG_PATTERN = /\+[^@]*/;++export function normalizeTrialEmail(email: string) {+ const trimmed = email.trim().toLowerCase();+ const atIndex = trimmed.lastIndexOf("@");++ if (atIndex <= 0) {+ return trimmed;+ }++ const local = trimmed.slice(0, atIndex).replace(PLUS_TAG_PATTERN, "");+ const domain = trimmed.slice(atIndex + 1);++ return local ? `${local}@${domain}` : trimmed;+}++export function hashTrialEmail(email: string) {+ return createHash("sha256").update(normalizeTrialEmail(email)).digest("hex");+}diff --git a/apps/api/src/database/index.ts b/apps/api/src/database/index.tsindex 296d03f40..c6d8edeb8 100644--- a/apps/api/src/database/index.ts+++ b/apps/api/src/database/index.ts@@ -55,6 +55,8 @@ import {teamMemberTable,teamTable,timeEntryTable,+ trialGrantTable,+ userAvatarTable,userNotificationPreferenceTable,userNotificationWorkspaceProjectTable,userNotificationWorkspaceRuleTable,@@ -93,7 +95,9 @@ export const schema = {teamMemberTable,teamTable,timeEntryTable,+ trialGrantTable,userTable,+ userAvatarTable,userNotificationPreferenceTable,userNotificationWorkspaceProjectTable,userNotificationWorkspaceRuleTable,diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.tsindex 8c9f79ac2..fcad5abe5 100644--- a/apps/api/src/database/schema.ts+++ b/apps/api/src/database/schema.ts@@ -2,6 +2,7 @@ import { createId } from "@paralleldrive/cuid2";import { relations, sql } from "drizzle-orm";import {boolean,+ customType,foreignKey,index,integer,@@ -13,6 +14,12 @@ import {uniqueIndex,} from "drizzle-orm/pg-core";+const bytea = customType<{ data: Buffer; driverData: Buffer }>({+ dataType() {+ return "bytea";+ },+});+export const userTable = pgTable("user", {id: text("id").$defaultFn(() => createId())@@ -88,6 +95,31 @@ export const accountTable = pgTable((table) => [index("account_userId_idx").on(table.userId)],);+export const userAvatarTable = pgTable(+ "user_avatar",+ {+ id: text("id")+ .$defaultFn(() => createId())+ .primaryKey(),+ userId: text("user_id")+ .notNull()+ .unique("user_avatar_user_id_unique")+ .references(() => userTable.id, {+ onDelete: "cascade",+ onUpdate: "cascade",+ }),+ mimeType: text("mime_type").notNull(),+ size: integer("size").notNull(),+ data: bytea("data").notNull(),+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),+ updatedAt: timestamp("updated_at", { mode: "date" })+ .defaultNow()+ .$onUpdate(() => new Date())+ .notNull(),+ },+ (table) => [index("user_avatar_userId_idx").on(table.userId)],+);+export const verificationTable = pgTable("verification",{@@ -176,6 +208,12 @@ export const workspaceBillingTable = pgTable((table) => [index("workspace_billing_workspaceId_idx").on(table.workspaceId)],);+export const trialGrantTable = pgTable("trial_grant", {+ emailHash: text("email_hash").primaryKey(),+ trialEndsAt: timestamp("trial_ends_at", { mode: "date" }).notNull(),+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),+});+export const billingEventTable = pgTable("billing_event", {id: text("id").primaryKey(),eventType: text("event_type").notNull(),@@ -375,7 +413,7 @@ export const taskTable = pgTable(position: integer("position").default(0),number: integer("number").default(1),userId: text("assignee_id").references(() => userTable.id, {- onDelete: "cascade",+ onDelete: "set null",onUpdate: "cascade",}),title: text("title").notNull(),@@ -480,7 +518,7 @@ export const timeEntryTable = pgTable(onUpdate: "cascade",}),userId: text("user_id").references(() => userTable.id, {- onDelete: "cascade",+ onDelete: "set null",onUpdate: "cascade",}),description: text("description"),@@ -518,7 +556,7 @@ export const activityTable = pgTable(.$onUpdate(() => new Date()).notNull(),userId: text("user_id").references(() => userTable.id, {- onDelete: "cascade",+ onDelete: "set null",onUpdate: "cascade",}),content: text("content"),diff --git a/apps/api/src/index.ts b/apps/api/src/index.tsindex 308df6a85..0a2909596 100644--- a/apps/api/src/index.ts+++ b/apps/api/src/index.ts@@ -55,6 +55,8 @@ import task from "./task";import taskRelation from "./task-relation";import telegramIntegration from "./telegram-integration";import timeEntry from "./time-entry";+import user from "./user";+import getAvatar from "./user/controllers/get-avatar";import { authenticateApiRequest } from "./utils/authenticate-api-request";import { authorizeAssetAccess } from "./utils/authorize-asset-access";import { getInvitationDetails } from "./utils/check-registration-allowed";@@ -275,8 +277,7 @@ export function createApp() {},}),async (c) => {- const session = await auth.api.getSession({ headers: c.req.raw.headers });- return c.json(session ?? null);+ return auth.handler(c.req.raw);},);@@ -356,6 +357,52 @@ export function createApp() {},);+ api.get(+ "/user/avatar/:id",+ describeRoute({+ operationId: "getUserAvatar",+ tags: ["User"],+ description: "Download a user avatar by its avatar ID",+ security: [],+ responses: {+ 200: {+ description: "The avatar image",+ content: {+ "image/*": { schema: { type: "string", format: "binary" } },+ },+ },+ 404: {+ description: "Avatar not found",+ },+ },+ }),+ validator("param", v.object({ id: v.string() })),+ async (c) => {+ const { id } = c.req.valid("param");+ const avatar = await getAvatar(id);++ if (!avatar) {+ throw new HTTPException(404, { message: "Avatar not found" });+ }++ const etag = `"${avatar.id}"`;+ if (c.req.header("If-None-Match") === etag) {+ return new Response(null, { status: 304, headers: { ETag: etag } });+ }++ return new Response(new Uint8Array(avatar.data) as BodyInit, {+ headers: {+ "Cache-Control": "public, max-age=31536000, immutable",+ "Content-Length": avatar.size.toString(),+ "Content-Type": avatar.mimeType,+ "X-Content-Type-Options": "nosniff",+ ETag: etag,+ "Last-Modified": avatar.updatedAt.toUTCString(),+ },+ });+ },+ );+const configApi = api.route("/config", config);const honoOpenApiHandler = openAPIRouteHandler(api, {@@ -589,6 +636,7 @@ export function createApp() {const workflowRuleApi = api.route("/workflow-rule", workflowRule);const invitationApi = api.route("/invitation", invitation);const workspaceApi = api.route("/workspace", workspace);+ const userApi = api.route("/user", user);app.route("/",@@ -751,6 +799,7 @@ export function createApp() {taskRelationApi,telegramIntegrationApi,timeEntryApi,+ userApi,workflowRuleApi,workspaceApi,oauthApi,@@ -868,6 +917,7 @@ const {taskRelationApi,telegramIntegrationApi,timeEntryApi,+ userApi,workflowRuleApi,workspaceApi,oauthApi,@@ -907,6 +957,7 @@ export type AppType =| typeof workflowRuleApi| typeof invitationApi| typeof workspaceApi+ | typeof userApi| typeof publicProjectApi| typeof invitationPublicApi| typeof oauthApi;diff --git a/apps/api/src/user/account-deletion.ts b/apps/api/src/user/account-deletion.tsnew file mode 100644index 000000000..036d64ff3--- /dev/null+++ b/apps/api/src/user/account-deletion.ts@@ -0,0 +1,56 @@+export type WorkspaceMembershipSummary = {+ workspaceId: string;+ workspaceName: string;+ isOwner: boolean;+ memberCount: number;+ ownerCount: number;+};++export type AccountDeletionPlan = {+ blockedWorkspaceNames: string[];+ workspaceIdsToDelete: string[];+ workspaceIdsToLeave: string[];+};++export function hasOwnerRole(role: string) {+ return role+ .split(",")+ .map((entry) => entry.trim().toLowerCase())+ .includes("owner");+}++export function planAccountDeletion(+ memberships: WorkspaceMembershipSummary[],+): AccountDeletionPlan {+ const plan: AccountDeletionPlan = {+ blockedWorkspaceNames: [],+ workspaceIdsToDelete: [],+ workspaceIdsToLeave: [],+ };++ for (const membership of memberships) {+ if (membership.memberCount <= 1) {+ plan.workspaceIdsToDelete.push(membership.workspaceId);+ continue;+ }++ if (membership.isOwner && membership.ownerCount <= 1) {+ plan.blockedWorkspaceNames.push(membership.workspaceName);+ continue;+ }++ plan.workspaceIdsToLeave.push(membership.workspaceId);+ }++ return plan;+}++export function formatBlockedWorkspacesMessage(names: string[]) {+ const quoted = names.map((name) => `"${name}"`);+ const list =+ quoted.length === 1+ ? quoted[0]+ : `${quoted.slice(0, -1).join(", ")} and ${quoted[quoted.length - 1]}`;++ return `You are the only owner of ${list}. Transfer ownership or delete ${names.length === 1 ? "it" : "them"} before deleting your account.`;+}diff --git a/apps/api/src/user/avatar.ts b/apps/api/src/user/avatar.tsnew file mode 100644index 000000000..7a2eed713--- /dev/null+++ b/apps/api/src/user/avatar.ts@@ -0,0 +1,87 @@+export const MAX_AVATAR_BYTES = 512 * 1024;++const AVATAR_MIME_TYPES = ["image/png", "image/jpeg", "image/webp"] as const;++export type AvatarMimeType = (typeof AVATAR_MIME_TYPES)[number];++const BASE64_PATTERN = /^[A-Za-z0-9+/]+={0,2}$/;++export function isAvatarMimeType(value: string): value is AvatarMimeType {+ return (AVATAR_MIME_TYPES as readonly string[]).includes(value);+}++export function normalizeAvatarMimeType(value: string) {+ const normalized = value.trim().toLowerCase();+ return normalized === "image/jpg" ? "image/jpeg" : normalized;+}++function hasMagicBytes(mimeType: AvatarMimeType, bytes: Buffer) {+ switch (mimeType) {+ case "image/png":+ return (+ bytes.length >= 8 &&+ bytes.subarray(0, 8).equals(+ // biome-ignore format: PNG signature+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),+ )+ );+ case "image/jpeg":+ return (+ bytes.length >= 3 &&+ bytes[0] === 0xff &&+ bytes[1] === 0xd8 &&+ bytes[2] === 0xff+ );+ case "image/webp":+ return (+ bytes.length >= 12 &&+ bytes.subarray(0, 4).toString("ascii") === "RIFF" &&+ bytes.subarray(8, 12).toString("ascii") === "WEBP"+ );+ }+}++export function stripDataUrlPrefix(value: string) {+ return value.replace(/^data:[^;,]*;base64,/, "");+}++export function decodeAvatarUpload(input: {+ contentType: string;+ data: string;+}): { mimeType: AvatarMimeType; bytes: Buffer } {+ const mimeType = normalizeAvatarMimeType(input.contentType);++ if (!isAvatarMimeType(mimeType)) {+ throw new Error(+ "Unsupported image type. Upload a PNG, JPEG, or WebP image.",+ );+ }++ const payload = stripDataUrlPrefix(input.data).replace(/\s+/g, "");++ if (!payload || !BASE64_PATTERN.test(payload) || payload.length % 4 !== 0) {+ throw new Error("Image data must be base64 encoded.");+ }++ const bytes = Buffer.from(payload, "base64");++ if (bytes.length === 0) {+ throw new Error("Image data must not be empty.");+ }++ if (bytes.length > MAX_AVATAR_BYTES) {+ throw new Error(+ `Image exceeds the maximum avatar size of ${Math.floor(MAX_AVATAR_BYTES / 1024)}KB.`,+ );+ }++ if (!hasMagicBytes(mimeType, bytes)) {+ throw new Error(`Image data does not match the declared ${mimeType} type.`);+ }++ return { mimeType, bytes };+}++export function buildAvatarUrl(avatarId: string) {+ return `/api/user/avatar/${avatarId}`;+}diff --git a/apps/api/src/user/controllers/delete-account-data.ts b/apps/api/src/user/controllers/delete-account-data.tsnew file mode 100644index 000000000..e0892c939--- /dev/null+++ b/apps/api/src/user/controllers/delete-account-data.ts@@ -0,0 +1,111 @@+import { APIError } from "better-auth/api";+import { and, eq, inArray } from "drizzle-orm";+import {+ findBillableWorkspaces,+ formatBillableWorkspacesMessage,+} from "../../billing/controllers/find-billable-workspaces";+import { syncWorkspaceSeats } from "../../billing/controllers/sync-seats";+import db from "../../database";+import { workspaceTable, workspaceUserTable } from "../../database/schema";+import {+ formatBlockedWorkspacesMessage,+ hasOwnerRole,+ planAccountDeletion,+ type WorkspaceMembershipSummary,+} from "../account-deletion";++async function collectMemberships(+ userId: string,+): Promise<WorkspaceMembershipSummary[]> {+ const memberships = await db+ .select({+ workspaceId: workspaceUserTable.workspaceId,+ role: workspaceUserTable.role,+ })+ .from(workspaceUserTable)+ .where(eq(workspaceUserTable.userId, userId));++ if (memberships.length === 0) {+ return [];+ }++ const workspaceIds = memberships.map((membership) => membership.workspaceId);++ const members = await db+ .select({+ workspaceId: workspaceUserTable.workspaceId,+ workspaceName: workspaceTable.name,+ role: workspaceUserTable.role,+ })+ .from(workspaceUserTable)+ .innerJoin(+ workspaceTable,+ eq(workspaceUserTable.workspaceId, workspaceTable.id),+ )+ .where(inArray(workspaceUserTable.workspaceId, workspaceIds));++ return memberships.map((membership) => {+ const workspaceMembers = members.filter(+ (member) => member.workspaceId === membership.workspaceId,+ );++ return {+ workspaceId: membership.workspaceId,+ workspaceName: workspaceMembers[0]?.workspaceName ?? "workspace",+ isOwner: hasOwnerRole(membership.role),+ memberCount: workspaceMembers.length,+ ownerCount: workspaceMembers.filter((member) => hasOwnerRole(member.role))+ .length,+ };+ });+}++export async function deleteAccountData(userId: string) {+ const plan = planAccountDeletion(await collectMemberships(userId));++ if (plan.blockedWorkspaceNames.length > 0) {+ throw new APIError("CONFLICT", {+ message: formatBlockedWorkspacesMessage(plan.blockedWorkspaceNames),+ });+ }++ const billable = await findBillableWorkspaces(plan.workspaceIdsToDelete);+ if (billable.length > 0) {+ throw new APIError("CONFLICT", {+ message: formatBillableWorkspacesMessage(+ billable.map((workspace) => workspace.name),+ ),+ });+ }++ if (plan.workspaceIdsToDelete.length > 0) {+ await db+ .delete(workspaceTable)+ .where(inArray(workspaceTable.id, plan.workspaceIdsToDelete));+ }++ if (plan.workspaceIdsToLeave.length > 0) {+ await db+ .delete(workspaceUserTable)+ .where(+ and(+ eq(workspaceUserTable.userId, userId),+ inArray(workspaceUserTable.workspaceId, plan.workspaceIdsToLeave),+ ),+ );++ for (const workspaceId of plan.workspaceIdsToLeave) {+ await syncWorkspaceSeats(workspaceId).catch((error) => {+ console.error(+ "Seat sync after account deletion failed:",+ workspaceId,+ error,+ );+ });+ }+ }++ return plan;+}++export default deleteAccountData;diff --git a/apps/api/src/user/controllers/delete-avatar.ts b/apps/api/src/user/controllers/delete-avatar.tsnew file mode 100644index 000000000..a6b9c5976--- /dev/null+++ b/apps/api/src/user/controllers/delete-avatar.ts@@ -0,0 +1,14 @@+import { eq } from "drizzle-orm";+import db from "../../database";+import { userAvatarTable } from "../../database/schema";++export async function deleteAvatar(userId: string) {+ const deleted = await db+ .delete(userAvatarTable)+ .where(eq(userAvatarTable.userId, userId))+ .returning({ id: userAvatarTable.id });++ return { deleted: deleted.length > 0 };+}++export default deleteAvatar;diff --git a/apps/api/src/user/controllers/get-avatar.ts b/apps/api/src/user/controllers/get-avatar.tsnew file mode 100644index 000000000..acf834ea3--- /dev/null+++ b/apps/api/src/user/controllers/get-avatar.ts@@ -0,0 +1,21 @@+import { eq } from "drizzle-orm";+import db from "../../database";+import { userAvatarTable } from "../../database/schema";++export async function getAvatar(id: string) {+ const [avatar] = await db+ .select({+ id: userAvatarTable.id,+ mimeType: userAvatarTable.mimeType,+ size: userAvatarTable.size,+ data: userAvatarTable.data,+ updatedAt: userAvatarTable.updatedAt,+ })+ .from(userAvatarTable)+ .where(eq(userAvatarTable.id, id))+ .limit(1);++ return avatar ?? null;+}++export default getAvatar;diff --git a/apps/api/src/user/controllers/save-avatar.ts b/apps/api/src/user/controllers/save-avatar.tsnew file mode 100644index 000000000..a517bc01b--- /dev/null+++ b/apps/api/src/user/controllers/save-avatar.ts@@ -0,0 +1,44 @@+import { createId } from "@paralleldrive/cuid2";+import db from "../../database";+import { userAvatarTable } from "../../database/schema";+import { buildAvatarUrl, decodeAvatarUpload } from "../avatar";++export async function saveAvatar({+ userId,+ contentType,+ data,+}: {+ userId: string;+ contentType: string;+ data: string;+}) {+ const { mimeType, bytes } = decodeAvatarUpload({ contentType, data });++ const [saved] = await db+ .insert(userAvatarTable)+ .values({+ userId,+ mimeType,+ size: bytes.length,+ data: bytes,+ })+ .onConflictDoUpdate({+ target: userAvatarTable.userId,+ set: {+ id: createId(),+ mimeType,+ size: bytes.length,+ data: bytes,+ updatedAt: new Date(),+ },+ })+ .returning({ id: userAvatarTable.id });++ if (!saved) {+ throw new Error("Failed to store avatar");+ }++ return { id: saved.id, url: buildAvatarUrl(saved.id), size: bytes.length };+}++export default saveAvatar;diff --git a/apps/api/src/user/index.ts b/apps/api/src/user/index.tsnew file mode 100644index 000000000..ced5298cd--- /dev/null+++ b/apps/api/src/user/index.ts@@ -0,0 +1,99 @@+import { Hono } from "hono";+import { HTTPException } from "hono/http-exception";+import { describeRoute, resolver, validator } from "hono-openapi";+import * as v from "valibot";+import { MAX_AVATAR_BYTES } from "./avatar";+import deleteAvatar from "./controllers/delete-avatar";+import saveAvatar from "./controllers/save-avatar";++const httpErrorSchema = v.object({ message: v.string() });++const avatarResponseSchema = v.object({+ id: v.string(),+ url: v.string(),+ size: v.number(),+});++const user = new Hono<{+ Variables: {+ userId: string;+ userEmail: string;+ };+}>()+ .put(+ "/avatar",+ describeRoute({+ operationId: "uploadUserAvatar",+ tags: ["User"],+ description: `Store a base64 encoded avatar (PNG, JPEG, or WebP, up to ${Math.floor(MAX_AVATAR_BYTES / 1024)}KB) for the current user and return its public URL`,+ responses: {+ 200: {+ description: "Avatar stored",+ content: {+ "application/json": { schema: resolver(avatarResponseSchema) },+ },+ },+ 400: {+ description: "Validation error",+ content: {+ "application/json": { schema: resolver(httpErrorSchema) },+ },+ },+ 401: {+ description: "Unauthorized",+ content: {+ "application/json": { schema: resolver(httpErrorSchema) },+ },+ },+ },+ }),+ validator(+ "json",+ v.object({+ contentType: v.string(),+ data: v.string(),+ }),+ ),+ async (c) => {+ const userId = c.get("userId");+ const { contentType, data } = c.req.valid("json");++ try {+ return c.json(await saveAvatar({ userId, contentType, data }));+ } catch (error) {+ throw new HTTPException(400, {+ message:+ error instanceof Error ? error.message : "Invalid avatar upload",+ });+ }+ },+ )+ .delete(+ "/avatar",+ describeRoute({+ operationId: "deleteUserAvatar",+ tags: ["User"],+ description: "Remove the uploaded avatar of the current user",+ responses: {+ 200: {+ description: "Avatar removed",+ content: {+ "application/json": {+ schema: resolver(v.object({ deleted: v.boolean() })),+ },+ },+ },+ 401: {+ description: "Unauthorized",+ content: {+ "application/json": { schema: resolver(httpErrorSchema) },+ },+ },+ },+ }),+ async (c) => {+ return c.json(await deleteAvatar(c.get("userId")));+ },+ );++export default user;diff --git a/apps/web/src/components/providers/auth-provider/index.tsx b/apps/web/src/components/providers/auth-provider/index.tsxindex 70389f70f..b03f75fa7 100644--- a/apps/web/src/components/providers/auth-provider/index.tsx+++ b/apps/web/src/components/providers/auth-provider/index.tsx@@ -8,13 +8,15 @@ const { useSession } = authClient;export const AuthContext = createContext<{user: User | null | undefined;isLoading: boolean;+ refetchUser: () => Promise<void>;}>({user: undefined,isLoading: true,+ refetchUser: async () => {},});function AuthProvider({ children }: PropsWithChildren) {- const { data, isPending } = useSession();+ const { data, isPending, refetch } = useSession();// Only show the loading skeleton during the *first* session fetch. Better// Auth re-fetches the session on window focus; if we kept returning the// skeleton while those background fetches are pending we'd unmount the@@ -34,6 +36,9 @@ function AuthProvider({ children }: PropsWithChildren) {value={{user: (data?.user as User | null | undefined) ?? null,isLoading: isPending,+ refetchUser: async () => {+ await refetch({ query: { disableCookieCache: true } });+ },}}>{children}diff --git a/apps/web/src/components/ui/avatar.tsx b/apps/web/src/components/ui/avatar.tsxindex 8d4ad2795..57500100b 100644--- a/apps/web/src/components/ui/avatar.tsx+++ b/apps/web/src/components/ui/avatar.tsx@@ -3,6 +3,7 @@import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";import { cn } from "@/lib/cn";+import { resolveAvatarSrc } from "@/lib/resolve-avatar-src";function Avatar({ className, ...props }: AvatarPrimitive.Root.Props) {return (@@ -17,11 +18,16 @@ function Avatar({ className, ...props }: AvatarPrimitive.Root.Props) {);}-function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {+function AvatarImage({+ className,+ src,+ ...props+}: AvatarPrimitive.Image.Props) {return (<AvatarPrimitive.ImageclassName={cn("size-full object-cover", className)}data-slot="avatar-image"+ src={typeof src === "string" ? resolveAvatarSrc(src) : src}{...props}/>);diff --git a/apps/web/src/fetchers/user/delete-avatar.ts b/apps/web/src/fetchers/user/delete-avatar.tsnew file mode 100644index 000000000..04e849832--- /dev/null+++ b/apps/web/src/fetchers/user/delete-avatar.ts@@ -0,0 +1,13 @@+import { client } from "@kaneo/libs";++async function deleteAvatar() {+ const response = await client.user.avatar.$delete();++ if (!response.ok) {+ throw new Error(await response.text());+ }++ return response.json();+}++export default deleteAvatar;diff --git a/apps/web/src/fetchers/user/upload-avatar.ts b/apps/web/src/fetchers/user/upload-avatar.tsnew file mode 100644index 000000000..46f925b15--- /dev/null+++ b/apps/web/src/fetchers/user/upload-avatar.ts@@ -0,0 +1,21 @@+import { client } from "@kaneo/libs";++async function uploadAvatar({+ contentType,+ data,+}: {+ contentType: string;+ data: string;+}) {+ const response = await client.user.avatar.$put({+ json: { contentType, data },+ });++ if (!response.ok) {+ throw new Error(await response.text());+ }++ return response.json();+}++export default uploadAvatar;diff --git a/apps/web/src/hooks/mutations/invalidate-user-profile-queries.ts b/apps/web/src/hooks/mutations/invalidate-user-profile-queries.tsnew file mode 100644index 000000000..bdf4e72a2--- /dev/null+++ b/apps/web/src/hooks/mutations/invalidate-user-profile-queries.ts@@ -0,0 +1,20 @@+import type { QueryClient } from "@tanstack/react-query";++const USER_PROFILE_QUERY_KEYS = [+ ["active-workspace-users"],+ ["workspace-users"],+ ["workspace", "full"],+ ["activities"],+ ["tasks"],+ ["task"],+] as const;++export async function invalidateUserProfileQueries(queryClient: QueryClient) {+ await Promise.all(+ USER_PROFILE_QUERY_KEYS.map((queryKey) =>+ queryClient.invalidateQueries({ queryKey }),+ ),+ );+}++export default invalidateUserProfileQueries;diff --git a/apps/web/src/hooks/mutations/use-delete-account.ts b/apps/web/src/hooks/mutations/use-delete-account.tsnew file mode 100644index 000000000..558ad0102--- /dev/null+++ b/apps/web/src/hooks/mutations/use-delete-account.ts@@ -0,0 +1,24 @@+import { useMutation } from "@tanstack/react-query";+import { authClient } from "@/lib/auth-client";++export const SESSION_TOO_OLD = "SESSION_TOO_OLD";++function useDeleteAccount() {+ return useMutation({+ mutationFn: async () => {+ const { data, error } = await authClient.deleteUser();++ if (error) {+ if (error.code === "SESSION_EXPIRED") {+ throw new Error(SESSION_TOO_OLD);+ }++ throw new Error(error.message || "Failed to delete account");+ }++ return data;+ },+ });+}++export default useDeleteAccount;diff --git a/apps/web/src/hooks/mutations/use-remove-user-avatar.ts b/apps/web/src/hooks/mutations/use-remove-user-avatar.tsnew file mode 100644index 000000000..96e32478d--- /dev/null+++ b/apps/web/src/hooks/mutations/use-remove-user-avatar.ts@@ -0,0 +1,23 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";+import deleteAvatar from "@/fetchers/user/delete-avatar";+import { authClient } from "@/lib/auth-client";+import invalidateUserProfileQueries from "./invalidate-user-profile-queries";++function useRemoveUserAvatar() {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: async () => {+ const { error } = await authClient.updateUser({ image: null });++ if (error) {+ throw new Error(error.message || "Failed to remove profile picture");+ }++ return deleteAvatar();+ },+ onSuccess: () => invalidateUserProfileQueries(queryClient),+ });+}++export default useRemoveUserAvatar;diff --git a/apps/web/src/hooks/mutations/use-update-user-avatar.ts b/apps/web/src/hooks/mutations/use-update-user-avatar.tsnew file mode 100644index 000000000..42eb16285--- /dev/null+++ b/apps/web/src/hooks/mutations/use-update-user-avatar.ts@@ -0,0 +1,27 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";+import uploadAvatar from "@/fetchers/user/upload-avatar";+import { authClient } from "@/lib/auth-client";+import { prepareAvatarImage } from "@/lib/prepare-avatar-image";+import invalidateUserProfileQueries from "./invalidate-user-profile-queries";++function useUpdateUserAvatar() {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: async (file: File) => {+ const { contentType, data } = await prepareAvatarImage(file);+ const avatar = await uploadAvatar({ contentType, data });++ const { error } = await authClient.updateUser({ image: avatar.url });++ if (error) {+ throw new Error(error.message || "Failed to update profile picture");+ }++ return avatar;+ },+ onSuccess: () => invalidateUserProfileQueries(queryClient),+ });+}++export default useUpdateUserAvatar;diff --git a/apps/web/src/hooks/mutations/use-update-user-profile.ts b/apps/web/src/hooks/mutations/use-update-user-profile.tsindex 35efb1de4..1d6b2e1a8 100644--- a/apps/web/src/hooks/mutations/use-update-user-profile.ts+++ b/apps/web/src/hooks/mutations/use-update-user-profile.ts@@ -1,5 +1,6 @@-import { useMutation } from "@tanstack/react-query";+import { useMutation, useQueryClient } from "@tanstack/react-query";import { authClient } from "@/lib/auth-client";+import invalidateUserProfileQueries from "./invalidate-user-profile-queries";type UpdateUserProfileRequest = {name?: string;@@ -7,6 +8,8 @@ type UpdateUserProfileRequest = {};function useUpdateUserProfile() {+ const queryClient = useQueryClient();+return useMutation({mutationFn: async ({ name, locale }: UpdateUserProfileRequest) => {const { data, error } = await authClient.updateUser({@@ -20,6 +23,7 @@ function useUpdateUserProfile() {return data;},+ onSuccess: () => invalidateUserProfileQueries(queryClient),});}diff --git a/apps/web/src/lib/prepare-avatar-image.test.ts b/apps/web/src/lib/prepare-avatar-image.test.tsnew file mode 100644index 000000000..7b9883d63--- /dev/null+++ b/apps/web/src/lib/prepare-avatar-image.test.ts@@ -0,0 +1,36 @@+import { describe, expect, it } from "vitest";+import { getCoverCropRect } from "./prepare-avatar-image";++describe("getCoverCropRect", () => {+ it("keeps a square image whole", () => {+ expect(getCoverCropRect(400, 400)).toEqual({+ sourceX: 0,+ sourceY: 0,+ side: 400,+ });+ });++ it("crops a landscape image around its center", () => {+ expect(getCoverCropRect(800, 400)).toEqual({+ sourceX: 200,+ sourceY: 0,+ side: 400,+ });+ });++ it("crops a portrait image around its center", () => {+ expect(getCoverCropRect(400, 900)).toEqual({+ sourceX: 0,+ sourceY: 250,+ side: 400,+ });+ });++ it("rounds an odd offset", () => {+ expect(getCoverCropRect(101, 100)).toEqual({+ sourceX: 1,+ sourceY: 0,+ side: 100,+ });+ });+});diff --git a/apps/web/src/lib/prepare-avatar-image.ts b/apps/web/src/lib/prepare-avatar-image.tsnew file mode 100644index 000000000..105c69b0c--- /dev/null+++ b/apps/web/src/lib/prepare-avatar-image.ts@@ -0,0 +1,117 @@+export const AVATAR_OUTPUT_SIZE = 256;+export const MAX_AVATAR_SOURCE_BYTES = 10 * 1024 * 1024;+export const ACCEPTED_AVATAR_TYPES = "image/*";++const SUPPORTED_OUTPUT_TYPES = ["image/webp", "image/png"] as const;++export type PreparedAvatar = {+ contentType: string;+ data: string;+};++function isSupportedOutputType(type: string) {+ return (SUPPORTED_OUTPUT_TYPES as readonly string[]).includes(type);+}++export function getCoverCropRect(width: number, height: number) {+ const side = Math.min(width, height);++ return {+ sourceX: Math.round((width - side) / 2),+ sourceY: Math.round((height - side) / 2),+ side,+ };+}++async function decodeImage(file: File) {+ if (typeof createImageBitmap === "function") {+ return createImageBitmap(file, { imageOrientation: "from-image" });+ }++ const objectUrl = URL.createObjectURL(file);+ try {+ return await new Promise<HTMLImageElement>((resolve, reject) => {+ const image = new Image();+ image.onload = () => resolve(image);+ image.onerror = () => reject(new Error("The image could not be read."));+ image.src = objectUrl;+ });+ } finally {+ URL.revokeObjectURL(objectUrl);+ }+}++function toBlob(canvas: HTMLCanvasElement, type: string) {+ return new Promise<Blob | null>((resolve) => {+ canvas.toBlob(resolve, type, 0.9);+ });+}++async function blobToBase64(blob: Blob) {+ const buffer = await blob.arrayBuffer();+ const bytes = new Uint8Array(buffer);+ let binary = "";++ for (let index = 0; index < bytes.length; index += 1) {+ binary += String.fromCharCode(bytes[index] as number);+ }++ return btoa(binary);+}++export async function prepareAvatarImage(file: File): Promise<PreparedAvatar> {+ if (!file.type.startsWith("image/")) {+ throw new Error("Choose an image file.");+ }++ if (file.size > MAX_AVATAR_SOURCE_BYTES) {+ throw new Error("Choose an image smaller than 10MB.");+ }++ const source = await decodeImage(file);+ const width = "width" in source ? source.width : 0;+ const height = "height" in source ? source.height : 0;++ if (!width || !height) {+ throw new Error("The image could not be read.");+ }++ const { sourceX, sourceY, side } = getCoverCropRect(width, height);+ const canvas = document.createElement("canvas");+ canvas.width = AVATAR_OUTPUT_SIZE;+ canvas.height = AVATAR_OUTPUT_SIZE;++ const context = canvas.getContext("2d");+ if (!context) {+ throw new Error("The image could not be processed.");+ }++ context.imageSmoothingQuality = "high";+ context.drawImage(+ source as CanvasImageSource,+ sourceX,+ sourceY,+ side,+ side,+ 0,+ 0,+ AVATAR_OUTPUT_SIZE,+ AVATAR_OUTPUT_SIZE,+ );++ if ("close" in source) {+ source.close();+ }++ const blob =+ (await toBlob(canvas, "image/webp")) ?? (await toBlob(canvas, "image/png"));++ if (!blob || !isSupportedOutputType(blob.type)) {+ throw new Error("The image could not be processed.");+ }++ return {+ contentType: blob.type,+ data: await blobToBase64(blob),+ };+}diff --git a/apps/web/src/lib/resolve-avatar-src.test.ts b/apps/web/src/lib/resolve-avatar-src.test.tsnew file mode 100644index 000000000..84dae20c4--- /dev/null+++ b/apps/web/src/lib/resolve-avatar-src.test.ts@@ -0,0 +1,29 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { resolveAvatarSrc } from "./resolve-avatar-src";++afterEach(() => {+ vi.unstubAllEnvs();+});++describe("resolveAvatarSrc", () => {+ it("points an uploaded avatar at the API origin", () => {+ vi.stubEnv("VITE_API_URL", "https://api.example.com");++ expect(resolveAvatarSrc("/api/user/avatar/abc123")).toBe(+ "https://api.example.com/api/user/avatar/abc123",+ );+ });++ it("leaves provider avatars untouched", () => {+ vi.stubEnv("VITE_API_URL", "https://api.example.com");++ expect(resolveAvatarSrc("https://avatars.githubusercontent.com/u/1")).toBe(+ "https://avatars.githubusercontent.com/u/1",+ );+ });++ it("passes through empty and undefined values", () => {+ expect(resolveAvatarSrc("")).toBe("");+ expect(resolveAvatarSrc(undefined)).toBeUndefined();+ });+});diff --git a/apps/web/src/lib/resolve-avatar-src.ts b/apps/web/src/lib/resolve-avatar-src.tsnew file mode 100644index 000000000..28eaf15e0--- /dev/null+++ b/apps/web/src/lib/resolve-avatar-src.ts@@ -0,0 +1,8 @@+import { getApiUrl } from "@/fetchers/get-api-url";++export function resolveAvatarSrc(src: string | undefined) {+ if (!src?.startsWith("/api/")) return src;+ return getApiUrl(src.slice("/api/".length));+}++export default resolveAvatarSrc;diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/information.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/information.tsxindex 5d9a11559..a24717064 100644--- a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/information.tsx+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/information.tsx@@ -1,13 +1,24 @@import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";import { useQueryClient } from "@tanstack/react-query";-import { createFileRoute } from "@tanstack/react-router";-import { useCallback, useEffect, useRef } from "react";+import { createFileRoute, useNavigate } from "@tanstack/react-router";+import { Loader2, Pencil, X } from "lucide-react";+import { useCallback, useEffect, useRef, useState } from "react";import { useForm } from "react-hook-form";import { useTranslation } from "react-i18next";import { z } from "zod";import PageTitle from "@/components/page-title";import useAuth from "@/components/providers/auth-provider/hooks/use-auth";+import {+ AlertDialog,+ AlertDialogClose,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from "@/components/ui/alert-dialog";import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";+import { Button } from "@/components/ui/button";import {Form,FormControl,@@ -17,9 +28,22 @@ import {FormMessage,} from "@/components/ui/form";import { Input } from "@/components/ui/input";+import { Label } from "@/components/ui/label";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from "@/components/ui/menu";import { Separator } from "@/components/ui/separator";+import useDeleteAccount, {+ SESSION_TOO_OLD,+} from "@/hooks/mutations/use-delete-account";+import useRemoveUserAvatar from "@/hooks/mutations/use-remove-user-avatar";+import useUpdateUserAvatar from "@/hooks/mutations/use-update-user-avatar";import useUpdateUserProfile from "@/hooks/mutations/use-update-user-profile";import { getInitials } from "@/lib/get-initials";+import { ACCEPTED_AVATAR_TYPES } from "@/lib/prepare-avatar-image";import { toast } from "@/lib/toast";export const Route = createFileRoute(@@ -49,9 +73,22 @@ function normalizeProfileValues(function RouteComponent() {const { t } = useTranslation();- const { user } = useAuth();+ const { user, refetchUser } = useAuth();const queryClient = useQueryClient();+ const navigate = useNavigate();const { mutateAsync: updateProfile } = useUpdateUserProfile();+ const { mutateAsync: updateAvatar, isPending: isUploadingAvatar } =+ useUpdateUserAvatar();+ const { mutateAsync: removeAvatar, isPending: isRemovingAvatar } =+ useRemoveUserAvatar();+ const { mutateAsync: deleteAccount, isPending: isDeletingAccount } =+ useDeleteAccount();+ const avatarInputRef = useRef<HTMLInputElement>(null);+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);+ const [deleteConfirmation, setDeleteConfirmation] = useState("");+ const canConfirmDelete =+ Boolean(user?.email) &&+ deleteConfirmation.trim().toLowerCase() === user?.email.toLowerCase();const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);const isSavingRef = useRef(false);const queuedSaveRef = useRef<ProfileFormValues | null>(null);@@ -113,7 +150,7 @@ function RouteComponent() {lastSavedRef.current = normalizedData;queuedSaveRef.current = null;- await queryClient.invalidateQueries({ queryKey: ["session"] });+ await refetchUser();toast.success(t("settings:informationPage.updateSuccess"));} catch (error) {toast.error(@@ -131,9 +168,66 @@ function RouteComponent() {}}},- [t, updateProfile, queryClient, profileForm],+ [t, updateProfile, refetchUser, profileForm],+ );++ const handleAvatarSelected = useCallback(+ async (event: React.ChangeEvent<HTMLInputElement>) => {+ const file = event.target.files?.[0];+ event.target.value = "";++ if (!file) return;++ try {+ await updateAvatar(file);+ await refetchUser();+ toast.success(t("settings:informationPage.avatar.updateSuccess"));+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:informationPage.avatar.updateError"),+ );+ }+ },+ [updateAvatar, refetchUser, t],);+ const handleAvatarRemoved = useCallback(async () => {+ try {+ await removeAvatar();+ await refetchUser();+ toast.success(t("settings:informationPage.avatar.removeSuccess"));+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:informationPage.avatar.removeError"),+ );+ }+ }, [removeAvatar, refetchUser, t]);++ const handleDeleteAccount = useCallback(async () => {+ try {+ await deleteAccount();+ setIsDeleteModalOpen(false);+ queryClient.clear();+ toast.success(t("settings:informationPage.deleteAccount.success"));+ navigate({ to: "/auth/sign-in" });+ } catch (error) {+ if (error instanceof Error && error.message === SESSION_TOO_OLD) {+ toast.error(t("settings:informationPage.deleteAccount.sessionTooOld"));+ return;+ }++ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:informationPage.deleteAccount.error"),+ );+ }+ }, [deleteAccount, queryClient, navigate, t]);+const debouncedSave = useCallback((data: ProfileFormValues) => {if (debounceTimeoutRef.current) {@@ -189,18 +283,67 @@ function RouteComponent() {</div><div className="space-y-4 border border-border rounded-md p-4 bg-sidebar">- <div className="flex items-center justify-between">+ <div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4"><div className="space-y-0.5"><p className="text-sm font-medium">{t("settings:informationPage.profilePicture")}</p>+ <p className="text-xs text-muted-foreground">+ {t("settings:informationPage.avatar.hint")}+ </p>+ </div>+ <div className="flex items-center gap-3">+ <input+ ref={avatarInputRef}+ type="file"+ accept={ACCEPTED_AVATAR_TYPES}+ className="hidden"+ onChange={handleAvatarSelected}+ />+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <button+ type="button"+ aria-label={t("settings:informationPage.avatar.edit")}+ disabled={isUploadingAvatar || isRemovingAvatar}+ className="group relative rounded-full outline-none transition-transform duration-150 ease-out active:scale-97 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"+ />+ }+ >+ <Avatar className="h-10 w-10">+ <AvatarImage+ src={user?.image ?? ""}+ alt={user?.name || ""}+ />+ <AvatarFallback className="text-xs font-medium border border-border/30">+ {getInitials(user?.name)}+ </AvatarFallback>+ </Avatar>+ <span className="pointer-events-none absolute inset-0 flex items-center justify-center rounded-full bg-black/55 text-white opacity-0 transition-opacity duration-150 ease-out group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[popup-open]:opacity-100 group-disabled:opacity-100">+ {isUploadingAvatar || isRemovingAvatar ? (+ <Loader2 className="size-4 animate-spin" />+ ) : (+ <Pencil className="size-3.5" />+ )}+ </span>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" side="bottom">+ <DropdownMenuItem+ onClick={() => avatarInputRef.current?.click()}+ >+ <Pencil />+ {t("settings:informationPage.avatar.change")}+ </DropdownMenuItem>+ {user?.image ? (+ <DropdownMenuItem onClick={handleAvatarRemoved}>+ <X />+ {t("settings:informationPage.avatar.remove")}+ </DropdownMenuItem>+ ) : null}+ </DropdownMenuContent>+ </DropdownMenu></div>- <Avatar className="h-10 w-10">- <AvatarImage src={user?.image ?? ""} alt={user?.name || ""} />- <AvatarFallback className="text-xs font-medium border border-border/30">- {getInitials(user?.name)}- </AvatarFallback>- </Avatar></div><Separator />@@ -266,6 +409,101 @@ function RouteComponent() {</Form></div></div>++ <div className="space-y-6">+ <div className="space-y-1">+ <h2 className="text-md font-medium">+ {t("settings:informationPage.deleteAccount.sectionTitle")}+ </h2>+ <p className="text-xs text-muted-foreground">+ {t("settings:informationPage.deleteAccount.sectionSubtitle")}+ </p>+ </div>++ <div className="space-y-4 border border-border rounded-md p-4 bg-sidebar">+ <div className="flex flex-col items-start gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4">+ <div className="space-y-0.5">+ <p className="text-sm font-medium">+ {t("settings:informationPage.deleteAccount.title")}+ </p>+ <p className="text-xs text-muted-foreground">+ {t("settings:informationPage.deleteAccount.description")}+ </p>+ </div>+ <Button+ variant="ghost"+ size="sm"+ className="text-destructive hover:text-destructive transition-colors shrink-0"+ type="button"+ onClick={() => setIsDeleteModalOpen(true)}+ >+ {t("settings:informationPage.deleteAccount.title")}+ </Button>+ </div>+ </div>+ </div>++ <AlertDialog+ open={isDeleteModalOpen}+ onOpenChange={(open) => {+ setIsDeleteModalOpen(open);+ if (!open) setDeleteConfirmation("");+ }}+ >+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>+ {t("settings:informationPage.deleteAccount.modalTitle")}+ </AlertDialogTitle>+ <AlertDialogDescription>+ {t("settings:informationPage.deleteAccount.modalDescription", {+ email: user?.email ?? "",+ })}+ </AlertDialogDescription>+ </AlertDialogHeader>+ <div className="space-y-2 px-6 pb-5">+ <Label htmlFor="delete-account-confirmation">+ {t("settings:informationPage.deleteAccount.confirmLabel", {+ email: user?.email ?? "",+ })}+ </Label>+ <Input+ id="delete-account-confirmation"+ autoComplete="off"+ autoCapitalize="none"+ spellCheck={false}+ disabled={isDeletingAccount}+ value={deleteConfirmation}+ onChange={(event) => setDeleteConfirmation(event.target.value)}+ placeholder={user?.email ?? ""}+ />+ </div>+ <AlertDialogFooter>+ <AlertDialogClose+ render={+ <Button+ variant="outline"+ size="sm"+ disabled={isDeletingAccount}+ />+ }+ >+ {t("common:actions.cancel")}+ </AlertDialogClose>+ <Button+ variant="destructive"+ size="sm"+ type="button"+ disabled={isDeletingAccount || !canConfirmDelete}+ onClick={handleDeleteAccount}+ >+ {isDeletingAccount+ ? t("common:actions.deleting")+ : t("settings:informationPage.deleteAccount.confirm")}+ </Button>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog></div></>);diff --git a/i18n/de-DE.json b/i18n/de-DE.jsonindex e83136d52..084b49944 100644--- a/i18n/de-DE.json+++ b/i18n/de-DE.json@@ -334,6 +334,29 @@"nameRequired": "Name ist erforderlich","nameShort": "Der Name muss mindestens 2 Zeichen lang sein","invalidEmail": "Ungültige E-Mail-Adresse"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/el-GR.json b/i18n/el-GR.jsonindex 4bac9ec62..00febf705 100644--- a/i18n/el-GR.json+++ b/i18n/el-GR.json@@ -334,6 +334,29 @@"nameRequired": "Το όνομα είναι υποχρεωτικό","nameShort": "Το όνομα πρέπει να έχει τουλάχιστον 2 χαρακτήρες","invalidEmail": "Μη έγκυρη διεύθυνση email"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/en-US.json b/i18n/en-US.jsonindex eadd54aff..de0dd42ce 100644--- a/i18n/en-US.json+++ b/i18n/en-US.json@@ -334,6 +334,29 @@"nameRequired": "Name is required","nameShort": "Name must be at least 2 characters","invalidEmail": "Invalid email address"+ },+ "avatar": {+ "hint": "Click your picture to change or remove it. Cropped to a square and resized to 256x256.",+ "remove": "Remove avatar",+ "updateSuccess": "Profile picture updated",+ "updateError": "Failed to update profile picture",+ "removeSuccess": "Profile picture removed",+ "removeError": "Failed to remove profile picture",+ "edit": "Change your profile picture",+ "change": "Change avatar"+ },+ "deleteAccount": {+ "sectionTitle": "Danger zone",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "title": "Delete account",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "modalTitle": "Delete your account?",+ "modalDescription": "This permanently deletes your account and cannot be undone.",+ "confirmLabel": "Type {{email}} to confirm",+ "confirm": "Delete account",+ "success": "Your account has been deleted",+ "error": "Failed to delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/es-ES.json b/i18n/es-ES.jsonindex 56afed379..dd158a696 100644--- a/i18n/es-ES.json+++ b/i18n/es-ES.json@@ -333,6 +333,29 @@"nameRequired": "El nombre es obligatorio","nameShort": "Tu nombre debe tener al menos 2 caracteres","invalidEmail": "Dirección de correo electrónico no válida"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"preferencesPage": {diff --git a/i18n/fr-FR.json b/i18n/fr-FR.jsonindex 6ec21ae9c..982813d40 100644--- a/i18n/fr-FR.json+++ b/i18n/fr-FR.json@@ -334,6 +334,29 @@"nameRequired": "Le nom est requis","nameShort": "Le nom doit contenir au moins 2 caractères","invalidEmail": "Adresse email invalide"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/hi-IN.json b/i18n/hi-IN.jsonindex f79d29b1f..3ac75fd17 100644--- a/i18n/hi-IN.json+++ b/i18n/hi-IN.json@@ -334,6 +334,29 @@"nameRequired": "नाम आवश्यक है","nameShort": "नाम कम से कम 2 अक्षरों का होना चाहिए","invalidEmail": "अमान्य ईमेल पता"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/id-ID.json b/i18n/id-ID.jsonindex 65b08ef39..6e322f43d 100644--- a/i18n/id-ID.json+++ b/i18n/id-ID.json@@ -334,6 +334,29 @@"nameRequired": "Nama wajib diisi","nameShort": "Nama harus minimal 2 karakter","invalidEmail": "Alamat email tidak valid"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/it-IT.json b/i18n/it-IT.jsonindex b3b9d2631..f38c2bbb7 100644--- a/i18n/it-IT.json+++ b/i18n/it-IT.json@@ -334,6 +334,29 @@"nameRequired": "Il nome è obbligatorio","nameShort": "Il nome deve essere di almeno 2 caratteri","invalidEmail": "Indirizzo email non valido"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/ko-KR.json b/i18n/ko-KR.jsonindex 8c0c17aad..a272c90c0 100644--- a/i18n/ko-KR.json+++ b/i18n/ko-KR.json@@ -334,6 +334,29 @@"nameRequired": "이름은 필수입니다","nameShort": "이름은 2자 이상이어야 합니다","invalidEmail": "잘못된 이메일 주소입니다"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/mk-MK.json b/i18n/mk-MK.jsonindex 718ae47a9..26576a50c 100644--- a/i18n/mk-MK.json+++ b/i18n/mk-MK.json@@ -334,6 +334,29 @@"nameRequired": "Името е задолжително","nameShort": "Името мора да има најмалку 2 знаци","invalidEmail": "Невалидна е-пошта"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/nl-NL.json b/i18n/nl-NL.jsonindex 47b72e0bb..ce501d10d 100644--- a/i18n/nl-NL.json+++ b/i18n/nl-NL.json@@ -333,6 +333,29 @@"nameRequired": "Naam is verplicht","nameShort": "Naam moet minimaal 2 tekens bevatten","invalidEmail": "Ongeldig e-mailadres"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"preferencesPage": {diff --git a/i18n/pt-BR.json b/i18n/pt-BR.jsonindex 6d1e50082..c6aeda6e3 100644--- a/i18n/pt-BR.json+++ b/i18n/pt-BR.json@@ -334,6 +334,29 @@"nameRequired": "O nome é obrigatório","nameShort": "O nome deve ter pelo menos 2 caracteres","invalidEmail": "Endereço de e-mail inválido"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/ru-RU.json b/i18n/ru-RU.jsonindex 394ab9929..49507937d 100644--- a/i18n/ru-RU.json+++ b/i18n/ru-RU.json@@ -334,6 +334,29 @@"nameRequired": "Имя обязательно","nameShort": "Имя должно содержать не менее 2 символов","invalidEmail": "Некорректный адрес электронной почты"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/tr-TR.json b/i18n/tr-TR.jsonindex b5db61d9d..560afc868 100644--- a/i18n/tr-TR.json+++ b/i18n/tr-TR.json@@ -334,6 +334,29 @@"nameRequired": "Ad gereklidir","nameShort": "Ad en az 2 karakter olmalıdır","invalidEmail": "Geçersiz e-posta adresi"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/uk-UA.json b/i18n/uk-UA.jsonindex c63ff5b7d..352ffd6b9 100644--- a/i18n/uk-UA.json+++ b/i18n/uk-UA.json@@ -334,6 +334,29 @@"nameRequired": "Ім'я є обов'язковим","nameShort": "Ім'я має містити щонайменше 2 символи","invalidEmail": "Невірна адреса електронної пошти"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/vi-VN.json b/i18n/vi-VN.jsonindex 4105aba25..5e180aec9 100644--- a/i18n/vi-VN.json+++ b/i18n/vi-VN.json@@ -334,6 +334,29 @@"nameRequired": "Cần có tên","nameShort": "Tên phải có ít nhất 2 ký tự","invalidEmail": "Địa chỉ email không hợp lệ"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/i18n/zh-CN.json b/i18n/zh-CN.jsonindex 6a6af3b3e..ca69160a1 100644--- a/i18n/zh-CN.json+++ b/i18n/zh-CN.json@@ -334,6 +334,29 @@"nameRequired": "名称不能为空","nameShort": "姓名至少需要 2 个字符","invalidEmail": "邮箱地址无效"+ },+ "avatar": {+ "hint": "PNG, JPEG, or WebP. Cropped to a square and resized to 256x256.",+ "remove": "Remove",+ "removeError": "Failed to remove profile picture",+ "removeSuccess": "Profile picture removed",+ "updateError": "Failed to update profile picture",+ "updateSuccess": "Profile picture updated",+ "change": "Change avatar",+ "edit": "Change your profile picture"+ },+ "deleteAccount": {+ "confirm": "Delete account",+ "confirmLabel": "Confirm your email address",+ "description": "Workspaces only you belong to are deleted with your account. Elsewhere, your tasks stay and become unassigned, and your comments are removed.",+ "error": "Failed to delete account",+ "modalDescription": "This cannot be undone. Type {{email}} to confirm.",+ "modalTitle": "Delete your account?",+ "sectionSubtitle": "Permanent actions that affect your whole account.",+ "sectionTitle": "Danger zone",+ "success": "Your account has been deleted",+ "title": "Delete account",+ "sessionTooOld": "For security, sign out and sign back in before deleting your account."}},"notificationsPage": {diff --git a/tests/api-integration/account-deletion.test.ts b/tests/api-integration/account-deletion.test.tsnew file mode 100644index 000000000..7f9904a3b--- /dev/null+++ b/tests/api-integration/account-deletion.test.ts@@ -0,0 +1,320 @@+import { randomUUID } from "node:crypto";+import { eq } from "drizzle-orm";+import { beforeEach, describe, expect, it } from "vitest";+import db, { schema } from "../../apps/api/src/database";+import { createApp } from "../../apps/api/src/index";+import deleteAccountData from "../../apps/api/src/user/controllers/delete-account-data";+import { mockAuthenticatedSession } from "./helpers/auth";+import { resetTestDatabase } from "./helpers/database";+import {+ createProjectFixture,+ createWorkspaceMember,+} from "./helpers/fixtures";++async function addMember(workspaceId: string, role: string) {+ const userId = `user-${randomUUID()}`;++ const [user] = await db+ .insert(schema.userTable)+ .values({+ id: userId,+ email: `${userId}@example.com`,+ emailVerified: true,+ name: "Other Member",+ })+ .returning();++ await db.insert(schema.workspaceUserTable).values({+ workspaceId,+ userId: user.id,+ role,+ joinedAt: new Date(),+ });++ return user;+}++describe("API integration: account deletion", () => {+ beforeEach(async () => {+ await resetTestDatabase();+ });++ it("deletes a workspace the account is the only member of", async () => {+ const owner = await createWorkspaceMember({ role: "owner" });++ await deleteAccountData(owner.user.id);++ const workspaces = await db+ .select()+ .from(schema.workspaceTable)+ .where(eq(schema.workspaceTable.id, owner.workspace.id));++ expect(workspaces).toHaveLength(0);+ });++ it("refuses to delete while the account is the only owner of a shared workspace", async () => {+ const owner = await createWorkspaceMember({+ role: "owner",+ workspaceName: "Acme",+ });+ await addMember(owner.workspace.id, "member");++ await expect(deleteAccountData(owner.user.id)).rejects.toThrow(+ /only owner of "Acme"/,+ );++ const workspaces = await db+ .select()+ .from(schema.workspaceTable)+ .where(eq(schema.workspaceTable.id, owner.workspace.id));++ expect(workspaces).toHaveLength(1);+ });++ it("leaves a shared workspace that keeps another owner", async () => {+ const owner = await createWorkspaceMember({ role: "owner" });+ await addMember(owner.workspace.id, "owner");++ await deleteAccountData(owner.user.id);++ const workspaces = await db+ .select()+ .from(schema.workspaceTable)+ .where(eq(schema.workspaceTable.id, owner.workspace.id));+ const members = await db+ .select()+ .from(schema.workspaceUserTable)+ .where(eq(schema.workspaceUserTable.userId, owner.user.id));++ expect(workspaces).toHaveLength(1);+ expect(members).toHaveLength(0);+ });++ it("keeps tasks, time entries, and activity of another workspace after the user row is deleted", async () => {+ const host = await createWorkspaceMember({ role: "owner" });+ const guest = await addMember(host.workspace.id, "member");+ const { project } = await createProjectFixture({+ workspaceId: host.workspace.id,+ });++ const [task] = await db+ .insert(schema.taskTable)+ .values({+ projectId: project.id,+ userId: guest.id,+ title: "Assigned to the leaving user",+ status: "to-do",+ priority: "medium",+ number: 1,+ position: 1,+ })+ .returning();++ const [timeEntry] = await db+ .insert(schema.timeEntryTable)+ .values({+ taskId: task.id,+ userId: guest.id,+ startTime: new Date(),+ duration: 60,+ })+ .returning();++ const [activity] = await db+ .insert(schema.activityTable)+ .values({+ taskId: task.id,+ userId: guest.id,+ type: "comment",+ content: "Worth keeping",+ })+ .returning();++ await deleteAccountData(guest.id);+ await db.delete(schema.userTable).where(eq(schema.userTable.id, guest.id));++ const [remainingTask] = await db+ .select()+ .from(schema.taskTable)+ .where(eq(schema.taskTable.id, task.id));+ const [remainingTimeEntry] = await db+ .select()+ .from(schema.timeEntryTable)+ .where(eq(schema.timeEntryTable.id, timeEntry.id));+ const [remainingActivity] = await db+ .select()+ .from(schema.activityTable)+ .where(eq(schema.activityTable.id, activity.id));++ expect(remainingTask?.title).toBe("Assigned to the leaving user");+ expect(remainingTask?.userId).toBeNull();+ expect(remainingTimeEntry?.duration).toBe(60);+ expect(remainingTimeEntry?.userId).toBeNull();+ expect(remainingActivity?.content).toBe("Worth keeping");+ expect(remainingActivity?.userId).toBeNull();+ });++ it("removes the stored avatar with the account", async () => {+ const member = await createWorkspaceMember({ role: "owner" });++ const [avatar] = await db+ .insert(schema.userAvatarTable)+ .values({+ userId: member.user.id,+ mimeType: "image/png",+ size: 8,+ data: Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),+ })+ .returning();++ await db+ .delete(schema.userTable)+ .where(eq(schema.userTable.id, member.user.id));++ const avatars = await db+ .select()+ .from(schema.userAvatarTable)+ .where(eq(schema.userAvatarTable.id, avatar.id));++ expect(avatars).toHaveLength(0);+ });+});++describe("API integration: avatar routes", () => {+ beforeEach(async () => {+ await resetTestDatabase();+ });++ it("stores an uploaded avatar and serves it back without authentication", async () => {+ const member = await createWorkspaceMember({ role: "owner" });+ mockAuthenticatedSession(member.user);+ const { app } = createApp();++ const png = Buffer.from([+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x01, 0x02,+ ]);++ const uploadResponse = await app.request("/api/user/avatar", {+ method: "PUT",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({+ contentType: "image/png",+ data: png.toString("base64"),+ }),+ });++ expect(uploadResponse.status).toBe(200);+ const avatar = (await uploadResponse.json()) as {+ id: string;+ url: string;+ size: number;+ };+ expect(avatar.url).toBe(`/api/user/avatar/${avatar.id}`);+ expect(avatar.size).toBe(png.length);++ const downloadResponse = await app.request(avatar.url);++ expect(downloadResponse.status).toBe(200);+ expect(downloadResponse.headers.get("content-type")).toBe("image/png");+ expect(downloadResponse.headers.get("x-content-type-options")).toBe(+ "nosniff",+ );+ expect(Buffer.from(await downloadResponse.arrayBuffer())).toEqual(png);+ });++ it("rejects bytes that do not match the declared image type", async () => {+ const member = await createWorkspaceMember({ role: "owner" });+ mockAuthenticatedSession(member.user);+ const { app } = createApp();++ const response = await app.request("/api/user/avatar", {+ method: "PUT",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({+ contentType: "image/png",+ data: Buffer.from("<html></html>").toString("base64"),+ }),+ });++ expect(response.status).toBe(400);+ });++ it("replaces the previous avatar and retires its URL", async () => {+ const member = await createWorkspaceMember({ role: "owner" });+ mockAuthenticatedSession(member.user);+ const { app } = createApp();++ const upload = (contentType: string, data: Buffer) =>+ app.request("/api/user/avatar", {+ method: "PUT",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({+ contentType,+ data: data.toString("base64"),+ }),+ });++ const first = (await (+ await upload(+ "image/png",+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),+ )+ ).json()) as { id: string; url: string };++ const second = (await (+ await upload("image/jpeg", Buffer.from([0xff, 0xd8, 0xff, 0x01]))+ ).json()) as { id: string; url: string };++ expect(second.id).not.toBe(first.id);+ expect((await app.request(first.url)).status).toBe(404);+ expect((await app.request(second.url)).status).toBe(200);++ const rows = await db+ .select()+ .from(schema.userAvatarTable)+ .where(eq(schema.userAvatarTable.userId, member.user.id));+ expect(rows).toHaveLength(1);+ });++ it("deletes the avatar of the current user", async () => {+ const member = await createWorkspaceMember({ role: "owner" });+ mockAuthenticatedSession(member.user);+ const { app } = createApp();++ await app.request("/api/user/avatar", {+ method: "PUT",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({+ contentType: "image/png",+ data: Buffer.from([+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,+ ]).toString("base64"),+ }),+ });++ const response = await app.request("/api/user/avatar", {+ method: "DELETE",+ });++ expect(response.status).toBe(200);+ await expect(response.json()).resolves.toEqual({ deleted: true });++ const rows = await db+ .select()+ .from(schema.userAvatarTable)+ .where(eq(schema.userAvatarTable.userId, member.user.id));+ expect(rows).toHaveLength(0);+ });++ it("requires authentication to upload an avatar", async () => {+ const { app } = createApp();++ const response = await app.request("/api/user/avatar", {+ method: "PUT",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ contentType: "image/png", data: "" }),+ });++ expect(response.status).toBe(401);+ });+});diff --git a/tests/api-integration/billing-delete-guard.test.ts b/tests/api-integration/billing-delete-guard.test.tsnew file mode 100644index 000000000..9fa793644--- /dev/null+++ b/tests/api-integration/billing-delete-guard.test.ts@@ -0,0 +1,153 @@+import { eq } from "drizzle-orm";+import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";+import db, { schema } from "../../apps/api/src/database";+import { createApp } from "../../apps/api/src/index";+import deleteAccountData from "../../apps/api/src/user/controllers/delete-account-data";+import { resetTestDatabase } from "./helpers/database";+import { createWorkspaceMember } from "./helpers/fixtures";++const CLOUD_ENV = {+ KANEO_CLOUD: "true",+ CREEM_API_KEY: "creem_test_dummy",+ CREEM_WEBHOOK_SECRET: "whsec_dummy",+};+const saved: Record<string, string | undefined> = {};++async function setBilling(+ workspaceId: string,+ values: Partial<typeof schema.workspaceBillingTable.$inferInsert>,+) {+ await db+ .insert(schema.workspaceBillingTable)+ .values({ workspaceId, ...values })+ .onConflictDoUpdate({+ target: schema.workspaceBillingTable.workspaceId,+ set: values,+ });+}++describe("API integration: deleting paid workspaces", () => {+ beforeAll(() => {+ for (const [key, value] of Object.entries(CLOUD_ENV)) {+ saved[key] = process.env[key];+ process.env[key] = value;+ }+ });++ afterAll(() => {+ for (const key of Object.keys(CLOUD_ENV)) {+ if (saved[key] === undefined) {+ delete process.env[key];+ } else {+ process.env[key] = saved[key];+ }+ }+ });++ beforeEach(async () => {+ await resetTestDatabase();+ });++ it("refuses account deletion while a workspace still has an active subscription", async () => {+ const owner = await createWorkspaceMember({+ role: "owner",+ workspaceName: "Paid Space",+ });+ await setBilling(owner.workspace.id, {+ creemSubscriptionId: "sub_active",+ creemProductId: "prod_1",+ plan: "team",+ status: "active",+ });++ await expect(deleteAccountData(owner.user.id)).rejects.toThrow(+ /"Paid Space" still has an active subscription/,+ );++ const workspaces = await db+ .select()+ .from(schema.workspaceTable)+ .where(eq(schema.workspaceTable.id, owner.workspace.id));+ expect(workspaces).toHaveLength(1);+ });++ it("allows account deletion once the subscription is cancelled", async () => {+ const owner = await createWorkspaceMember({ role: "owner" });+ await setBilling(owner.workspace.id, {+ creemSubscriptionId: "sub_gone",+ status: "canceled",+ });++ await deleteAccountData(owner.user.id);++ const workspaces = await db+ .select()+ .from(schema.workspaceTable)+ .where(eq(schema.workspaceTable.id, owner.workspace.id));+ expect(workspaces).toHaveLength(0);+ });++ it("allows account deletion for a workspace on the free trial", async () => {+ const owner = await createWorkspaceMember({ role: "owner" });+ await setBilling(owner.workspace.id, {+ trialEndsAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),+ });++ await deleteAccountData(owner.user.id);++ const workspaces = await db+ .select()+ .from(schema.workspaceTable)+ .where(eq(schema.workspaceTable.id, owner.workspace.id));+ expect(workspaces).toHaveLength(0);+ });++ it("refuses workspace deletion through the API while the subscription is active", async () => {+ const { app } = createApp();++ const signUp = await app.request("/api/auth/sign-up/email", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({+ email: "[email protected]",+ password: "correct horse battery staple",+ name: "Paid Owner",+ }),+ });+ expect(signUp.status).toBe(200);+ const cookie = signUp.headers+ .getSetCookie()+ .map((entry) => entry.split(";")[0])+ .join("; ");++ const created = await app.request("/api/auth/organization/create", {+ method: "POST",+ headers: { "content-type": "application/json", cookie },+ body: JSON.stringify({ name: "Paid Space", slug: "paid-space" }),+ });+ expect(created.status).toBe(200);+ const workspace = (await created.json()) as { id: string };++ await setBilling(workspace.id, {+ creemSubscriptionId: "sub_active",+ creemProductId: "prod_1",+ plan: "team",+ status: "active",+ });++ const deleted = await app.request("/api/auth/organization/delete", {+ method: "POST",+ headers: { "content-type": "application/json", cookie },+ body: JSON.stringify({ organizationId: workspace.id }),+ });++ expect(deleted.status).toBe(409);+ expect(await deleted.text()).toMatch(/active subscription/);++ const rows = await db+ .select()+ .from(schema.workspaceTable)+ .where(eq(schema.workspaceTable.id, workspace.id));+ expect(rows).toHaveLength(1);+ });+});diff --git a/tests/api-integration/billing-trial-per-user.test.ts b/tests/api-integration/billing-trial-per-user.test.tsindex 7f9001209..b1d2da97e 100644--- a/tests/api-integration/billing-trial-per-user.test.ts+++ b/tests/api-integration/billing-trial-per-user.test.ts@@ -3,6 +3,7 @@ import { eq } from "drizzle-orm";import { beforeEach, describe, expect, it } from "vitest";import { getOrCreateWorkspaceBilling } from "../../apps/api/src/billing/controllers/get-workspace-billing";import db, { schema } from "../../apps/api/src/database";+import deleteAccountData from "../../apps/api/src/user/controllers/delete-account-data";import { resetTestDatabase } from "./helpers/database";import { createWorkspaceMember } from "./helpers/fixtures";@@ -107,4 +108,51 @@ describe("trial is granted once per owner", () => {expect(billing.trialEndsAt?.getTime()).toBe(pinned.getTime());});++ it("does not hand out a new trial after the account is deleted", async () => {+ const first = await createWorkspaceMember({ role: "owner" });+ const firstBilling = await getOrCreateWorkspaceBilling(first.workspace.id);+ expect(firstBilling.trialEndsAt).not.toBeNull();++ await deleteAccountData(first.user.id);+ await db+ .delete(schema.userTable)+ .where(eq(schema.userTable.id, first.user.id));++ const returning = await createWorkspaceMember({ role: "owner" });+ await db+ .update(schema.userTable)+ .set({ email: first.user.email })+ .where(eq(schema.userTable.id, returning.user.id));++ const secondBilling = await getOrCreateWorkspaceBilling(+ returning.workspace.id,+ );++ expect(secondBilling.trialEndsAt?.getTime()).toBe(+ firstBilling.trialEndsAt?.getTime(),+ );+ });++ it("treats a plus-addressed signup as the same trial identity", async () => {+ const first = await createWorkspaceMember({ role: "owner" });+ await db+ .update(schema.userTable)+ .set({ email: "[email protected]" })+ .where(eq(schema.userTable.id, first.user.id));+ const firstBilling = await getOrCreateWorkspaceBilling(first.workspace.id);++ const second = await createWorkspaceMember({ role: "owner" });+ await db+ .update(schema.userTable)+ .set({ email: "[email protected]" })+ .where(eq(schema.userTable.id, second.user.id));+ const secondBilling = await getOrCreateWorkspaceBilling(+ second.workspace.id,+ );++ expect(secondBilling.trialEndsAt?.getTime()).toBe(+ firstBilling.trialEndsAt?.getTime(),+ );+ });});diff --git a/tests/api-integration/session-freshness.test.ts b/tests/api-integration/session-freshness.test.tsnew file mode 100644index 000000000..ce0192a6b--- /dev/null+++ b/tests/api-integration/session-freshness.test.ts@@ -0,0 +1,108 @@+import { beforeEach, describe, expect, it } from "vitest";+import { createApp } from "../../apps/api/src/index";+import { resetTestDatabase } from "./helpers/database";++type SessionResponse = { user: { image: string | null; name: string } } | null;++function applyCookies(existing: string, response: Response) {+ const jar = new Map<string, string>();++ for (const pair of existing.split("; ").filter(Boolean)) {+ const [name, ...value] = pair.split("=");+ if (name) jar.set(name, value.join("="));+ }++ for (const setCookie of response.headers.getSetCookie()) {+ const [pair] = setCookie.split(";");+ const [name, ...value] = (pair ?? "").split("=");+ if (!name) continue;+ if (value.join("=") === "") {+ jar.delete(name);+ continue;+ }+ jar.set(name, value.join("="));+ }++ return [...jar].map(([name, value]) => `${name}=${value}`).join("; ");+}++function collectCookies(response: Response) {+ return applyCookies("", response);+}++async function signUp(app: ReturnType<typeof createApp>["app"]) {+ const response = await app.request("/api/auth/sign-up/email", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({+ email: "[email protected]",+ password: "correct horse battery staple",+ name: "Avatar Session",+ }),+ });++ expect(response.status).toBe(200);+ const cookies = collectCookies(response);+ expect(cookies).not.toBe("");++ return cookies;+}++describe("API integration: session freshness after profile updates", () => {+ beforeEach(async () => {+ await resetTestDatabase();+ });++ it("serves the updated user when the session cookie cache is bypassed", async () => {+ const { app } = createApp();+ const cookies = await signUp(app);++ const update = await app.request("/api/auth/update-user", {+ method: "POST",+ headers: { "content-type": "application/json", cookie: cookies },+ body: JSON.stringify({ image: "/api/user/avatar/new-avatar-id" }),+ });+ expect(update.status).toBe(200);++ const cached = (await (+ await app.request("/api/auth/get-session", {+ headers: { cookie: cookies },+ })+ ).json()) as SessionResponse;+ expect(cached?.user.image).toBeNull();++ const fresh = (await (+ await app.request("/api/auth/get-session?disableCookieCache=true", {+ headers: { cookie: cookies },+ })+ ).json()) as SessionResponse;+ expect(fresh?.user.image).toBe("/api/user/avatar/new-avatar-id");+ });++ it("refreshes the cached session cookie on get-session", async () => {+ const { app } = createApp();+ const cookies = await signUp(app);++ await app.request("/api/auth/update-user", {+ method: "POST",+ headers: { "content-type": "application/json", cookie: cookies },+ body: JSON.stringify({ name: "Renamed User" }),+ });++ const refreshed = await app.request(+ "/api/auth/get-session?disableCookieCache=true",+ { headers: { cookie: cookies } },+ );++ expect(refreshed.headers.getSetCookie().length).toBeGreaterThan(0);++ const nextCookies = applyCookies(cookies, refreshed);+ const cached = (await (+ await app.request("/api/auth/get-session", {+ headers: { cookie: nextCookies },+ })+ ).json()) as SessionResponse;++ expect(cached?.user.name).toBe("Renamed User");+ });+});diff --git a/tests/api/billing/subscription-state.test.ts b/tests/api/billing/subscription-state.test.tsnew file mode 100644index 000000000..8826c02b8--- /dev/null+++ b/tests/api/billing/subscription-state.test.ts@@ -0,0 +1,28 @@+import { describe, expect, it } from "vitest";+import { hasBillableSubscription } from "../../../apps/api/src/billing/subscription-state";++describe("hasBillableSubscription", () => {+ it("is false without a subscription id", () => {+ expect(+ hasBillableSubscription({ creemSubscriptionId: null, status: "active" }),+ ).toBe(false);+ expect(hasBillableSubscription(null)).toBe(false);+ expect(hasBillableSubscription(undefined)).toBe(false);+ });++ it("is true while the subscription can still charge", () => {+ for (const status of ["active", "trialing", "past_due"]) {+ expect(+ hasBillableSubscription({ creemSubscriptionId: "sub_1", status }),+ ).toBe(true);+ }+ });++ it("is false once the subscription is winding down", () => {+ for (const status of ["scheduled_cancel", "canceled", "expired", null]) {+ expect(+ hasBillableSubscription({ creemSubscriptionId: "sub_1", status }),+ ).toBe(false);+ }+ });+});diff --git a/tests/api/billing/trial-identity.test.ts b/tests/api/billing/trial-identity.test.tsnew file mode 100644index 000000000..ea1561cee--- /dev/null+++ b/tests/api/billing/trial-identity.test.ts@@ -0,0 +1,43 @@+import { describe, expect, it } from "vitest";+import {+ hashTrialEmail,+ normalizeTrialEmail,+} from "../../../apps/api/src/billing/trial-identity";++describe("normalizeTrialEmail", () => {+ it("lowercases and trims", () => {+ expect(normalizeTrialEmail(" [email protected] ")).toBe("[email protected]");+ });++ it("drops plus tags so aliases share one trial", () => {+ expect(normalizeTrialEmail("[email protected]")).toBe(+ "[email protected]",+ );+ });++ it("keeps the address when stripping would empty the local part", () => {+ expect(normalizeTrialEmail("[email protected]")).toBe("[email protected]");+ });++ it("leaves values without an address shape alone", () => {+ expect(normalizeTrialEmail("not-an-email")).toBe("not-an-email");+ });+});++describe("hashTrialEmail", () => {+ it("matches for addresses that normalize to the same mailbox", () => {+ expect(hashTrialEmail("[email protected]")).toBe(+ hashTrialEmail("[email protected]"),+ );+ });++ it("differs for different mailboxes", () => {+ expect(hashTrialEmail("[email protected]")).not.toBe(+ hashTrialEmail("[email protected]"),+ );+ });++ it("does not store the address itself", () => {+ expect(hashTrialEmail("[email protected]")).not.toContain("kaneo");+ });+});diff --git a/tests/api/user/account-deletion.test.ts b/tests/api/user/account-deletion.test.tsnew file mode 100644index 000000000..ec872193d--- /dev/null+++ b/tests/api/user/account-deletion.test.ts@@ -0,0 +1,117 @@+import { describe, expect, it } from "vitest";+import {+ formatBlockedWorkspacesMessage,+ hasOwnerRole,+ planAccountDeletion,+ type WorkspaceMembershipSummary,+} from "../../../apps/api/src/user/account-deletion";++function membership(+ overrides: Partial<WorkspaceMembershipSummary> = {},+): WorkspaceMembershipSummary {+ return {+ workspaceId: "workspace-1",+ workspaceName: "Acme",+ isOwner: true,+ memberCount: 1,+ ownerCount: 1,+ ...overrides,+ };+}++describe("hasOwnerRole", () => {+ it("matches a plain owner role", () => {+ expect(hasOwnerRole("owner")).toBe(true);+ });++ it("matches owner inside a comma separated role list", () => {+ expect(hasOwnerRole("admin,owner")).toBe(true);+ expect(hasOwnerRole("member, Owner ")).toBe(true);+ });++ it("does not match other roles", () => {+ expect(hasOwnerRole("admin")).toBe(false);+ expect(hasOwnerRole("ownership")).toBe(false);+ });+});++describe("planAccountDeletion", () => {+ it("deletes a workspace nobody else belongs to", () => {+ const plan = planAccountDeletion([membership()]);++ expect(plan.workspaceIdsToDelete).toEqual(["workspace-1"]);+ expect(plan.workspaceIdsToLeave).toEqual([]);+ expect(plan.blockedWorkspaceNames).toEqual([]);+ });++ it("blocks when the account is the only owner of a shared workspace", () => {+ const plan = planAccountDeletion([+ membership({ memberCount: 3, ownerCount: 1 }),+ ]);++ expect(plan.blockedWorkspaceNames).toEqual(["Acme"]);+ expect(plan.workspaceIdsToDelete).toEqual([]);+ expect(plan.workspaceIdsToLeave).toEqual([]);+ });++ it("leaves a shared workspace that keeps another owner", () => {+ const plan = planAccountDeletion([+ membership({ memberCount: 3, ownerCount: 2 }),+ ]);++ expect(plan.workspaceIdsToLeave).toEqual(["workspace-1"]);+ expect(plan.blockedWorkspaceNames).toEqual([]);+ });++ it("leaves workspaces the account does not own", () => {+ const plan = planAccountDeletion([+ membership({ isOwner: false, memberCount: 4, ownerCount: 1 }),+ ]);++ expect(plan.workspaceIdsToLeave).toEqual(["workspace-1"]);+ });++ it("plans each workspace independently", () => {+ const plan = planAccountDeletion([+ membership({ workspaceId: "solo" }),+ membership({+ workspaceId: "shared",+ workspaceName: "Shared",+ memberCount: 2,+ ownerCount: 1,+ }),+ membership({+ workspaceId: "guest",+ isOwner: false,+ memberCount: 5,+ ownerCount: 1,+ }),+ ]);++ expect(plan.workspaceIdsToDelete).toEqual(["solo"]);+ expect(plan.blockedWorkspaceNames).toEqual(["Shared"]);+ expect(plan.workspaceIdsToLeave).toEqual(["guest"]);+ });++ it("returns an empty plan for an account without workspaces", () => {+ expect(planAccountDeletion([])).toEqual({+ blockedWorkspaceNames: [],+ workspaceIdsToDelete: [],+ workspaceIdsToLeave: [],+ });+ });+});++describe("formatBlockedWorkspacesMessage", () => {+ it("names a single workspace", () => {+ expect(formatBlockedWorkspacesMessage(["Acme"])).toBe(+ 'You are the only owner of "Acme". Transfer ownership or delete it before deleting your account.',+ );+ });++ it("joins several workspaces", () => {+ expect(formatBlockedWorkspacesMessage(["Acme", "Globex", "Initech"])).toBe(+ 'You are the only owner of "Acme", "Globex" and "Initech". Transfer ownership or delete them before deleting your account.',+ );+ });+});diff --git a/tests/api/user/avatar.test.ts b/tests/api/user/avatar.test.tsnew file mode 100644index 000000000..277b7cda5--- /dev/null+++ b/tests/api/user/avatar.test.ts@@ -0,0 +1,121 @@+import { describe, expect, it } from "vitest";+import {+ buildAvatarUrl,+ decodeAvatarUpload,+ MAX_AVATAR_BYTES,+ normalizeAvatarMimeType,+} from "../../../apps/api/src/user/avatar";++const PNG_HEADER = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];++function encode(bytes: number[]) {+ return Buffer.from(bytes).toString("base64");+}++function pngOfSize(size: number) {+ const bytes = Buffer.alloc(size);+ Buffer.from(PNG_HEADER).copy(bytes);+ return bytes.toString("base64");+}++describe("decodeAvatarUpload", () => {+ it("accepts a PNG upload", () => {+ const result = decodeAvatarUpload({+ contentType: "image/png",+ data: encode([...PNG_HEADER, 1, 2, 3]),+ });++ expect(result.mimeType).toBe("image/png");+ expect(result.bytes.length).toBe(11);+ });++ it("accepts a JPEG upload", () => {+ const result = decodeAvatarUpload({+ contentType: "image/jpeg",+ data: encode([0xff, 0xd8, 0xff, 0xe0, 0x00]),+ });++ expect(result.mimeType).toBe("image/jpeg");+ });++ it("accepts a WebP upload", () => {+ const riff = Buffer.concat([+ Buffer.from("RIFF", "ascii"),+ Buffer.from([0x00, 0x00, 0x00, 0x00]),+ Buffer.from("WEBP", "ascii"),+ Buffer.from([0x00]),+ ]);++ const result = decodeAvatarUpload({+ contentType: "image/webp",+ data: riff.toString("base64"),+ });++ expect(result.mimeType).toBe("image/webp");+ });++ it("normalizes image/jpg to image/jpeg", () => {+ expect(normalizeAvatarMimeType("IMAGE/JPG")).toBe("image/jpeg");++ const result = decodeAvatarUpload({+ contentType: "image/jpg",+ data: encode([0xff, 0xd8, 0xff, 0x00]),+ });++ expect(result.mimeType).toBe("image/jpeg");+ });++ it("strips a data URL prefix", () => {+ const result = decodeAvatarUpload({+ contentType: "image/png",+ data: `data:image/png;base64,${encode(PNG_HEADER)}`,+ });++ expect(result.bytes.length).toBe(8);+ });++ it("rejects an unsupported image type", () => {+ expect(() =>+ decodeAvatarUpload({+ contentType: "image/svg+xml",+ data: encode(PNG_HEADER),+ }),+ ).toThrow(/Unsupported image type/);+ });++ it("rejects data that is not valid base64", () => {+ expect(() =>+ decodeAvatarUpload({ contentType: "image/png", data: "not base64!!" }),+ ).toThrow(/base64/);+ });++ it("rejects empty data", () => {+ expect(() =>+ decodeAvatarUpload({ contentType: "image/png", data: "" }),+ ).toThrow(/base64/);+ });++ it("rejects uploads above the size limit", () => {+ expect(() =>+ decodeAvatarUpload({+ contentType: "image/png",+ data: pngOfSize(MAX_AVATAR_BYTES + 1),+ }),+ ).toThrow(/maximum avatar size/);+ });++ it("rejects bytes that do not match the declared type", () => {+ expect(() =>+ decodeAvatarUpload({+ contentType: "image/png",+ data: Buffer.from("<html>hello</html>").toString("base64"),+ }),+ ).toThrow(/does not match the declared/);+ });+});++describe("buildAvatarUrl", () => {+ it("builds an API-relative URL", () => {+ expect(buildAvatarUrl("abc123")).toBe("/api/user/avatar/abc123");+ });+});