Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🗃️ feat(database): workspace share link invitations (#22245)

Rdmclin2bb6f96cf6a22
diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbml
index b69cf73d987..04ac7def035 100644
--- a/docs/development/database-schema.dbml
+++ b/docs/development/database-schema.dbml
@@ -5521,7 +5521,8 @@ table workspace_invitations {
role text [not null, default: 'member']
token text [not null, unique]
status text [not null, default: 'pending']
- expires_at "timestamp with time zone" [not null]
+ reusable boolean [not null, default: false]
+ expires_at "timestamp with time zone"
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
@@ -5530,6 +5531,7 @@ table workspace_invitations {
inviter_id [name: 'workspace_invitations_inviter_id_idx']
email [name: 'workspace_invitations_email_idx']
token [name: 'workspace_invitations_token_idx']
+
}
}
diff --git a/packages/database/migrations/0204_workspace_invitation_link.sql b/packages/database/migrations/0204_workspace_invitation_link.sql
new file mode 100644
index 00000000000..45f300f6f01
--- /dev/null
+++ b/packages/database/migrations/0204_workspace_invitation_link.sql
@@ -0,0 +1,5 @@
+ALTER TABLE "workspace_invitations" ALTER COLUMN "expires_at" DROP NOT NULL;--> statement-breakpoint
+ALTER TABLE "workspace_invitations" ADD COLUMN IF NOT EXISTS "reusable" boolean DEFAULT false NOT NULL;--> statement-breakpoint
+DO $$ BEGIN
+ ALTER TABLE "workspace_invitations" ADD CONSTRAINT "workspace_invitations_expiry_required" CHECK ("workspace_invitations"."reusable" OR "workspace_invitations"."expires_at" IS NOT NULL);
+EXCEPTION WHEN duplicate_object THEN NULL; END $$;
diff --git a/packages/database/migrations/meta/0194_snapshot.json b/packages/database/migrations/meta/0204_snapshot.json
similarity index 96%
rename from packages/database/migrations/meta/0194_snapshot.json
rename to packages/database/migrations/meta/0204_snapshot.json
index 52be84e2eea..a8b0a2ee623 100644
--- a/packages/database/migrations/meta/0194_snapshot.json
+++ b/packages/database/migrations/meta/0204_snapshot.json
@@ -6,9 +6,9 @@
},
"dialect": "postgresql",
"enums": {},
- "id": "180656bc-dfba-4351-8bba-5c66cd31a299",
+ "id": "f22d5caf-0104-4f65-9ab8-8f6823ea199e",
"policies": {},
- "prevId": "0504dd92-6a40-4f7b-97be-7a6f934887c0",
+ "prevId": "ebab7fa5-987a-48f1-81d0-c4262738714d",
"roles": {},
"schemas": {},
"sequences": {
@@ -7162,6 +7162,388 @@
"checkConstraints": {},
"isRLSEnabled": false
},
+ "public.agent_device_account_bindings": {
+ "name": "agent_device_account_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "agent_device_account_bindings_agent_device_unique": {
+ "name": "agent_device_account_bindings_agent_device_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_device_account_bindings_device_id_idx": {
+ "name": "agent_device_account_bindings_device_id_idx",
+ "columns": [
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_device_account_bindings_account_device_idx": {
+ "name": "agent_device_account_bindings_account_device_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_device_account_bindings_user_id_idx": {
+ "name": "agent_device_account_bindings_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_device_account_bindings_workspace_id_idx": {
+ "name": "agent_device_account_bindings_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_device_account_bindings_agent_id_agents_id_fk": {
+ "name": "agent_device_account_bindings_agent_id_agents_id_fk",
+ "tableFrom": "agent_device_account_bindings",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_device_account_bindings_user_id_users_id_fk": {
+ "name": "agent_device_account_bindings_user_id_users_id_fk",
+ "tableFrom": "agent_device_account_bindings",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_device_account_bindings_workspace_id_workspaces_id_fk": {
+ "name": "agent_device_account_bindings_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_device_account_bindings",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_device_account_bindings_device_id_devices_id_fk": {
+ "name": "agent_device_account_bindings_device_id_devices_id_fk",
+ "tableFrom": "agent_device_account_bindings",
+ "tableTo": "devices",
+ "columnsFrom": ["device_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_device_account_bindings_account_id_agent_provider_accounts_id_fk": {
+ "name": "agent_device_account_bindings_account_id_agent_provider_accounts_id_fk",
+ "tableFrom": "agent_device_account_bindings",
+ "tableTo": "agent_provider_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_device_account_bindings_login_fk": {
+ "name": "agent_device_account_bindings_login_fk",
+ "tableFrom": "agent_device_account_bindings",
+ "tableTo": "agent_provider_account_logins",
+ "columnsFrom": ["account_id", "device_id"],
+ "columnsTo": ["account_id", "device_id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_provider_account_logins": {
+ "name": "agent_provider_account_logins",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_seen_at": {
+ "name": "first_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "agent_provider_account_logins_device_id_idx": {
+ "name": "agent_provider_account_logins_device_id_idx",
+ "columns": [
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_provider_account_logins_user_id_idx": {
+ "name": "agent_provider_account_logins_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_provider_account_logins_workspace_id_idx": {
+ "name": "agent_provider_account_logins_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_provider_account_logins_account_id_agent_provider_accounts_id_fk": {
+ "name": "agent_provider_account_logins_account_id_agent_provider_accounts_id_fk",
+ "tableFrom": "agent_provider_account_logins",
+ "tableTo": "agent_provider_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_provider_account_logins_device_id_devices_id_fk": {
+ "name": "agent_provider_account_logins_device_id_devices_id_fk",
+ "tableFrom": "agent_provider_account_logins",
+ "tableTo": "devices",
+ "columnsFrom": ["device_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_provider_account_logins_user_id_users_id_fk": {
+ "name": "agent_provider_account_logins_user_id_users_id_fk",
+ "tableFrom": "agent_provider_account_logins",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_provider_account_logins_workspace_id_workspaces_id_fk": {
+ "name": "agent_provider_account_logins_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_provider_account_logins",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_provider_account_logins_account_device_unique": {
+ "name": "agent_provider_account_logins_account_device_unique",
+ "nullsNotDistinct": false,
+ "columns": ["account_id", "device_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
"public.agent_provider_accounts": {
"name": "agent_provider_accounts",
"schema": "",
@@ -7185,6 +7567,13 @@
"primaryKey": false,
"notNull": false
},
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
"provider": {
"name": "provider",
"type": "text",
@@ -7337,6 +7726,33 @@
"method": "btree",
"with": {}
},
+ "agent_provider_accounts_workspace_visibility_idx": {
+ "name": "agent_provider_accounts_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
"agent_provider_accounts_token_expires_at_idx": {
"name": "agent_provider_accounts_token_expires_at_idx",
"columns": [
@@ -10343,13 +10759,6 @@
"primaryKey": false,
"notNull": true
},
- "delivery_key": {
- "name": "delivery_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'initial'"
- },
"status": {
"name": "status",
"type": "text",
@@ -10491,12 +10900,6 @@
"isExpression": false,
"asc": true,
"nulls": "last"
- },
- {
- "expression": "delivery_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
}
],
"isUnique": true,
@@ -11700,6 +12103,12 @@
"notNull": true,
"default": "'private'"
},
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
"metadata": {
"name": "metadata",
"type": "jsonb",
@@ -19832,6 +20241,19 @@
"primaryKey": false,
"notNull": false
},
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
"deleted_at": {
"name": "deleted_at",
"type": "timestamp with time zone",
@@ -19890,6 +20312,33 @@
"method": "btree",
"with": {}
},
+ "goals_workspace_visibility_idx": {
+ "name": "goals_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
"goals_agent_id_idx": {
"name": "goals_agent_id_idx",
"columns": [
@@ -28560,6 +29009,12 @@
"primaryKey": false,
"notNull": false
},
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
"accessed_at": {
"name": "accessed_at",
"type": "timestamp with time zone",
@@ -36366,118 +36821,482 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.threads": {
- "name": "threads",
+ "public.task_label_links": {
+ "name": "task_label_links",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "text",
+ "type": "uuid",
"primaryKey": true,
- "notNull": true
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "gen_random_uuid()"
},
- "content": {
- "name": "content",
+ "task_id": {
+ "name": "task_id",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "editor_data": {
- "name": "editor_data",
- "type": "jsonb",
+ "label_id": {
+ "name": "label_id",
+ "type": "uuid",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "type": {
- "name": "type",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "status": {
- "name": "status",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "topic_id": {
- "name": "topic_id",
- "type": "text",
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_label_links_task_id_label_id_unique": {
+ "name": "task_label_links_task_id_label_id_unique",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "label_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
},
- "source_message_id": {
- "name": "source_message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
+ "task_label_links_label_id_idx": {
+ "name": "task_label_links_label_id_idx",
+ "columns": [
+ {
+ "expression": "label_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
},
- "parent_thread_id": {
- "name": "parent_thread_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
+ "task_label_links_user_id_idx": {
+ "name": "task_label_links_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
},
- "client_id": {
- "name": "client_id",
+ "task_label_links_workspace_id_idx": {
+ "name": "task_label_links_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_label_links_task_id_tasks_id_fk": {
+ "name": "task_label_links_task_id_tasks_id_fk",
+ "tableFrom": "task_label_links",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_label_links_label_id_task_labels_id_fk": {
+ "name": "task_label_links_label_id_task_labels_id_fk",
+ "tableFrom": "task_label_links",
+ "tableTo": "task_labels",
+ "columnsFrom": ["label_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_label_links_user_id_users_id_fk": {
+ "name": "task_label_links_user_id_users_id_fk",
+ "tableFrom": "task_label_links",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_label_links_workspace_id_workspaces_id_fk": {
+ "name": "task_label_links_workspace_id_workspaces_id_fk",
+ "tableFrom": "task_label_links",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_labels": {
+ "name": "task_labels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "agent_id": {
- "name": "agent_id",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "group_id": {
- "name": "group_id",
- "type": "text",
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": false
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
+ "is_group": {
+ "name": "is_group",
+ "type": "boolean",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": false
},
- "user_id": {
- "name": "user_id",
+ "name": {
+ "name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "last_active_at": {
- "name": "last_active_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "workspace_id": {
- "name": "workspace_id",
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
+ "color": {
+ "name": "color",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "is_deleted": {
- "name": "is_deleted",
- "type": "boolean",
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "task_labels_user_id_idx": {
+ "name": "task_labels_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_labels_workspace_id_idx": {
+ "name": "task_labels_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_labels_parent_id_idx": {
+ "name": "task_labels_parent_id_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_labels_user_id_name_unique": {
+ "name": "task_labels_user_id_name_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"name\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"task_labels\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_labels_workspace_id_name_unique": {
+ "name": "task_labels_workspace_id_name_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"name\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"task_labels\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_labels_user_id_users_id_fk": {
+ "name": "task_labels_user_id_users_id_fk",
+ "tableFrom": "task_labels",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "task_labels_workspace_id_workspaces_id_fk": {
+ "name": "task_labels_workspace_id_workspaces_id_fk",
+ "tableFrom": "task_labels",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_labels_parent_id_task_labels_id_fk": {
+ "name": "task_labels_parent_id_task_labels_id_fk",
+ "tableFrom": "task_labels",
+ "tableTo": "task_labels",
+ "columnsFrom": ["parent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.threads": {
+ "name": "threads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_message_id": {
+ "name": "source_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_thread_id": {
+ "name": "parent_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_active_at": {
+ "name": "last_active_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
},
"accessed_at": {
"name": "accessed_at",
@@ -37545,6 +38364,305 @@
"checkConstraints": {},
"isRLSEnabled": false
},
+ "public.topic_analyses": {
+ "name": "topic_analyses",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "taxonomy_version": {
+ "name": "taxonomy_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secondary_category": {
+ "name": "secondary_category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labels": {
+ "name": "labels",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_model": {
+ "name": "topic_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_provider": {
+ "name": "topic_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens": {
+ "name": "total_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_input_tokens": {
+ "name": "total_input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_output_tokens": {
+ "name": "total_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "llm_calls": {
+ "name": "llm_calls",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_calls": {
+ "name": "tool_calls",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_messages": {
+ "name": "user_messages",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assistant_messages": {
+ "name": "assistant_messages",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_id": {
+ "name": "last_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_updated_at": {
+ "name": "last_message_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "topic_analyses_topic_version_unique": {
+ "name": "topic_analyses_topic_version_unique",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "taxonomy_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_analyses_user_id_created_at_idx": {
+ "name": "topic_analyses_user_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_analyses_workspace_id_created_at_idx": {
+ "name": "topic_analyses_workspace_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"topic_analyses\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_analyses_version_category_idx": {
+ "name": "topic_analyses_version_category_idx",
+ "columns": [
+ {
+ "expression": "taxonomy_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "topic_analyses_topic_id_topics_id_fk": {
+ "name": "topic_analyses_topic_id_topics_id_fk",
+ "tableFrom": "topic_analyses",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_analyses_user_id_users_id_fk": {
+ "name": "topic_analyses_user_id_users_id_fk",
+ "tableFrom": "topic_analyses",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_analyses_workspace_id_workspaces_id_fk": {
+ "name": "topic_analyses_workspace_id_workspaces_id_fk",
+ "tableFrom": "topic_analyses",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
"public.topic_comment_mentions": {
"name": "topic_comment_mentions",
"schema": "",
@@ -38662,8 +39780,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.user_memories": {
- "name": "user_memories",
+ "public.user_memories_activities": {
+ "name": "user_memories_activities",
"schema": "",
"columns": {
"id": {
@@ -38678,84 +39796,115 @@
"primaryKey": false,
"notNull": false
},
- "memory_category": {
- "name": "memory_category",
+ "user_memory_id": {
+ "name": "user_memory_id",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
- "memory_layer": {
- "name": "memory_layer",
- "type": "varchar(255)",
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "memory_type": {
- "name": "memory_type",
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "timezone": {
+ "name": "timezone",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
- "metadata": {
- "name": "metadata",
+ "starts_at": {
+ "name": "starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ends_at": {
+ "name": "ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "associated_objects": {
+ "name": "associated_objects",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "tags": {
- "name": "tags",
- "type": "text[]",
+ "associated_subjects": {
+ "name": "associated_subjects",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "title": {
- "name": "title",
- "type": "varchar(255)",
+ "associated_locations": {
+ "name": "associated_locations",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "summary": {
- "name": "summary",
+ "notes": {
+ "name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "summary_vector_1024": {
- "name": "summary_vector_1024",
+ "narrative": {
+ "name": "narrative",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "narrative_vector": {
+ "name": "narrative_vector",
"type": "vector(1024)",
"primaryKey": false,
"notNull": false
},
- "details": {
- "name": "details",
+ "feedback": {
+ "name": "feedback",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "details_vector_1024": {
- "name": "details_vector_1024",
+ "feedback_vector": {
+ "name": "feedback_vector",
"type": "vector(1024)",
"primaryKey": false,
"notNull": false
},
- "status": {
- "name": "status",
+ "dossier_id": {
+ "name": "dossier_id",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
- "accessed_count": {
- "name": "accessed_count",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false,
- "default": 0
- },
- "last_accessed_at": {
- "name": "last_accessed_at",
- "type": "timestamp with time zone",
+ "injectable": {
+ "name": "injectable",
+ "type": "boolean",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": true
},
"captured_at": {
"name": "captured_at",
@@ -38764,18 +39913,6 @@
"notNull": true,
"default": "now()"
},
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "is_deleted": {
- "name": "is_deleted",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
"accessed_at": {
"name": "accessed_at",
"type": "timestamp with time zone",
@@ -38799,11 +39936,11 @@
}
},
"indexes": {
- "user_memories_summary_vector_1024_index": {
- "name": "user_memories_summary_vector_1024_index",
+ "user_memories_activities_narrative_vector_index": {
+ "name": "user_memories_activities_narrative_vector_index",
"columns": [
{
- "expression": "summary_vector_1024",
+ "expression": "narrative_vector",
"isExpression": false,
"asc": true,
"nulls": "last",
@@ -38815,11 +39952,11 @@
"method": "hnsw",
"with": {}
},
- "user_memories_details_vector_1024_index": {
- "name": "user_memories_details_vector_1024_index",
+ "user_memories_activities_feedback_vector_index": {
+ "name": "user_memories_activities_feedback_vector_index",
"columns": [
{
- "expression": "details_vector_1024",
+ "expression": "feedback_vector",
"isExpression": false,
"asc": true,
"nulls": "last",
@@ -38831,8 +39968,23 @@
"method": "hnsw",
"with": {}
},
- "user_memories_user_id_index": {
- "name": "user_memories_user_id_index",
+ "user_memories_activities_type_index": {
+ "name": "user_memories_activities_type_index",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_activities_user_id_index": {
+ "name": "user_memories_activities_user_id_index",
"columns": [
{
"expression": "user_id",
@@ -38845,17 +39997,81 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "user_memories_activities_user_memory_id_index": {
+ "name": "user_memories_activities_user_memory_id_index",
+ "columns": [
+ {
+ "expression": "user_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_activities_status_index": {
+ "name": "user_memories_activities_status_index",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_activities_dossier_id_index": {
+ "name": "user_memories_activities_dossier_id_index",
+ "columns": [
+ {
+ "expression": "dossier_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"user_memories_activities\".\"dossier_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
- "user_memories_user_id_users_id_fk": {
- "name": "user_memories_user_id_users_id_fk",
- "tableFrom": "user_memories",
+ "user_memories_activities_user_id_users_id_fk": {
+ "name": "user_memories_activities_user_id_users_id_fk",
+ "tableFrom": "user_memories_activities",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "user_memories_activities_user_memory_id_user_memories_id_fk": {
+ "name": "user_memories_activities_user_memory_id_user_memories_id_fk",
+ "tableFrom": "user_memories_activities",
+ "tableTo": "user_memories",
+ "columnsFrom": ["user_memory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memories_activities_dossier_id_user_memories_dossiers_id_fk": {
+ "name": "user_memories_activities_dossier_id_user_memories_dossiers_id_fk",
+ "tableFrom": "user_memories_activities",
+ "tableTo": "user_memories_dossiers",
+ "columnsFrom": ["dossier_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -38864,8 +40080,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.user_memories_activities": {
- "name": "user_memories_activities",
+ "public.user_memories": {
+ "name": "user_memories",
"schema": "",
"columns": {
"id": {
@@ -38880,8 +40096,20 @@
"primaryKey": false,
"notNull": false
},
- "user_memory_id": {
- "name": "user_memory_id",
+ "memory_category": {
+ "name": "memory_category",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_layer": {
+ "name": "memory_layer",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_type": {
+ "name": "memory_type",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
@@ -38898,84 +40126,67 @@
"primaryKey": false,
"notNull": false
},
- "type": {
- "name": "type",
- "type": "varchar(255)",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "varchar(255)",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "timezone": {
- "name": "timezone",
+ "title": {
+ "name": "title",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
- "starts_at": {
- "name": "starts_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "ends_at": {
- "name": "ends_at",
- "type": "timestamp with time zone",
+ "summary": {
+ "name": "summary",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "associated_objects": {
- "name": "associated_objects",
- "type": "jsonb",
+ "summary_vector_1024": {
+ "name": "summary_vector_1024",
+ "type": "vector(1024)",
"primaryKey": false,
"notNull": false
},
- "associated_subjects": {
- "name": "associated_subjects",
- "type": "jsonb",
+ "details": {
+ "name": "details",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "associated_locations": {
- "name": "associated_locations",
- "type": "jsonb",
+ "details_vector_1024": {
+ "name": "details_vector_1024",
+ "type": "vector(1024)",
"primaryKey": false,
"notNull": false
},
- "notes": {
- "name": "notes",
- "type": "text",
+ "status": {
+ "name": "status",
+ "type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
- "narrative": {
- "name": "narrative",
+ "state": {
+ "name": "state",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "narrative_vector": {
- "name": "narrative_vector",
- "type": "vector(1024)",
+ "user_locked": {
+ "name": "user_locked",
+ "type": "boolean",
"primaryKey": false,
- "notNull": false
+ "notNull": false,
+ "default": false
},
- "feedback": {
- "name": "feedback",
- "type": "text",
+ "accessed_count": {
+ "name": "accessed_count",
+ "type": "bigint",
"primaryKey": false,
- "notNull": false
+ "notNull": false,
+ "default": 0
},
- "feedback_vector": {
- "name": "feedback_vector",
- "type": "vector(1024)",
+ "last_accessed_at": {
+ "name": "last_accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
"captured_at": {
"name": "captured_at",
@@ -38984,6 +40195,18 @@
"notNull": true,
"default": "now()"
},
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
"accessed_at": {
"name": "accessed_at",
"type": "timestamp with time zone",
@@ -39007,11 +40230,11 @@
}
},
"indexes": {
- "user_memories_activities_narrative_vector_index": {
- "name": "user_memories_activities_narrative_vector_index",
+ "user_memories_summary_vector_1024_index": {
+ "name": "user_memories_summary_vector_1024_index",
"columns": [
{
- "expression": "narrative_vector",
+ "expression": "summary_vector_1024",
"isExpression": false,
"asc": true,
"nulls": "last",
@@ -39023,11 +40246,11 @@
"method": "hnsw",
"with": {}
},
- "user_memories_activities_feedback_vector_index": {
- "name": "user_memories_activities_feedback_vector_index",
+ "user_memories_details_vector_1024_index": {
+ "name": "user_memories_details_vector_1024_index",
"columns": [
{
- "expression": "feedback_vector",
+ "expression": "details_vector_1024",
"isExpression": false,
"asc": true,
"nulls": "last",
@@ -39039,23 +40262,8 @@
"method": "hnsw",
"with": {}
},
- "user_memories_activities_type_index": {
- "name": "user_memories_activities_type_index",
- "columns": [
- {
- "expression": "type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "user_memories_activities_user_id_index": {
- "name": "user_memories_activities_user_id_index",
+ "user_memories_user_id_index": {
+ "name": "user_memories_user_id_index",
"columns": [
{
"expression": "user_id",
@@ -39068,56 +40276,17 @@
"concurrently": false,
"method": "btree",
"with": {}
- },
- "user_memories_activities_user_memory_id_index": {
- "name": "user_memories_activities_user_memory_id_index",
- "columns": [
- {
- "expression": "user_memory_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "user_memories_activities_status_index": {
- "name": "user_memories_activities_status_index",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
}
},
"foreignKeys": {
- "user_memories_activities_user_id_users_id_fk": {
- "name": "user_memories_activities_user_id_users_id_fk",
- "tableFrom": "user_memories_activities",
+ "user_memories_user_id_users_id_fk": {
+ "name": "user_memories_user_id_users_id_fk",
+ "tableFrom": "user_memories",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
- },
- "user_memories_activities_user_memory_id_user_memories_id_fk": {
- "name": "user_memories_activities_user_memory_id_user_memories_id_fk",
- "tableFrom": "user_memories_activities",
- "tableTo": "user_memories",
- "columnsFrom": ["user_memory_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -39307,6 +40476,12 @@
"primaryKey": false,
"notNull": false
},
+ "user_memory_id": {
+ "name": "user_memory_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
"user_memory_ids": {
"name": "user_memory_ids",
"type": "jsonb",
@@ -39381,6 +40556,42 @@
"notNull": false,
"default": 0
},
+ "now": {
+ "name": "now",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_steps": {
+ "name": "next_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "open_questions": {
+ "name": "open_questions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_seen_at": {
+ "name": "first_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_evidence_at": {
+ "name": "last_evidence_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "synthesized_at": {
+ "name": "synthesized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
"captured_at": {
"name": "captured_at",
"type": "timestamp with time zone",
@@ -39471,6 +40682,42 @@
"concurrently": false,
"method": "gin",
"with": {}
+ },
+ "user_memories_contexts_user_memory_id_index": {
+ "name": "user_memories_contexts_user_memory_id_index",
+ "columns": [
+ {
+ "expression": "user_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_contexts_user_id_last_evidence_at_index": {
+ "name": "user_memories_contexts_user_id_last_evidence_at_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "last_evidence_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
@@ -39482,6 +40729,15 @@
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "user_memories_contexts_user_memory_id_user_memories_id_fk": {
+ "name": "user_memories_contexts_user_memory_id_user_memories_id_fk",
+ "tableFrom": "user_memories_contexts",
+ "tableTo": "user_memories",
+ "columnsFrom": ["user_memory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -40856,6 +42112,12 @@
"primaryKey": false,
"notNull": false
},
+ "entity_id": {
+ "name": "entity_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
"captured_at": {
"name": "captured_at",
"type": "timestamp with time zone",
@@ -40946,6 +42208,21 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "user_memories_identities_entity_id_index": {
+ "name": "user_memories_identities_entity_id_index",
+ "columns": [
+ {
+ "expression": "entity_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
@@ -40966,6 +42243,15 @@
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "user_memories_identities_entity_id_user_memories_entities_id_fk": {
+ "name": "user_memories_identities_entity_id_user_memories_entities_id_fk",
+ "tableFrom": "user_memories_identities",
+ "tableTo": "user_memories_entities",
+ "columnsFrom": ["entity_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -41085,203 +42371,23 @@
}
},
"indexes": {
- "user_memories_operations_user_id_state_created_at_index": {
- "name": "user_memories_operations_user_id_state_created_at_index",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "user_memories_operations_workspace_id_state_created_at_index": {
- "name": "user_memories_operations_workspace_id_state_created_at_index",
- "columns": [
- {
- "expression": "workspace_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_memories_operations_user_id_users_id_fk": {
- "name": "user_memories_operations_user_id_users_id_fk",
- "tableFrom": "user_memories_operations",
- "tableTo": "users",
- "columnsFrom": ["user_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "user_memories_operations_workspace_id_workspaces_id_fk": {
- "name": "user_memories_operations_workspace_id_workspaces_id_fk",
- "tableFrom": "user_memories_operations",
- "tableTo": "workspaces",
- "columnsFrom": ["workspace_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_memories_preferences": {
- "name": "user_memories_preferences",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "varchar(255)",
- "primaryKey": true,
- "notNull": true
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_memory_id": {
- "name": "user_memory_id",
- "type": "varchar(255)",
- "primaryKey": false,
- "notNull": false
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "tags": {
- "name": "tags",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "conclusion_directives": {
- "name": "conclusion_directives",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "conclusion_directives_vector": {
- "name": "conclusion_directives_vector",
- "type": "vector(1024)",
- "primaryKey": false,
- "notNull": false
- },
- "type": {
- "name": "type",
- "type": "varchar(255)",
- "primaryKey": false,
- "notNull": false
- },
- "suggestions": {
- "name": "suggestions",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "score_priority": {
- "name": "score_priority",
- "type": "numeric",
- "primaryKey": false,
- "notNull": false,
- "default": 0
- },
- "captured_at": {
- "name": "captured_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "accessed_at": {
- "name": "accessed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "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": {
- "user_memories_preferences_conclusion_directives_vector_index": {
- "name": "user_memories_preferences_conclusion_directives_vector_index",
+ "user_memories_operations_user_id_state_created_at_index": {
+ "name": "user_memories_operations_user_id_state_created_at_index",
"columns": [
{
- "expression": "conclusion_directives_vector",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "vector_cosine_ops"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "hnsw",
- "with": {}
- },
- "user_memories_preferences_user_id_index": {
- "name": "user_memories_preferences_user_id_index",
- "columns": [
+ "nulls": "last"
+ },
{
- "expression": "user_id",
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -41292,11 +42398,23 @@
"method": "btree",
"with": {}
},
- "user_memories_preferences_user_memory_id_index": {
- "name": "user_memories_preferences_user_memory_id_index",
+ "user_memories_operations_workspace_id_state_created_at_index": {
+ "name": "user_memories_operations_workspace_id_state_created_at_index",
"columns": [
{
- "expression": "user_memory_id",
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -41309,20 +42427,20 @@
}
},
"foreignKeys": {
- "user_memories_preferences_user_id_users_id_fk": {
- "name": "user_memories_preferences_user_id_users_id_fk",
- "tableFrom": "user_memories_preferences",
+ "user_memories_operations_user_id_users_id_fk": {
+ "name": "user_memories_operations_user_id_users_id_fk",
+ "tableFrom": "user_memories_operations",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "user_memories_preferences_user_memory_id_user_memories_id_fk": {
- "name": "user_memories_preferences_user_memory_id_user_memories_id_fk",
- "tableFrom": "user_memories_preferences",
- "tableTo": "user_memories",
- "columnsFrom": ["user_memory_id"],
+ "user_memories_operations_workspace_id_workspaces_id_fk": {
+ "name": "user_memories_operations_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_memories_operations",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
@@ -41688,6 +42806,259 @@
"checkConstraints": {},
"isRLSEnabled": false
},
+ "public.user_memories_preferences": {
+ "name": "user_memories_preferences",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_memory_id": {
+ "name": "user_memory_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conclusion_directives": {
+ "name": "conclusion_directives",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conclusion_directives_vector": {
+ "name": "conclusion_directives_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suggestions": {
+ "name": "suggestions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "score_priority": {
+ "name": "score_priority",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "holder_entity_id": {
+ "name": "holder_entity_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applies_to_entity_id": {
+ "name": "applies_to_entity_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence_source": {
+ "name": "evidence_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence_count": {
+ "name": "evidence_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_evidence_at": {
+ "name": "last_evidence_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "user_memories_preferences_conclusion_directives_vector_index": {
+ "name": "user_memories_preferences_conclusion_directives_vector_index",
+ "columns": [
+ {
+ "expression": "conclusion_directives_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_preferences_user_id_index": {
+ "name": "user_memories_preferences_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_preferences_user_memory_id_index": {
+ "name": "user_memories_preferences_user_memory_id_index",
+ "columns": [
+ {
+ "expression": "user_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_preferences_holder_entity_id_index": {
+ "name": "user_memories_preferences_holder_entity_id_index",
+ "columns": [
+ {
+ "expression": "holder_entity_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_preferences_applies_to_entity_id_index": {
+ "name": "user_memories_preferences_applies_to_entity_id_index",
+ "columns": [
+ {
+ "expression": "applies_to_entity_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memories_preferences_user_id_users_id_fk": {
+ "name": "user_memories_preferences_user_id_users_id_fk",
+ "tableFrom": "user_memories_preferences",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memories_preferences_user_memory_id_user_memories_id_fk": {
+ "name": "user_memories_preferences_user_memory_id_user_memories_id_fk",
+ "tableFrom": "user_memories_preferences",
+ "tableTo": "user_memories",
+ "columnsFrom": ["user_memory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memories_preferences_holder_entity_id_user_memories_entities_id_fk": {
+ "name": "user_memories_preferences_holder_entity_id_user_memories_entities_id_fk",
+ "tableFrom": "user_memories_preferences",
+ "tableTo": "user_memories_entities",
+ "columnsFrom": ["holder_entity_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "user_memories_preferences_applies_to_entity_id_user_memories_entities_id_fk": {
+ "name": "user_memories_preferences_applies_to_entity_id_user_memories_entities_id_fk",
+ "tableFrom": "user_memories_preferences",
+ "tableTo": "user_memories_entities",
+ "columnsFrom": ["applies_to_entity_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
"public.acceptances": {
"name": "acceptances",
"schema": "",
@@ -45846,11 +47217,18 @@
"notNull": true,
"default": "'pending'"
},
+ "reusable": {
+ "name": "reusable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
"expires_at": {
"name": "expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
"created_at": {
"name": "created_at",
@@ -45958,7 +47336,12 @@
}
},
"policies": {},
- "checkConstraints": {},
+ "checkConstraints": {
+ "workspace_invitations_expiry_required": {
+ "name": "workspace_invitations_expiry_required",
+ "value": "\"workspace_invitations\".\"reusable\" OR \"workspace_invitations\".\"expires_at\" IS NOT NULL"
+ }
+ },
"isRLSEnabled": false
},
"public.workspace_members": {
diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.json
index d246bf8ea58..a5520ca0f50 100644
--- a/packages/database/migrations/meta/_journal.json
+++ b/packages/database/migrations/meta/_journal.json
@@ -1428,6 +1428,13 @@
"when": 1793815529290,
"tag": "0203_project_site_last_seen",
"breakpoints": true
+ },
+ {
+ "idx": 204,
+ "version": "7",
+ "when": 1793869041794,
+ "tag": "0204_workspace_invitation_link",
+ "breakpoints": true
}
],
"version": "6"
diff --git a/packages/database/src/models/__tests__/workspaceMember.test.ts b/packages/database/src/models/__tests__/workspaceMember.test.ts
index ec005bec8f8..99fce205b09 100644
--- a/packages/database/src/models/__tests__/workspaceMember.test.ts
+++ b/packages/database/src/models/__tests__/workspaceMember.test.ts
@@ -653,6 +653,28 @@ describe('WorkspaceMemberModel', () => {
expect(a.token).not.toBe(b.token);
});
+
+ it('allows a null expiry only on reusable invitations (database check constraint)', async () => {
+ await expect(
+ serverDB.insert(workspaceInvitations).values({
+ inviterId,
+ token: 'single-use-without-expiry',
+ workspaceId,
+ }),
+ ).rejects.toThrow();
+
+ const [link] = await serverDB
+ .insert(workspaceInvitations)
+ .values({ inviterId, reusable: true, token: 'link-without-expiry', workspaceId })
+ .returning();
+ expect(link).toMatchObject({ expiresAt: null, reusable: true });
+
+ const single = await new WorkspaceMemberModel(serverDB, inviterId).createInvitation({
+ workspaceId,
+ });
+ expect(single.reusable).toBe(false);
+ expect(single.expiresAt).toBeInstanceOf(Date);
+ });
});
describe('findInvitationByToken', () => {
diff --git a/packages/database/src/schemas/workspace.ts b/packages/database/src/schemas/workspace.ts
index d06764c22d8..834b260198e 100644
--- a/packages/database/src/schemas/workspace.ts
+++ b/packages/database/src/schemas/workspace.ts
@@ -2,6 +2,7 @@ import type { WorkspaceUserPreference } from '@lobechat/types';
import { sql } from 'drizzle-orm';
import {
boolean,
+ check,
foreignKey,
index,
jsonb,
@@ -110,7 +111,13 @@ export const workspaceInvitations = pgTable(
role: text('role').notNull().default('member'),
token: text('token').unique().notNull(),
status: text('status').notNull().default('pending'),
- expiresAt: timestamptz('expires_at').notNull(),
+ /**
+ * A reusable (shareable link) invitation admits any number of users and
+ * stays `pending` after each accept; a regular invitation is single-use.
+ */
+ reusable: boolean('reusable').notNull().default(false),
+ /** `null` means the invitation never expires (reusable links only). */
+ expiresAt: timestamptz('expires_at'),
createdAt: createdAt(),
updatedAt: updatedAt(),
},
@@ -119,6 +126,11 @@ export const workspaceInvitations = pgTable(
index('workspace_invitations_inviter_id_idx').on(t.inviterId),
index('workspace_invitations_email_idx').on(t.email),
index('workspace_invitations_token_idx').on(t.token),
+ // Only a reusable link may never expire; a single-use invitation always has an expiry.
+ check(
+ 'workspace_invitations_expiry_required',
+ sql`${t.reusable} OR ${t.expiresAt} IS NOT NULL`,
+ ),
],
);