diff --git a/apps/backend/migrations-postgres/0057_add_org_default_project_id.sql b/apps/backend/migrations-postgres/0057_add_org_default_project_id.sql new file mode 100644 index 000000000..82668910e --- /dev/null +++ b/apps/backend/migrations-postgres/0057_add_org_default_project_id.sql @@ -0,0 +1 @@ +ALTER TABLE "organization" ADD COLUMN "default_project_id" text; \ No newline at end of file diff --git a/apps/backend/migrations-postgres/meta/0057_snapshot.json b/apps/backend/migrations-postgres/meta/0057_snapshot.json new file mode 100644 index 000000000..542ebdf44 --- /dev/null +++ b/apps/backend/migrations-postgres/meta/0057_snapshot.json @@ -0,0 +1,6770 @@ +{ + "id": "220ff28b-6698-4901-8527-4f934adf66f8", + "prevId": "64a407ba-aaf5-4e72-a7e6-fc85afbe850e", + "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 + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'completed'" + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shared_story_id": { + "name": "shared_story_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shared_chat_id": { + "name": "shared_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activity_projectId_idx": { + "name": "activity_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_userId_idx": { + "name": "activity_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_type_idx": { + "name": "activity_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_storyId_idx": { + "name": "activity_storyId_idx", + "columns": [ + { + "expression": "story_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_chatId_idx": { + "name": "activity_chatId_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_sharedStoryId_idx": { + "name": "activity_sharedStoryId_idx", + "columns": [ + { + "expression": "shared_story_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_sharedChatId_idx": { + "name": "activity_sharedChatId_idx", + "columns": [ + { + "expression": "shared_chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_startedAt_idx": { + "name": "activity_startedAt_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_project_id_project_id_fk": { + "name": "activity_project_id_project_id_fk", + "tableFrom": "activity", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "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": "no action" + }, + "activity_story_id_story_id_fk": { + "name": "activity_story_id_story_id_fk", + "tableFrom": "activity", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "activity_chat_id_chat_id_fk": { + "name": "activity_chat_id_chat_id_fk", + "tableFrom": "activity", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "activity_shared_story_id_shared_story_id_fk": { + "name": "activity_shared_story_id_shared_story_id_fk", + "tableFrom": "activity", + "tableTo": "shared_story", + "columnsFrom": [ + "shared_story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "activity_shared_chat_id_shared_chat_id_fk": { + "name": "activity_shared_chat_id_shared_chat_id_fk", + "tableFrom": "activity", + "tableTo": "shared_chat", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.analytics_event": { + "name": "analytics_event", + "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 + }, + "asset_type": { + "name": "asset_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shared_chat_id": { + "name": "shared_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shared_story_id": { + "name": "shared_story_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "analytics_event_projectId_idx": { + "name": "analytics_event_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analytics_event_chatId_idx": { + "name": "analytics_event_chatId_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analytics_event_storyId_idx": { + "name": "analytics_event_storyId_idx", + "columns": [ + { + "expression": "story_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analytics_event_sharedChatId_idx": { + "name": "analytics_event_sharedChatId_idx", + "columns": [ + { + "expression": "shared_chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analytics_event_sharedStoryId_idx": { + "name": "analytics_event_sharedStoryId_idx", + "columns": [ + { + "expression": "shared_story_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analytics_event_actorUserId_idx": { + "name": "analytics_event_actorUserId_idx", + "columns": [ + { + "expression": "actor_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analytics_event_type_createdAt_idx": { + "name": "analytics_event_type_createdAt_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "analytics_event_project_id_project_id_fk": { + "name": "analytics_event_project_id_project_id_fk", + "tableFrom": "analytics_event", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analytics_event_actor_user_id_user_id_fk": { + "name": "analytics_event_actor_user_id_user_id_fk", + "tableFrom": "analytics_event", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "analytics_event_chat_id_chat_id_fk": { + "name": "analytics_event_chat_id_chat_id_fk", + "tableFrom": "analytics_event", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analytics_event_story_id_story_id_fk": { + "name": "analytics_event_story_id_story_id_fk", + "tableFrom": "analytics_event", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analytics_event_shared_chat_id_shared_chat_id_fk": { + "name": "analytics_event_shared_chat_id_shared_chat_id_fk", + "tableFrom": "analytics_event", + "tableTo": "shared_chat", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "analytics_event_shared_story_id_shared_story_id_fk": { + "name": "analytics_event_shared_story_id_shared_story_id_fk", + "tableFrom": "analytics_event", + "tableTo": "shared_story", + "columnsFrom": [ + "shared_story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "analytics_event_asset_id_required": { + "name": "analytics_event_asset_id_required", + "value": "CASE WHEN \"analytics_event\".\"asset_type\" = 'chat' THEN \"analytics_event\".\"chat_id\" IS NOT NULL WHEN \"analytics_event\".\"asset_type\" = 'story' THEN \"analytics_event\".\"story_id\" IS NOT NULL ELSE TRUE END" + } + }, + "isRLSEnabled": false + }, + "public.api_key": { + "name": "api_key", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "org_id": { + "name": "org_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "api_key_orgId_idx": { + "name": "api_key_orgId_idx", + "columns": [ + { + "expression": "org_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_key_org_id_organization_id_fk": { + "name": "api_key_org_id_organization_id_fk", + "tableFrom": "api_key", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_created_by_user_id_fk": { + "name": "api_key_created_by_user_id_fk", + "tableFrom": "api_key", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_key_key_hash_unique": { + "name": "api_key_key_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "key_hash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation": { + "name": "automation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_job_id": { + "name": "scheduled_job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schedule_description": { + "name": "schedule_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model_provider": { + "name": "model_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mcp_enabled": { + "name": "mcp_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mcp_servers": { + "name": "mcp_servers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "integrations": { + "name": "integrations", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "webhook_enabled": { + "name": "webhook_enabled", + "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": { + "automation_projectId_idx": { + "name": "automation_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_userId_idx": { + "name": "automation_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_scheduledJobId_idx": { + "name": "automation_scheduledJobId_idx", + "columns": [ + { + "expression": "scheduled_job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_project_id_project_id_fk": { + "name": "automation_project_id_project_id_fk", + "tableFrom": "automation", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_user_id_user_id_fk": { + "name": "automation_user_id_user_id_fk", + "tableFrom": "automation", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_scheduled_job_id_scheduled_job_id_fk": { + "name": "automation_scheduled_job_id_scheduled_job_id_fk", + "tableFrom": "automation", + "tableTo": "scheduled_job", + "columnsFrom": [ + "scheduled_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_run": { + "name": "automation_run", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "integration_results": { + "name": "integration_results", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + } + }, + "indexes": { + "automation_run_automationId_idx": { + "name": "automation_run_automationId_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_run_chatId_idx": { + "name": "automation_run_chatId_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_run_status_idx": { + "name": "automation_run_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_run_automation_id_automation_id_fk": { + "name": "automation_run_automation_id_automation_id_fk", + "tableFrom": "automation_run", + "tableTo": "automation", + "columnsFrom": [ + "automation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_run_chat_id_chat_id_fk": { + "name": "automation_run_chat_id_chat_id_fk", + "tableFrom": "automation_run", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.branding_config": { + "name": "branding_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "app_name": { + "name": "app_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tab_title": { + "name": "tab_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo_data": { + "name": "logo_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo_media_type": { + "name": "logo_media_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "favicon_data": { + "name": "favicon_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "favicon_media_type": { + "name": "favicon_media_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "brand_color": { + "name": "brand_color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chat": { + "name": "chat", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'New Conversation'" + }, + "is_starred": { + "name": "is_starred", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "slack_thread_id": { + "name": "slack_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "teams_thread_id": { + "name": "teams_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_thread_id": { + "name": "telegram_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "whatsapp_thread_id": { + "name": "whatsapp_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fork_metadata": { + "name": "fork_metadata", + "type": "jsonb", + "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": { + "chat_userId_idx": { + "name": "chat_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_projectId_idx": { + "name": "chat_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_slack_thread_idx": { + "name": "chat_slack_thread_idx", + "columns": [ + { + "expression": "slack_thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_teams_thread_idx": { + "name": "chat_teams_thread_idx", + "columns": [ + { + "expression": "teams_thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_telegram_thread_idx": { + "name": "chat_telegram_thread_idx", + "columns": [ + { + "expression": "telegram_thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_whatsapp_thread_idx": { + "name": "chat_whatsapp_thread_idx", + "columns": [ + { + "expression": "whatsapp_thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chat_user_id_user_id_fk": { + "name": "chat_user_id_user_id_fk", + "tableFrom": "chat", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chat_project_id_project_id_fk": { + "name": "chat_project_id_project_id_fk", + "tableFrom": "chat", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chat_message": { + "name": "chat_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stop_reason": { + "name": "stop_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "superseded_at": { + "name": "superseded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "version_group_id": { + "name": "version_group_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "isForked": { + "name": "isForked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "citation": { + "name": "citation", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "input_total_tokens": { + "name": "input_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "input_no_cache_tokens": { + "name": "input_no_cache_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "input_cache_read_tokens": { + "name": "input_cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "input_cache_write_tokens": { + "name": "input_cache_write_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "output_total_tokens": { + "name": "output_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "output_text_tokens": { + "name": "output_text_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "output_reasoning_tokens": { + "name": "output_reasoning_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "chat_message_chatId_idx": { + "name": "chat_message_chatId_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_message_createdAt_idx": { + "name": "chat_message_createdAt_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_message_versionGroupId_idx": { + "name": "chat_message_versionGroupId_idx", + "columns": [ + { + "expression": "version_group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chat_message_chat_id_chat_id_fk": { + "name": "chat_message_chat_id_chat_id_fk", + "tableFrom": "chat_message", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.context_recommendation": { + "name": "context_recommendation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "suggested_file": { + "name": "suggested_file", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject_key": { + "name": "subject_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "snoozed_until": { + "name": "snoozed_until", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'medium'" + }, + "impact_score": { + "name": "impact_score", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "impact": { + "name": "impact", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "insights": { + "name": "insights", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "suggested_action": { + "name": "suggested_action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fix_kind": { + "name": "fix_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "proposed_edits": { + "name": "proposed_edits", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "fix_guidance": { + "name": "fix_guidance", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fix_prompt": { + "name": "fix_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pr_url": { + "name": "pr_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pr_branch": { + "name": "pr_branch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pr_created_at": { + "name": "pr_created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "occurrence_count": { + "name": "occurrence_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "status_changed_by": { + "name": "status_changed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "context_recommendation_project_fingerprint_unique": { + "name": "context_recommendation_project_fingerprint_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fingerprint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "context_recommendation_projectId_status_idx": { + "name": "context_recommendation_projectId_status_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "context_recommendation_runId_idx": { + "name": "context_recommendation_runId_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "context_recommendation_project_id_project_id_fk": { + "name": "context_recommendation_project_id_project_id_fk", + "tableFrom": "context_recommendation", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "context_recommendation_status_changed_by_user_id_fk": { + "name": "context_recommendation_status_changed_by_user_id_fk", + "tableFrom": "context_recommendation", + "tableTo": "user", + "columnsFrom": [ + "status_changed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "context_recommendation_run_fk": { + "name": "context_recommendation_run_fk", + "tableFrom": "context_recommendation", + "tableTo": "context_recommendation_run", + "columnsFrom": [ + "run_id", + "project_id" + ], + "columnsTo": [ + "id", + "project_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.context_recommendation_config": { + "name": "context_recommendation_config", + "schema": "", + "columns": { + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model_provider": { + "name": "model_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom_system_prompt_instructions": { + "name": "custom_system_prompt_instructions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "repo_full_name": { + "name": "repo_full_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "repo_provider": { + "name": "repo_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_create_prs": { + "name": "auto_create_prs", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "max_auto_prs_per_run": { + "name": "max_auto_prs_per_run", + "type": "integer", + "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": {}, + "foreignKeys": { + "context_recommendation_config_project_id_project_id_fk": { + "name": "context_recommendation_config_project_id_project_id_fk", + "tableFrom": "context_recommendation_config", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.context_recommendation_run": { + "name": "context_recommendation_run", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'schedule'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "window_start": { + "name": "window_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "window_end": { + "name": "window_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_total_tokens": { + "name": "input_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "output_total_tokens": { + "name": "output_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "context_recommendation_run_projectId_idx": { + "name": "context_recommendation_run_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "context_recommendation_run_chatId_idx": { + "name": "context_recommendation_run_chatId_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "context_recommendation_run_status_idx": { + "name": "context_recommendation_run_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "context_recommendation_run_project_id_project_id_fk": { + "name": "context_recommendation_run_project_id_project_id_fk", + "tableFrom": "context_recommendation_run", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "context_recommendation_run_chat_id_chat_id_fk": { + "name": "context_recommendation_run_chat_id_chat_id_fk", + "tableFrom": "context_recommendation_run", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "context_recommendation_run_id_project_unique": { + "name": "context_recommendation_run_id_project_unique", + "nullsNotDistinct": false, + "columns": [ + "id", + "project_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.favorite": { + "name": "favorite", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "favorite_user_id_idx": { + "name": "favorite_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "favorite_user_id_user_id_fk": { + "name": "favorite_user_id_user_id_fk", + "tableFrom": "favorite", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "favorite_story_id_story_id_fk": { + "name": "favorite_story_id_story_id_fk", + "tableFrom": "favorite", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "favorite_folder_id_story_folder_id_fk": { + "name": "favorite_folder_id_story_folder_id_fk", + "tableFrom": "favorite", + "tableTo": "story_folder", + "columnsFrom": [ + "folder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "favorite_user_id_story_id_unique": { + "name": "favorite_user_id_story_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "story_id" + ] + }, + "favorite_user_id_folder_id_unique": { + "name": "favorite_user_id_folder_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "folder_id" + ] + } + }, + "policies": {}, + "checkConstraints": { + "favorite_xor_target": { + "name": "favorite_xor_target", + "value": "(\"favorite\".\"story_id\" IS NOT NULL)::int + (\"favorite\".\"folder_id\" IS NOT NULL)::int = 1" + } + }, + "isRLSEnabled": false + }, + "public.jwks": { + "name": "jwks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.llm_inference": { + "name": "llm_inference", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_total_tokens": { + "name": "input_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "input_no_cache_tokens": { + "name": "input_no_cache_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "input_cache_read_tokens": { + "name": "input_cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "input_cache_write_tokens": { + "name": "input_cache_write_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "output_total_tokens": { + "name": "output_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "output_text_tokens": { + "name": "output_text_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "output_reasoning_tokens": { + "name": "output_reasoning_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "llm_inference_projectId_idx": { + "name": "llm_inference_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "llm_inference_userId_idx": { + "name": "llm_inference_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "llm_inference_type_idx": { + "name": "llm_inference_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "llm_inference_project_id_project_id_fk": { + "name": "llm_inference_project_id_project_id_fk", + "tableFrom": "llm_inference", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "llm_inference_user_id_user_id_fk": { + "name": "llm_inference_user_id_user_id_fk", + "tableFrom": "llm_inference", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "llm_inference_chat_id_chat_id_fk": { + "name": "llm_inference_chat_id_chat_id_fk", + "tableFrom": "llm_inference", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.log": { + "name": "log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "context": { + "name": "context", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "log_createdAt_idx": { + "name": "log_createdAt_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "log_level_idx": { + "name": "log_level_idx", + "columns": [ + { + "expression": "level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "log_projectId_idx": { + "name": "log_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "log_project_id_project_id_fk": { + "name": "log_project_id_project_id_fk", + "tableFrom": "log", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_call_log": { + "name": "mcp_call_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "success": { + "name": "success", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "tool_input": { + "name": "tool_input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tool_output": { + "name": "tool_output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "called_at": { + "name": "called_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_call_log_projectId_idx": { + "name": "mcp_call_log_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_call_log_userId_idx": { + "name": "mcp_call_log_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_call_log_calledAt_idx": { + "name": "mcp_call_log_calledAt_idx", + "columns": [ + { + "expression": "called_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_call_log_project_id_project_id_fk": { + "name": "mcp_call_log_project_id_project_id_fk", + "tableFrom": "mcp_call_log", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_call_log_user_id_user_id_fk": { + "name": "mcp_call_log_user_id_user_id_fk", + "tableFrom": "mcp_call_log", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_chart_embed": { + "name": "mcp_chart_embed", + "schema": "", + "columns": { + "chart_embed_id": { + "name": "chart_embed_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "query_id": { + "name": "query_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chart_config": { + "name": "chart_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_chat_id": { + "name": "source_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_chart_embed_query_id_idx": { + "name": "mcp_chart_embed_query_id_idx", + "columns": [ + { + "expression": "query_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_chart_embed_query_id_mcp_query_data_query_id_fk": { + "name": "mcp_chart_embed_query_id_mcp_query_data_query_id_fk", + "tableFrom": "mcp_chart_embed", + "tableTo": "mcp_query_data", + "columnsFrom": [ + "query_id" + ], + "columnsTo": [ + "query_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_oauth_client": { + "name": "mcp_oauth_client", + "schema": "", + "columns": { + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_data": { + "name": "client_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discovery_user_id": { + "name": "discovery_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()" + } + }, + "indexes": {}, + "foreignKeys": { + "mcp_oauth_client_project_id_project_id_fk": { + "name": "mcp_oauth_client_project_id_project_id_fk", + "tableFrom": "mcp_oauth_client", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_oauth_client_discovery_user_id_user_id_fk": { + "name": "mcp_oauth_client_discovery_user_id_user_id_fk", + "tableFrom": "mcp_oauth_client", + "tableTo": "user", + "columnsFrom": [ + "discovery_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "mcp_oauth_client_project_id_server_name_pk": { + "name": "mcp_oauth_client_project_id_server_name_pk", + "columns": [ + "project_id", + "server_name" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_query_data": { + "name": "mcp_query_data", + "schema": "", + "columns": { + "query_id": { + "name": "query_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "call_log_id": { + "name": "call_log_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_chat_id": { + "name": "source_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "columns": { + "name": "columns", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "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()" + } + }, + "indexes": { + "mcp_query_data_project_id_idx": { + "name": "mcp_query_data_project_id_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_query_data_callLogId_idx": { + "name": "mcp_query_data_callLogId_idx", + "columns": [ + { + "expression": "call_log_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_query_data_project_id_project_id_fk": { + "name": "mcp_query_data_project_id_project_id_fk", + "tableFrom": "mcp_query_data", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_user_token": { + "name": "mcp_user_token", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "server_name": { + "name": "server_name", + "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 + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_verifier": { + "name": "code_verifier", + "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": { + "mcp_user_token_project_server_idx": { + "name": "mcp_user_token_project_server_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "server_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_user_token_user_id_user_id_fk": { + "name": "mcp_user_token_user_id_user_id_fk", + "tableFrom": "mcp_user_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_user_token_project_id_project_id_fk": { + "name": "mcp_user_token_project_id_project_id_fk", + "tableFrom": "mcp_user_token", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "mcp_user_token_user_id_project_id_server_name_pk": { + "name": "mcp_user_token_user_id_project_id_server_name_pk", + "columns": [ + "user_id", + "project_id", + "server_name" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memories": { + "name": "memories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "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()" + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "superseded_by": { + "name": "superseded_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memories_userId_idx": { + "name": "memories_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memories_chatId_idx": { + "name": "memories_chatId_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memories_supersededBy_idx": { + "name": "memories_supersededBy_idx", + "columns": [ + { + "expression": "superseded_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memories_user_id_user_id_fk": { + "name": "memories_user_id_user_id_fk", + "tableFrom": "memories", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memories_chat_id_chat_id_fk": { + "name": "memories_chat_id_chat_id_fk", + "tableFrom": "memories", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message_feedback": { + "name": "message_feedback", + "schema": "", + "columns": { + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "vote": { + "name": "vote", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "explanation": { + "name": "explanation", + "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": {}, + "foreignKeys": { + "message_feedback_message_id_chat_message_id_fk": { + "name": "message_feedback_message_id_chat_message_id_fk", + "tableFrom": "message_feedback", + "tableTo": "chat_message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message_image": { + "name": "message_image", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "media_type": { + "name": "media_type", + "type": "text", + "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.message_part": { + "name": "message_part", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_text": { + "name": "reasoning_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_state": { + "name": "tool_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_error_text": { + "name": "tool_error_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_input": { + "name": "tool_input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tool_raw_input": { + "name": "tool_raw_input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tool_output": { + "name": "tool_output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tool_approval_id": { + "name": "tool_approval_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_approval_approved": { + "name": "tool_approval_approved", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "tool_approval_reason": { + "name": "tool_approval_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_provider_metadata": { + "name": "tool_provider_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "provider_metadata": { + "name": "provider_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "media_type": { + "name": "media_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "parts_message_id_idx": { + "name": "parts_message_id_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "parts_message_id_order_idx": { + "name": "parts_message_id_order_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_part_message_id_chat_message_id_fk": { + "name": "message_part_message_id_chat_message_id_fk", + "tableFrom": "message_part", + "tableTo": "chat_message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "message_part_image_id_message_image_id_fk": { + "name": "message_part_image_id_message_image_id_fk", + "tableFrom": "message_part", + "tableTo": "message_image", + "columnsFrom": [ + "image_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "message_part_tool_call_id_unique": { + "name": "message_part_tool_call_id_unique", + "nullsNotDistinct": false, + "columns": [ + "tool_call_id" + ] + } + }, + "policies": {}, + "checkConstraints": { + "text_required_if_type_is_text": { + "name": "text_required_if_type_is_text", + "value": "CASE WHEN \"message_part\".\"type\" = 'text' THEN \"message_part\".\"text\" IS NOT NULL ELSE TRUE END" + }, + "reasoning_text_required_if_type_is_reasoning": { + "name": "reasoning_text_required_if_type_is_reasoning", + "value": "CASE WHEN \"message_part\".\"type\" = 'reasoning' THEN \"message_part\".\"reasoning_text\" IS NOT NULL ELSE TRUE END" + }, + "tool_call_fields_required": { + "name": "tool_call_fields_required", + "value": "CASE WHEN \"message_part\".\"type\" LIKE 'tool-%' THEN \"message_part\".\"tool_call_id\" IS NOT NULL AND \"message_part\".\"tool_state\" IS NOT NULL ELSE TRUE END" + }, + "file_fields_required": { + "name": "file_fields_required", + "value": "CASE WHEN \"message_part\".\"type\" = 'file' THEN \"message_part\".\"media_type\" IS NOT NULL AND \"message_part\".\"image_id\" IS NOT NULL ELSE TRUE END" + } + }, + "isRLSEnabled": false + }, + "public.chart_image": { + "name": "chart_image", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "chart_image_tool_call_id_unique": { + "name": "chart_image_tool_call_id_unique", + "nullsNotDistinct": false, + "columns": [ + "tool_call_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_id": { + "name": "refresh_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "oauth_access_token_clientId_idx": { + "name": "oauth_access_token_clientId_idx", + "columns": [ + { + "expression": "client_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_access_token_userId_idx": { + "name": "oauth_access_token_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_access_token_refreshId_idx": { + "name": "oauth_access_token_refreshId_idx", + "columns": [ + { + "expression": "refresh_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oauth_access_token_client_id_oauth_client_client_id_fk": { + "name": "oauth_access_token_client_id_oauth_client_client_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "oauth_client", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "client_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_access_token_session_id_session_id_fk": { + "name": "oauth_access_token_session_id_session_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "session", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "oauth_access_token_user_id_user_id_fk": { + "name": "oauth_access_token_user_id_user_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": { + "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "oauth_refresh_token", + "columnsFrom": [ + "refresh_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_token_unique": { + "name": "oauth_access_token_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_client": { + "name": "oauth_client", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "skip_consent": { + "name": "skip_consent", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "enable_end_session": { + "name": "enable_end_session", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "subject_type": { + "name": "subject_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contacts": { + "name": "contacts", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tos": { + "name": "tos", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "policy": { + "name": "policy", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "software_id": { + "name": "software_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "software_version": { + "name": "software_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "software_statement": { + "name": "software_statement", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_uris": { + "name": "redirect_uris", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "post_logout_redirect_uris": { + "name": "post_logout_redirect_uris", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_endpoint_auth_method": { + "name": "token_endpoint_auth_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "grant_types": { + "name": "grant_types", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response_types": { + "name": "response_types", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "public": { + "name": "public", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "require_pkce": { + "name": "require_pkce", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "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": { + "oauth_client_userId_idx": { + "name": "oauth_client_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oauth_client_user_id_user_id_fk": { + "name": "oauth_client_user_id_user_id_fk", + "tableFrom": "oauth_client", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_client_client_id_unique": { + "name": "oauth_client_client_id_unique", + "nullsNotDistinct": false, + "columns": [ + "client_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "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": { + "oauth_consent_clientId_idx": { + "name": "oauth_consent_clientId_idx", + "columns": [ + { + "expression": "client_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_consent_userId_idx": { + "name": "oauth_consent_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oauth_consent_client_id_oauth_client_client_id_fk": { + "name": "oauth_consent_client_id_oauth_client_client_id_fk", + "tableFrom": "oauth_consent", + "tableTo": "oauth_client", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "client_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_consent_user_id_user_id_fk": { + "name": "oauth_consent_user_id_user_id_fk", + "tableFrom": "oauth_consent", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_refresh_token": { + "name": "oauth_refresh_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked": { + "name": "revoked", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "auth_time": { + "name": "auth_time", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "oauth_refresh_token_clientId_idx": { + "name": "oauth_refresh_token_clientId_idx", + "columns": [ + { + "expression": "client_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_refresh_token_userId_idx": { + "name": "oauth_refresh_token_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_refresh_token_sessionId_idx": { + "name": "oauth_refresh_token_sessionId_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oauth_refresh_token_client_id_oauth_client_client_id_fk": { + "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk", + "tableFrom": "oauth_refresh_token", + "tableTo": "oauth_client", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "client_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_refresh_token_session_id_session_id_fk": { + "name": "oauth_refresh_token_session_id_session_id_fk", + "tableFrom": "oauth_refresh_token", + "tableTo": "session", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "oauth_refresh_token_user_id_user_id_fk": { + "name": "oauth_refresh_token_user_id_user_id_fk", + "tableFrom": "oauth_refresh_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_refresh_token_token_unique": { + "name": "oauth_refresh_token_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_member": { + "name": "org_member", + "schema": "", + "columns": { + "org_id": { + "name": "org_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 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_member_userId_idx": { + "name": "org_member_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "org_member_org_id_organization_id_fk": { + "name": "org_member_org_id_organization_id_fk", + "tableFrom": "org_member", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "org_member_user_id_user_id_fk": { + "name": "org_member_user_id_user_id_fk", + "tableFrom": "org_member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "org_member_org_id_user_id_pk": { + "name": "org_member_org_id_user_id_pk", + "columns": [ + "org_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "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 + }, + "google_client_id": { + "name": "google_client_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_client_secret": { + "name": "google_client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_auth_domains": { + "name": "google_auth_domains", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "default_project_id": { + "name": "default_project_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()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_slug_unique": { + "name": "organization_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project": { + "name": "project", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "org_id": { + "name": "org_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_settings": { + "name": "agent_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "enabled_tools": { + "name": "enabled_tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "known_mcp_servers": { + "name": "known_mcp_servers", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "disabled_mcp_servers": { + "name": "disabled_mcp_servers", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "disabled_mcp_tools": { + "name": "disabled_mcp_tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "env_vars": { + "name": "env_vars", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "slack_settings": { + "name": "slack_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "teams_settings": { + "name": "teams_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "telegram_settings": { + "name": "telegram_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "whatsapp_settings": { + "name": "whatsapp_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "mcp_endpoint_settings": { + "name": "mcp_endpoint_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "display_settings": { + "name": "display_settings", + "type": "jsonb", + "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": { + "project_orgId_idx": { + "name": "project_orgId_idx", + "columns": [ + { + "expression": "org_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_org_id_organization_id_fk": { + "name": "project_org_id_organization_id_fk", + "tableFrom": "project", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "local_project_path_required": { + "name": "local_project_path_required", + "value": "CASE WHEN \"type\" = 'local' THEN \"path\" IS NOT NULL ELSE TRUE END" + } + }, + "isRLSEnabled": false + }, + "public.project_llm_config": { + "name": "project_llm_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credentials": { + "name": "credentials", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "enabled_models": { + "name": "enabled_models", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "custom_models": { + "name": "custom_models", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "model_settings": { + "name": "model_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "base_url": { + "name": "base_url", + "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": { + "project_llm_config_projectId_idx": { + "name": "project_llm_config_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_llm_config_project_id_project_id_fk": { + "name": "project_llm_config_project_id_project_id_fk", + "tableFrom": "project_llm_config", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "project_llm_config_project_provider": { + "name": "project_llm_config_project_provider", + "nullsNotDistinct": false, + "columns": [ + "project_id", + "provider" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project_member": { + "name": "project_member", + "schema": "", + "columns": { + "project_id": { + "name": "project_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 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "project_member_userId_idx": { + "name": "project_member_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_member_project_id_project_id_fk": { + "name": "project_member_project_id_project_id_fk", + "tableFrom": "project_member", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_member_user_id_user_id_fk": { + "name": "project_member_user_id_user_id_fk", + "tableFrom": "project_member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_member_project_id_user_id_pk": { + "name": "project_member_project_id_user_id_pk", + "columns": [ + "project_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project_provider_budget": { + "name": "project_provider_budget", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "limit_usd": { + "name": "limit_usd", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "current_period_start": { + "name": "current_period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "notified_at": { + "name": "notified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "project_provider_budget_projectId_idx": { + "name": "project_provider_budget_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_provider_budget_project_id_project_id_fk": { + "name": "project_provider_budget_project_id_project_id_fk", + "tableFrom": "project_provider_budget", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "project_provider_budget_project_provider": { + "name": "project_provider_budget_project_provider", + "nullsNotDistinct": false, + "columns": [ + "project_id", + "provider" + ] + } + }, + "policies": {}, + "checkConstraints": { + "budget_period_valid": { + "name": "budget_period_valid", + "value": "\"project_provider_budget\".\"period\" IN ('day', 'week', 'month')" + } + }, + "isRLSEnabled": false + }, + "public.project_saved_prompt": { + "name": "project_saved_prompt", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "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": { + "project_saved_prompt_projectId_idx": { + "name": "project_saved_prompt_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_saved_prompt_project_id_project_id_fk": { + "name": "project_saved_prompt_project_id_project_id_fk", + "tableFrom": "project_saved_prompt", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project_whatsapp_link": { + "name": "project_whatsapp_link", + "schema": "", + "columns": { + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "whatsapp_user_id": { + "name": "whatsapp_user_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": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "project_whatsapp_link_userId_idx": { + "name": "project_whatsapp_link_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_whatsapp_link_project_id_project_id_fk": { + "name": "project_whatsapp_link_project_id_project_id_fk", + "tableFrom": "project_whatsapp_link", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_whatsapp_link_user_id_user_id_fk": { + "name": "project_whatsapp_link_user_id_user_id_fk", + "tableFrom": "project_whatsapp_link", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_whatsapp_link_project_id_whatsapp_user_id_pk": { + "name": "project_whatsapp_link_project_id_whatsapp_user_id_pk", + "columns": [ + "project_id", + "whatsapp_user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scheduled_job": { + "name": "scheduled_job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "run_at": { + "name": "run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "cron": { + "name": "cron", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locked_at": { + "name": "locked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "locked_by": { + "name": "locked_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unique_key": { + "name": "unique_key", + "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": { + "scheduled_job_status_runAt_idx": { + "name": "scheduled_job_status_runAt_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scheduled_job_name_idx": { + "name": "scheduled_job_name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "scheduled_job_unique_key_unique": { + "name": "scheduled_job_unique_key_unique", + "nullsNotDistinct": false, + "columns": [ + "unique_key" + ] + } + }, + "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 + } + }, + "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.shared_chat": { + "name": "shared_chat", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'project'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "shared_chat_chat_id_chat_id_fk": { + "name": "shared_chat_chat_id_chat_id_fk", + "tableFrom": "shared_chat", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "shared_chat_chatId_unique": { + "name": "shared_chat_chatId_unique", + "nullsNotDistinct": false, + "columns": [ + "chat_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shared_chat_access": { + "name": "shared_chat_access", + "schema": "", + "columns": { + "shared_chat_id": { + "name": "shared_chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "shared_chat_access_shared_chat_id_shared_chat_id_fk": { + "name": "shared_chat_access_shared_chat_id_shared_chat_id_fk", + "tableFrom": "shared_chat_access", + "tableTo": "shared_chat", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_chat_access_user_id_user_id_fk": { + "name": "shared_chat_access_user_id_user_id_fk", + "tableFrom": "shared_chat_access", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "shared_chat_access_shared_chat_id_user_id_pk": { + "name": "shared_chat_access_shared_chat_id_user_id_pk", + "columns": [ + "shared_chat_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shared_story": { + "name": "shared_story", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'project'" + }, + "is_pinned": { + "name": "is_pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shared_story_projectId_idx": { + "name": "shared_story_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shared_story_storyId_idx": { + "name": "shared_story_storyId_idx", + "columns": [ + { + "expression": "story_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shared_story_project_story_unique": { + "name": "shared_story_project_story_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "story_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shared_story_story_id_story_id_fk": { + "name": "shared_story_story_id_story_id_fk", + "tableFrom": "shared_story", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_story_project_id_project_id_fk": { + "name": "shared_story_project_id_project_id_fk", + "tableFrom": "shared_story", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_story_user_id_user_id_fk": { + "name": "shared_story_user_id_user_id_fk", + "tableFrom": "shared_story", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shared_story_access": { + "name": "shared_story_access", + "schema": "", + "columns": { + "shared_story_id": { + "name": "shared_story_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "shared_story_access_shared_story_id_shared_story_id_fk": { + "name": "shared_story_access_shared_story_id_shared_story_id_fk", + "tableFrom": "shared_story_access", + "tableTo": "shared_story", + "columnsFrom": [ + "shared_story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_story_access_user_id_user_id_fk": { + "name": "shared_story_access_user_id_user_id_fk", + "tableFrom": "shared_story_access", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "shared_story_access_shared_story_id_user_id_pk": { + "name": "shared_story_access_shared_story_id_user_id_pk", + "columns": [ + "shared_story_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.story": { + "name": "story", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_live": { + "name": "is_live", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_live_text_dynamic": { + "name": "is_live_text_dynamic", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "cache_schedule": { + "name": "cache_schedule", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cache_schedule_description": { + "name": "cache_schedule_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scheduled_job_id": { + "name": "scheduled_job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_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": { + "story_standalone_slug_unique": { + "name": "story_standalone_slug_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"story\".\"chat_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "story_chatId_idx": { + "name": "story_chatId_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "story_projectId_idx": { + "name": "story_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "story_userId_idx": { + "name": "story_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "story_scheduledJobId_idx": { + "name": "story_scheduledJobId_idx", + "columns": [ + { + "expression": "scheduled_job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "story_chat_id_chat_id_fk": { + "name": "story_chat_id_chat_id_fk", + "tableFrom": "story", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_project_id_project_id_fk": { + "name": "story_project_id_project_id_fk", + "tableFrom": "story", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_user_id_user_id_fk": { + "name": "story_user_id_user_id_fk", + "tableFrom": "story", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_scheduled_job_id_scheduled_job_id_fk": { + "name": "story_scheduled_job_id_scheduled_job_id_fk", + "tableFrom": "story", + "tableTo": "scheduled_job", + "columnsFrom": [ + "scheduled_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "story_chat_slug_unique": { + "name": "story_chat_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "chat_id", + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": { + "story_owner_required": { + "name": "story_owner_required", + "value": "\"story\".\"chat_id\" IS NOT NULL OR (\"story\".\"project_id\" IS NOT NULL AND \"story\".\"user_id\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.story_data_cache": { + "name": "story_data_cache", + "schema": "", + "columns": { + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "query_data": { + "name": "query_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "analysis_results": { + "name": "analysis_results", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cached_at": { + "name": "cached_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "story_data_cache_story_id_story_id_fk": { + "name": "story_data_cache_story_id_story_id_fk", + "tableFrom": "story_data_cache", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.story_folder": { + "name": "story_folder", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'public'" + }, + "system_type": { + "name": "system_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_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": { + "story_folder_private_root_unique": { + "name": "story_folder_private_root_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"story_folder\".\"system_type\" = 'private_folder'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "story_folder_ownerProjectParent_idx": { + "name": "story_folder_ownerProjectParent_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "story_folder_projectId_idx": { + "name": "story_folder_projectId_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "story_folder_owner_id_user_id_fk": { + "name": "story_folder_owner_id_user_id_fk", + "tableFrom": "story_folder", + "tableTo": "user", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_folder_project_id_project_id_fk": { + "name": "story_folder_project_id_project_id_fk", + "tableFrom": "story_folder", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_folder_parent_id_story_folder_id_fk": { + "name": "story_folder_parent_id_story_folder_id_fk", + "tableFrom": "story_folder", + "tableTo": "story_folder", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.story_folder_item": { + "name": "story_folder_item", + "schema": "", + "columns": { + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "story_folder_item_folderId_idx": { + "name": "story_folder_item_folderId_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "story_folder_item_story_id_story_id_fk": { + "name": "story_folder_item_story_id_story_id_fk", + "tableFrom": "story_folder_item", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_folder_item_folder_id_story_folder_id_fk": { + "name": "story_folder_item_folder_id_story_folder_id_fk", + "tableFrom": "story_folder_item", + "tableTo": "story_folder", + "columnsFrom": [ + "folder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.story_version": { + "name": "story_version", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "story_version_storyId_idx": { + "name": "story_version_storyId_idx", + "columns": [ + { + "expression": "story_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "story_version_story_id_story_id_fk": { + "name": "story_version_story_id_story_id_fk", + "tableFrom": "story_version", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "story_version_story_version_unique": { + "name": "story_version_story_version_unique", + "nullsNotDistinct": false, + "columns": [ + "story_id", + "version" + ] + } + }, + "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, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requires_password_reset": { + "name": "requires_password_reset", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "memory_enabled": { + "name": "memory_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "messaging_provider_code": { + "name": "messaging_provider_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "github_access_token": { + "name": "github_access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gitlab_access_token": { + "name": "gitlab_access_token", + "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": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + }, + "user_messaging_provider_code_unique": { + "name": "user_messaging_provider_code_unique", + "nullsNotDistinct": false, + "columns": [ + "messaging_provider_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_preference": { + "name": "user_preference", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "preferences": { + "name": "preferences", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "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_preference_user_id_user_id_fk": { + "name": "user_preference_user_id_user_id_fk", + "tableFrom": "user_preference", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "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 + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/migrations-postgres/meta/_journal.json b/apps/backend/migrations-postgres/meta/_journal.json index 782031c32..f54adbaf3 100644 --- a/apps/backend/migrations-postgres/meta/_journal.json +++ b/apps/backend/migrations-postgres/meta/_journal.json @@ -400,6 +400,13 @@ "when": 1783697856052, "tag": "0056_model_settings", "breakpoints": true + }, + { + "idx": 57, + "version": "7", + "when": 1784138854554, + "tag": "0057_add_org_default_project_id", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/backend/migrations-sqlite/0057_add_org_default_project_id.sql b/apps/backend/migrations-sqlite/0057_add_org_default_project_id.sql new file mode 100644 index 000000000..ff2a293b3 --- /dev/null +++ b/apps/backend/migrations-sqlite/0057_add_org_default_project_id.sql @@ -0,0 +1 @@ +ALTER TABLE `organization` ADD `default_project_id` text; \ No newline at end of file diff --git a/apps/backend/migrations-sqlite/meta/0057_snapshot.json b/apps/backend/migrations-sqlite/meta/0057_snapshot.json new file mode 100644 index 000000000..a4297b464 --- /dev/null +++ b/apps/backend/migrations-sqlite/meta/0057_snapshot.json @@ -0,0 +1,6325 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "1109ab58-d5ec-4082-a15b-ee413614abf3", + "prevId": "0a579216-7320-416d-b330-2a4857de72e6", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "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": {}, + "checkConstraints": {} + }, + "activity": { + "name": "activity", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'completed'" + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "shared_story_id": { + "name": "shared_story_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "shared_chat_id": { + "name": "shared_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "activity_projectId_idx": { + "name": "activity_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "activity_userId_idx": { + "name": "activity_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "activity_type_idx": { + "name": "activity_type_idx", + "columns": [ + "type" + ], + "isUnique": false + }, + "activity_storyId_idx": { + "name": "activity_storyId_idx", + "columns": [ + "story_id" + ], + "isUnique": false + }, + "activity_chatId_idx": { + "name": "activity_chatId_idx", + "columns": [ + "chat_id" + ], + "isUnique": false + }, + "activity_sharedStoryId_idx": { + "name": "activity_sharedStoryId_idx", + "columns": [ + "shared_story_id" + ], + "isUnique": false + }, + "activity_sharedChatId_idx": { + "name": "activity_sharedChatId_idx", + "columns": [ + "shared_chat_id" + ], + "isUnique": false + }, + "activity_startedAt_idx": { + "name": "activity_startedAt_idx", + "columns": [ + "started_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "activity_project_id_project_id_fk": { + "name": "activity_project_id_project_id_fk", + "tableFrom": "activity", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "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": "no action" + }, + "activity_story_id_story_id_fk": { + "name": "activity_story_id_story_id_fk", + "tableFrom": "activity", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "activity_chat_id_chat_id_fk": { + "name": "activity_chat_id_chat_id_fk", + "tableFrom": "activity", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "activity_shared_story_id_shared_story_id_fk": { + "name": "activity_shared_story_id_shared_story_id_fk", + "tableFrom": "activity", + "tableTo": "shared_story", + "columnsFrom": [ + "shared_story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "activity_shared_chat_id_shared_chat_id_fk": { + "name": "activity_shared_chat_id_shared_chat_id_fk", + "tableFrom": "activity", + "tableTo": "shared_chat", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "analytics_event": { + "name": "analytics_event", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "asset_type": { + "name": "asset_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "shared_chat_id": { + "name": "shared_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "shared_story_id": { + "name": "shared_story_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "analytics_event_projectId_idx": { + "name": "analytics_event_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "analytics_event_chatId_idx": { + "name": "analytics_event_chatId_idx", + "columns": [ + "chat_id" + ], + "isUnique": false + }, + "analytics_event_storyId_idx": { + "name": "analytics_event_storyId_idx", + "columns": [ + "story_id" + ], + "isUnique": false + }, + "analytics_event_sharedChatId_idx": { + "name": "analytics_event_sharedChatId_idx", + "columns": [ + "shared_chat_id" + ], + "isUnique": false + }, + "analytics_event_sharedStoryId_idx": { + "name": "analytics_event_sharedStoryId_idx", + "columns": [ + "shared_story_id" + ], + "isUnique": false + }, + "analytics_event_actorUserId_idx": { + "name": "analytics_event_actorUserId_idx", + "columns": [ + "actor_user_id" + ], + "isUnique": false + }, + "analytics_event_type_createdAt_idx": { + "name": "analytics_event_type_createdAt_idx", + "columns": [ + "type", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "analytics_event_project_id_project_id_fk": { + "name": "analytics_event_project_id_project_id_fk", + "tableFrom": "analytics_event", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analytics_event_actor_user_id_user_id_fk": { + "name": "analytics_event_actor_user_id_user_id_fk", + "tableFrom": "analytics_event", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "analytics_event_chat_id_chat_id_fk": { + "name": "analytics_event_chat_id_chat_id_fk", + "tableFrom": "analytics_event", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analytics_event_story_id_story_id_fk": { + "name": "analytics_event_story_id_story_id_fk", + "tableFrom": "analytics_event", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analytics_event_shared_chat_id_shared_chat_id_fk": { + "name": "analytics_event_shared_chat_id_shared_chat_id_fk", + "tableFrom": "analytics_event", + "tableTo": "shared_chat", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "analytics_event_shared_story_id_shared_story_id_fk": { + "name": "analytics_event_shared_story_id_shared_story_id_fk", + "tableFrom": "analytics_event", + "tableTo": "shared_story", + "columnsFrom": [ + "shared_story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "analytics_event_asset_id_required": { + "name": "analytics_event_asset_id_required", + "value": "CASE WHEN asset_type = 'chat' THEN chat_id IS NOT NULL WHEN asset_type = 'story' THEN story_id IS NOT NULL ELSE TRUE END" + } + } + }, + "api_key": { + "name": "api_key", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "api_key_key_hash_unique": { + "name": "api_key_key_hash_unique", + "columns": [ + "key_hash" + ], + "isUnique": true + }, + "api_key_orgId_idx": { + "name": "api_key_orgId_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "api_key_org_id_organization_id_fk": { + "name": "api_key_org_id_organization_id_fk", + "tableFrom": "api_key", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_created_by_user_id_fk": { + "name": "api_key_created_by_user_id_fk", + "tableFrom": "api_key", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "automation": { + "name": "automation", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scheduled_job_id": { + "name": "scheduled_job_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schedule_description": { + "name": "schedule_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_provider": { + "name": "model_provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mcp_enabled": { + "name": "mcp_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "mcp_servers": { + "name": "mcp_servers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "integrations": { + "name": "integrations", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "webhook_enabled": { + "name": "webhook_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "automation_projectId_idx": { + "name": "automation_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "automation_userId_idx": { + "name": "automation_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "automation_scheduledJobId_idx": { + "name": "automation_scheduledJobId_idx", + "columns": [ + "scheduled_job_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "automation_project_id_project_id_fk": { + "name": "automation_project_id_project_id_fk", + "tableFrom": "automation", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_user_id_user_id_fk": { + "name": "automation_user_id_user_id_fk", + "tableFrom": "automation", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_scheduled_job_id_scheduled_job_id_fk": { + "name": "automation_scheduled_job_id_scheduled_job_id_fk", + "tableFrom": "automation", + "tableTo": "scheduled_job", + "columnsFrom": [ + "scheduled_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "automation_run": { + "name": "automation_run", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'running'" + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "integration_results": { + "name": "integration_results", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + } + }, + "indexes": { + "automation_run_automationId_idx": { + "name": "automation_run_automationId_idx", + "columns": [ + "automation_id" + ], + "isUnique": false + }, + "automation_run_chatId_idx": { + "name": "automation_run_chatId_idx", + "columns": [ + "chat_id" + ], + "isUnique": false + }, + "automation_run_status_idx": { + "name": "automation_run_status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "automation_run_automation_id_automation_id_fk": { + "name": "automation_run_automation_id_automation_id_fk", + "tableFrom": "automation_run", + "tableTo": "automation", + "columnsFrom": [ + "automation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_run_chat_id_chat_id_fk": { + "name": "automation_run_chat_id_chat_id_fk", + "tableFrom": "automation_run", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "branding_config": { + "name": "branding_config", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "app_name": { + "name": "app_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tab_title": { + "name": "tab_title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "logo_data": { + "name": "logo_data", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "logo_media_type": { + "name": "logo_media_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "favicon_data": { + "name": "favicon_data", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "favicon_media_type": { + "name": "favicon_media_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "brand_color": { + "name": "brand_color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "chat": { + "name": "chat", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'New Conversation'" + }, + "is_starred": { + "name": "is_starred", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "slack_thread_id": { + "name": "slack_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "teams_thread_id": { + "name": "teams_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_thread_id": { + "name": "telegram_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "whatsapp_thread_id": { + "name": "whatsapp_thread_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fork_metadata": { + "name": "fork_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "chat_userId_idx": { + "name": "chat_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "chat_projectId_idx": { + "name": "chat_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "chat_slack_thread_idx": { + "name": "chat_slack_thread_idx", + "columns": [ + "slack_thread_id" + ], + "isUnique": false + }, + "chat_teams_thread_idx": { + "name": "chat_teams_thread_idx", + "columns": [ + "teams_thread_id" + ], + "isUnique": false + }, + "chat_telegram_thread_idx": { + "name": "chat_telegram_thread_idx", + "columns": [ + "telegram_thread_id" + ], + "isUnique": false + }, + "chat_whatsapp_thread_idx": { + "name": "chat_whatsapp_thread_idx", + "columns": [ + "whatsapp_thread_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "chat_user_id_user_id_fk": { + "name": "chat_user_id_user_id_fk", + "tableFrom": "chat", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chat_project_id_project_id_fk": { + "name": "chat_project_id_project_id_fk", + "tableFrom": "chat", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "chat_message": { + "name": "chat_message", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stop_reason": { + "name": "stop_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "superseded_at": { + "name": "superseded_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version_group_id": { + "name": "version_group_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "isForked": { + "name": "isForked", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "citation": { + "name": "citation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "input_total_tokens": { + "name": "input_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_no_cache_tokens": { + "name": "input_no_cache_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_cache_read_tokens": { + "name": "input_cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_cache_write_tokens": { + "name": "input_cache_write_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_total_tokens": { + "name": "output_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_text_tokens": { + "name": "output_text_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_reasoning_tokens": { + "name": "output_reasoning_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "chat_message_chatId_idx": { + "name": "chat_message_chatId_idx", + "columns": [ + "chat_id" + ], + "isUnique": false + }, + "chat_message_createdAt_idx": { + "name": "chat_message_createdAt_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "chat_message_versionGroupId_idx": { + "name": "chat_message_versionGroupId_idx", + "columns": [ + "version_group_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "chat_message_chat_id_chat_id_fk": { + "name": "chat_message_chat_id_chat_id_fk", + "tableFrom": "chat_message", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_recommendation": { + "name": "context_recommendation", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "suggested_file": { + "name": "suggested_file", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_key": { + "name": "subject_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'open'" + }, + "snoozed_until": { + "name": "snoozed_until", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'medium'" + }, + "impact_score": { + "name": "impact_score", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "impact": { + "name": "impact", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "insights": { + "name": "insights", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "suggested_action": { + "name": "suggested_action", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fix_kind": { + "name": "fix_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proposed_edits": { + "name": "proposed_edits", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fix_guidance": { + "name": "fix_guidance", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fix_prompt": { + "name": "fix_prompt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pr_url": { + "name": "pr_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pr_branch": { + "name": "pr_branch", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pr_created_at": { + "name": "pr_created_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "occurrence_count": { + "name": "occurrence_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_changed_by": { + "name": "status_changed_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "context_recommendation_project_fingerprint_unique": { + "name": "context_recommendation_project_fingerprint_unique", + "columns": [ + "project_id", + "fingerprint" + ], + "isUnique": true + }, + "context_recommendation_projectId_status_idx": { + "name": "context_recommendation_projectId_status_idx", + "columns": [ + "project_id", + "status" + ], + "isUnique": false + }, + "context_recommendation_runId_idx": { + "name": "context_recommendation_runId_idx", + "columns": [ + "run_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "context_recommendation_project_id_project_id_fk": { + "name": "context_recommendation_project_id_project_id_fk", + "tableFrom": "context_recommendation", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "context_recommendation_status_changed_by_user_id_fk": { + "name": "context_recommendation_status_changed_by_user_id_fk", + "tableFrom": "context_recommendation", + "tableTo": "user", + "columnsFrom": [ + "status_changed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "context_recommendation_run_fk": { + "name": "context_recommendation_run_fk", + "tableFrom": "context_recommendation", + "tableTo": "context_recommendation_run", + "columnsFrom": [ + "run_id", + "project_id" + ], + "columnsTo": [ + "id", + "project_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_recommendation_config": { + "name": "context_recommendation_config", + "columns": { + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_provider": { + "name": "model_provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "custom_system_prompt_instructions": { + "name": "custom_system_prompt_instructions", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "repo_full_name": { + "name": "repo_full_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "repo_provider": { + "name": "repo_provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "auto_create_prs": { + "name": "auto_create_prs", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_auto_prs_per_run": { + "name": "max_auto_prs_per_run", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "context_recommendation_config_project_id_project_id_fk": { + "name": "context_recommendation_config_project_id_project_id_fk", + "tableFrom": "context_recommendation_config", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_recommendation_run": { + "name": "context_recommendation_run", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'schedule'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'running'" + }, + "window_start": { + "name": "window_start", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "window_end": { + "name": "window_end", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_total_tokens": { + "name": "input_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_total_tokens": { + "name": "output_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "context_recommendation_run_projectId_idx": { + "name": "context_recommendation_run_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "context_recommendation_run_chatId_idx": { + "name": "context_recommendation_run_chatId_idx", + "columns": [ + "chat_id" + ], + "isUnique": false + }, + "context_recommendation_run_status_idx": { + "name": "context_recommendation_run_status_idx", + "columns": [ + "status" + ], + "isUnique": false + }, + "context_recommendation_run_id_project_unique": { + "name": "context_recommendation_run_id_project_unique", + "columns": [ + "id", + "project_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "context_recommendation_run_project_id_project_id_fk": { + "name": "context_recommendation_run_project_id_project_id_fk", + "tableFrom": "context_recommendation_run", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "context_recommendation_run_chat_id_chat_id_fk": { + "name": "context_recommendation_run_chat_id_chat_id_fk", + "tableFrom": "context_recommendation_run", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "favorite": { + "name": "favorite", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "favorite_user_id_idx": { + "name": "favorite_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "favorite_user_id_story_id_unique": { + "name": "favorite_user_id_story_id_unique", + "columns": [ + "user_id", + "story_id" + ], + "isUnique": true + }, + "favorite_user_id_folder_id_unique": { + "name": "favorite_user_id_folder_id_unique", + "columns": [ + "user_id", + "folder_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "favorite_user_id_user_id_fk": { + "name": "favorite_user_id_user_id_fk", + "tableFrom": "favorite", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "favorite_story_id_story_id_fk": { + "name": "favorite_story_id_story_id_fk", + "tableFrom": "favorite", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "favorite_folder_id_story_folder_id_fk": { + "name": "favorite_folder_id_story_folder_id_fk", + "tableFrom": "favorite", + "tableTo": "story_folder", + "columnsFrom": [ + "folder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "favorite_xor_target": { + "name": "favorite_xor_target", + "value": "(\"favorite\".\"story_id\" IS NOT NULL) + (\"favorite\".\"folder_id\" IS NOT NULL) = 1" + } + } + }, + "jwks": { + "name": "jwks", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "llm_inference": { + "name": "llm_inference", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "llm_provider": { + "name": "llm_provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "llm_model_id": { + "name": "llm_model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_total_tokens": { + "name": "input_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_no_cache_tokens": { + "name": "input_no_cache_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_cache_read_tokens": { + "name": "input_cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_cache_write_tokens": { + "name": "input_cache_write_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_total_tokens": { + "name": "output_total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_text_tokens": { + "name": "output_text_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_reasoning_tokens": { + "name": "output_reasoning_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "llm_inference_projectId_idx": { + "name": "llm_inference_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "llm_inference_userId_idx": { + "name": "llm_inference_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "llm_inference_type_idx": { + "name": "llm_inference_type_idx", + "columns": [ + "type" + ], + "isUnique": false + } + }, + "foreignKeys": { + "llm_inference_project_id_project_id_fk": { + "name": "llm_inference_project_id_project_id_fk", + "tableFrom": "llm_inference", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "llm_inference_user_id_user_id_fk": { + "name": "llm_inference_user_id_user_id_fk", + "tableFrom": "llm_inference", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "llm_inference_chat_id_chat_id_fk": { + "name": "llm_inference_chat_id_chat_id_fk", + "tableFrom": "llm_inference", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "log": { + "name": "log", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context": { + "name": "context", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "log_createdAt_idx": { + "name": "log_createdAt_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "log_level_idx": { + "name": "log_level_idx", + "columns": [ + "level" + ], + "isUnique": false + }, + "log_projectId_idx": { + "name": "log_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "log_project_id_project_id_fk": { + "name": "log_project_id_project_id_fk", + "tableFrom": "log", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "mcp_call_log": { + "name": "mcp_call_log", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "success": { + "name": "success", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_input": { + "name": "tool_input", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_output": { + "name": "tool_output", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "called_at": { + "name": "called_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "mcp_call_log_projectId_idx": { + "name": "mcp_call_log_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "mcp_call_log_userId_idx": { + "name": "mcp_call_log_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "mcp_call_log_calledAt_idx": { + "name": "mcp_call_log_calledAt_idx", + "columns": [ + "called_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "mcp_call_log_project_id_project_id_fk": { + "name": "mcp_call_log_project_id_project_id_fk", + "tableFrom": "mcp_call_log", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_call_log_user_id_user_id_fk": { + "name": "mcp_call_log_user_id_user_id_fk", + "tableFrom": "mcp_call_log", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "mcp_chart_embed": { + "name": "mcp_chart_embed", + "columns": { + "chart_embed_id": { + "name": "chart_embed_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "query_id": { + "name": "query_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chart_config": { + "name": "chart_config", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_chat_id": { + "name": "source_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "mcp_chart_embed_query_id_idx": { + "name": "mcp_chart_embed_query_id_idx", + "columns": [ + "query_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "mcp_chart_embed_query_id_mcp_query_data_query_id_fk": { + "name": "mcp_chart_embed_query_id_mcp_query_data_query_id_fk", + "tableFrom": "mcp_chart_embed", + "tableTo": "mcp_query_data", + "columnsFrom": [ + "query_id" + ], + "columnsTo": [ + "query_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "mcp_oauth_client": { + "name": "mcp_oauth_client", + "columns": { + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "client_data": { + "name": "client_data", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "discovery_user_id": { + "name": "discovery_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "mcp_oauth_client_project_id_project_id_fk": { + "name": "mcp_oauth_client_project_id_project_id_fk", + "tableFrom": "mcp_oauth_client", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_oauth_client_discovery_user_id_user_id_fk": { + "name": "mcp_oauth_client_discovery_user_id_user_id_fk", + "tableFrom": "mcp_oauth_client", + "tableTo": "user", + "columnsFrom": [ + "discovery_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "mcp_oauth_client_project_id_server_name_pk": { + "columns": [ + "project_id", + "server_name" + ], + "name": "mcp_oauth_client_project_id_server_name_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "mcp_query_data": { + "name": "mcp_query_data", + "columns": { + "query_id": { + "name": "query_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "call_log_id": { + "name": "call_log_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_chat_id": { + "name": "source_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "columns": { + "name": "columns", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "mcp_query_data_project_id_idx": { + "name": "mcp_query_data_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "mcp_query_data_callLogId_idx": { + "name": "mcp_query_data_callLogId_idx", + "columns": [ + "call_log_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "mcp_query_data_project_id_project_id_fk": { + "name": "mcp_query_data_project_id_project_id_fk", + "tableFrom": "mcp_query_data", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "mcp_user_token": { + "name": "mcp_user_token", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "mcp_user_token_project_server_idx": { + "name": "mcp_user_token_project_server_idx", + "columns": [ + "project_id", + "server_name" + ], + "isUnique": false + } + }, + "foreignKeys": { + "mcp_user_token_user_id_user_id_fk": { + "name": "mcp_user_token_user_id_user_id_fk", + "tableFrom": "mcp_user_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_user_token_project_id_project_id_fk": { + "name": "mcp_user_token_project_id_project_id_fk", + "tableFrom": "mcp_user_token", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "mcp_user_token_user_id_project_id_server_name_pk": { + "columns": [ + "user_id", + "project_id", + "server_name" + ], + "name": "mcp_user_token_user_id_project_id_server_name_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "memories": { + "name": "memories", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "superseded_by": { + "name": "superseded_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "memories_userId_idx": { + "name": "memories_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "memories_chatId_idx": { + "name": "memories_chatId_idx", + "columns": [ + "chat_id" + ], + "isUnique": false + }, + "memories_supersededBy_idx": { + "name": "memories_supersededBy_idx", + "columns": [ + "superseded_by" + ], + "isUnique": false + } + }, + "foreignKeys": { + "memories_user_id_user_id_fk": { + "name": "memories_user_id_user_id_fk", + "tableFrom": "memories", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memories_chat_id_chat_id_fk": { + "name": "memories_chat_id_chat_id_fk", + "tableFrom": "memories", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "message_feedback": { + "name": "message_feedback", + "columns": { + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "vote": { + "name": "vote", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "explanation": { + "name": "explanation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "message_feedback_message_id_chat_message_id_fk": { + "name": "message_feedback_message_id_chat_message_id_fk", + "tableFrom": "message_feedback", + "tableTo": "chat_message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "message_image": { + "name": "message_image", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "media_type": { + "name": "media_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "message_part": { + "name": "message_part", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reasoning_text": { + "name": "reasoning_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_state": { + "name": "tool_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_error_text": { + "name": "tool_error_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_input": { + "name": "tool_input", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_raw_input": { + "name": "tool_raw_input", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_output": { + "name": "tool_output", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_approval_id": { + "name": "tool_approval_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_approval_approved": { + "name": "tool_approval_approved", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_approval_reason": { + "name": "tool_approval_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_provider_metadata": { + "name": "tool_provider_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider_metadata": { + "name": "provider_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "media_type": { + "name": "media_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "message_part_tool_call_id_unique": { + "name": "message_part_tool_call_id_unique", + "columns": [ + "tool_call_id" + ], + "isUnique": true + }, + "parts_message_id_idx": { + "name": "parts_message_id_idx", + "columns": [ + "message_id" + ], + "isUnique": false + }, + "parts_message_id_order_idx": { + "name": "parts_message_id_order_idx", + "columns": [ + "message_id", + "order" + ], + "isUnique": false + } + }, + "foreignKeys": { + "message_part_message_id_chat_message_id_fk": { + "name": "message_part_message_id_chat_message_id_fk", + "tableFrom": "message_part", + "tableTo": "chat_message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "message_part_image_id_message_image_id_fk": { + "name": "message_part_image_id_message_image_id_fk", + "tableFrom": "message_part", + "tableTo": "message_image", + "columnsFrom": [ + "image_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "text_required_if_type_is_text": { + "name": "text_required_if_type_is_text", + "value": "CASE WHEN type = 'text' THEN text IS NOT NULL ELSE TRUE END" + }, + "reasoning_text_required_if_type_is_reasoning": { + "name": "reasoning_text_required_if_type_is_reasoning", + "value": "CASE WHEN type = 'reasoning' THEN reasoning_text IS NOT NULL ELSE TRUE END" + }, + "tool_call_fields_required": { + "name": "tool_call_fields_required", + "value": "CASE WHEN type LIKE 'tool-%' THEN tool_call_id IS NOT NULL AND tool_state IS NOT NULL ELSE TRUE END" + }, + "file_fields_required": { + "name": "file_fields_required", + "value": "CASE WHEN type = 'file' THEN media_type IS NOT NULL ELSE TRUE END" + } + } + }, + "chart_image": { + "name": "chart_image", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "chart_image_tool_call_id_unique": { + "name": "chart_image_tool_call_id_unique", + "columns": [ + "tool_call_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "oauth_access_token": { + "name": "oauth_access_token", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_id": { + "name": "refresh_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "oauth_access_token_token_unique": { + "name": "oauth_access_token_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "oauth_access_token_clientId_idx": { + "name": "oauth_access_token_clientId_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "oauth_access_token_userId_idx": { + "name": "oauth_access_token_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "oauth_access_token_refreshId_idx": { + "name": "oauth_access_token_refreshId_idx", + "columns": [ + "refresh_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "oauth_access_token_client_id_oauth_client_client_id_fk": { + "name": "oauth_access_token_client_id_oauth_client_client_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "oauth_client", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "client_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_access_token_session_id_session_id_fk": { + "name": "oauth_access_token_session_id_session_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "session", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "oauth_access_token_user_id_user_id_fk": { + "name": "oauth_access_token_user_id_user_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": { + "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk", + "tableFrom": "oauth_access_token", + "tableTo": "oauth_refresh_token", + "columnsFrom": [ + "refresh_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "oauth_client": { + "name": "oauth_client", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled": { + "name": "disabled", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": false + }, + "skip_consent": { + "name": "skip_consent", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enable_end_session": { + "name": "enable_end_session", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "subject_type": { + "name": "subject_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "contacts": { + "name": "contacts", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tos": { + "name": "tos", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "policy": { + "name": "policy", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "software_id": { + "name": "software_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "software_version": { + "name": "software_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "software_statement": { + "name": "software_statement", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "redirect_uris": { + "name": "redirect_uris", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "post_logout_redirect_uris": { + "name": "post_logout_redirect_uris", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token_endpoint_auth_method": { + "name": "token_endpoint_auth_method", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "grant_types": { + "name": "grant_types", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response_types": { + "name": "response_types", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "public": { + "name": "public", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "require_pkce": { + "name": "require_pkce", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "oauth_client_client_id_unique": { + "name": "oauth_client_client_id_unique", + "columns": [ + "client_id" + ], + "isUnique": true + }, + "oauth_client_userId_idx": { + "name": "oauth_client_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "oauth_client_user_id_user_id_fk": { + "name": "oauth_client_user_id_user_id_fk", + "tableFrom": "oauth_client", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "oauth_consent": { + "name": "oauth_consent", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "oauth_consent_clientId_idx": { + "name": "oauth_consent_clientId_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "oauth_consent_userId_idx": { + "name": "oauth_consent_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "oauth_consent_client_id_oauth_client_client_id_fk": { + "name": "oauth_consent_client_id_oauth_client_client_id_fk", + "tableFrom": "oauth_consent", + "tableTo": "oauth_client", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "client_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_consent_user_id_user_id_fk": { + "name": "oauth_consent_user_id_user_id_fk", + "tableFrom": "oauth_consent", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "oauth_refresh_token": { + "name": "oauth_refresh_token", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "revoked": { + "name": "revoked", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "auth_time": { + "name": "auth_time", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "oauth_refresh_token_token_unique": { + "name": "oauth_refresh_token_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "oauth_refresh_token_clientId_idx": { + "name": "oauth_refresh_token_clientId_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "oauth_refresh_token_userId_idx": { + "name": "oauth_refresh_token_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "oauth_refresh_token_sessionId_idx": { + "name": "oauth_refresh_token_sessionId_idx", + "columns": [ + "session_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "oauth_refresh_token_client_id_oauth_client_client_id_fk": { + "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk", + "tableFrom": "oauth_refresh_token", + "tableTo": "oauth_client", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "client_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_refresh_token_session_id_session_id_fk": { + "name": "oauth_refresh_token_session_id_session_id_fk", + "tableFrom": "oauth_refresh_token", + "tableTo": "session", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "oauth_refresh_token_user_id_user_id_fk": { + "name": "oauth_refresh_token_user_id_user_id_fk", + "tableFrom": "oauth_refresh_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "org_member": { + "name": "org_member", + "columns": { + "org_id": { + "name": "org_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "org_member_userId_idx": { + "name": "org_member_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "org_member_org_id_organization_id_fk": { + "name": "org_member_org_id_organization_id_fk", + "tableFrom": "org_member", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "org_member_user_id_user_id_fk": { + "name": "org_member_user_id_user_id_fk", + "tableFrom": "org_member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "org_member_org_id_user_id_pk": { + "columns": [ + "org_id", + "user_id" + ], + "name": "org_member_org_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organization": { + "name": "organization", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "google_client_id": { + "name": "google_client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "google_client_secret": { + "name": "google_client_secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "google_auth_domains": { + "name": "google_auth_domains", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_project_id": { + "name": "default_project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "organization_slug_unique": { + "name": "organization_slug_unique", + "columns": [ + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project": { + "name": "project", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_settings": { + "name": "agent_settings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled_tools": { + "name": "enabled_tools", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "known_mcp_servers": { + "name": "known_mcp_servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "disabled_mcp_servers": { + "name": "disabled_mcp_servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "disabled_mcp_tools": { + "name": "disabled_mcp_tools", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "env_vars": { + "name": "env_vars", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "slack_settings": { + "name": "slack_settings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "teams_settings": { + "name": "teams_settings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_settings": { + "name": "telegram_settings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "whatsapp_settings": { + "name": "whatsapp_settings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mcp_endpoint_settings": { + "name": "mcp_endpoint_settings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "display_settings": { + "name": "display_settings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_orgId_idx": { + "name": "project_orgId_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_org_id_organization_id_fk": { + "name": "project_org_id_organization_id_fk", + "tableFrom": "project", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "local_project_path_required": { + "name": "local_project_path_required", + "value": "CASE WHEN \"type\" = 'local' THEN \"path\" IS NOT NULL ELSE TRUE END" + } + } + }, + "project_llm_config": { + "name": "project_llm_config", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credentials": { + "name": "credentials", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled_models": { + "name": "enabled_models", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "custom_models": { + "name": "custom_models", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "model_settings": { + "name": "model_settings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_llm_config_projectId_idx": { + "name": "project_llm_config_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "project_llm_config_project_provider": { + "name": "project_llm_config_project_provider", + "columns": [ + "project_id", + "provider" + ], + "isUnique": true + } + }, + "foreignKeys": { + "project_llm_config_project_id_project_id_fk": { + "name": "project_llm_config_project_id_project_id_fk", + "tableFrom": "project_llm_config", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_member": { + "name": "project_member", + "columns": { + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_member_userId_idx": { + "name": "project_member_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_member_project_id_project_id_fk": { + "name": "project_member_project_id_project_id_fk", + "tableFrom": "project_member", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_member_user_id_user_id_fk": { + "name": "project_member_user_id_user_id_fk", + "tableFrom": "project_member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_member_project_id_user_id_pk": { + "columns": [ + "project_id", + "user_id" + ], + "name": "project_member_project_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_provider_budget": { + "name": "project_provider_budget", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "limit_usd": { + "name": "limit_usd", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "current_period_start": { + "name": "current_period_start", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "notified_at": { + "name": "notified_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_provider_budget_projectId_idx": { + "name": "project_provider_budget_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "project_provider_budget_project_provider": { + "name": "project_provider_budget_project_provider", + "columns": [ + "project_id", + "provider" + ], + "isUnique": true + } + }, + "foreignKeys": { + "project_provider_budget_project_id_project_id_fk": { + "name": "project_provider_budget_project_id_project_id_fk", + "tableFrom": "project_provider_budget", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "budget_period_valid": { + "name": "budget_period_valid", + "value": "period IN ('day', 'week', 'month')" + } + } + }, + "project_saved_prompt": { + "name": "project_saved_prompt", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_saved_prompt_projectId_idx": { + "name": "project_saved_prompt_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_saved_prompt_project_id_project_id_fk": { + "name": "project_saved_prompt_project_id_project_id_fk", + "tableFrom": "project_saved_prompt", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_whatsapp_link": { + "name": "project_whatsapp_link", + "columns": { + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "whatsapp_user_id": { + "name": "whatsapp_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_whatsapp_link_userId_idx": { + "name": "project_whatsapp_link_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_whatsapp_link_project_id_project_id_fk": { + "name": "project_whatsapp_link_project_id_project_id_fk", + "tableFrom": "project_whatsapp_link", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_whatsapp_link_user_id_user_id_fk": { + "name": "project_whatsapp_link_user_id_user_id_fk", + "tableFrom": "project_whatsapp_link", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_whatsapp_link_project_id_whatsapp_user_id_pk": { + "columns": [ + "project_id", + "whatsapp_user_id" + ], + "name": "project_whatsapp_link_project_id_whatsapp_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scheduled_job": { + "name": "scheduled_job", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "run_at": { + "name": "run_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cron": { + "name": "cron", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 5 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "locked_at": { + "name": "locked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "locked_by": { + "name": "locked_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unique_key": { + "name": "unique_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "scheduled_job_unique_key_unique": { + "name": "scheduled_job_unique_key_unique", + "columns": [ + "unique_key" + ], + "isUnique": true + }, + "scheduled_job_status_runAt_idx": { + "name": "scheduled_job_status_runAt_idx", + "columns": [ + "status", + "run_at" + ], + "isUnique": false + }, + "scheduled_job_name_idx": { + "name": "scheduled_job_name_idx", + "columns": [ + "name" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_token_unique": { + "name": "session_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "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": {}, + "checkConstraints": {} + }, + "shared_chat": { + "name": "shared_chat", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'project'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "shared_chat_chatId_unique": { + "name": "shared_chat_chatId_unique", + "columns": [ + "chat_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "shared_chat_chat_id_chat_id_fk": { + "name": "shared_chat_chat_id_chat_id_fk", + "tableFrom": "shared_chat", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "shared_chat_access": { + "name": "shared_chat_access", + "columns": { + "shared_chat_id": { + "name": "shared_chat_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "shared_chat_access_shared_chat_id_shared_chat_id_fk": { + "name": "shared_chat_access_shared_chat_id_shared_chat_id_fk", + "tableFrom": "shared_chat_access", + "tableTo": "shared_chat", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_chat_access_user_id_user_id_fk": { + "name": "shared_chat_access_user_id_user_id_fk", + "tableFrom": "shared_chat_access", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "shared_chat_access_shared_chat_id_user_id_pk": { + "columns": [ + "shared_chat_id", + "user_id" + ], + "name": "shared_chat_access_shared_chat_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "shared_story": { + "name": "shared_story", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'project'" + }, + "is_pinned": { + "name": "is_pinned", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "shared_story_projectId_idx": { + "name": "shared_story_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "shared_story_storyId_idx": { + "name": "shared_story_storyId_idx", + "columns": [ + "story_id" + ], + "isUnique": false + }, + "shared_story_project_story_unique": { + "name": "shared_story_project_story_unique", + "columns": [ + "project_id", + "story_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "shared_story_story_id_story_id_fk": { + "name": "shared_story_story_id_story_id_fk", + "tableFrom": "shared_story", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_story_project_id_project_id_fk": { + "name": "shared_story_project_id_project_id_fk", + "tableFrom": "shared_story", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_story_user_id_user_id_fk": { + "name": "shared_story_user_id_user_id_fk", + "tableFrom": "shared_story", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "shared_story_access": { + "name": "shared_story_access", + "columns": { + "shared_story_id": { + "name": "shared_story_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "shared_story_access_shared_story_id_shared_story_id_fk": { + "name": "shared_story_access_shared_story_id_shared_story_id_fk", + "tableFrom": "shared_story_access", + "tableTo": "shared_story", + "columnsFrom": [ + "shared_story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_story_access_user_id_user_id_fk": { + "name": "shared_story_access_user_id_user_id_fk", + "tableFrom": "shared_story_access", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "shared_story_access_shared_story_id_user_id_pk": { + "columns": [ + "shared_story_id", + "user_id" + ], + "name": "shared_story_access_shared_story_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "story": { + "name": "story", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_live": { + "name": "is_live", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_live_text_dynamic": { + "name": "is_live_text_dynamic", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "cache_schedule": { + "name": "cache_schedule", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_schedule_description": { + "name": "cache_schedule_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scheduled_job_id": { + "name": "scheduled_job_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "story_standalone_slug_unique": { + "name": "story_standalone_slug_unique", + "columns": [ + "project_id", + "user_id", + "slug" + ], + "isUnique": true, + "where": "chat_id IS NULL" + }, + "story_chatId_idx": { + "name": "story_chatId_idx", + "columns": [ + "chat_id" + ], + "isUnique": false + }, + "story_projectId_idx": { + "name": "story_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "story_userId_idx": { + "name": "story_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "story_scheduledJobId_idx": { + "name": "story_scheduledJobId_idx", + "columns": [ + "scheduled_job_id" + ], + "isUnique": false + }, + "story_chat_slug_unique": { + "name": "story_chat_slug_unique", + "columns": [ + "chat_id", + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": { + "story_chat_id_chat_id_fk": { + "name": "story_chat_id_chat_id_fk", + "tableFrom": "story", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_project_id_project_id_fk": { + "name": "story_project_id_project_id_fk", + "tableFrom": "story", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_user_id_user_id_fk": { + "name": "story_user_id_user_id_fk", + "tableFrom": "story", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_scheduled_job_id_scheduled_job_id_fk": { + "name": "story_scheduled_job_id_scheduled_job_id_fk", + "tableFrom": "story", + "tableTo": "scheduled_job", + "columnsFrom": [ + "scheduled_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "story_owner_required": { + "name": "story_owner_required", + "value": "chat_id IS NOT NULL OR (project_id IS NOT NULL AND user_id IS NOT NULL)" + } + } + }, + "story_data_cache": { + "name": "story_data_cache", + "columns": { + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "query_data": { + "name": "query_data", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "analysis_results": { + "name": "analysis_results", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cached_at": { + "name": "cached_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "story_data_cache_story_id_story_id_fk": { + "name": "story_data_cache_story_id_story_id_fk", + "tableFrom": "story_data_cache", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "story_folder": { + "name": "story_folder", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'public'" + }, + "system_type": { + "name": "system_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "story_folder_private_root_unique": { + "name": "story_folder_private_root_unique", + "columns": [ + "project_id", + "owner_id" + ], + "isUnique": true, + "where": "\"story_folder\".\"system_type\" = 'private_folder'" + }, + "story_folder_ownerProjectParent_idx": { + "name": "story_folder_ownerProjectParent_idx", + "columns": [ + "owner_id", + "project_id", + "parent_id" + ], + "isUnique": false + }, + "story_folder_projectId_idx": { + "name": "story_folder_projectId_idx", + "columns": [ + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "story_folder_owner_id_user_id_fk": { + "name": "story_folder_owner_id_user_id_fk", + "tableFrom": "story_folder", + "tableTo": "user", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_folder_project_id_project_id_fk": { + "name": "story_folder_project_id_project_id_fk", + "tableFrom": "story_folder", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_folder_parent_id_story_folder_id_fk": { + "name": "story_folder_parent_id_story_folder_id_fk", + "tableFrom": "story_folder", + "tableTo": "story_folder", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "story_folder_item": { + "name": "story_folder_item", + "columns": { + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "story_folder_item_folderId_idx": { + "name": "story_folder_item_folderId_idx", + "columns": [ + "folder_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "story_folder_item_story_id_story_id_fk": { + "name": "story_folder_item_story_id_story_id_fk", + "tableFrom": "story_folder_item", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "story_folder_item_folder_id_story_folder_id_fk": { + "name": "story_folder_item_folder_id_story_folder_id_fk", + "tableFrom": "story_folder_item", + "tableTo": "story_folder", + "columnsFrom": [ + "folder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "story_version": { + "name": "story_version", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "story_id": { + "name": "story_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "story_version_storyId_idx": { + "name": "story_version_storyId_idx", + "columns": [ + "story_id" + ], + "isUnique": false + }, + "story_version_story_version_unique": { + "name": "story_version_story_version_unique", + "columns": [ + "story_id", + "version" + ], + "isUnique": true + } + }, + "foreignKeys": { + "story_version_story_id_story_id_fk": { + "name": "story_version_story_id_story_id_fk", + "tableFrom": "story_version", + "tableTo": "story", + "columnsFrom": [ + "story_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "requires_password_reset": { + "name": "requires_password_reset", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "memory_enabled": { + "name": "memory_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "messaging_provider_code": { + "name": "messaging_provider_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "github_access_token": { + "name": "github_access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "gitlab_access_token": { + "name": "gitlab_access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "user_email_unique": { + "name": "user_email_unique", + "columns": [ + "email" + ], + "isUnique": true + }, + "user_messaging_provider_code_unique": { + "name": "user_messaging_provider_code_unique", + "columns": [ + "messaging_provider_code" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_preference": { + "name": "user_preference", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "preferences": { + "name": "preferences", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "user_preference_user_id_user_id_fk": { + "name": "user_preference_user_id_user_id_fk", + "tableFrom": "user_preference", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "verification": { + "name": "verification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + "identifier" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/apps/backend/migrations-sqlite/meta/_journal.json b/apps/backend/migrations-sqlite/meta/_journal.json index afb40f673..89e2a2cf7 100644 --- a/apps/backend/migrations-sqlite/meta/_journal.json +++ b/apps/backend/migrations-sqlite/meta/_journal.json @@ -400,6 +400,13 @@ "when": 1783697772869, "tag": "0056_model_settings", "breakpoints": true + }, + { + "idx": 57, + "version": "6", + "when": 1784138876738, + "tag": "0057_add_org_default_project_id", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/backend/src/auth.ts b/apps/backend/src/auth.ts index b8618a09e..943277119 100644 --- a/apps/backend/src/auth.ts +++ b/apps/backend/src/auth.ts @@ -24,13 +24,11 @@ import { hasFeature, LICENSE_FEATURES } from './services/license.service'; import { augmentSocialProvidersWithMicrosoft, getTrustedProvidersForMicrosoft, - isSocialProviderMicrosoft, } from './services/microsoft-auth.service'; import { augmentPluginsWithOidc, getOidcProviderId, getTrustedProvidersForOidc, - isSocialProviderOidc, } from './services/oidc-auth.service'; import { buildForgotPasswordEmail } from './utils/email-builders'; import { logger, serializeError } from './utils/logger'; @@ -256,11 +254,6 @@ async function createAuthInstance(baseURL: string) { }, async after(user, ctx) { const providerId = resolveProviderId(ctx); - const isSocial = - providerId === 'google' || - providerId === 'github' || - providerId === 'gitlab' || - (ssoEnabled && (isSocialProviderMicrosoft(providerId) || isSocialProviderOidc(providerId))); try { if (isCloud) { @@ -279,9 +272,7 @@ async function createAuthInstance(baseURL: string) { } } else { await orgQueries.initializeDefaultOrganizationForFirstUser(user.id); - if (isSocial) { - await orgQueries.addUserToDefaultProjectIfExists(user.id); - } + await orgQueries.addUserToDefaultProjectIfExists(user.id); } await refreshAuthAfterInitialSelfHostedSignup(); } catch (err) { diff --git a/apps/backend/src/db/pg-schema.ts b/apps/backend/src/db/pg-schema.ts index 556c6f092..6ecfb50ca 100644 --- a/apps/backend/src/db/pg-schema.ts +++ b/apps/backend/src/db/pg-schema.ts @@ -154,6 +154,7 @@ export const organization = pgTable('organization', { googleClientId: text('google_client_id'), googleClientSecret: text('google_client_secret'), googleAuthDomains: text('google_auth_domains'), // comma-separated list + defaultProjectId: text('default_project_id'), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at') diff --git a/apps/backend/src/db/sqlite-schema.ts b/apps/backend/src/db/sqlite-schema.ts index bc3e38be9..fa36e352d 100644 --- a/apps/backend/src/db/sqlite-schema.ts +++ b/apps/backend/src/db/sqlite-schema.ts @@ -165,6 +165,7 @@ export const organization = sqliteTable('organization', { googleClientId: text('google_client_id'), googleClientSecret: text('google_client_secret'), googleAuthDomains: text('google_auth_domains'), // comma-separated list + defaultProjectId: text('default_project_id'), createdAt: integer('created_at', { mode: 'timestamp_ms' }) .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`) diff --git a/apps/backend/src/queries/organization.queries.ts b/apps/backend/src/queries/organization.queries.ts index b5b5f8bea..291417f26 100644 --- a/apps/backend/src/queries/organization.queries.ts +++ b/apps/backend/src/queries/organization.queries.ts @@ -1,7 +1,7 @@ import type { UserRole } from '@nao/shared/types'; import { and, asc, count, eq, isNotNull, isNull, sql } from 'drizzle-orm'; -import s, { DBOrganization, DBOrgMember, NewOrganization, NewOrgMember } from '../db/abstractSchema'; +import s, { DBOrganization, DBOrgMember, DBProject, NewOrganization, NewOrgMember } from '../db/abstractSchema'; import { db } from '../db/db'; import { env } from '../env'; import { OrgRole } from '../types/organization'; @@ -231,13 +231,19 @@ export const initializeDefaultOrganizationForFirstUser = async (userId: string): .execute(); await tx.insert(s.projectMember).values({ projectId: project.id, userId, role: 'admin' }).execute(); + + await tx + .update(s.organization) + .set({ defaultProjectId: project.id }) + .where(eq(s.organization.id, org.id)) + .execute(); } } }); }; /** - * Add a user to the default organization and project if they don't already exist. + * Add a user to the default organization and its default project. * Called when a new user signs up. * Idempotent: safe to call multiple times for the same user. */ @@ -247,11 +253,6 @@ export const addUserToDefaultProjectIfExists = async (userId: string): Promise { @@ -262,11 +263,13 @@ export const addUserToDefaultProjectIfExists = async (userId: string): Promise => { + await db.update(s.organization).set({ defaultProjectId: projectId }).where(eq(s.organization.id, orgId)).execute(); +}; + +export const ensureUserInDefaultProject = async (orgId: string, userId: string): Promise => { + const org = await getOrganizationById(orgId); + if (!org?.defaultProjectId) { + return; + } + + const existingMember = await projectQueries.getProjectMember(org.defaultProjectId, userId); + if (!existingMember) { + await projectQueries.addProjectMember({ + projectId: org.defaultProjectId, + userId, + role: env.DEFAULT_USER_ROLE, + }); + } +}; + +export const ensureAllOrgMembersInDefaultProject = async (orgId: string): Promise => { + const org = await getOrganizationById(orgId); + if (!org?.defaultProjectId) { + return; + } + + const members = await db.select().from(s.orgMember).where(eq(s.orgMember.orgId, orgId)).execute(); + for (const member of members) { + const existingMember = await projectQueries.getProjectMember(org.defaultProjectId, member.userId); + if (!existingMember) { + await projectQueries.addProjectMember({ + projectId: org.defaultProjectId, + userId: member.userId, + role: member.role, + }); + } + } +}; + export const removeOrgMember = async (orgId: string, userId: string): Promise => { await db .delete(s.orgMember) @@ -420,7 +462,8 @@ export const countOrgAdmins = async (orgId: string): Promise => { }; /** - * Ensures a project exists for the current NAO_DEFAULT_PROJECT_PATH. + * Ensures a project exists for the current NAO_DEFAULT_PROJECT_PATH + * and sets it as the org's default project with all members enrolled. * When users change the project path and restart, the DB may not have a record for the new path. */ const ensureDefaultProject = async (org: DBOrganization): Promise => { @@ -430,25 +473,32 @@ const ensureDefaultProject = async (org: DBOrganization): Promise => { } const existing = await projectQueries.getProjectByPath(projectPath); - if (existing) { - return; - } + let project: DBProject | null = existing; + + if (!existing) { + const projectName = projectPath.split('/').pop() || 'Default Project'; + project = await projectQueries.createProject({ + name: projectName, + type: 'local', + path: projectPath, + orgId: org.id, + }); - const projectName = projectPath.split('/').pop() || 'Default Project'; - const project = await projectQueries.createProject({ - name: projectName, - type: 'local', - path: projectPath, - orgId: org.id, - }); + // Add all org members to the new project + const orgMembers = await db.select().from(s.orgMember).where(eq(s.orgMember.orgId, org.id)).execute(); + for (const member of orgMembers) { + await projectQueries.addProjectMember({ + projectId: project.id, + userId: member.userId, + role: member.role, + }); + } + } - // Add all org members to the new project - const orgMembers = await db.select().from(s.orgMember).where(eq(s.orgMember.orgId, org.id)).execute(); - for (const member of orgMembers) { - await projectQueries.addProjectMember({ - projectId: project.id, - userId: member.userId, - role: member.role, - }); + // Set as org's default project (idempotent — safe even if already set) + if (project) { + await setOrgDefaultProject(org.id, project.id); + // Backfill: ensure all existing org members have access + await ensureAllOrgMembersInDefaultProject(org.id); } }; diff --git a/apps/backend/src/trpc/organization.routes.ts b/apps/backend/src/trpc/organization.routes.ts index 0094aa5a1..c14d5075f 100644 --- a/apps/backend/src/trpc/organization.routes.ts +++ b/apps/backend/src/trpc/organization.routes.ts @@ -5,6 +5,7 @@ import { z } from 'zod/v4'; import { env, isCloud } from '../env'; import * as accountQueries from '../queries/account.queries'; import * as orgQueries from '../queries/organization.queries'; +import * as projectQueries from '../queries/project.queries'; import * as userQueries from '../queries/user.queries'; import { emailService } from '../services/email'; import { addTeamMember } from '../services/team-member'; @@ -40,6 +41,40 @@ export const organizationRoutes = { return orgQueries.listOrgProjectsWithAccess(ctx.org.id, ctx.user.id); }), + getDefaultProject: orgAdminProcedure.query(async ({ ctx }) => { + if (!ctx.org.defaultProjectId) { + return null; + } + return projectQueries.getProjectById(ctx.org.defaultProjectId); + }), + + setDefaultProject: orgAdminOnlyProcedure + .input(z.object({ projectId: z.string().nullable() })) + .mutation(async ({ input, ctx }) => { + if (!isCloud && env.NAO_DEFAULT_PROJECT_PATH) { + throw new TRPCError({ + code: 'BAD_REQUEST', + message: + 'Default project is managed via the NAO_DEFAULT_PROJECT_PATH environment variable in self-hosted mode.', + }); + } + + if (input.projectId) { + const project = await projectQueries.getProjectById(input.projectId); + if (!project || project.orgId !== ctx.org.id) { + throw new TRPCError({ + code: 'BAD_REQUEST', + message: 'Project not found or does not belong to this organization.', + }); + } + } + await orgQueries.setOrgDefaultProject(ctx.org.id, input.projectId); + if (input.projectId) { + await orgQueries.ensureAllOrgMembersInDefaultProject(ctx.org.id); + } + return { projectId: input.projectId }; + }), + getMembers: orgAdminProcedure.query(async ({ ctx }) => { return orgQueries.listOrgMembersWithUsers(ctx.org.id); }), @@ -84,7 +119,7 @@ export const organizationRoutes = { await orgQueries.updateOrgMemberRole(ctx.org.id, input.userId, input.role); }), - addMember: orgAdminOnlyProcedure + addMember: orgAdminOnlyProcedure .input(z.object({ email: z.string().min(1), name: z.string().min(1).optional() })) .mutation(async ({ input, ctx }) => { const orgId = ctx.org.id; @@ -95,6 +130,7 @@ export const organizationRoutes = { checkExisting: async (userId) => !!(await orgQueries.getOrgMember(orgId, userId)), addMember: async (userId) => { await orgQueries.addOrgMember({ orgId, userId, role: env.DEFAULT_USER_ROLE }); + await orgQueries.ensureUserInDefaultProject(orgId, userId); }, buildEmail: (user, password) => buildUserAddedEmail(user, ctx.org.name, 'organization', password), }); diff --git a/apps/backend/src/trpc/system.routes.ts b/apps/backend/src/trpc/system.routes.ts index e66801bab..9dd016ba9 100644 --- a/apps/backend/src/trpc/system.routes.ts +++ b/apps/backend/src/trpc/system.routes.ts @@ -10,6 +10,7 @@ export const systemRoutes = { enableUserSignup: await isUserSignupAvailable(), betaAutomationsEnabled: env.BETA_AUTOMATIONS_ENABLED, betaContextRecommendationsEnabled: env.BETA_CONTEXT_RECOMMENDATIONS_ENABLED, + hasDefaultProjectPath: !!env.NAO_DEFAULT_PROJECT_PATH, })), version: adminProtectedProcedure.query(() => ({ diff --git a/apps/frontend/src/routes/_sidebar-layout.settings.organization.tsx b/apps/frontend/src/routes/_sidebar-layout.settings.organization.tsx index 2fb8c8833..7f1241705 100644 --- a/apps/frontend/src/routes/_sidebar-layout.settings.organization.tsx +++ b/apps/frontend/src/routes/_sidebar-layout.settings.organization.tsx @@ -1,7 +1,7 @@ import { createFileRoute, Link } from '@tanstack/react-router'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useState, useCallback } from 'react'; -import { Github, Plus } from 'lucide-react'; +import { Check, Github, Plus } from 'lucide-react'; import { ORG_MEMBER_ROLES, USER_ROLE_LABELS } from '@nao/shared/types'; import type { UserRole } from '@nao/shared/types'; @@ -41,6 +41,7 @@ function OrganizationPage() { const systemConfig = useQuery(trpc.system.getPublicConfig.queryOptions()); const { isOrgAdmin } = usePermissions(); const isCloud = systemConfig.data?.naoMode === 'cloud'; + const hasDefaultProjectPath = systemConfig.data?.hasDefaultProjectPath === true; const githubAvailable = useQuery(trpc.github.isAvailable.queryOptions()); const githubStatus = useQuery({ @@ -61,6 +62,10 @@ function OrganizationPage() { const [removeMember, setRemoveMember] = useState(null); const [resetPasswordMember, setResetPasswordMember] = useState(null); const [credentials, setCredentials] = useState<{ email: string; password: string } | null>(null); + const [defaultProjectDialogOpen, setDefaultProjectDialogOpen] = useState(false); + + const defaultProjectQuery = useQuery(trpc.organization.getDefaultProject.queryOptions()); + const setDefaultProject = useMutation(trpc.organization.setDefaultProject.mutationOptions()); const invalidateMembers = useCallback(() => { queryClient.invalidateQueries({ queryKey: trpc.organization.getMembers.queryKey() }); @@ -227,6 +232,28 @@ function OrganizationPage() { )} + setDefaultProjectDialogOpen(true)}> + Change + + ) : undefined + } + > + {!isCloud && hasDefaultProjectPath ? ( +
+ Managed via the NAO_DEFAULT_PROJECT_PATH environment variable. +
+ ) : defaultProjectQuery.isLoading ? ( +
Loading...
+ ) : defaultProjectQuery.data ? ( +
{defaultProjectQuery.data.name}
+ ) : ( +
No default project set.
+ )} +
{isCloud && } @@ -280,6 +307,47 @@ function OrganizationPage() { + + + + + Default Project + +
+ {projectsQuery.data?.map((project) => ( + + ))} + {defaultProjectQuery.data && ( + <> +
+ + + )} +
+
+
); }