diff --git a/packages/control-plane/drizzle/0048_computers_gateway_key_hash_idx.sql b/packages/control-plane/drizzle/0048_computers_gateway_key_hash_idx.sql new file mode 100644 index 00000000..9c20ccbf --- /dev/null +++ b/packages/control-plane/drizzle/0048_computers_gateway_key_hash_idx.sql @@ -0,0 +1 @@ +CREATE UNIQUE INDEX "computers_gateway_key_hash_idx" ON "computers" USING btree ("gateway_key_hash"); \ No newline at end of file diff --git a/packages/control-plane/drizzle/meta/0048_snapshot.json b/packages/control-plane/drizzle/meta/0048_snapshot.json new file mode 100644 index 00000000..89f43c14 --- /dev/null +++ b/packages/control-plane/drizzle/meta/0048_snapshot.json @@ -0,0 +1,5221 @@ +{ + "id": "e50216a7-3f29-44df-826b-3c51ed541d94", + "prevId": "834aed3d-4045-4b01-9f9b-e1dfb4a5b542", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account_credentials": { + "name": "account_credentials", + "schema": "", + "columns": { + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_enc": { + "name": "access_enc", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_enc": { + "name": "refresh_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_expires_at": { + "name": "access_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_expires_at": { + "name": "refresh_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "generation": { + "name": "generation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + } + }, + "indexes": {}, + "foreignKeys": { + "account_credentials_account_id_accounts_id_fk": { + "name": "account_credentials_account_id_accounts_id_fk", + "tableFrom": "account_credentials", + "tableTo": "accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.accounts": { + "name": "accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "computer_id": { + "name": "computer_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "via": { + "name": "via", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tier": { + "name": "tier", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'confirm_publish'" + }, + "login": { + "name": "login", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "login_changed_at": { + "name": "login_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "login_generation": { + "name": "login_generation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "login_failure": { + "name": "login_failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "login_failed_at": { + "name": "login_failed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "accounts_owner_id_idx": { + "name": "accounts_owner_id_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "accounts_computer_platform_via_handle_idx": { + "name": "accounts_computer_platform_via_handle_idx", + "columns": [ + { + "expression": "computer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "via", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "handle", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "accounts_owner_platform_via_none_idx": { + "name": "accounts_owner_platform_via_none_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "via", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"accounts\".\"login\" = 'none'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "accounts_owner_id_users_id_fk": { + "name": "accounts_owner_id_users_id_fk", + "tableFrom": "accounts", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "accounts_computer_id_computers_id_fk": { + "name": "accounts_computer_id_computers_id_fk", + "tableFrom": "accounts", + "tableTo": "computers", + "columnsFrom": [ + "computer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "accounts_computer_tier_ck": { + "name": "accounts_computer_tier_ck", + "value": "\"accounts\".\"via\" <> 'computer' OR \"accounts\".\"tier\" <> 'direct_publish'" + }, + "accounts_via_ck": { + "name": "accounts_via_ck", + "value": "\"accounts\".\"via\" = 'computer' OR \"accounts\".\"platform\" <> 'xiaohongshu'" + }, + "accounts_via_api_ck": { + "name": "accounts_via_api_ck", + "value": "\"accounts\".\"via\" = 'api' OR \"accounts\".\"platform\" <> 'github'" + }, + "accounts_handle_ck": { + "name": "accounts_handle_ck", + "value": "(\"accounts\".\"login\" = 'none') = (\"accounts\".\"handle\" IS NULL)" + }, + "accounts_login_failure_ck": { + "name": "accounts_login_failure_ck", + "value": "(\"accounts\".\"login_failure\" IS NULL) = (\"accounts\".\"login_failed_at\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.agent_outbox": { + "name": "agent_outbox", + "schema": "", + "columns": { + "computer_id": { + "name": "computer_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_outbox_run_id_idx": { + "name": "agent_outbox_run_id_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_outbox_computer_id_computers_id_fk": { + "name": "agent_outbox_computer_id_computers_id_fk", + "tableFrom": "agent_outbox", + "tableTo": "computers", + "columnsFrom": [ + "computer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_outbox_run_id_runs_id_fk": { + "name": "agent_outbox_run_id_runs_id_fk", + "tableFrom": "agent_outbox", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "agent_outbox_computer_id_seq_pk": { + "name": "agent_outbox_computer_id_seq_pk", + "columns": [ + "computer_id", + "seq" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.approvals": { + "name": "approvals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "call_id": { + "name": "call_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "view": { + "name": "view", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "grant_id": { + "name": "grant_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reminded_at": { + "name": "reminded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deadline_at": { + "name": "deadline_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "approvals_group_id_status_idx": { + "name": "approvals_group_id_status_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "approvals_run_id_call_id_idx": { + "name": "approvals_run_id_call_id_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "approvals_status_deadline_at_idx": { + "name": "approvals_status_deadline_at_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deadline_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "approvals_run_id_runs_id_fk": { + "name": "approvals_run_id_runs_id_fk", + "tableFrom": "approvals", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "approvals_bot_id_bots_id_fk": { + "name": "approvals_bot_id_bots_id_fk", + "tableFrom": "approvals", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "approvals_group_id_groups_id_fk": { + "name": "approvals_group_id_groups_id_fk", + "tableFrom": "approvals", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "approvals_grant_id_grants_id_fk": { + "name": "approvals_grant_id_grants_id_fk", + "tableFrom": "approvals", + "tableTo": "grants", + "columnsFrom": [ + "grant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "approvals_message_id_messages_id_fk": { + "name": "approvals_message_id_messages_id_fk", + "tableFrom": "approvals", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.attachments": { + "name": "attachments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bytes": { + "name": "bytes", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "attachments_owner_bot_group_sha256_idx": { + "name": "attachments_owner_bot_group_sha256_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "attachments_owner_id_users_id_fk": { + "name": "attachments_owner_id_users_id_fk", + "tableFrom": "attachments", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "attachments_bot_id_bots_id_fk": { + "name": "attachments_bot_id_bots_id_fk", + "tableFrom": "attachments", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "attachments_group_id_groups_id_fk": { + "name": "attachments_group_id_groups_id_fk", + "tableFrom": "attachments", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bot_preferences": { + "name": "bot_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_message_id": { + "name": "source_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "private": { + "name": "private", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bot_preferences_bot_id_idx": { + "name": "bot_preferences_bot_id_idx", + "columns": [ + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bot_preferences_bot_id_bots_id_fk": { + "name": "bot_preferences_bot_id_bots_id_fk", + "tableFrom": "bot_preferences", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bot_preferences_source_message_id_messages_id_fk": { + "name": "bot_preferences_source_message_id_messages_id_fk", + "tableFrom": "bot_preferences", + "tableTo": "messages", + "columnsFrom": [ + "source_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bots": { + "name": "bots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "run_state": { + "name": "run_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "hue": { + "name": "hue", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "shape": { + "name": "shape", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "notify": { + "name": "notify", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bots_owner_id_idx": { + "name": "bots_owner_id_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "bots_owner_id_assistant_idx": { + "name": "bots_owner_id_assistant_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"bots\".\"role\" = 'assistant'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "bots_owner_id_preset_idx": { + "name": "bots_owner_id_preset_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "preset", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"bots\".\"preset\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bots_owner_id_users_id_fk": { + "name": "bots_owner_id_users_id_fk", + "tableFrom": "bots", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.brand_books": { + "name": "brand_books", + "schema": "", + "columns": { + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "facts": { + "name": "facts", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "voice": { + "name": "voice", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "taboo": { + "name": "taboo", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "assets_dir": { + "name": "assets_dir", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "edits": { + "name": "edits", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "brand_books_owner_id_users_id_fk": { + "name": "brand_books_owner_id_users_id_fk", + "tableFrom": "brand_books", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.computers": { + "name": "computers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'creating'" + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gateway_key_hash": { + "name": "gateway_key_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "up_stream": { + "name": "up_stream", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "up_acked": { + "name": "up_acked", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "down_seq": { + "name": "down_seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "down_applied": { + "name": "down_applied", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "conn_gen": { + "name": "conn_gen", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "lease_until": { + "name": "lease_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "install_id": { + "name": "install_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "host": { + "name": "host", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idle_since": { + "name": "idle_since", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "computers_owner_id_kind_idx": { + "name": "computers_owner_id_kind_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "computers_gateway_key_hash_idx": { + "name": "computers_gateway_key_hash_idx", + "columns": [ + { + "expression": "gateway_key_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "computers_owner_id_users_id_fk": { + "name": "computers_owner_id_users_id_fk", + "tableFrom": "computers", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.content_plans": { + "name": "content_plans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "content_plans_owner_id_status_idx": { + "name": "content_plans_owner_id_status_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "content_plans_owner_id_users_id_fk": { + "name": "content_plans_owner_id_users_id_fk", + "tableFrom": "content_plans", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "content_plans_group_id_groups_id_fk": { + "name": "content_plans_group_id_groups_id_fk", + "tableFrom": "content_plans", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "content_plans_bot_id_bots_id_fk": { + "name": "content_plans_bot_id_bots_id_fk", + "tableFrom": "content_plans", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "content_plans_run_id_runs_id_fk": { + "name": "content_plans_run_id_runs_id_fk", + "tableFrom": "content_plans", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.drafts": { + "name": "drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan_id": { + "name": "plan_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_hash": { + "name": "approved_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "edits": { + "name": "edits", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "claimed_login_generation": { + "name": "claimed_login_generation", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "drafts_status_scheduled_at_idx": { + "name": "drafts_status_scheduled_at_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "drafts_owner_id_status_idx": { + "name": "drafts_owner_id_status_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "drafts_plan_id_idx": { + "name": "drafts_plan_id_idx", + "columns": [ + { + "expression": "plan_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "drafts_owner_id_users_id_fk": { + "name": "drafts_owner_id_users_id_fk", + "tableFrom": "drafts", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "drafts_group_id_groups_id_fk": { + "name": "drafts_group_id_groups_id_fk", + "tableFrom": "drafts", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "drafts_bot_id_bots_id_fk": { + "name": "drafts_bot_id_bots_id_fk", + "tableFrom": "drafts", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "drafts_run_id_runs_id_fk": { + "name": "drafts_run_id_runs_id_fk", + "tableFrom": "drafts", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "drafts_plan_id_content_plans_id_fk": { + "name": "drafts_plan_id_content_plans_id_fk", + "tableFrom": "drafts", + "tableTo": "content_plans", + "columnsFrom": [ + "plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "drafts_account_id_accounts_id_fk": { + "name": "drafts_account_id_accounts_id_fk", + "tableFrom": "drafts", + "tableTo": "accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.grants": { + "name": "grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "grants_owner_id_idx": { + "name": "grants_owner_id_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "grants_owner_id_users_id_fk": { + "name": "grants_owner_id_users_id_fk", + "tableFrom": "grants", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grants_group_id_groups_id_fk": { + "name": "grants_group_id_groups_id_fk", + "tableFrom": "grants", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "grants_owner_action_target_group_uq": { + "name": "grants_owner_action_target_group_uq", + "nullsNotDistinct": true, + "columns": [ + "owner_id", + "action", + "target", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": { + "grants_scope_group_ck": { + "name": "grants_scope_group_ck", + "value": "(\"grants\".\"scope\" = 'project' AND \"grants\".\"group_id\" IS NOT NULL) OR (\"grants\".\"scope\" = 'forever' AND \"grants\".\"group_id\" IS NULL)" + }, + "grants_action_ck": { + "name": "grants_action_ck", + "value": "\"grants\".\"action\" NOT IN ('spend', 'account_security', 'delete')" + }, + "grants_forever_ck": { + "name": "grants_forever_ck", + "value": "\"grants\".\"scope\" <> 'forever' OR \"grants\".\"action\" <> 'write_outside'" + } + }, + "isRLSEnabled": false + }, + "public.group_members": { + "name": "group_members", + "schema": "", + "columns": { + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "computer_kind": { + "name": "computer_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "group_members_bot_id_idx": { + "name": "group_members_bot_id_idx", + "columns": [ + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "group_members_group_id_groups_id_fk": { + "name": "group_members_group_id_groups_id_fk", + "tableFrom": "group_members", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "group_members_bot_id_bots_id_fk": { + "name": "group_members_bot_id_bots_id_fk", + "tableFrom": "group_members", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "group_members_group_id_bot_id_pk": { + "name": "group_members_group_id_bot_id_pk", + "columns": [ + "group_id", + "bot_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "group_members_computer_kind_check": { + "name": "group_members_computer_kind_check", + "value": "\"group_members\".\"computer_kind\" IS NULL OR \"group_members\".\"computer_kind\" IN ('local', 'remote')" + } + }, + "isRLSEnabled": false + }, + "public.groups": { + "name": "groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "solo_bot_id": { + "name": "solo_bot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "chief_bot_id": { + "name": "chief_bot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "groups_owner_id_idx": { + "name": "groups_owner_id_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "groups_owner_id_users_id_fk": { + "name": "groups_owner_id_users_id_fk", + "tableFrom": "groups", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "groups_solo_bot_id_bots_id_fk": { + "name": "groups_solo_bot_id_bots_id_fk", + "tableFrom": "groups", + "tableTo": "bots", + "columnsFrom": [ + "solo_bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "groups_chief_bot_id_bots_id_fk": { + "name": "groups_chief_bot_id_bots_id_fk", + "tableFrom": "groups", + "tableTo": "bots", + "columnsFrom": [ + "chief_bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "groups_solo_bot_id_unique": { + "name": "groups_solo_bot_id_unique", + "nullsNotDistinct": false, + "columns": [ + "solo_bot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.handoffs": { + "name": "handoffs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_bot_id": { + "name": "from_bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_bot_id": { + "name": "to_bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "done": { + "name": "done", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "not_done": { + "name": "not_done", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next": { + "name": "next", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checklist_index": { + "name": "checklist_index", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reminded_at": { + "name": "reminded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "handoffs_group_id_status_idx": { + "name": "handoffs_group_id_status_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "handoffs_group_id_groups_id_fk": { + "name": "handoffs_group_id_groups_id_fk", + "tableFrom": "handoffs", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "handoffs_from_bot_id_bots_id_fk": { + "name": "handoffs_from_bot_id_bots_id_fk", + "tableFrom": "handoffs", + "tableTo": "bots", + "columnsFrom": [ + "from_bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "handoffs_to_bot_id_bots_id_fk": { + "name": "handoffs_to_bot_id_bots_id_fk", + "tableFrom": "handoffs", + "tableTo": "bots", + "columnsFrom": [ + "to_bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "handoffs_message_id_messages_id_fk": { + "name": "handoffs_message_id_messages_id_fk", + "tableFrom": "handoffs", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lane_leases": { + "name": "lane_leases", + "schema": "", + "columns": { + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "holder_computer_id": { + "name": "holder_computer_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "holder_install_id": { + "name": "holder_install_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "epoch": { + "name": "epoch", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "lane_leases_bot_id_bots_id_fk": { + "name": "lane_leases_bot_id_bots_id_fk", + "tableFrom": "lane_leases", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lane_leases_group_id_groups_id_fk": { + "name": "lane_leases_group_id_groups_id_fk", + "tableFrom": "lane_leases", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lane_leases_holder_computer_id_computers_id_fk": { + "name": "lane_leases_holder_computer_id_computers_id_fk", + "tableFrom": "lane_leases", + "tableTo": "computers", + "columnsFrom": [ + "holder_computer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "lane_leases_bot_id_group_id_pk": { + "name": "lane_leases_bot_id_group_id_pk", + "columns": [ + "bot_id", + "group_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "lane_leases_epoch_check": { + "name": "lane_leases_epoch_check", + "value": "\"lane_leases\".\"epoch\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "seq": { + "name": "seq", + "type": "bigserial", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "skill_offer_source": { + "name": "skill_offer_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revision": { + "name": "revision", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "visible_to": { + "name": "visible_to", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "messages_group_id_seq_idx": { + "name": "messages_group_id_seq_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "seq", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "messages_group_id_groups_id_fk": { + "name": "messages_group_id_groups_id_fk", + "tableFrom": "messages", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "messages_visible_to_check": { + "name": "messages_visible_to_check", + "value": "\"messages\".\"visible_to\" IS NULL OR (jsonb_typeof(\"messages\".\"visible_to\") = 'array' AND jsonb_array_length(\"messages\".\"visible_to\") > 0)" + } + }, + "isRLSEnabled": false + }, + "public.metric_samples": { + "name": "metric_samples", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sampled_at": { + "name": "sampled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "metric_samples_group_id_sampled_at_idx": { + "name": "metric_samples_group_id_sampled_at_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sampled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "metric_samples_group_id_groups_id_fk": { + "name": "metric_samples_group_id_groups_id_fk", + "tableFrom": "metric_samples", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_states": { + "name": "oauth_states", + "schema": "", + "columns": { + "state": { + "name": "state", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "oauth_states_expires_at_idx": { + "name": "oauth_states_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_states_owner_platform_idx": { + "name": "oauth_states_owner_platform_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_at", + "isExpression": false, + "asc": false, + "nulls": "first" + }, + { + "expression": "state", + "isExpression": false, + "asc": false, + "nulls": "first" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oauth_states_owner_id_users_id_fk": { + "name": "oauth_states_owner_id_users_id_fk", + "tableFrom": "oauth_states", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.poker_act_receipts": { + "name": "poker_act_receipts", + "schema": "", + "columns": { + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "call_id": { + "name": "call_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "poker_act_receipts_run_id_runs_id_fk": { + "name": "poker_act_receipts_run_id_runs_id_fk", + "tableFrom": "poker_act_receipts", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "poker_act_receipts_run_id_call_id_pk": { + "name": "poker_act_receipts_run_id_call_id_pk", + "columns": [ + "run_id", + "call_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.poker_events": { + "name": "poker_events", + "schema": "", + "columns": { + "hand_id": { + "name": "hand_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "event": { + "name": "event", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "poker_events_hand_id_poker_hands_id_fk": { + "name": "poker_events_hand_id_poker_hands_id_fk", + "tableFrom": "poker_events", + "tableTo": "poker_hands", + "columnsFrom": [ + "hand_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "poker_events_hand_id_seq_pk": { + "name": "poker_events_hand_id_seq_pk", + "columns": [ + "hand_id", + "seq" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.poker_hands": { + "name": "poker_hands", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "seed": { + "name": "seed", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "seats_start": { + "name": "seats_start", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "button_seat": { + "name": "button_seat", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "blinds": { + "name": "blinds", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'playing'" + }, + "turn_seat": { + "name": "turn_seat", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "turn_run_id": { + "name": "turn_run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "turn_attempts": { + "name": "turn_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "turn_deadline": { + "name": "turn_deadline", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "dispatch_seq": { + "name": "dispatch_seq", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "dispatch_count": { + "name": "dispatch_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "poker_hands_group_id_number_idx": { + "name": "poker_hands_group_id_number_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "poker_hands_group_id_playing_idx": { + "name": "poker_hands_group_id_playing_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"poker_hands\".\"status\" = 'playing'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "poker_hands_session_id_idx": { + "name": "poker_hands_session_id_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "poker_hands_group_id_poker_tables_group_id_fk": { + "name": "poker_hands_group_id_poker_tables_group_id_fk", + "tableFrom": "poker_hands", + "tableTo": "poker_tables", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "group_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "poker_hands_session_id_poker_sessions_id_fk": { + "name": "poker_hands_session_id_poker_sessions_id_fk", + "tableFrom": "poker_hands", + "tableTo": "poker_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "poker_hands_turn_run_id_runs_id_fk": { + "name": "poker_hands_turn_run_id_runs_id_fk", + "tableFrom": "poker_hands", + "tableTo": "runs", + "columnsFrom": [ + "turn_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "poker_hands_status_check": { + "name": "poker_hands_status_check", + "value": "\"poker_hands\".\"status\" IN ('playing', 'complete', 'abandoned')" + }, + "poker_hands_dispatch_check": { + "name": "poker_hands_dispatch_check", + "value": "(\"poker_hands\".\"dispatch_seq\" IS NULL) = (\"poker_hands\".\"dispatch_count\" = 0)" + } + }, + "isRLSEnabled": false + }, + "public.poker_hints": { + "name": "poker_hints", + "schema": "", + "columns": { + "hand_id": { + "name": "hand_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "poker_hints_run_id_idx": { + "name": "poker_hints_run_id_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "poker_hints_hand_id_poker_hands_id_fk": { + "name": "poker_hints_hand_id_poker_hands_id_fk", + "tableFrom": "poker_hints", + "tableTo": "poker_hands", + "columnsFrom": [ + "hand_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "poker_hints_run_id_runs_id_fk": { + "name": "poker_hints_run_id_runs_id_fk", + "tableFrom": "poker_hints", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "poker_hints_message_id_messages_id_fk": { + "name": "poker_hints_message_id_messages_id_fk", + "tableFrom": "poker_hints", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "poker_hints_hand_id_seq_pk": { + "name": "poker_hints_hand_id_seq_pk", + "columns": [ + "hand_id", + "seq" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.poker_sessions": { + "name": "poker_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "review": { + "name": "review", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "poker_sessions_group_id_idx": { + "name": "poker_sessions_group_id_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "poker_sessions_group_id_open_idx": { + "name": "poker_sessions_group_id_open_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"poker_sessions\".\"ended_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "poker_sessions_group_id_poker_tables_group_id_fk": { + "name": "poker_sessions_group_id_poker_tables_group_id_fk", + "tableFrom": "poker_sessions", + "tableTo": "poker_tables", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "group_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.poker_tables": { + "name": "poker_tables", + "schema": "", + "columns": { + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "seats": { + "name": "seats", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "button_seat": { + "name": "button_seat", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "small_blind": { + "name": "small_blind", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "big_blind": { + "name": "big_blind", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "starting_stack": { + "name": "starting_stack", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "hand_count": { + "name": "hand_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'idle'" + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "poker_tables_owner_id_request_id_idx": { + "name": "poker_tables_owner_id_request_id_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "poker_tables_group_id_groups_id_fk": { + "name": "poker_tables_group_id_groups_id_fk", + "tableFrom": "poker_tables", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "poker_tables_owner_id_users_id_fk": { + "name": "poker_tables_owner_id_users_id_fk", + "tableFrom": "poker_tables", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "poker_tables_status_check": { + "name": "poker_tables_status_check", + "value": "\"poker_tables\".\"status\" IN ('idle', 'in_hand')" + } + }, + "isRLSEnabled": false + }, + "public.project_reviews": { + "name": "project_reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "week_start": { + "name": "week_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "project_reviews_group_id_week_start_idx": { + "name": "project_reviews_group_id_week_start_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "week_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_reviews_group_id_groups_id_fk": { + "name": "project_reviews_group_id_groups_id_fk", + "tableFrom": "project_reviews", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_reviews_run_id_runs_id_fk": { + "name": "project_reviews_run_id_runs_id_fk", + "tableFrom": "project_reviews", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.publications": { + "name": "publications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "draft_id": { + "name": "draft_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "publications_group_id_published_at_idx": { + "name": "publications_group_id_published_at_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "published_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "publications_owner_id_users_id_fk": { + "name": "publications_owner_id_users_id_fk", + "tableFrom": "publications", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "publications_draft_id_drafts_id_fk": { + "name": "publications_draft_id_drafts_id_fk", + "tableFrom": "publications", + "tableTo": "drafts", + "columnsFrom": [ + "draft_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "publications_group_id_groups_id_fk": { + "name": "publications_group_id_groups_id_fk", + "tableFrom": "publications", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "publications_account_id_accounts_id_fk": { + "name": "publications_account_id_accounts_id_fk", + "tableFrom": "publications", + "tableTo": "accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "publications_draft_id_unique": { + "name": "publications_draft_id_unique", + "nullsNotDistinct": false, + "columns": [ + "draft_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.routine_runs": { + "name": "routine_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "routine_id": { + "name": "routine_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "seen_at": { + "name": "seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "has_result": { + "name": "has_result", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "routine_runs_routine_id_started_at_idx": { + "name": "routine_runs_routine_id_started_at_idx", + "columns": [ + { + "expression": "routine_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "routine_runs_routine_id_routines_id_fk": { + "name": "routine_runs_routine_id_routines_id_fk", + "tableFrom": "routine_runs", + "tableTo": "routines", + "columnsFrom": [ + "routine_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.routines": { + "name": "routines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instruction": { + "name": "instruction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "triggers": { + "name": "triggers", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "on_failure": { + "name": "on_failure", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'stop_and_tell'" + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'plan'" + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'on'" + }, + "boundary": { + "name": "boundary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "on_today": { + "name": "on_today", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "routines_bot_id_idx": { + "name": "routines_bot_id_idx", + "columns": [ + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "routines_triggers_idx": { + "name": "routines_triggers_idx", + "columns": [ + { + "expression": "triggers", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "routines_group_id_idx": { + "name": "routines_group_id_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "routines_bot_id_bots_id_fk": { + "name": "routines_bot_id_bots_id_fk", + "tableFrom": "routines", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "routines_group_id_groups_id_fk": { + "name": "routines_group_id_groups_id_fk", + "tableFrom": "routines", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.runs": { + "name": "runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "computer_id": { + "name": "computer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trigger_message_id": { + "name": "trigger_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "routine_run_id": { + "name": "routine_run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_routine": { + "name": "is_routine", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "charged_at": { + "name": "charged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "steps": { + "name": "steps", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "amount": { + "name": "amount", + "type": "numeric(14, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "unsettled_context": { + "name": "unsettled_context", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "context_confirmed_at": { + "name": "context_confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "settled_context": { + "name": "settled_context", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "visible_to": { + "name": "visible_to", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "table_role": { + "name": "table_role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "continue_requested": { + "name": "continue_requested", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "continues_run_id": { + "name": "continues_run_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "runs_table_role_open_idx": { + "name": "runs_table_role_open_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "table_role", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"runs\".\"table_role\" IN ('advisor', 'reviewer') AND \"runs\".\"ended_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_table_bot_open_idx": { + "name": "runs_table_bot_open_idx", + "columns": [ + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"runs\".\"table_role\" IS NOT NULL AND \"runs\".\"ended_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_group_id_started_at_idx": { + "name": "runs_group_id_started_at_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_context_confirmed_idx": { + "name": "runs_context_confirmed_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "context_confirmed_at", + "isExpression": false, + "asc": false, + "nulls": "first" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": false, + "nulls": "first" + } + ], + "isUnique": false, + "where": "\"runs\".\"context_confirmed_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_bot_id_idx": { + "name": "runs_bot_id_idx", + "columns": [ + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_owner_id_started_at_idx": { + "name": "runs_owner_id_started_at_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_routine_run_id_idx": { + "name": "runs_routine_run_id_idx", + "columns": [ + { + "expression": "routine_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_computer_id_idx": { + "name": "runs_computer_id_idx", + "columns": [ + { + "expression": "computer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_continues_run_idx": { + "name": "runs_continues_run_idx", + "columns": [ + { + "expression": "continues_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"runs\".\"continues_run_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_continue_requested_idx": { + "name": "runs_continue_requested_idx", + "columns": [ + { + "expression": "ended_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"runs\".\"continue_requested\"", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "runs_owner_id_users_id_fk": { + "name": "runs_owner_id_users_id_fk", + "tableFrom": "runs", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "runs_bot_id_bots_id_fk": { + "name": "runs_bot_id_bots_id_fk", + "tableFrom": "runs", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "runs_group_id_groups_id_fk": { + "name": "runs_group_id_groups_id_fk", + "tableFrom": "runs", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "runs_computer_id_computers_id_fk": { + "name": "runs_computer_id_computers_id_fk", + "tableFrom": "runs", + "tableTo": "computers", + "columnsFrom": [ + "computer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "runs_trigger_message_id_messages_id_fk": { + "name": "runs_trigger_message_id_messages_id_fk", + "tableFrom": "runs", + "tableTo": "messages", + "columnsFrom": [ + "trigger_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "runs_routine_run_id_routine_runs_id_fk": { + "name": "runs_routine_run_id_routine_runs_id_fk", + "tableFrom": "runs", + "tableTo": "routine_runs", + "columnsFrom": [ + "routine_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "runs_continues_run_id_runs_id_fk": { + "name": "runs_continues_run_id_runs_id_fk", + "tableFrom": "runs", + "tableTo": "runs", + "columnsFrom": [ + "continues_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "runs_table_role_check": { + "name": "runs_table_role_check", + "value": "\"runs\".\"table_role\" IS NULL OR \"runs\".\"table_role\" IN ('player', 'advisor', 'reviewer')" + } + }, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "sessions_user_id_idx": { + "name": "sessions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "notify": { + "name": "notify", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "dnd_from": { + "name": "dnd_from", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dnd_to": { + "name": "dnd_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "budget": { + "name": "budget", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "budget_alerted_month": { + "name": "budget_alerted_month", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "settings_user_id_users_id_fk": { + "name": "settings_user_id_users_id_fk", + "tableFrom": "settings", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.skills": { + "name": "skills", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "skills_bot_id_name_idx": { + "name": "skills_bot_id_name_idx", + "columns": [ + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "skills_bot_id_bots_id_fk": { + "name": "skills_bot_id_bots_id_fk", + "tableFrom": "skills", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "due_at": { + "name": "due_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "checklist": { + "name": "checklist", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "current_bot_id": { + "name": "current_bot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "handled": { + "name": "handled", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "cadence": { + "name": "cadence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "goal_target": { + "name": "goal_target", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "goal_unit": { + "name": "goal_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "goal_due_at": { + "name": "goal_due_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "metric_source": { + "name": "metric_source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_group_id_groups_id_fk": { + "name": "tasks_group_id_groups_id_fk", + "tableFrom": "tasks", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tasks_current_bot_id_bots_id_fk": { + "name": "tasks_current_bot_id_bots_id_fk", + "tableFrom": "tasks", + "tableTo": "bots", + "columnsFrom": [ + "current_bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "tasks_group_id_unique": { + "name": "tasks_group_id_unique", + "nullsNotDistinct": false, + "columns": [ + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tool_connection_bots": { + "name": "tool_connection_bots", + "schema": "", + "columns": { + "tool_connection_id": { + "name": "tool_connection_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "tool_connection_bots_bot_id_idx": { + "name": "tool_connection_bots_bot_id_idx", + "columns": [ + { + "expression": "bot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tool_connection_bots_tool_connection_id_tool_connections_id_fk": { + "name": "tool_connection_bots_tool_connection_id_tool_connections_id_fk", + "tableFrom": "tool_connection_bots", + "tableTo": "tool_connections", + "columnsFrom": [ + "tool_connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tool_connection_bots_bot_id_bots_id_fk": { + "name": "tool_connection_bots_bot_id_bots_id_fk", + "tableFrom": "tool_connection_bots", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tool_connection_bots_tool_connection_id_bot_id_pk": { + "name": "tool_connection_bots_tool_connection_id_bot_id_pk", + "columns": [ + "tool_connection_id", + "bot_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tool_connections": { + "name": "tool_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorization_enc": { + "name": "authorization_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operations": { + "name": "operations", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ready'" + }, + "local_only": { + "name": "local_only", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tool_connections_owner_id_name_idx": { + "name": "tool_connections_owner_id_name_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tool_connections_owner_id_users_id_fk": { + "name": "tool_connections_owner_id_users_id_fk", + "tableFrom": "tool_connections", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_counters": { + "name": "user_counters", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "next_task_number": { + "name": "next_task_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1001 + }, + "next_hue_index": { + "name": "next_hue_index", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "user_counters_user_id_users_id_fk": { + "name": "user_counters_user_id_users_id_fk", + "tableFrom": "user_counters", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "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 + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.work_entries": { + "name": "work_entries", + "schema": "", + "columns": { + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stream": { + "name": "stream", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "epoch": { + "name": "epoch", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entry_id": { + "name": "entry_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pi_type": { + "name": "pi_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "retention": { + "name": "retention", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "line": { + "name": "line", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "search_text": { + "name": "search_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entry_at": { + "name": "entry_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "visible_to": { + "name": "visible_to", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "work_entries_chat_search_idx": { + "name": "work_entries_chat_search_idx", + "columns": [ + { + "expression": "search_text", + "isExpression": false, + "asc": true, + "nulls": "last", + "opclass": "gin_trgm_ops" + } + ], + "isUnique": false, + "where": "\"work_entries\".\"stream\" = 'chat' AND \"work_entries\".\"visible_to\" IS NULL", + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "work_entries_bot_id_bots_id_fk": { + "name": "work_entries_bot_id_bots_id_fk", + "tableFrom": "work_entries", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "work_entries_group_id_groups_id_fk": { + "name": "work_entries_group_id_groups_id_fk", + "tableFrom": "work_entries", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "work_entries_owner_id_users_id_fk": { + "name": "work_entries_owner_id_users_id_fk", + "tableFrom": "work_entries", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "work_entries_run_id_runs_id_fk": { + "name": "work_entries_run_id_runs_id_fk", + "tableFrom": "work_entries", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "work_entries_bot_id_group_id_stream_seq_pk": { + "name": "work_entries_bot_id_group_id_stream_seq_pk", + "columns": [ + "bot_id", + "group_id", + "stream", + "seq" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "work_entries_stream_check": { + "name": "work_entries_stream_check", + "value": "\"work_entries\".\"stream\" IN ('chat', 'table')" + }, + "work_entries_retention_check": { + "name": "work_entries_retention_check", + "value": "\"work_entries\".\"retention\" IN ('verbatim', 'redacted')" + }, + "work_entries_seq_check": { + "name": "work_entries_seq_check", + "value": "\"work_entries\".\"seq\" >= 0" + }, + "work_entries_visible_to_check": { + "name": "work_entries_visible_to_check", + "value": "\"work_entries\".\"visible_to\" IS NULL OR (jsonb_typeof(\"work_entries\".\"visible_to\") = 'array' AND jsonb_array_length(\"work_entries\".\"visible_to\") > 0)" + } + }, + "isRLSEnabled": false + }, + "public.work_streams": { + "name": "work_streams", + "schema": "", + "columns": { + "bot_id": { + "name": "bot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stream": { + "name": "stream", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_seq": { + "name": "next_seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "head": { + "name": "head", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'0000000000000000000000000000000000000000000000000000000000000000'" + }, + "tail_entry_id": { + "name": "tail_entry_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retain_snapshot": { + "name": "retain_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "pi_session_version": { + "name": "pi_session_version", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "work_streams_bot_id_bots_id_fk": { + "name": "work_streams_bot_id_bots_id_fk", + "tableFrom": "work_streams", + "tableTo": "bots", + "columnsFrom": [ + "bot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "work_streams_group_id_groups_id_fk": { + "name": "work_streams_group_id_groups_id_fk", + "tableFrom": "work_streams", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "work_streams_bot_id_group_id_stream_pk": { + "name": "work_streams_bot_id_group_id_stream_pk", + "columns": [ + "bot_id", + "group_id", + "stream" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "work_streams_stream_check": { + "name": "work_streams_stream_check", + "value": "\"work_streams\".\"stream\" IN ('chat', 'table')" + }, + "work_streams_next_seq_check": { + "name": "work_streams_next_seq_check", + "value": "\"work_streams\".\"next_seq\" >= 0" + } + }, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/control-plane/drizzle/meta/_journal.json b/packages/control-plane/drizzle/meta/_journal.json index a5d8ccff..7eb4119d 100644 --- a/packages/control-plane/drizzle/meta/_journal.json +++ b/packages/control-plane/drizzle/meta/_journal.json @@ -337,6 +337,13 @@ "when": 1792557724084, "tag": "0047_drop_cli_tools", "breakpoints": true + }, + { + "idx": 48, + "version": "7", + "when": 1792756743833, + "tag": "0048_computers_gateway_key_hash_idx", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/control-plane/src/db/schema.ts b/packages/control-plane/src/db/schema.ts index 53913a7f..ad452901 100644 --- a/packages/control-plane/src/db/schema.ts +++ b/packages/control-plane/src/db/schema.ts @@ -393,7 +393,10 @@ export const computers = pgTable( lastSeenAt: timestamp("last_seen_at", { withTimezone: true }), createdAt: createdAt(), }, - (t) => [uniqueIndex("computers_owner_id_kind_idx").on(t.ownerId, t.kind)], + (t) => [ + uniqueIndex("computers_owner_id_kind_idx").on(t.ownerId, t.kind), + uniqueIndex("computers_gateway_key_hash_idx").on(t.gatewayKeyHash), + ], ); export const accounts = pgTable(