From dc0563193b360715176ba8c564076074e027531b Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 10:09:02 -0500
Subject: [PATCH 01/33] Add organizations.slug column
---
.../db/src/migrations/0174_massive_drax.sql | 2 +
.../db/src/migrations/meta/0174_snapshot.json | 32112 ++++++++++++++++
packages/db/src/migrations/meta/_journal.json | 7 +
packages/db/src/schema.ts | 1 +
4 files changed, 32122 insertions(+)
create mode 100644 packages/db/src/migrations/0174_massive_drax.sql
create mode 100644 packages/db/src/migrations/meta/0174_snapshot.json
diff --git a/packages/db/src/migrations/0174_massive_drax.sql b/packages/db/src/migrations/0174_massive_drax.sql
new file mode 100644
index 0000000000..513810a08e
--- /dev/null
+++ b/packages/db/src/migrations/0174_massive_drax.sql
@@ -0,0 +1,2 @@
+ALTER TABLE "organizations" ADD COLUMN "slug" text;--> statement-breakpoint
+ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_unique" UNIQUE("slug");
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/0174_snapshot.json b/packages/db/src/migrations/meta/0174_snapshot.json
new file mode 100644
index 0000000000..6ed208920e
--- /dev/null
+++ b/packages/db/src/migrations/meta/0174_snapshot.json
@@ -0,0 +1,32112 @@
+{
+ "id": "3cf41bc8-067b-4620-8dbe-522443a39b69",
+ "prevId": "06265fd6-428e-4b7d-9092-dba307d6255e",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.agent_configs": {
+ "name": "agent_configs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_type": {
+ "name": "agent_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_configs_org_id": {
+ "name": "IDX_agent_configs_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_owned_by_user_id": {
+ "name": "IDX_agent_configs_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_agent_type": {
+ "name": "IDX_agent_configs_agent_type",
+ "columns": [
+ {
+ "expression": "agent_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_platform": {
+ "name": "IDX_agent_configs_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_configs_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_configs_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_configs",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_configs_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_configs_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_configs_org_agent_platform": {
+ "name": "UQ_agent_configs_org_agent_platform",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_organization_id",
+ "agent_type",
+ "platform"
+ ]
+ },
+ "UQ_agent_configs_user_agent_platform": {
+ "name": "UQ_agent_configs_user_agent_platform",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_user_id",
+ "agent_type",
+ "platform"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_configs_owner_check": {
+ "name": "agent_configs_owner_check",
+ "value": "(\n (\"agent_configs\".\"owned_by_user_id\" IS NOT NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_configs\".\"owned_by_user_id\" IS NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "agent_configs_agent_type_check": {
+ "name": "agent_configs_agent_type_check",
+ "value": "\"agent_configs\".\"agent_type\" IN ('code_review', 'auto_triage', 'auto_fix', 'security_scan')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_agents": {
+ "name": "agent_environment_profile_agents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_agents_profile_id": {
+ "name": "IDX_agent_env_profile_agents_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_agents",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_agents_profile_slug": {
+ "name": "UQ_agent_env_profile_agents_profile_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_commands": {
+ "name": "agent_environment_profile_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "command": {
+ "name": "command",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_commands_profile_id": {
+ "name": "IDX_agent_env_profile_commands_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_commands",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_commands_profile_sequence": {
+ "name": "UQ_agent_env_profile_commands_profile_sequence",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "sequence"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_kilo_commands": {
+ "name": "agent_environment_profile_kilo_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "template": {
+ "name": "template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent": {
+ "name": "agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subtask": {
+ "name": "subtask",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_kilo_cmds_profile_id": {
+ "name": "IDX_agent_env_profile_kilo_cmds_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_kilo_commands",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_kilo_cmds_profile_name": {
+ "name": "UQ_agent_env_profile_kilo_cmds_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_mcp_servers": {
+ "name": "agent_environment_profile_mcp_servers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "timeout": {
+ "name": "timeout",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_mcp_servers_profile_id": {
+ "name": "IDX_agent_env_profile_mcp_servers_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_mcp_servers",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_mcp_servers_profile_name": {
+ "name": "UQ_agent_env_profile_mcp_servers_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_repo_bindings": {
+ "name": "agent_environment_profile_repo_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_agent_env_profile_repo_bindings_user": {
+ "name": "UQ_agent_env_profile_repo_bindings_user",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profile_repo_bindings_org": {
+ "name": "UQ_agent_env_profile_repo_bindings_org",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_env_profile_repo_bindings_owner_check": {
+ "name": "agent_env_profile_repo_bindings_owner_check",
+ "value": "(\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_skills": {
+ "name": "agent_environment_profile_skills",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_markdown": {
+ "name": "raw_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "files": {
+ "name": "files",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_skills_profile_id": {
+ "name": "IDX_agent_env_profile_skills_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_skills",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_skills_profile_name": {
+ "name": "UQ_agent_env_profile_skills_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_vars": {
+ "name": "agent_environment_profile_vars",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_secret": {
+ "name": "is_secret",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_vars_profile_id": {
+ "name": "IDX_agent_env_profile_vars_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_vars",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_vars_profile_key": {
+ "name": "UQ_agent_env_profile_vars_profile_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profiles": {
+ "name": "agent_environment_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_agent_env_profiles_org_name": {
+ "name": "UQ_agent_env_profiles_org_name",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_user_name": {
+ "name": "UQ_agent_env_profiles_user_name",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_org_default": {
+ "name": "UQ_agent_env_profiles_org_default",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_user_default": {
+ "name": "UQ_agent_env_profiles_user_default",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_org_id": {
+ "name": "IDX_agent_env_profiles_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_user_id": {
+ "name": "IDX_agent_env_profiles_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_created_by_user_id": {
+ "name": "IDX_agent_env_profiles_created_by_user_id",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profiles_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_environment_profiles_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_environment_profiles",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_environment_profiles",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_env_profiles_owner_check": {
+ "name": "agent_env_profiles_owner_check",
+ "value": "(\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.api_kind": {
+ "name": "api_kind",
+ "schema": "",
+ "columns": {
+ "api_kind_id": {
+ "name": "api_kind_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "api_kind": {
+ "name": "api_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_api_kind": {
+ "name": "UQ_api_kind",
+ "columns": [
+ {
+ "expression": "api_kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.api_request_compress_log": {
+ "name": "api_request_compress_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request": {
+ "name": "request",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_api_request_compress_log_created_at": {
+ "name": "idx_api_request_compress_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.api_request_log": {
+ "name": "api_request_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request": {
+ "name": "request",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response": {
+ "name": "response",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_api_request_log_created_at": {
+ "name": "idx_api_request_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_feedback": {
+ "name": "app_builder_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "preview_status": {
+ "name": "preview_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_streaming": {
+ "name": "is_streaming",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_count": {
+ "name": "message_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recent_messages": {
+ "name": "recent_messages",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_feedback_created_at": {
+ "name": "IDX_app_builder_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_feedback_kilo_user_id": {
+ "name": "IDX_app_builder_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_feedback_project_id": {
+ "name": "IDX_app_builder_feedback_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "app_builder_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "app_builder_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "app_builder_feedback_project_id_app_builder_projects_id_fk": {
+ "name": "app_builder_feedback_project_id_app_builder_projects_id_fk",
+ "tableFrom": "app_builder_feedback",
+ "tableTo": "app_builder_projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_project_sessions": {
+ "name": "app_builder_project_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_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
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worker_version": {
+ "name": "worker_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'v2'"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_project_sessions_project_id": {
+ "name": "IDX_app_builder_project_sessions_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_project_sessions_project_id_app_builder_projects_id_fk": {
+ "name": "app_builder_project_sessions_project_id_app_builder_projects_id_fk",
+ "tableFrom": "app_builder_project_sessions",
+ "tableTo": "app_builder_projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_app_builder_project_sessions_cloud_agent_session_id": {
+ "name": "UQ_app_builder_project_sessions_cloud_agent_session_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "cloud_agent_session_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_projects": {
+ "name": "app_builder_projects",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "template": {
+ "name": "template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_at": {
+ "name": "last_message_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_repo_full_name": {
+ "name": "git_repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_platform_integration_id": {
+ "name": "git_platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "migrated_at": {
+ "name": "migrated_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_projects_created_by_user_id": {
+ "name": "IDX_app_builder_projects_created_by_user_id",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_owned_by_user_id": {
+ "name": "IDX_app_builder_projects_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_owned_by_organization_id": {
+ "name": "IDX_app_builder_projects_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_created_at": {
+ "name": "IDX_app_builder_projects_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_last_message_at": {
+ "name": "IDX_app_builder_projects_last_message_at",
+ "columns": [
+ {
+ "expression": "last_message_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_git_repo_integration": {
+ "name": "IDX_app_builder_projects_git_repo_integration",
+ "columns": [
+ {
+ "expression": "git_repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"app_builder_projects\".\"git_repo_full_name\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_projects_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "app_builder_projects_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_owned_by_organization_id_organizations_id_fk": {
+ "name": "app_builder_projects_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_deployment_id_deployments_id_fk": {
+ "name": "app_builder_projects_deployment_id_deployments_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk": {
+ "name": "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "git_platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "app_builder_projects_owner_check": {
+ "name": "app_builder_projects_owner_check",
+ "value": "(\n (\"app_builder_projects\".\"owned_by_user_id\" IS NOT NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NULL) OR\n (\"app_builder_projects\".\"owned_by_user_id\" IS NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_min_versions": {
+ "name": "app_min_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ios_min_version": {
+ "name": "ios_min_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'1.0.0'"
+ },
+ "android_min_version": {
+ "name": "android_min_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'1.0.0'"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_reported_messages": {
+ "name": "app_reported_messages",
+ "schema": "",
+ "columns": {
+ "report_id": {
+ "name": "report_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "signature": {
+ "name": "signature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "app_reported_messages_cli_session_id_cli_sessions_session_id_fk": {
+ "name": "app_reported_messages_cli_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "app_reported_messages",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "cli_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auto_fix_tickets": {
+ "name": "auto_fix_tickets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "triage_ticket_id": {
+ "name": "triage_ticket_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_url": {
+ "name": "issue_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_title": {
+ "name": "issue_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_body": {
+ "name": "issue_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "issue_author": {
+ "name": "issue_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_labels": {
+ "name": "issue_labels",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "trigger_source": {
+ "name": "trigger_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'label'"
+ },
+ "review_comment_id": {
+ "name": "review_comment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_comment_body": {
+ "name": "review_comment_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "line_number": {
+ "name": "line_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "diff_hunk": {
+ "name": "diff_hunk",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_ref": {
+ "name": "pr_head_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent_summary": {
+ "name": "intent_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_files": {
+ "name": "related_files",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_branch": {
+ "name": "pr_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_fix_tickets_repo_issue": {
+ "name": "UQ_auto_fix_tickets_repo_issue",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_fix_tickets\".\"trigger_source\" = 'label'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_auto_fix_tickets_repo_review_comment": {
+ "name": "UQ_auto_fix_tickets_repo_review_comment",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "review_comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_fix_tickets\".\"review_comment_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_owned_by_org": {
+ "name": "IDX_auto_fix_tickets_owned_by_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_owned_by_user": {
+ "name": "IDX_auto_fix_tickets_owned_by_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_status": {
+ "name": "IDX_auto_fix_tickets_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_created_at": {
+ "name": "IDX_auto_fix_tickets_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_triage_ticket_id": {
+ "name": "IDX_auto_fix_tickets_triage_ticket_id",
+ "columns": [
+ {
+ "expression": "triage_ticket_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_session_id": {
+ "name": "IDX_auto_fix_tickets_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_fix_tickets_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_fix_tickets_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk": {
+ "name": "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk": {
+ "name": "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "auto_triage_tickets",
+ "columnsFrom": [
+ "triage_ticket_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk": {
+ "name": "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "cli_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_fix_tickets_owner_check": {
+ "name": "auto_fix_tickets_owner_check",
+ "value": "(\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "auto_fix_tickets_status_check": {
+ "name": "auto_fix_tickets_status_check",
+ "value": "\"auto_fix_tickets\".\"status\" IN ('pending', 'running', 'completed', 'failed', 'cancelled')"
+ },
+ "auto_fix_tickets_classification_check": {
+ "name": "auto_fix_tickets_classification_check",
+ "value": "\"auto_fix_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'unclear')"
+ },
+ "auto_fix_tickets_confidence_check": {
+ "name": "auto_fix_tickets_confidence_check",
+ "value": "\"auto_fix_tickets\".\"confidence\" >= 0 AND \"auto_fix_tickets\".\"confidence\" <= 1"
+ },
+ "auto_fix_tickets_trigger_source_check": {
+ "name": "auto_fix_tickets_trigger_source_check",
+ "value": "\"auto_fix_tickets\".\"trigger_source\" IN ('label', 'review_comment')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.auto_model": {
+ "name": "auto_model",
+ "schema": "",
+ "columns": {
+ "auto_model_id": {
+ "name": "auto_model_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "auto_model": {
+ "name": "auto_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_auto_model": {
+ "name": "UQ_auto_model",
+ "columns": [
+ {
+ "expression": "auto_model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auto_top_up_configs": {
+ "name": "auto_top_up_configs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_method_id": {
+ "name": "stripe_payment_method_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_cents": {
+ "name": "amount_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 5000
+ },
+ "last_auto_top_up_at": {
+ "name": "last_auto_top_up_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_started_at": {
+ "name": "attempt_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disabled_reason": {
+ "name": "disabled_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_top_up_configs_owned_by_user_id": {
+ "name": "UQ_auto_top_up_configs_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_auto_top_up_configs_owned_by_organization_id": {
+ "name": "UQ_auto_top_up_configs_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_top_up_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "auto_top_up_configs_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_top_up_configs_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_top_up_configs",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_top_up_configs_exactly_one_owner": {
+ "name": "auto_top_up_configs_exactly_one_owner",
+ "value": "(\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NULL) OR (\"auto_top_up_configs\".\"owned_by_user_id\" IS NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.auto_triage_tickets": {
+ "name": "auto_triage_tickets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_url": {
+ "name": "issue_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_title": {
+ "name": "issue_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_body": {
+ "name": "issue_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "issue_author": {
+ "name": "issue_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type": {
+ "name": "issue_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_labels": {
+ "name": "issue_labels",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent_summary": {
+ "name": "intent_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_files": {
+ "name": "related_files",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_duplicate": {
+ "name": "is_duplicate",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "duplicate_of_ticket_id": {
+ "name": "duplicate_of_ticket_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "similarity_score": {
+ "name": "similarity_score",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "qdrant_point_id": {
+ "name": "qdrant_point_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "should_auto_fix": {
+ "name": "should_auto_fix",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "action_taken": {
+ "name": "action_taken",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_metadata": {
+ "name": "action_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_triage_tickets_repo_issue": {
+ "name": "UQ_auto_triage_tickets_repo_issue",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owned_by_org": {
+ "name": "IDX_auto_triage_tickets_owned_by_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owned_by_user": {
+ "name": "IDX_auto_triage_tickets_owned_by_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_status": {
+ "name": "IDX_auto_triage_tickets_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_created_at": {
+ "name": "IDX_auto_triage_tickets_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_qdrant_point_id": {
+ "name": "IDX_auto_triage_tickets_qdrant_point_id",
+ "columns": [
+ {
+ "expression": "qdrant_point_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owner_status_created": {
+ "name": "IDX_auto_triage_tickets_owner_status_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_user_status_created": {
+ "name": "IDX_auto_triage_tickets_user_status_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_repo_classification": {
+ "name": "IDX_auto_triage_tickets_repo_classification",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "classification",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_triage_tickets_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_triage_tickets_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk": {
+ "name": "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk": {
+ "name": "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "auto_triage_tickets",
+ "columnsFrom": [
+ "duplicate_of_ticket_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_triage_tickets_owner_check": {
+ "name": "auto_triage_tickets_owner_check",
+ "value": "(\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "auto_triage_tickets_issue_type_check": {
+ "name": "auto_triage_tickets_issue_type_check",
+ "value": "\"auto_triage_tickets\".\"issue_type\" IN ('issue', 'pull_request')"
+ },
+ "auto_triage_tickets_classification_check": {
+ "name": "auto_triage_tickets_classification_check",
+ "value": "\"auto_triage_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'duplicate', 'unclear')"
+ },
+ "auto_triage_tickets_confidence_check": {
+ "name": "auto_triage_tickets_confidence_check",
+ "value": "\"auto_triage_tickets\".\"confidence\" >= 0 AND \"auto_triage_tickets\".\"confidence\" <= 1"
+ },
+ "auto_triage_tickets_similarity_score_check": {
+ "name": "auto_triage_tickets_similarity_score_check",
+ "value": "\"auto_triage_tickets\".\"similarity_score\" >= 0 AND \"auto_triage_tickets\".\"similarity_score\" <= 1"
+ },
+ "auto_triage_tickets_status_check": {
+ "name": "auto_triage_tickets_status_check",
+ "value": "\"auto_triage_tickets\".\"status\" IN ('pending', 'analyzing', 'actioned', 'failed', 'skipped')"
+ },
+ "auto_triage_tickets_action_taken_check": {
+ "name": "auto_triage_tickets_action_taken_check",
+ "value": "\"auto_triage_tickets\".\"action_taken\" IN ('pr_created', 'comment_posted', 'closed_duplicate', 'needs_clarification')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.bot_request_cloud_agent_sessions": {
+ "name": "bot_request_cloud_agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "bot_request_id": {
+ "name": "bot_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "spawn_group_id": {
+ "name": "spawn_group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repo": {
+ "name": "github_repo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gitlab_project": {
+ "name": "gitlab_project",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "callback_step": {
+ "name": "callback_step",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message": {
+ "name": "final_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message_fetched_at": {
+ "name": "final_message_fetched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message_error": {
+ "name": "final_message_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "continuation_started_at": {
+ "name": "continuation_started_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_bot_request_cas_cloud_agent_session_id": {
+ "name": "UQ_bot_request_cas_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id": {
+ "name": "IDX_bot_request_cas_bot_request_id",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id_spawn_group_id": {
+ "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spawn_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id_spawn_group_id_status": {
+ "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id_status",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spawn_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk": {
+ "name": "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk",
+ "tableFrom": "bot_request_cloud_agent_sessions",
+ "tableTo": "bot_requests",
+ "columnsFrom": [
+ "bot_request_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bot_requests": {
+ "name": "bot_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_thread_id": {
+ "name": "platform_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_message_id": {
+ "name": "platform_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message": {
+ "name": "user_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_used": {
+ "name": "model_used",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "steps": {
+ "name": "steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_bot_requests_created_at": {
+ "name": "IDX_bot_requests_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_created_by": {
+ "name": "IDX_bot_requests_created_by",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_organization_id": {
+ "name": "IDX_bot_requests_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_platform_integration_id": {
+ "name": "IDX_bot_requests_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_status": {
+ "name": "IDX_bot_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "bot_requests_created_by_kilocode_users_id_fk": {
+ "name": "bot_requests_created_by_kilocode_users_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bot_requests_organization_id_organizations_id_fk": {
+ "name": "bot_requests_organization_id_organizations_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bot_requests_platform_integration_id_platform_integrations_id_fk": {
+ "name": "bot_requests_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.byok_api_keys": {
+ "name": "byok_api_keys",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "management_source": {
+ "name": "management_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'user'"
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "IDX_byok_api_keys_organization_id": {
+ "name": "IDX_byok_api_keys_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_byok_api_keys_kilo_user_id": {
+ "name": "IDX_byok_api_keys_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_byok_api_keys_provider_id": {
+ "name": "IDX_byok_api_keys_provider_id",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "byok_api_keys_organization_id_organizations_id_fk": {
+ "name": "byok_api_keys_organization_id_organizations_id_fk",
+ "tableFrom": "byok_api_keys",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "byok_api_keys_kilo_user_id_kilocode_users_id_fk": {
+ "name": "byok_api_keys_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "byok_api_keys",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_byok_api_keys_org_provider": {
+ "name": "UQ_byok_api_keys_org_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "provider_id"
+ ]
+ },
+ "UQ_byok_api_keys_user_provider": {
+ "name": "UQ_byok_api_keys_user_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_user_id",
+ "provider_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "byok_api_keys_management_source_check": {
+ "name": "byok_api_keys_management_source_check",
+ "value": "\"byok_api_keys\".\"management_source\" IN ('user', 'coding_plan')"
+ },
+ "byok_api_keys_owner_check": {
+ "name": "byok_api_keys_owner_check",
+ "value": "(\n (\"byok_api_keys\".\"kilo_user_id\" IS NOT NULL AND \"byok_api_keys\".\"organization_id\" IS NULL) OR\n (\"byok_api_keys\".\"kilo_user_id\" IS NULL AND \"byok_api_keys\".\"organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cli_sessions": {
+ "name": "cli_sessions",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_on_platform": {
+ "name": "created_on_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "api_conversation_history_blob_url": {
+ "name": "api_conversation_history_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_metadata_blob_url": {
+ "name": "task_metadata_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ui_messages_blob_url": {
+ "name": "ui_messages_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_state_blob_url": {
+ "name": "git_state_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "forked_from": {
+ "name": "forked_from",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_session_id": {
+ "name": "parent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_mode": {
+ "name": "last_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_model": {
+ "name": "last_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cli_sessions_kilo_user_id": {
+ "name": "IDX_cli_sessions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_created_at": {
+ "name": "IDX_cli_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_updated_at": {
+ "name": "IDX_cli_sessions_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_organization_id": {
+ "name": "IDX_cli_sessions_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_user_updated": {
+ "name": "IDX_cli_sessions_user_updated",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_sessions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cli_sessions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_forked_from_cli_sessions_session_id_fk": {
+ "name": "cli_sessions_forked_from_cli_sessions_session_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "forked_from"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_parent_session_id_cli_sessions_session_id_fk": {
+ "name": "cli_sessions_parent_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "parent_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_organization_id_organizations_id_fk": {
+ "name": "cli_sessions_organization_id_organizations_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "cli_sessions_cloud_agent_session_id_unique": {
+ "name": "cli_sessions_cloud_agent_session_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "cloud_agent_session_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_sessions_v2": {
+ "name": "cli_sessions_v2",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_session_id": {
+ "name": "parent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_on_platform": {
+ "name": "created_on_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_updated_at": {
+ "name": "status_updated_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cli_sessions_v2_parent_session_id_kilo_user_id": {
+ "name": "IDX_cli_sessions_v2_parent_session_id_kilo_user_id",
+ "columns": [
+ {
+ "expression": "parent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cli_sessions_v2_public_id": {
+ "name": "UQ_cli_sessions_v2_public_id",
+ "columns": [
+ {
+ "expression": "public_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cli_sessions_v2\".\"public_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cli_sessions_v2_cloud_agent_session_id": {
+ "name": "UQ_cli_sessions_v2_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cli_sessions_v2\".\"cloud_agent_session_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_organization_id": {
+ "name": "IDX_cli_sessions_v2_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_kilo_user_id": {
+ "name": "IDX_cli_sessions_v2_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_created_at": {
+ "name": "IDX_cli_sessions_v2_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_user_updated": {
+ "name": "IDX_cli_sessions_v2_user_updated",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_sessions_v2_git_url_branch_idx": {
+ "name": "cli_sessions_v2_git_url_branch_idx",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_v2_organization_id_organizations_id_fk": {
+ "name": "cli_sessions_v2_organization_id_organizations_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_v2_parent_session_id_kilo_user_id_fk": {
+ "name": "cli_sessions_v2_parent_session_id_kilo_user_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "cli_sessions_v2",
+ "columnsFrom": [
+ "parent_session_id",
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "session_id",
+ "kilo_user_id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "cli_sessions_v2_session_id_kilo_user_id_pk": {
+ "name": "cli_sessions_v2_session_id_kilo_user_id_pk",
+ "columns": [
+ "session_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_code_review_attempts": {
+ "name": "cloud_agent_code_review_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_review_id": {
+ "name": "code_review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_number": {
+ "name": "attempt_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "retry_of_attempt_id": {
+ "name": "retry_of_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "retry_reason": {
+ "name": "retry_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analytics_enabled_at_dispatch": {
+ "name": "analytics_enabled_at_dispatch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_reason": {
+ "name": "terminal_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_code_review_attempts_review_attempt_number": {
+ "name": "UQ_cloud_agent_code_review_attempts_review_attempt_number",
+ "columns": [
+ {
+ "expression": "code_review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "attempt_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_code_review_id": {
+ "name": "idx_cloud_agent_code_review_attempts_code_review_id",
+ "columns": [
+ {
+ "expression": "code_review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_session_id": {
+ "name": "idx_cloud_agent_code_review_attempts_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_cli_session_id": {
+ "name": "idx_cloud_agent_code_review_attempts_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_status": {
+ "name": "idx_cloud_agent_code_review_attempts_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_retry_reason": {
+ "name": "idx_cloud_agent_code_review_attempts_retry_reason",
+ "columns": [
+ {
+ "expression": "retry_reason",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk": {
+ "name": "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk",
+ "tableFrom": "cloud_agent_code_review_attempts",
+ "tableTo": "cloud_agent_code_reviews",
+ "columnsFrom": [
+ "code_review_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk": {
+ "name": "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk",
+ "tableFrom": "cloud_agent_code_review_attempts",
+ "tableTo": "cloud_agent_code_review_attempts",
+ "columnsFrom": [
+ "retry_of_attempt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_code_review_attempts_attempt_number_check": {
+ "name": "cloud_agent_code_review_attempts_attempt_number_check",
+ "value": "\"cloud_agent_code_review_attempts\".\"attempt_number\" >= 1"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_code_reviews": {
+ "name": "cloud_agent_code_reviews",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_title": {
+ "name": "pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_author": {
+ "name": "pr_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_author_github_id": {
+ "name": "pr_author_github_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_ref": {
+ "name": "base_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_ref": {
+ "name": "head_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "platform_project_id": {
+ "name": "platform_project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "dispatch_reservation_id": {
+ "name": "dispatch_reservation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_reason": {
+ "name": "terminal_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_version": {
+ "name": "agent_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'v1'"
+ },
+ "check_run_id": {
+ "name": "check_run_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_review_instructions_used": {
+ "name": "repository_review_instructions_used",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "repository_review_instructions_ref": {
+ "name": "repository_review_instructions_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_review_instructions_truncated": {
+ "name": "repository_review_instructions_truncated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "previous_summary_body": {
+ "name": "previous_summary_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_summary_head_sha": {
+ "name": "previous_summary_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens_in": {
+ "name": "total_tokens_in",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens_out": {
+ "name": "total_tokens_out",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost_musd": {
+ "name": "total_cost_musd",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_code_reviews_repo_pr_sha": {
+ "name": "UQ_cloud_agent_code_reviews_repo_pr_sha",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "pr_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_owned_by_org_id": {
+ "name": "idx_cloud_agent_code_reviews_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_owned_by_user_id": {
+ "name": "idx_cloud_agent_code_reviews_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_session_id": {
+ "name": "idx_cloud_agent_code_reviews_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_cli_session_id": {
+ "name": "idx_cloud_agent_code_reviews_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_status": {
+ "name": "idx_cloud_agent_code_reviews_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_repo": {
+ "name": "idx_cloud_agent_code_reviews_repo",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_pr_number": {
+ "name": "idx_cloud_agent_code_reviews_pr_number",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "pr_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_created_at": {
+ "name": "idx_cloud_agent_code_reviews_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_pr_author_github_id": {
+ "name": "idx_cloud_agent_code_reviews_pr_author_github_id",
+ "columns": [
+ {
+ "expression": "pr_author_github_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk": {
+ "name": "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_code_reviews_owner_check": {
+ "name": "cloud_agent_code_reviews_owner_check",
+ "value": "(\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NOT NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NULL) OR\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_feedback": {
+ "name": "cloud_agent_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_streaming": {
+ "name": "is_streaming",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_count": {
+ "name": "message_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recent_messages": {
+ "name": "recent_messages",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cloud_agent_feedback_created_at": {
+ "name": "IDX_cloud_agent_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_feedback_kilo_user_id": {
+ "name": "IDX_cloud_agent_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_feedback_cloud_agent_session_id": {
+ "name": "IDX_cloud_agent_feedback_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "cloud_agent_feedback_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_feedback_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_feedback",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_session_runs": {
+ "name": "cloud_agent_session_runs",
+ "schema": "",
+ "columns": {
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wrapper_run_id": {
+ "name": "wrapper_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dispatch_accepted_at": {
+ "name": "dispatch_accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_activity_observed_at": {
+ "name": "agent_activity_observed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message_redacted": {
+ "name": "error_message_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_expires_at": {
+ "name": "error_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_cloud_agent_session_runs_wrapper_run_id": {
+ "name": "IDX_cloud_agent_session_runs_wrapper_run_id",
+ "columns": [
+ {
+ "expression": "wrapper_run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_session_runs\".\"wrapper_run_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_session_queued": {
+ "name": "IDX_cloud_agent_session_runs_session_queued",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_queued_at": {
+ "name": "IDX_cloud_agent_session_runs_queued_at",
+ "columns": [
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_terminal_at": {
+ "name": "IDX_cloud_agent_session_runs_terminal_at",
+ "columns": [
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_status_terminal": {
+ "name": "IDX_cloud_agent_session_runs_status_terminal",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_failure_terminal": {
+ "name": "IDX_cloud_agent_session_runs_failure_terminal",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_error_expires_at": {
+ "name": "IDX_cloud_agent_session_runs_error_expires_at",
+ "columns": [
+ {
+ "expression": "error_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_session_runs\".\"error_expires_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk": {
+ "name": "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk",
+ "tableFrom": "cloud_agent_session_runs",
+ "tableTo": "cloud_agent_sessions",
+ "columnsFrom": [
+ "cloud_agent_session_id"
+ ],
+ "columnsTo": [
+ "cloud_agent_session_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk": {
+ "name": "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk",
+ "columns": [
+ "cloud_agent_session_id",
+ "message_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_session_runs_status_check": {
+ "name": "cloud_agent_session_runs_status_check",
+ "value": "\"cloud_agent_session_runs\".\"status\" IN ('queued', 'accepted', 'completed', 'failed', 'interrupted')"
+ },
+ "cloud_agent_session_runs_failure_classification_check": {
+ "name": "cloud_agent_session_runs_failure_classification_check",
+ "value": "(\"cloud_agent_session_runs\".\"failure_stage\" IS NULL AND \"cloud_agent_session_runs\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'pre_dispatch' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('sandbox_connect_failed', 'workspace_setup_failed', 'kilo_server_failed', 'wrapper_start_failed', 'invalid_delivery_request', 'session_metadata_missing', 'model_missing', 'delivery_failure_unknown')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'post_dispatch_no_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('wrapper_disconnected', 'wrapper_no_output', 'wrapper_ping_timeout', 'wrapper_error_before_activity', 'missing_assistant_reply')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'agent_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('assistant_error', 'wrapper_error_after_activity')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'interruption' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('user_interrupt', 'container_shutdown', 'system_interrupt')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'unknown' AND \"cloud_agent_session_runs\".\"failure_code\" = 'unclassified')"
+ },
+ "cloud_agent_session_runs_error_message_bounded_check": {
+ "name": "cloud_agent_session_runs_error_message_bounded_check",
+ "value": "\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_session_runs\".\"error_message_redacted\") <= 4096"
+ },
+ "cloud_agent_session_runs_error_expiry_check": {
+ "name": "cloud_agent_session_runs_error_expiry_check",
+ "value": "(\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_sessions": {
+ "name": "cloud_agent_sessions",
+ "schema": "",
+ "columns": {
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "initial_message_id": {
+ "name": "initial_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "failure_at": {
+ "name": "failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message_redacted": {
+ "name": "error_message_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_expires_at": {
+ "name": "error_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_sessions_kilo_session_id": {
+ "name": "UQ_cloud_agent_sessions_kilo_session_id",
+ "columns": [
+ {
+ "expression": "kilo_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cloud_agent_sessions_initial_message_id": {
+ "name": "UQ_cloud_agent_sessions_initial_message_id",
+ "columns": [
+ {
+ "expression": "initial_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_sandbox_id": {
+ "name": "IDX_cloud_agent_sessions_sandbox_id",
+ "columns": [
+ {
+ "expression": "sandbox_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"sandbox_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_created_at": {
+ "name": "IDX_cloud_agent_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_created": {
+ "name": "IDX_cloud_agent_sessions_failure_created",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_at": {
+ "name": "IDX_cloud_agent_sessions_failure_at",
+ "columns": [
+ {
+ "expression": "failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_classification_at": {
+ "name": "IDX_cloud_agent_sessions_failure_classification_at",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_error_expires_at": {
+ "name": "IDX_cloud_agent_sessions_error_expires_at",
+ "columns": [
+ {
+ "expression": "error_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"error_expires_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_sessions_failure_classification_check": {
+ "name": "cloud_agent_sessions_failure_classification_check",
+ "value": "(\"cloud_agent_sessions\".\"failure_at\" IS NULL AND \"cloud_agent_sessions\".\"failure_stage\" IS NULL AND \"cloud_agent_sessions\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'sandbox_identity' AND \"cloud_agent_sessions\".\"failure_code\" = 'sandbox_id_derivation_failed') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'registration' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_registration_rejected') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'initial_admission' AND \"cloud_agent_sessions\".\"failure_code\" IN ('initial_admission_rejected', 'initial_queue_full', 'invalid_initial_intent')) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'transport' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_rpc_outcome_unknown')"
+ },
+ "cloud_agent_sessions_error_message_bounded_check": {
+ "name": "cloud_agent_sessions_error_message_bounded_check",
+ "value": "\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_sessions\".\"error_message_redacted\") <= 4096"
+ },
+ "cloud_agent_sessions_error_expiry_check": {
+ "name": "cloud_agent_sessions_error_expiry_check",
+ "value": "(\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_sessions\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_webhook_triggers": {
+ "name": "cloud_agent_webhook_triggers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "trigger_id": {
+ "name": "trigger_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_type": {
+ "name": "target_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cloud_agent'"
+ },
+ "kiloclaw_instance_id": {
+ "name": "kiloclaw_instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "activation_mode": {
+ "name": "activation_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'webhook'"
+ },
+ "cron_expression": {
+ "name": "cron_expression",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cron_timezone": {
+ "name": "cron_timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'UTC'"
+ },
+ "github_repo": {
+ "name": "github_repo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_webhook_triggers_user_trigger": {
+ "name": "UQ_cloud_agent_webhook_triggers_user_trigger",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "trigger_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cloud_agent_webhook_triggers\".\"user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cloud_agent_webhook_triggers_org_trigger": {
+ "name": "UQ_cloud_agent_webhook_triggers_org_trigger",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "trigger_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cloud_agent_webhook_triggers\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_user": {
+ "name": "IDX_cloud_agent_webhook_triggers_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_org": {
+ "name": "IDX_cloud_agent_webhook_triggers_org",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_active": {
+ "name": "IDX_cloud_agent_webhook_triggers_active",
+ "columns": [
+ {
+ "expression": "is_active",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_profile": {
+ "name": "IDX_cloud_agent_webhook_triggers_profile",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_webhook_triggers_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk": {
+ "name": "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "kiloclaw_instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk": {
+ "name": "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_cloud_agent_webhook_triggers_owner": {
+ "name": "CHK_cloud_agent_webhook_triggers_owner",
+ "value": "(\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NULL) OR\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NOT NULL)\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_cloud_agent_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_cloud_agent_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'cloud_agent' OR\n (\"cloud_agent_webhook_triggers\".\"github_repo\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"profile_id\" IS NOT NULL)\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_kiloclaw_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_kiloclaw_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'kiloclaw_chat' OR\n \"cloud_agent_webhook_triggers\".\"kiloclaw_instance_id\" IS NOT NULL\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_scheduled_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_scheduled_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"activation_mode\" != 'scheduled' OR\n \"cloud_agent_webhook_triggers\".\"cron_expression\" IS NOT NULL\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_indexing_manifest": {
+ "name": "code_indexing_manifest",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_hash": {
+ "name": "file_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chunk_count": {
+ "name": "chunk_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_lines": {
+ "name": "total_lines",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_ai_lines": {
+ "name": "total_ai_lines",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_code_indexing_manifest_organization_id": {
+ "name": "IDX_code_indexing_manifest_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_kilo_user_id": {
+ "name": "IDX_code_indexing_manifest_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_project_id": {
+ "name": "IDX_code_indexing_manifest_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_git_branch": {
+ "name": "IDX_code_indexing_manifest_git_branch",
+ "columns": [
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_created_at": {
+ "name": "IDX_code_indexing_manifest_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk": {
+ "name": "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_indexing_manifest",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_indexing_manifest_org_user_project_hash_branch": {
+ "name": "UQ_code_indexing_manifest_org_user_project_hash_branch",
+ "nullsNotDistinct": true,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "project_id",
+ "file_path",
+ "git_branch"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.code_indexing_search": {
+ "name": "code_indexing_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "query": {
+ "name": "query",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_code_indexing_search_organization_id": {
+ "name": "IDX_code_indexing_search_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_kilo_user_id": {
+ "name": "IDX_code_indexing_search_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_project_id": {
+ "name": "IDX_code_indexing_search_project_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_created_at": {
+ "name": "IDX_code_indexing_search_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_indexing_search_kilo_user_id_kilocode_users_id_fk": {
+ "name": "code_indexing_search_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_indexing_search",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.code_review_analytics_findings": {
+ "name": "code_review_analytics_findings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "analytics_result_id": {
+ "name": "analytics_result_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordinal": {
+ "name": "ordinal",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "security_class": {
+ "name": "security_class",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk": {
+ "name": "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk",
+ "tableFrom": "code_review_analytics_findings",
+ "tableTo": "code_review_analytics_results",
+ "columnsFrom": [
+ "analytics_result_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_analytics_findings_result_ordinal": {
+ "name": "UQ_code_review_analytics_findings_result_ordinal",
+ "nullsNotDistinct": false,
+ "columns": [
+ "analytics_result_id",
+ "ordinal"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_analytics_findings_severity_check": {
+ "name": "code_review_analytics_findings_severity_check",
+ "value": "\"code_review_analytics_findings\".\"severity\" IN ('critical', 'warning', 'suggestion')"
+ },
+ "code_review_analytics_findings_category_check": {
+ "name": "code_review_analytics_findings_category_check",
+ "value": "\"code_review_analytics_findings\".\"category\" IN ('security', 'correctness', 'reliability', 'data_integrity', 'performance', 'compatibility', 'maintainability', 'test_quality', 'documentation', 'accessibility', 'other')"
+ },
+ "code_review_analytics_findings_security_class_check": {
+ "name": "code_review_analytics_findings_security_class_check",
+ "value": "\"code_review_analytics_findings\".\"security_class\" IN ('auth_access', 'injection', 'data_protection', 'request_resource_boundary', 'deserialization_object_integrity', 'dependency_supply_chain', 'memory_safety', 'availability', 'concurrency', 'security_configuration', 'other')"
+ },
+ "code_review_analytics_findings_ordinal_check": {
+ "name": "code_review_analytics_findings_ordinal_check",
+ "value": "\"code_review_analytics_findings\".\"ordinal\" >= 0"
+ },
+ "code_review_analytics_findings_security_class_presence_check": {
+ "name": "code_review_analytics_findings_security_class_presence_check",
+ "value": "(\n (\"code_review_analytics_findings\".\"category\" = 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NOT NULL) OR\n (\"code_review_analytics_findings\".\"category\" <> 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_analytics_results": {
+ "name": "code_review_analytics_results",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_review_id": {
+ "name": "code_review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_attempt_id": {
+ "name": "source_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capture_status": {
+ "name": "capture_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "schema_version": {
+ "name": "schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "taxonomy_version": {
+ "name": "taxonomy_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "change_type": {
+ "name": "change_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_level": {
+ "name": "impact_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "complexity_level": {
+ "name": "complexity_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "classification_confidence": {
+ "name": "classification_confidence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finalized_at": {
+ "name": "finalized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_analytics_results_source_attempt_id": {
+ "name": "idx_code_review_analytics_results_source_attempt_id",
+ "columns": [
+ {
+ "expression": "source_attempt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_analytics_results_finalized_at": {
+ "name": "idx_code_review_analytics_results_finalized_at",
+ "columns": [
+ {
+ "expression": "finalized_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk": {
+ "name": "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk",
+ "tableFrom": "code_review_analytics_results",
+ "tableTo": "cloud_agent_code_reviews",
+ "columnsFrom": [
+ "code_review_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk": {
+ "name": "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk",
+ "tableFrom": "code_review_analytics_results",
+ "tableTo": "cloud_agent_code_review_attempts",
+ "columnsFrom": [
+ "source_attempt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_analytics_results_code_review_id": {
+ "name": "UQ_code_review_analytics_results_code_review_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "code_review_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_analytics_results_capture_status_check": {
+ "name": "code_review_analytics_results_capture_status_check",
+ "value": "\"code_review_analytics_results\".\"capture_status\" IN ('captured', 'missing', 'invalid', 'omitted')"
+ },
+ "code_review_analytics_results_change_type_check": {
+ "name": "code_review_analytics_results_change_type_check",
+ "value": "\"code_review_analytics_results\".\"change_type\" IN ('bug_fix', 'feature', 'refactor', 'maintenance', 'dependency', 'test', 'documentation', 'mixed', 'other')"
+ },
+ "code_review_analytics_results_impact_level_check": {
+ "name": "code_review_analytics_results_impact_level_check",
+ "value": "\"code_review_analytics_results\".\"impact_level\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_complexity_level_check": {
+ "name": "code_review_analytics_results_complexity_level_check",
+ "value": "\"code_review_analytics_results\".\"complexity_level\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_classification_confidence_check": {
+ "name": "code_review_analytics_results_classification_confidence_check",
+ "value": "\"code_review_analytics_results\".\"classification_confidence\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_classification_presence_check": {
+ "name": "code_review_analytics_results_classification_presence_check",
+ "value": "(\n (\n \"code_review_analytics_results\".\"capture_status\" = 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NOT NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NOT NULL\n ) OR (\n \"code_review_analytics_results\".\"capture_status\" <> 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NULL\n )\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_feedback_events": {
+ "name": "code_review_feedback_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_comment_id": {
+ "name": "kilo_comment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reply_excerpt": {
+ "name": "reply_excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_comment_excerpt": {
+ "name": "kilo_comment_excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_hash": {
+ "name": "dedupe_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_feedback_events_owned_by_org_id": {
+ "name": "idx_code_review_feedback_events_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_owned_by_user_id": {
+ "name": "idx_code_review_feedback_events_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_platform_repo": {
+ "name": "idx_code_review_feedback_events_platform_repo",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_created_at": {
+ "name": "idx_code_review_feedback_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_feedback_events_owned_by_organization_id_organizations_id_fk": {
+ "name": "code_review_feedback_events_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "code_review_feedback_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_review_feedback_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_feedback_events_dedupe_hash": {
+ "name": "UQ_code_review_feedback_events_dedupe_hash",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_hash"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_feedback_events_owner_check": {
+ "name": "code_review_feedback_events_owner_check",
+ "value": "(\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_memory_proposals": {
+ "name": "code_review_memory_proposals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "proposed_markdown": {
+ "name": "proposed_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "positive_count": {
+ "name": "positive_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "negative_count": {
+ "name": "negative_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "neutral_count": {
+ "name": "neutral_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "change_request_url": {
+ "name": "change_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_memory_proposals_owned_by_org_id": {
+ "name": "idx_code_review_memory_proposals_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_owned_by_user_id": {
+ "name": "idx_code_review_memory_proposals_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_platform_repo_status": {
+ "name": "idx_code_review_memory_proposals_platform_repo_status",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_updated_at": {
+ "name": "idx_code_review_memory_proposals_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_code_review_memory_proposals_org_active_scope": {
+ "name": "UQ_code_review_memory_proposals_org_active_scope",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_code_review_memory_proposals_user_active_scope": {
+ "name": "UQ_code_review_memory_proposals_user_active_scope",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk": {
+ "name": "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "code_review_memory_proposals",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_review_memory_proposals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "code_review_memory_proposals_owner_check": {
+ "name": "code_review_memory_proposals_owner_check",
+ "value": "(\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_availability_intents": {
+ "name": "coding_plan_availability_intents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_availability_intents_user_plan": {
+ "name": "UQ_coding_plan_availability_intents_user_plan",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_availability_intents_plan": {
+ "name": "IDX_coding_plan_availability_intents_plan",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_availability_intents_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_availability_intents_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_availability_intents",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_key_inventory": {
+ "name": "coding_plan_key_inventory",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "upstream_plan_id": {
+ "name": "upstream_plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_fingerprint": {
+ "name": "credential_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'available'"
+ },
+ "assigned_to_user_id": {
+ "name": "assigned_to_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assigned_at": {
+ "name": "assigned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_requested_at": {
+ "name": "revocation_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_attempt_count": {
+ "name": "revocation_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_revocation_error": {
+ "name": "last_revocation_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_key_inv_fingerprint": {
+ "name": "UQ_coding_plan_key_inv_fingerprint",
+ "columns": [
+ {
+ "expression": "credential_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_key_inv_plan_status": {
+ "name": "IDX_coding_plan_key_inv_plan_status",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_key_inv_available": {
+ "name": "IDX_coding_plan_key_inv_available",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"coding_plan_key_inventory\".\"status\" = 'available'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_key_inventory",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "assigned_to_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_key_inventory_status_check": {
+ "name": "coding_plan_key_inventory_status_check",
+ "value": "\"coding_plan_key_inventory\".\"status\" IN ('available', 'assigned', 'revocation_pending', 'revoked', 'revocation_failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_subscriptions": {
+ "name": "coding_plan_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_inventory_id": {
+ "name": "key_inventory_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_byok_key_id": {
+ "name": "installed_byok_key_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_period_days": {
+ "name": "billing_period_days",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_period_start": {
+ "name": "current_period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_renewal_at": {
+ "name": "credit_renewal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "past_due_started_at": {
+ "name": "past_due_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payment_grace_expires_at": {
+ "name": "payment_grace_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_attempted_for_due": {
+ "name": "auto_top_up_attempted_for_due",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_reason": {
+ "name": "cancellation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_sub_live_user_plan": {
+ "name": "UQ_coding_plan_sub_live_user_plan",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_status": {
+ "name": "IDX_coding_plan_sub_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_renewal": {
+ "name": "IDX_coding_plan_sub_renewal",
+ "columns": [
+ {
+ "expression": "credit_renewal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_inventory": {
+ "name": "IDX_coding_plan_sub_inventory",
+ "columns": [
+ {
+ "expression": "key_inventory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_subscriptions_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_subscriptions_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk": {
+ "name": "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "coding_plan_key_inventory",
+ "columnsFrom": [
+ "key_inventory_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk": {
+ "name": "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "byok_api_keys",
+ "columnsFrom": [
+ "installed_byok_key_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_subscriptions_status_check": {
+ "name": "coding_plan_subscriptions_status_check",
+ "value": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due', 'canceled')"
+ },
+ "coding_plan_subscriptions_live_access_check": {
+ "name": "coding_plan_subscriptions_live_access_check",
+ "value": "\"coding_plan_subscriptions\".\"status\" = 'canceled' OR \"coding_plan_subscriptions\".\"key_inventory_id\" IS NOT NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_terms": {
+ "name": "coding_plan_terms",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_start": {
+ "name": "period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_end": {
+ "name": "period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_transaction_id": {
+ "name": "credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_terms_request": {
+ "name": "UQ_coding_plan_terms_request",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_terms_subscription": {
+ "name": "IDX_coding_plan_terms_subscription",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk": {
+ "name": "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "coding_plan_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_terms_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_terms_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_terms_kind_check": {
+ "name": "coding_plan_terms_kind_check",
+ "value": "\"coding_plan_terms\".\"kind\" IN ('activation', 'extension', 'renewal')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_contributors": {
+ "name": "contributor_champion_contributors",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_profile_url": {
+ "name": "github_profile_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_contribution_at": {
+ "name": "first_contribution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contribution_at": {
+ "name": "last_contribution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "all_time_contributions": {
+ "name": "all_time_contributions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "manual_email": {
+ "name": "manual_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_contributors_last_contribution_at": {
+ "name": "IDX_contributor_champion_contributors_last_contribution_at",
+ "columns": [
+ {
+ "expression": "last_contribution_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_contributors_manual_email": {
+ "name": "IDX_contributor_champion_contributors_manual_email",
+ "columns": [
+ {
+ "expression": "manual_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_contributors_github_login": {
+ "name": "UQ_contributor_champion_contributors_github_login",
+ "nullsNotDistinct": false,
+ "columns": [
+ "github_login"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_events": {
+ "name": "contributor_champion_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "contributor_id": {
+ "name": "contributor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_number": {
+ "name": "github_pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_url": {
+ "name": "github_pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_title": {
+ "name": "github_pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_author_login": {
+ "name": "github_author_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_author_email": {
+ "name": "github_author_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_events_contributor_id": {
+ "name": "IDX_contributor_champion_events_contributor_id",
+ "columns": [
+ {
+ "expression": "contributor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_events_merged_at": {
+ "name": "IDX_contributor_champion_events_merged_at",
+ "columns": [
+ {
+ "expression": "merged_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_events_author_email": {
+ "name": "IDX_contributor_champion_events_author_email",
+ "columns": [
+ {
+ "expression": "github_author_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk": {
+ "name": "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk",
+ "tableFrom": "contributor_champion_events",
+ "tableTo": "contributor_champion_contributors",
+ "columnsFrom": [
+ "contributor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_events_repo_pr": {
+ "name": "UQ_contributor_champion_events_repo_pr",
+ "nullsNotDistinct": false,
+ "columns": [
+ "repo_full_name",
+ "github_pr_number"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_memberships": {
+ "name": "contributor_champion_memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "contributor_id": {
+ "name": "contributor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "selected_tier": {
+ "name": "selected_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enrolled_tier": {
+ "name": "enrolled_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enrolled_at": {
+ "name": "enrolled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_amount_microdollars": {
+ "name": "credit_amount_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "credits_last_granted_at": {
+ "name": "credits_last_granted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linked_kilo_user_id": {
+ "name": "linked_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_memberships_credits_due": {
+ "name": "IDX_contributor_champion_memberships_credits_due",
+ "columns": [
+ {
+ "expression": "credits_last_granted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NOT NULL AND \"contributor_champion_memberships\".\"credit_amount_microdollars\" > 0",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_memberships_linked_kilo_user_id": {
+ "name": "IDX_contributor_champion_memberships_linked_kilo_user_id",
+ "columns": [
+ {
+ "expression": "linked_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk": {
+ "name": "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk",
+ "tableFrom": "contributor_champion_memberships",
+ "tableTo": "contributor_champion_contributors",
+ "columnsFrom": [
+ "contributor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk": {
+ "name": "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "contributor_champion_memberships",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "linked_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_memberships_contributor_id": {
+ "name": "UQ_contributor_champion_memberships_contributor_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "contributor_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "contributor_champion_memberships_selected_tier_check": {
+ "name": "contributor_champion_memberships_selected_tier_check",
+ "value": "\"contributor_champion_memberships\".\"selected_tier\" IS NULL OR \"contributor_champion_memberships\".\"selected_tier\" IN ('contributor', 'ambassador', 'champion')"
+ },
+ "contributor_champion_memberships_enrolled_tier_check": {
+ "name": "contributor_champion_memberships_enrolled_tier_check",
+ "value": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NULL OR \"contributor_champion_memberships\".\"enrolled_tier\" IN ('contributor', 'ambassador', 'champion')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_sync_state": {
+ "name": "contributor_champion_sync_state",
+ "schema": "",
+ "columns": {
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "last_merged_at": {
+ "name": "last_merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.credit_campaigns": {
+ "name": "credit_campaigns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_category": {
+ "name": "credit_category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_microdollars": {
+ "name": "amount_microdollars",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_expiry_hours": {
+ "name": "credit_expiry_hours",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "campaign_ends_at": {
+ "name": "campaign_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_redemptions_allowed": {
+ "name": "total_redemptions_allowed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_credit_campaigns_slug": {
+ "name": "UQ_credit_campaigns_slug",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_credit_campaigns_credit_category": {
+ "name": "UQ_credit_campaigns_credit_category",
+ "columns": [
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "credit_campaigns_slug_format_check": {
+ "name": "credit_campaigns_slug_format_check",
+ "value": "\"credit_campaigns\".\"slug\" ~ '^[a-z0-9-]{5,40}$'"
+ },
+ "credit_campaigns_amount_positive_check": {
+ "name": "credit_campaigns_amount_positive_check",
+ "value": "\"credit_campaigns\".\"amount_microdollars\" > 0"
+ },
+ "credit_campaigns_credit_expiry_hours_positive_check": {
+ "name": "credit_campaigns_credit_expiry_hours_positive_check",
+ "value": "\"credit_campaigns\".\"credit_expiry_hours\" IS NULL OR \"credit_campaigns\".\"credit_expiry_hours\" > 0"
+ },
+ "credit_campaigns_total_redemptions_allowed_positive_check": {
+ "name": "credit_campaigns_total_redemptions_allowed_positive_check",
+ "value": "\"credit_campaigns\".\"total_redemptions_allowed\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.credit_transactions": {
+ "name": "credit_transactions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_microdollars": {
+ "name": "amount_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expiration_baseline_microdollars_used": {
+ "name": "expiration_baseline_microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_baseline_microdollars_used": {
+ "name": "original_baseline_microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_transaction_id": {
+ "name": "original_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_id": {
+ "name": "stripe_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coinbase_credit_block_id": {
+ "name": "coinbase_credit_block_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_category": {
+ "name": "credit_category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expiry_date": {
+ "name": "expiry_date",
+ "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()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_category_uniqueness": {
+ "name": "check_category_uniqueness",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "IDX_credit_transactions_created_at": {
+ "name": "IDX_credit_transactions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_is_free": {
+ "name": "IDX_credit_transactions_is_free",
+ "columns": [
+ {
+ "expression": "is_free",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_kilo_user_id": {
+ "name": "IDX_credit_transactions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_credit_category": {
+ "name": "IDX_credit_transactions_credit_category",
+ "columns": [
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_stripe_payment_id": {
+ "name": "IDX_credit_transactions_stripe_payment_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_original_transaction_id": {
+ "name": "IDX_credit_transactions_original_transaction_id",
+ "columns": [
+ {
+ "expression": "original_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_coinbase_credit_block_id": {
+ "name": "IDX_credit_transactions_coinbase_credit_block_id",
+ "columns": [
+ {
+ "expression": "coinbase_credit_block_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_organization_id": {
+ "name": "IDX_credit_transactions_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_unique_category": {
+ "name": "IDX_credit_transactions_unique_category",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"credit_transactions\".\"check_category_uniqueness\" = TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "credit_transactions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_llm2": {
+ "name": "custom_llm2",
+ "schema": "",
+ "columns": {
+ "public_id": {
+ "name": "public_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "definition": {
+ "name": "definition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deleted_user_email_tombstones": {
+ "name": "deleted_user_email_tombstones",
+ "schema": "",
+ "columns": {
+ "normalized_email_hash": {
+ "name": "normalized_email_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_builds": {
+ "name": "deployment_builds",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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": {
+ "idx_deployment_builds_deployment_id": {
+ "name": "idx_deployment_builds_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_builds_status": {
+ "name": "idx_deployment_builds_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_builds_deployment_id_deployments_id_fk": {
+ "name": "deployment_builds_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_builds",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_env_vars": {
+ "name": "deployment_env_vars",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_secret": {
+ "name": "is_secret",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployment_env_vars_deployment_id": {
+ "name": "idx_deployment_env_vars_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_env_vars_deployment_id_deployments_id_fk": {
+ "name": "deployment_env_vars_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_env_vars",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployment_env_vars_deployment_key": {
+ "name": "UQ_deployment_env_vars_deployment_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_events": {
+ "name": "deployment_events",
+ "schema": "",
+ "columns": {
+ "build_id": {
+ "name": "build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'log'"
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_deployment_events_build_id": {
+ "name": "idx_deployment_events_build_id",
+ "columns": [
+ {
+ "expression": "build_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_events_timestamp": {
+ "name": "idx_deployment_events_timestamp",
+ "columns": [
+ {
+ "expression": "timestamp",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_events_type": {
+ "name": "idx_deployment_events_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_events_build_id_deployment_builds_id_fk": {
+ "name": "deployment_events_build_id_deployment_builds_id_fk",
+ "tableFrom": "deployment_events",
+ "tableTo": "deployment_builds",
+ "columnsFrom": [
+ "build_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "deployment_events_build_id_event_id_pk": {
+ "name": "deployment_events_build_id_event_id_pk",
+ "columns": [
+ "build_id",
+ "event_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_threat_detections": {
+ "name": "deployment_threat_detections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "build_id": {
+ "name": "build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "threat_type": {
+ "name": "threat_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployment_threat_detections_deployment_id": {
+ "name": "idx_deployment_threat_detections_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_threat_detections_created_at": {
+ "name": "idx_deployment_threat_detections_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_threat_detections_deployment_id_deployments_id_fk": {
+ "name": "deployment_threat_detections_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_threat_detections",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "deployment_threat_detections_build_id_deployment_builds_id_fk": {
+ "name": "deployment_threat_detections_build_id_deployment_builds_id_fk",
+ "tableFrom": "deployment_threat_detections",
+ "tableTo": "deployment_builds",
+ "columnsFrom": [
+ "build_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployments": {
+ "name": "deployments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deployment_slug": {
+ "name": "deployment_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_worker_name": {
+ "name": "internal_worker_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_source": {
+ "name": "repository_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch": {
+ "name": "branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deployment_url": {
+ "name": "deployment_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "git_auth_token": {
+ "name": "git_auth_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_deployed_at": {
+ "name": "last_deployed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_build_id": {
+ "name": "last_build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "threat_status": {
+ "name": "threat_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_from": {
+ "name": "created_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_deployments_owned_by_user_id": {
+ "name": "idx_deployments_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_owned_by_organization_id": {
+ "name": "idx_deployments_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_platform_integration_id": {
+ "name": "idx_deployments_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_repository_source_branch": {
+ "name": "idx_deployments_repository_source_branch",
+ "columns": [
+ {
+ "expression": "repository_source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_threat_status_pending": {
+ "name": "idx_deployments_threat_status_pending",
+ "columns": [
+ {
+ "expression": "threat_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"deployments\".\"threat_status\" = 'pending_scan'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployments_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "deployments_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deployments_owned_by_organization_id_organizations_id_fk": {
+ "name": "deployments_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployments_deployment_slug": {
+ "name": "UQ_deployments_deployment_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "deployments_owner_check": {
+ "name": "deployments_owner_check",
+ "value": "(\n (\"deployments\".\"owned_by_user_id\" IS NOT NULL AND \"deployments\".\"owned_by_organization_id\" IS NULL) OR\n (\"deployments\".\"owned_by_user_id\" IS NULL AND \"deployments\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "deployments_source_type_check": {
+ "name": "deployments_source_type_check",
+ "value": "\"deployments\".\"source_type\" IN ('github', 'git', 'app-builder')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.deployments_ephemeral": {
+ "name": "deployments_ephemeral",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_worker_name": {
+ "name": "internal_worker_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deployment_slug": {
+ "name": "deployment_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_cleanup_at": {
+ "name": "next_cleanup_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cleanup_claim_token": {
+ "name": "cleanup_claim_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cleanup_claimed_until": {
+ "name": "cleanup_claimed_until",
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployments_ephemeral_owned_by_user_id": {
+ "name": "idx_deployments_ephemeral_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_ephemeral_next_cleanup_at": {
+ "name": "idx_deployments_ephemeral_next_cleanup_at",
+ "columns": [
+ {
+ "expression": "next_cleanup_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "deployments_ephemeral",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployments_ephemeral_internal_worker_name": {
+ "name": "UQ_deployments_ephemeral_internal_worker_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "internal_worker_name"
+ ]
+ },
+ "UQ_deployments_ephemeral_deployment_slug": {
+ "name": "UQ_deployments_ephemeral_deployment_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "deployments_ephemeral_source_type_check": {
+ "name": "deployments_ephemeral_source_type_check",
+ "value": "\"deployments_ephemeral\".\"source_type\" IN ('html')"
+ },
+ "deployments_ephemeral_status_check": {
+ "name": "deployments_ephemeral_status_check",
+ "value": "\"deployments_ephemeral\".\"status\" IN ('pending', 'active', 'cleanup_retry')"
+ },
+ "deployments_ephemeral_claim_fields_check": {
+ "name": "deployments_ephemeral_claim_fields_check",
+ "value": "(\"deployments_ephemeral\".\"cleanup_claim_token\" IS NULL) = (\"deployments_ephemeral\".\"cleanup_claimed_until\" IS NULL)"
+ },
+ "deployments_ephemeral_active_fields_check": {
+ "name": "deployments_ephemeral_active_fields_check",
+ "value": "\"deployments_ephemeral\".\"status\" <> 'active' OR (\"deployments_ephemeral\".\"deployment_slug\" IS NOT NULL AND \"deployments_ephemeral\".\"expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.device_auth_requests": {
+ "name": "device_auth_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_device_auth_requests_code": {
+ "name": "UQ_device_auth_requests_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_status": {
+ "name": "IDX_device_auth_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_expires_at": {
+ "name": "IDX_device_auth_requests_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_kilo_user_id": {
+ "name": "IDX_device_auth_requests_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "device_auth_requests_kilo_user_id_kilocode_users_id_fk": {
+ "name": "device_auth_requests_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "device_auth_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.discord_gateway_listener": {
+ "name": "discord_gateway_listener",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "default": 1
+ },
+ "listener_id": {
+ "name": "listener_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_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": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.editor_name": {
+ "name": "editor_name",
+ "schema": "",
+ "columns": {
+ "editor_name_id": {
+ "name": "editor_name_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "editor_name": {
+ "name": "editor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_editor_name": {
+ "name": "UQ_editor_name",
+ "columns": [
+ {
+ "expression": "editor_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.enrichment_data": {
+ "name": "enrichment_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_enrichment_data": {
+ "name": "github_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linkedin_enrichment_data": {
+ "name": "linkedin_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clay_enrichment_data": {
+ "name": "clay_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_enrichment_data_user_id": {
+ "name": "IDX_enrichment_data_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "enrichment_data_user_id_kilocode_users_id_fk": {
+ "name": "enrichment_data_user_id_kilocode_users_id_fk",
+ "tableFrom": "enrichment_data",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_enrichment_data_user_id": {
+ "name": "UQ_enrichment_data_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.exa_monthly_usage": {
+ "name": "exa_monthly_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "month": {
+ "name": "month",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "total_charged_microdollars": {
+ "name": "total_charged_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "free_allowance_microdollars": {
+ "name": "free_allowance_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 10000000
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_exa_monthly_usage_personal": {
+ "name": "idx_exa_monthly_usage_personal",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"exa_monthly_usage\".\"organization_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_exa_monthly_usage_org": {
+ "name": "idx_exa_monthly_usage_org",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"exa_monthly_usage\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.exa_usage_log": {
+ "name": "exa_usage_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "charged_to_balance": {
+ "name": "charged_to_balance",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "feature_id": {
+ "name": "feature_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_exa_usage_log_user_created": {
+ "name": "idx_exa_usage_log_user_created",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "exa_usage_log_id_created_at_pk": {
+ "name": "exa_usage_log_id_created_at_pk",
+ "columns": [
+ "id",
+ "created_at"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature": {
+ "name": "feature",
+ "schema": "",
+ "columns": {
+ "feature_id": {
+ "name": "feature_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_feature": {
+ "name": "UQ_feature",
+ "columns": [
+ {
+ "expression": "feature",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.finish_reason": {
+ "name": "finish_reason",
+ "schema": "",
+ "columns": {
+ "finish_reason_id": {
+ "name": "finish_reason_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "finish_reason": {
+ "name": "finish_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_finish_reason": {
+ "name": "UQ_finish_reason",
+ "columns": [
+ {
+ "expression": "finish_reason",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.free_model_usage": {
+ "name": "free_model_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_free_model_usage_ip_created_at": {
+ "name": "idx_free_model_usage_ip_created_at",
+ "columns": [
+ {
+ "expression": "ip_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_free_model_usage_created_at": {
+ "name": "idx_free_model_usage_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_branch_pull_requests": {
+ "name": "github_branch_pull_requests",
+ "schema": "",
+ "columns": {
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_state": {
+ "name": "pr_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_title": {
+ "name": "pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_sha": {
+ "name": "pr_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_review_decision": {
+ "name": "pr_review_decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_decision_pending": {
+ "name": "review_decision_pending",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "review_decision_fetching_at": {
+ "name": "review_decision_fetching_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_last_synced_at": {
+ "name": "pr_last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_github_branch_prs_org": {
+ "name": "UQ_github_branch_prs_org",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"github_branch_pull_requests\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_github_branch_prs_user": {
+ "name": "UQ_github_branch_prs_user",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"github_branch_pull_requests\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk": {
+ "name": "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "github_branch_pull_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "github_branch_pull_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "github_branch_pull_requests_owner_check": {
+ "name": "github_branch_pull_requests_owner_check",
+ "value": "(\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NOT NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NULL) OR\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NOT NULL)\n )"
+ },
+ "github_branch_pull_requests_review_decision_check": {
+ "name": "github_branch_pull_requests_review_decision_check",
+ "value": "\"github_branch_pull_requests\".\"pr_review_decision\" IS NULL OR \"github_branch_pull_requests\".\"pr_review_decision\" IN ('approved', 'changes_requested', 'review_required')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.http_ip": {
+ "name": "http_ip",
+ "schema": "",
+ "columns": {
+ "http_ip_id": {
+ "name": "http_ip_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "http_ip": {
+ "name": "http_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_http_ip": {
+ "name": "UQ_http_ip",
+ "columns": [
+ {
+ "expression": "http_ip",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.http_user_agent": {
+ "name": "http_user_agent",
+ "schema": "",
+ "columns": {
+ "http_user_agent_id": {
+ "name": "http_user_agent_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_http_user_agent": {
+ "name": "UQ_http_user_agent",
+ "columns": [
+ {
+ "expression": "http_user_agent",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_participants": {
+ "name": "impact_advocate_participants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "advocate_id": {
+ "name": "advocate_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "advocate_account_id": {
+ "name": "advocate_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_referral_identifier": {
+ "name": "opaque_referral_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contact_email": {
+ "name": "contact_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_state": {
+ "name": "registration_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "registered_at": {
+ "name": "registered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_registration_attempt_at": {
+ "name": "last_registration_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_code": {
+ "name": "last_error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_message": {
+ "name": "last_error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_impact_advocate_participants_program_referral_identifier": {
+ "name": "UQ_impact_advocate_participants_program_referral_identifier",
+ "columns": [
+ {
+ "expression": "program_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "opaque_referral_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"impact_advocate_participants\".\"opaque_referral_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_participants_registration_state": {
+ "name": "IDX_impact_advocate_participants_registration_state",
+ "columns": [
+ {
+ "expression": "registration_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_participants_user_id_kilocode_users_id_fk": {
+ "name": "impact_advocate_participants_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_advocate_participants",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_participants_program_user": {
+ "name": "UQ_impact_advocate_participants_program_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "program_key",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_participants_program_key_check": {
+ "name": "impact_advocate_participants_program_key_check",
+ "value": "\"impact_advocate_participants\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_advocate_participants_registration_state_check": {
+ "name": "impact_advocate_participants_registration_state_check",
+ "value": "\"impact_advocate_participants\".\"registration_state\" IN ('pending', 'retrying', 'registered', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_registration_attempts": {
+ "name": "impact_advocate_registration_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "participant_id": {
+ "name": "participant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_cookie_value": {
+ "name": "opaque_cookie_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cookie_value_length": {
+ "name": "cookie_value_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delivery_state": {
+ "name": "delivery_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_payload": {
+ "name": "response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_advocate_registration_attempts_participant_id": {
+ "name": "IDX_impact_advocate_registration_attempts_participant_id",
+ "columns": [
+ {
+ "expression": "participant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_registration_attempts_delivery_state": {
+ "name": "IDX_impact_advocate_registration_attempts_delivery_state",
+ "columns": [
+ {
+ "expression": "delivery_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk": {
+ "name": "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk",
+ "tableFrom": "impact_advocate_registration_attempts",
+ "tableTo": "impact_advocate_participants",
+ "columnsFrom": [
+ "participant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_registration_attempts_dedupe_key": {
+ "name": "UQ_impact_advocate_registration_attempts_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_registration_attempts_program_key_check": {
+ "name": "impact_advocate_registration_attempts_program_key_check",
+ "value": "\"impact_advocate_registration_attempts\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_advocate_registration_attempts_delivery_state_check": {
+ "name": "impact_advocate_registration_attempts_delivery_state_check",
+ "value": "\"impact_advocate_registration_attempts\".\"delivery_state\" IN ('queued', 'sending', 'succeeded', 'failed')"
+ },
+ "impact_advocate_registration_attempts_cookie_value_length_non_negative_check": {
+ "name": "impact_advocate_registration_attempts_cookie_value_length_non_negative_check",
+ "value": "\"impact_advocate_registration_attempts\".\"cookie_value_length\" >= 0"
+ },
+ "impact_advocate_registration_attempts_attempt_count_non_negative_check": {
+ "name": "impact_advocate_registration_attempts_attempt_count_non_negative_check",
+ "value": "\"impact_advocate_registration_attempts\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_reward_redemptions": {
+ "name": "impact_advocate_reward_redemptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "reward_id": {
+ "name": "reward_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "impact_reward_id": {
+ "name": "impact_reward_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lookup_response_payload": {
+ "name": "lookup_response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redeem_response_payload": {
+ "name": "redeem_response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redeemed_at": {
+ "name": "redeemed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_advocate_reward_redemptions_beneficiary_user_id": {
+ "name": "IDX_impact_advocate_reward_redemptions_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_reward_redemptions_state": {
+ "name": "IDX_impact_advocate_reward_redemptions_state",
+ "columns": [
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk": {
+ "name": "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk",
+ "tableFrom": "impact_advocate_reward_redemptions",
+ "tableTo": "impact_referral_rewards",
+ "columnsFrom": [
+ "reward_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_advocate_reward_redemptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_reward_redemptions_reward_id": {
+ "name": "UQ_impact_advocate_reward_redemptions_reward_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "reward_id"
+ ]
+ },
+ "UQ_impact_advocate_reward_redemptions_dedupe_key": {
+ "name": "UQ_impact_advocate_reward_redemptions_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_reward_redemptions_state_check": {
+ "name": "impact_advocate_reward_redemptions_state_check",
+ "value": "\"impact_advocate_reward_redemptions\".\"state\" IN ('queued', 'retrying', 'redeemed', 'failed')"
+ },
+ "impact_advocate_reward_redemptions_attempt_count_non_negative_check": {
+ "name": "impact_advocate_reward_redemptions_attempt_count_non_negative_check",
+ "value": "\"impact_advocate_reward_redemptions\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_attribution_touches": {
+ "name": "impact_attribution_touches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'kiloclaw'"
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "anonymous_id": {
+ "name": "anonymous_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touch_type": {
+ "name": "touch_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_tracking_value": {
+ "name": "opaque_tracking_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tracking_value_length": {
+ "name": "tracking_value_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_tracking_value_accepted": {
+ "name": "is_tracking_value_accepted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "rs_code": {
+ "name": "rs_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rs_share_medium": {
+ "name": "rs_share_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rs_engagement_medium": {
+ "name": "rs_engagement_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "im_ref": {
+ "name": "im_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landing_path": {
+ "name": "landing_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_source": {
+ "name": "utm_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_medium": {
+ "name": "utm_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_campaign": {
+ "name": "utm_campaign",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_term": {
+ "name": "utm_term",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_content": {
+ "name": "utm_content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touched_at": {
+ "name": "touched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sale_attributed_at": {
+ "name": "sale_attributed_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": {
+ "IDX_impact_attribution_touches_product_user_id": {
+ "name": "IDX_impact_attribution_touches_product_user_id",
+ "columns": [
+ {
+ "expression": "product",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_user_id": {
+ "name": "IDX_impact_attribution_touches_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_anonymous_id": {
+ "name": "IDX_impact_attribution_touches_anonymous_id",
+ "columns": [
+ {
+ "expression": "anonymous_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_expires_at": {
+ "name": "IDX_impact_attribution_touches_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_sale_attributed_at": {
+ "name": "IDX_impact_attribution_touches_sale_attributed_at",
+ "columns": [
+ {
+ "expression": "sale_attributed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_attribution_touches_user_id_kilocode_users_id_fk": {
+ "name": "impact_attribution_touches_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_attribution_touches",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_attribution_touches_dedupe_key": {
+ "name": "UQ_impact_attribution_touches_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_attribution_touches_product_check": {
+ "name": "impact_attribution_touches_product_check",
+ "value": "\"impact_attribution_touches\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_attribution_touches_program_key_check": {
+ "name": "impact_attribution_touches_program_key_check",
+ "value": "\"impact_attribution_touches\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_attribution_touches_touch_type_check": {
+ "name": "impact_attribution_touches_touch_type_check",
+ "value": "\"impact_attribution_touches\".\"touch_type\" IN ('affiliate', 'referral')"
+ },
+ "impact_attribution_touches_provider_check": {
+ "name": "impact_attribution_touches_provider_check",
+ "value": "\"impact_attribution_touches\".\"provider\" IN ('impact_performance', 'impact_advocate')"
+ },
+ "impact_attribution_touches_tracking_value_length_non_negative_check": {
+ "name": "impact_attribution_touches_tracking_value_length_non_negative_check",
+ "value": "\"impact_attribution_touches\".\"tracking_value_length\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_conversion_reports": {
+ "name": "impact_conversion_reports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_tracker_id": {
+ "name": "action_tracker_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "order_id": {
+ "name": "order_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_payload": {
+ "name": "response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delivered_at": {
+ "name": "delivered_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_conversion_reports_conversion_id": {
+ "name": "IDX_impact_conversion_reports_conversion_id",
+ "columns": [
+ {
+ "expression": "conversion_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_conversion_reports_state": {
+ "name": "IDX_impact_conversion_reports_state",
+ "columns": [
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_conversion_reports",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_conversion_reports_dedupe_key": {
+ "name": "UQ_impact_conversion_reports_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_conversion_reports_state_check": {
+ "name": "impact_conversion_reports_state_check",
+ "value": "\"impact_conversion_reports\".\"state\" IN ('queued', 'retrying', 'delivered', 'failed')"
+ },
+ "impact_conversion_reports_attempt_count_non_negative_check": {
+ "name": "impact_conversion_reports_attempt_count_non_negative_check",
+ "value": "\"impact_conversion_reports\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_conversions": {
+ "name": "impact_referral_conversions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "referee_user_id": {
+ "name": "referee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer_user_id": {
+ "name": "referrer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_touch_id": {
+ "name": "source_touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "winning_touch_type": {
+ "name": "winning_touch_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'credits'"
+ },
+ "source_payment_id": {
+ "name": "source_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "qualified": {
+ "name": "qualified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "disqualification_reason": {
+ "name": "disqualification_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "converted_at": {
+ "name": "converted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_conversions_referee_user_id": {
+ "name": "IDX_impact_referral_conversions_referee_user_id",
+ "columns": [
+ {
+ "expression": "referee_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_conversions_referrer_user_id": {
+ "name": "IDX_impact_referral_conversions_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_conversions_referee_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_conversions_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk": {
+ "name": "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "impact_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_conversions_product_payment_source": {
+ "name": "UQ_impact_referral_conversions_product_payment_source",
+ "nullsNotDistinct": false,
+ "columns": [
+ "product",
+ "payment_provider",
+ "source_payment_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_conversions_product_check": {
+ "name": "impact_referral_conversions_product_check",
+ "value": "\"impact_referral_conversions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_conversions_winning_touch_type_check": {
+ "name": "impact_referral_conversions_winning_touch_type_check",
+ "value": "\"impact_referral_conversions\".\"winning_touch_type\" IN ('referral', 'affiliate', 'none')"
+ },
+ "impact_referral_conversions_payment_provider_check": {
+ "name": "impact_referral_conversions_payment_provider_check",
+ "value": "\"impact_referral_conversions\".\"payment_provider\" IN ('stripe', 'credits', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_reward_applications": {
+ "name": "impact_referral_reward_applications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "reward_id": {
+ "name": "reward_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_renewal_boundary": {
+ "name": "previous_renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "new_renewal_boundary": {
+ "name": "new_renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_operation_id": {
+ "name": "local_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_operation_id": {
+ "name": "stripe_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_idempotency_key": {
+ "name": "stripe_idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_reward_applications_reward_id": {
+ "name": "IDX_impact_referral_reward_applications_reward_id",
+ "columns": [
+ {
+ "expression": "reward_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_reward_applications_beneficiary_user_id": {
+ "name": "IDX_impact_referral_reward_applications_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk": {
+ "name": "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk",
+ "tableFrom": "impact_referral_reward_applications",
+ "tableTo": "impact_referral_rewards",
+ "columnsFrom": [
+ "reward_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_reward_applications",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_reward_applications_product_check": {
+ "name": "impact_referral_reward_applications_product_check",
+ "value": "\"impact_referral_reward_applications\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_reward_decisions": {
+ "name": "impact_referral_reward_decisions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_role": {
+ "name": "beneficiary_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_kind": {
+ "name": "reward_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw_free_month'"
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "reward_percent": {
+ "name": "reward_percent",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_tier": {
+ "name": "source_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_amount_usd": {
+ "name": "reward_amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_reward_decisions_beneficiary_user_id": {
+ "name": "IDX_impact_referral_reward_decisions_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_referral_reward_decisions",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_reward_decisions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_reward_decisions_conversion_role": {
+ "name": "UQ_impact_referral_reward_decisions_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_reward_decisions_product_check": {
+ "name": "impact_referral_reward_decisions_product_check",
+ "value": "\"impact_referral_reward_decisions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_reward_decisions_beneficiary_role_check": {
+ "name": "impact_referral_reward_decisions_beneficiary_role_check",
+ "value": "\"impact_referral_reward_decisions\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "impact_referral_reward_decisions_outcome_check": {
+ "name": "impact_referral_reward_decisions_outcome_check",
+ "value": "\"impact_referral_reward_decisions\".\"outcome\" IN ('granted', 'cap_limited', 'disqualified')"
+ },
+ "impact_referral_reward_decisions_reward_kind_check": {
+ "name": "impact_referral_reward_decisions_reward_kind_check",
+ "value": "\"impact_referral_reward_decisions\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
+ },
+ "impact_referral_reward_decisions_months_granted_non_negative_check": {
+ "name": "impact_referral_reward_decisions_months_granted_non_negative_check",
+ "value": "\"impact_referral_reward_decisions\".\"months_granted\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_rewards": {
+ "name": "impact_referral_rewards",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "decision_id": {
+ "name": "decision_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_role": {
+ "name": "beneficiary_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reward_kind": {
+ "name": "reward_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw_free_month'"
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "reward_percent": {
+ "name": "reward_percent",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_tier": {
+ "name": "source_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_amount_usd": {
+ "name": "reward_amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "applies_to_subscription_id": {
+ "name": "applies_to_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applies_to_kilo_pass_subscription_id": {
+ "name": "applies_to_kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consumed_kilo_pass_issuance_id": {
+ "name": "consumed_kilo_pass_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consumed_kilo_pass_issuance_item_id": {
+ "name": "consumed_kilo_pass_issuance_item_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "earned_at": {
+ "name": "earned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reversed_at": {
+ "name": "reversed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_reason": {
+ "name": "review_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_rewards_beneficiary_user_id": {
+ "name": "IDX_impact_referral_rewards_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_rewards_status": {
+ "name": "IDX_impact_referral_rewards_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk": {
+ "name": "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "impact_referral_reward_decisions",
+ "columnsFrom": [
+ "decision_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_subscription": {
+ "name": "FK_impact_referral_rewards_kilo_pass_subscription",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "applies_to_kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_issuance": {
+ "name": "FK_impact_referral_rewards_kilo_pass_issuance",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "consumed_kilo_pass_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_issuance_item": {
+ "name": "FK_impact_referral_rewards_kilo_pass_issuance_item",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_issuance_items",
+ "columnsFrom": [
+ "consumed_kilo_pass_issuance_item_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_rewards_conversion_role": {
+ "name": "UQ_impact_referral_rewards_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ },
+ "UQ_impact_referral_rewards_decision_id": {
+ "name": "UQ_impact_referral_rewards_decision_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "decision_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_rewards_product_check": {
+ "name": "impact_referral_rewards_product_check",
+ "value": "\"impact_referral_rewards\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_rewards_beneficiary_role_check": {
+ "name": "impact_referral_rewards_beneficiary_role_check",
+ "value": "\"impact_referral_rewards\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "impact_referral_rewards_reward_kind_check": {
+ "name": "impact_referral_rewards_reward_kind_check",
+ "value": "\"impact_referral_rewards\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
+ },
+ "impact_referral_rewards_status_check": {
+ "name": "impact_referral_rewards_status_check",
+ "value": "\"impact_referral_rewards\".\"status\" IN ('pending', 'earned', 'applied', 'reversed', 'expired', 'canceled', 'review_required')"
+ },
+ "impact_referral_rewards_months_granted_non_negative_check": {
+ "name": "impact_referral_rewards_months_granted_non_negative_check",
+ "value": "\"impact_referral_rewards\".\"months_granted\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referrals": {
+ "name": "impact_referrals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "referee_user_id": {
+ "name": "referee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer_user_id": {
+ "name": "referrer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_touch_id": {
+ "name": "source_touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_referral_id": {
+ "name": "impact_referral_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referrals_referrer_user_id": {
+ "name": "IDX_impact_referrals_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referrals_source_touch_id": {
+ "name": "IDX_impact_referrals_source_touch_id",
+ "columns": [
+ {
+ "expression": "source_touch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referrals_referee_user_id_kilocode_users_id_fk": {
+ "name": "impact_referrals_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referrals_referrer_user_id_kilocode_users_id_fk": {
+ "name": "impact_referrals_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "impact_referrals_source_touch_id_impact_attribution_touches_id_fk": {
+ "name": "impact_referrals_source_touch_id_impact_attribution_touches_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "impact_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referrals_product_referee_user_id": {
+ "name": "UQ_impact_referrals_product_referee_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "product",
+ "referee_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referrals_product_check": {
+ "name": "impact_referrals_product_check",
+ "value": "\"impact_referrals\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.ja4_digest": {
+ "name": "ja4_digest",
+ "schema": "",
+ "columns": {
+ "ja4_digest_id": {
+ "name": "ja4_digest_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ja4_digest": {
+ "name": "ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_ja4_digest": {
+ "name": "UQ_ja4_digest",
+ "columns": [
+ {
+ "expression": "ja4_digest",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_audit_log": {
+ "name": "kilo_pass_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_invoice_id": {
+ "name": "stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_credit_transaction_id": {
+ "name": "related_credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_monthly_issuance_id": {
+ "name": "related_monthly_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_audit_log_created_at": {
+ "name": "IDX_kilo_pass_audit_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_kilo_user_id": {
+ "name": "IDX_kilo_pass_audit_log_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_kilo_pass_subscription_id": {
+ "name": "IDX_kilo_pass_audit_log_kilo_pass_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_action": {
+ "name": "IDX_kilo_pass_audit_log_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_result": {
+ "name": "IDX_kilo_pass_audit_log_result",
+ "columns": [
+ {
+ "expression": "result",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_idempotency_key": {
+ "name": "IDX_kilo_pass_audit_log_idempotency_key",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_event_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_invoice_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_invoice_id",
+ "columns": [
+ {
+ "expression": "stripe_invoice_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_subscription_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_related_credit_transaction_id": {
+ "name": "IDX_kilo_pass_audit_log_related_credit_transaction_id",
+ "columns": [
+ {
+ "expression": "related_credit_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_related_monthly_issuance_id": {
+ "name": "IDX_kilo_pass_audit_log_related_monthly_issuance_id",
+ "columns": [
+ {
+ "expression": "related_monthly_issuance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "related_credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk": {
+ "name": "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "related_monthly_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_audit_log_action_check": {
+ "name": "kilo_pass_audit_log_action_check",
+ "value": "\"kilo_pass_audit_log\".\"action\" IN ('stripe_webhook_received', 'kilo_pass_invoice_paid_handled', 'store_purchase_completed', 'store_notification_received', 'store_subscription_renewed', 'store_subscription_canceled', 'store_subscription_expired', 'store_subscription_refunded', 'base_credits_issued', 'bonus_credits_issued', 'bonus_credits_skipped_idempotent', 'first_month_50pct_promo_issued', 'yearly_monthly_base_cron_started', 'yearly_monthly_base_cron_completed', 'issue_yearly_remaining_credits', 'duplicate_card_subscription_canceled', 'yearly_monthly_bonus_cron_started', 'yearly_monthly_bonus_cron_completed')"
+ },
+ "kilo_pass_audit_log_result_check": {
+ "name": "kilo_pass_audit_log_result_check",
+ "value": "\"kilo_pass_audit_log\".\"result\" IN ('success', 'skipped_idempotent', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_issuance_items": {
+ "name": "kilo_pass_issuance_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_issuance_id": {
+ "name": "kilo_pass_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_transaction_id": {
+ "name": "credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bonus_percent_applied": {
+ "name": "bonus_percent_applied",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_issuance_items_issuance_id": {
+ "name": "IDX_kilo_pass_issuance_items_issuance_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_issuance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuance_items_credit_transaction_id": {
+ "name": "IDX_kilo_pass_issuance_items_credit_transaction_id",
+ "columns": [
+ {
+ "expression": "credit_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk": {
+ "name": "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk",
+ "tableFrom": "kilo_pass_issuance_items",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "kilo_pass_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "kilo_pass_issuance_items",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilo_pass_issuance_items_credit_transaction_id_unique": {
+ "name": "kilo_pass_issuance_items_credit_transaction_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "credit_transaction_id"
+ ]
+ },
+ "UQ_kilo_pass_issuance_items_issuance_kind": {
+ "name": "UQ_kilo_pass_issuance_items_issuance_kind",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_pass_issuance_id",
+ "kind"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_issuance_items_bonus_percent_applied_range_check": {
+ "name": "kilo_pass_issuance_items_bonus_percent_applied_range_check",
+ "value": "\"kilo_pass_issuance_items\".\"bonus_percent_applied\" IS NULL OR (\"kilo_pass_issuance_items\".\"bonus_percent_applied\" >= 0 AND \"kilo_pass_issuance_items\".\"bonus_percent_applied\" <= 1)"
+ },
+ "kilo_pass_issuance_items_amount_usd_non_negative_check": {
+ "name": "kilo_pass_issuance_items_amount_usd_non_negative_check",
+ "value": "\"kilo_pass_issuance_items\".\"amount_usd\" >= 0"
+ },
+ "kilo_pass_issuance_items_kind_check": {
+ "name": "kilo_pass_issuance_items_kind_check",
+ "value": "\"kilo_pass_issuance_items\".\"kind\" IN ('base', 'bonus', 'promo_first_month_50pct', 'referral_bonus')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_issuances": {
+ "name": "kilo_pass_issuances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_month": {
+ "name": "issue_month",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_invoice_id": {
+ "name": "stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initial_welcome_promo_eligibility_reason": {
+ "name": "initial_welcome_promo_eligibility_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kilo_pass_issuances_stripe_invoice_id": {
+ "name": "UQ_kilo_pass_issuances_stripe_invoice_id",
+ "columns": [
+ {
+ "expression": "stripe_invoice_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_issuances\".\"stripe_invoice_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuances_subscription_id": {
+ "name": "IDX_kilo_pass_issuances_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuances_issue_month": {
+ "name": "IDX_kilo_pass_issuances_issue_month",
+ "columns": [
+ {
+ "expression": "issue_month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_issuances",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kilo_pass_issuances_subscription_issue_month": {
+ "name": "UQ_kilo_pass_issuances_subscription_issue_month",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_pass_subscription_id",
+ "issue_month"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_issuances_issue_month_day_one_check": {
+ "name": "kilo_pass_issuances_issue_month_day_one_check",
+ "value": "EXTRACT(DAY FROM \"kilo_pass_issuances\".\"issue_month\") = 1"
+ },
+ "kilo_pass_issuances_source_check": {
+ "name": "kilo_pass_issuances_source_check",
+ "value": "\"kilo_pass_issuances\".\"source\" IN ('stripe_invoice', 'app_store_transaction', 'google_play_transaction', 'cron')"
+ },
+ "kilo_pass_issuances_initial_welcome_promo_reason_check": {
+ "name": "kilo_pass_issuances_initial_welcome_promo_reason_check",
+ "value": "\"kilo_pass_issuances\".\"initial_welcome_promo_eligibility_reason\" IN ('first_payment_fingerprint_claim', 'fingerprint_previously_claimed', 'missing_fingerprint', 'no_supported_fingerprint', 'no_positive_settlement', 'settlement_unresolved')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_pause_events": {
+ "name": "kilo_pass_pause_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "paused_at": {
+ "name": "paused_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resumes_at": {
+ "name": "resumes_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resumed_at": {
+ "name": "resumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_pause_events_subscription_id": {
+ "name": "IDX_kilo_pass_pause_events_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_pause_events_one_open_per_sub": {
+ "name": "UQ_kilo_pass_pause_events_one_open_per_sub",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_pause_events",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_pause_events_resumed_at_after_paused_at_check": {
+ "name": "kilo_pass_pause_events_resumed_at_after_paused_at_check",
+ "value": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL OR \"kilo_pass_pause_events\".\"resumed_at\" >= \"kilo_pass_pause_events\".\"paused_at\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_scheduled_changes": {
+ "name": "kilo_pass_scheduled_changes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_tier": {
+ "name": "from_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_cadence": {
+ "name": "from_cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_tier": {
+ "name": "to_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_cadence": {
+ "name": "to_cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_schedule_id": {
+ "name": "stripe_schedule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_at": {
+ "name": "effective_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_scheduled_changes_kilo_user_id": {
+ "name": "IDX_kilo_pass_scheduled_changes_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_status": {
+ "name": "IDX_kilo_pass_scheduled_changes_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_stripe_subscription_id": {
+ "name": "IDX_kilo_pass_scheduled_changes_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id": {
+ "name": "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_scheduled_changes\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_effective_at": {
+ "name": "IDX_kilo_pass_scheduled_changes_effective_at",
+ "columns": [
+ {
+ "expression": "effective_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_deleted_at": {
+ "name": "IDX_kilo_pass_scheduled_changes_deleted_at",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_scheduled_changes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk": {
+ "name": "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk",
+ "tableFrom": "kilo_pass_scheduled_changes",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "stripe_subscription_id"
+ ],
+ "columnsTo": [
+ "stripe_subscription_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_scheduled_changes_from_tier_check": {
+ "name": "kilo_pass_scheduled_changes_from_tier_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"from_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_scheduled_changes_from_cadence_check": {
+ "name": "kilo_pass_scheduled_changes_from_cadence_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"from_cadence\" IN ('monthly', 'yearly')"
+ },
+ "kilo_pass_scheduled_changes_to_tier_check": {
+ "name": "kilo_pass_scheduled_changes_to_tier_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"to_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_scheduled_changes_to_cadence_check": {
+ "name": "kilo_pass_scheduled_changes_to_cadence_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"to_cadence\" IN ('monthly', 'yearly')"
+ },
+ "kilo_pass_scheduled_changes_status_check": {
+ "name": "kilo_pass_scheduled_changes_status_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"status\" IN ('not_started', 'active', 'completed', 'released', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_store_events": {
+ "name": "kilo_pass_store_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_transaction_id": {
+ "name": "provider_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_account_token": {
+ "name": "app_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment": {
+ "name": "environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "processing_started_at": {
+ "name": "processing_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processed_at": {
+ "name": "processed_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": {
+ "UQ_kilo_pass_store_events_provider_event": {
+ "name": "UQ_kilo_pass_store_events_provider_event",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_events_provider_subscription": {
+ "name": "IDX_kilo_pass_store_events_provider_subscription",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_events_app_account_token": {
+ "name": "IDX_kilo_pass_store_events_app_account_token",
+ "columns": [
+ {
+ "expression": "app_account_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_store_events_payment_provider_check": {
+ "name": "kilo_pass_store_events_payment_provider_check",
+ "value": "\"kilo_pass_store_events\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_store_purchases": {
+ "name": "kilo_pass_store_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_transaction_id": {
+ "name": "provider_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_original_transaction_id": {
+ "name": "provider_original_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_account_token": {
+ "name": "app_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "purchase_token": {
+ "name": "purchase_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environment": {
+ "name": "environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purchased_at": {
+ "name": "purchased_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_payload_json": {
+ "name": "raw_payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kilo_pass_store_purchases_provider_transaction": {
+ "name": "UQ_kilo_pass_store_purchases_provider_transaction",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_subscription_id": {
+ "name": "IDX_kilo_pass_store_purchases_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_user_id": {
+ "name": "IDX_kilo_pass_store_purchases_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_app_account_token": {
+ "name": "IDX_kilo_pass_store_purchases_app_account_token",
+ "columns": [
+ {
+ "expression": "app_account_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_latest_subscription_purchase": {
+ "name": "IDX_kilo_pass_store_purchases_latest_subscription_purchase",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "purchased_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "FK_kilo_pass_store_purchases_subscription_owner_provider": {
+ "name": "FK_kilo_pass_store_purchases_subscription_owner_provider",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id",
+ "kilo_user_id",
+ "payment_provider",
+ "provider_subscription_id"
+ ],
+ "columnsTo": [
+ "id",
+ "kilo_user_id",
+ "payment_provider",
+ "provider_subscription_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_store_purchases_store_provider_check": {
+ "name": "kilo_pass_store_purchases_store_provider_check",
+ "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('app_store', 'google_play')"
+ },
+ "kilo_pass_store_purchases_payment_provider_check": {
+ "name": "kilo_pass_store_purchases_payment_provider_check",
+ "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_subscriptions": {
+ "name": "kilo_pass_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'stripe'"
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tier": {
+ "name": "tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cadence": {
+ "name": "cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_streak_months": {
+ "name": "current_streak_months",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_yearly_issue_at": {
+ "name": "next_yearly_issue_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_subscriptions_kilo_user_id": {
+ "name": "IDX_kilo_pass_subscriptions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_payment_provider": {
+ "name": "IDX_kilo_pass_subscriptions_payment_provider",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_status": {
+ "name": "IDX_kilo_pass_subscriptions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_cadence": {
+ "name": "IDX_kilo_pass_subscriptions_cadence",
+ "columns": [
+ {
+ "expression": "cadence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_subscriptions_provider_subscription": {
+ "name": "UQ_kilo_pass_subscriptions_provider_subscription",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_subscriptions_store_purchase_reference": {
+ "name": "UQ_kilo_pass_subscriptions_store_purchase_reference",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilo_pass_subscriptions_stripe_subscription_id_unique": {
+ "name": "kilo_pass_subscriptions_stripe_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_subscriptions_current_streak_months_non_negative_check": {
+ "name": "kilo_pass_subscriptions_current_streak_months_non_negative_check",
+ "value": "\"kilo_pass_subscriptions\".\"current_streak_months\" >= 0"
+ },
+ "kilo_pass_subscriptions_provider_ids_check": {
+ "name": "kilo_pass_subscriptions_provider_ids_check",
+ "value": "(\n \"kilo_pass_subscriptions\".\"payment_provider\" = 'stripe'\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" = \"kilo_pass_subscriptions\".\"stripe_subscription_id\"\n ) OR (\n \"kilo_pass_subscriptions\".\"payment_provider\" IN ('app_store', 'google_play')\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NULL\n )"
+ },
+ "kilo_pass_subscriptions_payment_provider_check": {
+ "name": "kilo_pass_subscriptions_payment_provider_check",
+ "value": "\"kilo_pass_subscriptions\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ },
+ "kilo_pass_subscriptions_tier_check": {
+ "name": "kilo_pass_subscriptions_tier_check",
+ "value": "\"kilo_pass_subscriptions\".\"tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_subscriptions_cadence_check": {
+ "name": "kilo_pass_subscriptions_cadence_check",
+ "value": "\"kilo_pass_subscriptions\".\"cadence\" IN ('monthly', 'yearly')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_welcome_promo_payment_fingerprint_claims": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims",
+ "schema": "",
+ "columns": {
+ "stripe_payment_method_type": {
+ "name": "stripe_payment_method_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_fingerprint": {
+ "name": "stripe_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_stripe_invoice_id": {
+ "name": "source_stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk",
+ "columns": [
+ "stripe_payment_method_type",
+ "stripe_fingerprint"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id": {
+ "name": "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_stripe_invoice_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check",
+ "value": "\"kilo_pass_welcome_promo_payment_fingerprint_claims\".\"stripe_payment_method_type\" IN ('card', 'sepa_debit', 'us_bank_account', 'bacs_debit', 'au_becs_debit')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_access_codes": {
+ "name": "kiloclaw_access_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redeemed_at": {
+ "name": "redeemed_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": {
+ "UQ_kiloclaw_access_codes_code": {
+ "name": "UQ_kiloclaw_access_codes_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_access_codes_user_status": {
+ "name": "IDX_kiloclaw_access_codes_user_status",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_access_codes_one_active_per_user": {
+ "name": "UQ_kiloclaw_access_codes_one_active_per_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "status = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_access_codes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_admin_audit_logs": {
+ "name": "kiloclaw_admin_audit_logs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_admin_audit_logs_target_user_id": {
+ "name": "IDX_kiloclaw_admin_audit_logs_target_user_id",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_admin_audit_logs_action": {
+ "name": "IDX_kiloclaw_admin_audit_logs_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_admin_audit_logs_created_at": {
+ "name": "IDX_kiloclaw_admin_audit_logs_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_cli_runs": {
+ "name": "kiloclaw_cli_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiated_by_admin_id": {
+ "name": "initiated_by_admin_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "exit_code": {
+ "name": "exit_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_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": {
+ "IDX_kiloclaw_cli_runs_user_id": {
+ "name": "IDX_kiloclaw_cli_runs_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_cli_runs_started_at": {
+ "name": "IDX_kiloclaw_cli_runs_started_at",
+ "columns": [
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_cli_runs_instance_id": {
+ "name": "IDX_kiloclaw_cli_runs_instance_id",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_cli_runs_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_cli_runs_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "initiated_by_admin_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_earlybird_purchases": {
+ "name": "kiloclaw_earlybird_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manual_payment_id": {
+ "name": "manual_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_cents": {
+ "name": "amount_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_earlybird_purchases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_earlybird_purchases_user_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "kiloclaw_earlybird_purchases_stripe_charge_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_stripe_charge_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_charge_id"
+ ]
+ },
+ "kiloclaw_earlybird_purchases_manual_payment_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_manual_payment_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "manual_payment_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_email_log": {
+ "name": "kiloclaw_email_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_type": {
+ "name": "email_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_start": {
+ "name": "period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'epoch'"
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_email_log_user_type_global": {
+ "name": "UQ_kiloclaw_email_log_user_type_global",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_email_log_user_instance_type_period": {
+ "name": "UQ_kiloclaw_email_log_user_instance_type_period",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_start",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_email_log_type_sent_instance": {
+ "name": "IDX_kiloclaw_email_log_type_sent_instance",
+ "columns": [
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sent_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_email_log_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_email_log_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_email_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_email_log",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_google_oauth_connections": {
+ "name": "kiloclaw_google_oauth_connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'google'"
+ },
+ "account_email": {
+ "name": "account_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_subject": {
+ "name": "account_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_secret_encrypted": {
+ "name": "oauth_client_secret_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_profile": {
+ "name": "credential_profile",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kilo_owned'"
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "grants_by_source": {
+ "name": "grants_by_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "capabilities": {
+ "name": "capabilities",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_at": {
+ "name": "last_error_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_at": {
+ "name": "connected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_google_oauth_connections_instance": {
+ "name": "UQ_kiloclaw_google_oauth_connections_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_google_oauth_connections_status": {
+ "name": "IDX_kiloclaw_google_oauth_connections_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_google_oauth_connections_provider": {
+ "name": "IDX_kiloclaw_google_oauth_connections_provider",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_google_oauth_connections",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_google_oauth_connections_status_check": {
+ "name": "kiloclaw_google_oauth_connections_status_check",
+ "value": "\"kiloclaw_google_oauth_connections\".\"status\" IN ('active', 'action_required', 'disconnected')"
+ },
+ "kiloclaw_google_oauth_connections_credential_profile_check": {
+ "name": "kiloclaw_google_oauth_connections_credential_profile_check",
+ "value": "\"kiloclaw_google_oauth_connections\".\"credential_profile\" IN ('legacy', 'kilo_owned')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_image_catalog": {
+ "name": "kiloclaw_image_catalog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "openclaw_version": {
+ "name": "openclaw_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "variant": {
+ "name": "variant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "image_tag": {
+ "name": "image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image_digest": {
+ "name": "image_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'available'"
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "rollout_percent": {
+ "name": "rollout_percent",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "is_latest": {
+ "name": "is_latest",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_image_catalog_status": {
+ "name": "IDX_kiloclaw_image_catalog_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_image_catalog_variant": {
+ "name": "IDX_kiloclaw_image_catalog_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_image_catalog_one_latest_per_variant": {
+ "name": "UQ_kiloclaw_image_catalog_one_latest_per_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_image_catalog\".\"is_latest\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_image_catalog_one_candidate_per_variant": {
+ "name": "UQ_kiloclaw_image_catalog_one_candidate_per_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_image_catalog\".\"is_latest\" = false AND \"kiloclaw_image_catalog\".\"rollout_percent\" > 0 AND \"kiloclaw_image_catalog\".\"status\" = 'available'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_image_catalog_image_tag_unique": {
+ "name": "kiloclaw_image_catalog_image_tag_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "image_tag"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_inbound_email_aliases": {
+ "name": "kiloclaw_inbound_email_aliases",
+ "schema": "",
+ "columns": {
+ "alias": {
+ "name": "alias",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "retired_at": {
+ "name": "retired_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_inbound_email_aliases_instance_id": {
+ "name": "IDX_kiloclaw_inbound_email_aliases_instance_id",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_inbound_email_aliases_active_instance": {
+ "name": "UQ_kiloclaw_inbound_email_aliases_active_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_inbound_email_aliases\".\"retired_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_inbound_email_aliases",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_inbound_email_reserved_aliases": {
+ "name": "kiloclaw_inbound_email_reserved_aliases",
+ "schema": "",
+ "columns": {
+ "alias": {
+ "name": "alias",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_instances": {
+ "name": "kiloclaw_instances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'fly'"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inbound_email_enabled": {
+ "name": "inbound_email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "inactive_trial_stopped_at": {
+ "name": "inactive_trial_stopped_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()"
+ },
+ "destroyed_at": {
+ "name": "destroyed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tracked_image_tag": {
+ "name": "tracked_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_type": {
+ "name": "instance_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "admin_size_override": {
+ "name": "admin_size_override",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_instances_active": {
+ "name": "UQ_kiloclaw_instances_active",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sandbox_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_personal_by_user": {
+ "name": "IDX_kiloclaw_instances_active_personal_by_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_org_by_user_org": {
+ "name": "IDX_kiloclaw_instances_active_org_by_user_org",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_org_by_org_created": {
+ "name": "IDX_kiloclaw_instances_active_org_by_org_created",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_user_id_created_at": {
+ "name": "IDX_kiloclaw_instances_user_id_created_at",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_tracked_image_tag": {
+ "name": "IDX_kiloclaw_instances_tracked_image_tag",
+ "columns": [
+ {
+ "expression": "tracked_image_tag",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_instance_type": {
+ "name": "IDX_kiloclaw_instances_instance_type",
+ "columns": [
+ {
+ "expression": "instance_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_admin_size_override": {
+ "name": "IDX_kiloclaw_instances_admin_size_override",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"admin_size_override\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_instances_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_instances_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_instances",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_instances_organization_id_organizations_id_fk": {
+ "name": "kiloclaw_instances_organization_id_organizations_id_fk",
+ "tableFrom": "kiloclaw_instances",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_kiloclaw_instances_instance_type": {
+ "name": "CHK_kiloclaw_instances_instance_type",
+ "value": "\"kiloclaw_instances\".\"instance_type\" IS NULL OR \"kiloclaw_instances\".\"instance_type\" IN ('perf-1-3', 'perf-4-8', 'perf-4-16', 'shared-2-3', 'shared-2-4', 'custom')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_morning_briefing_configs": {
+ "name": "kiloclaw_morning_briefing_configs",
+ "schema": "",
+ "columns": {
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0 7 * * *'"
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "interest_topics": {
+ "name": "interest_topics",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_morning_briefing_configs_enabled": {
+ "name": "IDX_kiloclaw_morning_briefing_configs_enabled",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_morning_briefing_configs\".\"enabled\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_morning_briefing_configs",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_notifications": {
+ "name": "kiloclaw_scheduled_action_notifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'notice'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel": {
+ "name": "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_notifications_pending": {
+ "name": "IDX_kiloclaw_scheduled_action_notifications_pending",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_notifications\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk": {
+ "name": "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_notifications",
+ "tableTo": "kiloclaw_scheduled_action_targets",
+ "columnsFrom": [
+ "target_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_stages": {
+ "name": "kiloclaw_scheduled_action_stages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_index": {
+ "name": "stage_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_at": {
+ "name": "scheduled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "notice_sent_at": {
+ "name": "notice_sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applied_count": {
+ "name": "applied_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "skipped_count": {
+ "name": "skipped_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "failed_count": {
+ "name": "failed_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_stages_parent_index": {
+ "name": "UQ_kiloclaw_scheduled_action_stages_parent_index",
+ "columns": [
+ {
+ "expression": "scheduled_action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stage_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_stages_notice_due": {
+ "name": "IDX_kiloclaw_scheduled_action_stages_notice_due",
+ "columns": [
+ {
+ "expression": "scheduled_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_stages\".\"notice_sent_at\" IS NULL AND \"kiloclaw_scheduled_action_stages\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
+ "name": "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_stages",
+ "tableTo": "kiloclaw_scheduled_actions",
+ "columnsFrom": [
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_targets": {
+ "name": "kiloclaw_scheduled_action_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_image_tag": {
+ "name": "source_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_image_tag": {
+ "name": "target_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "skip_reason": {
+ "name": "skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_targets_parent_instance": {
+ "name": "UQ_kiloclaw_scheduled_action_targets_parent_instance",
+ "columns": [
+ {
+ "expression": "scheduled_action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_targets_stage": {
+ "name": "IDX_kiloclaw_scheduled_action_targets_stage",
+ "columns": [
+ {
+ "expression": "stage_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_targets_pending_by_instance": {
+ "name": "IDX_kiloclaw_scheduled_action_targets_pending_by_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_targets\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_scheduled_actions",
+ "columnsFrom": [
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_scheduled_action_stages",
+ "columnsFrom": [
+ "stage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_actions": {
+ "name": "kiloclaw_scheduled_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_image_tag": {
+ "name": "target_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "override_pins": {
+ "name": "override_pins",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "notice_lead_hours": {
+ "name": "notice_lead_hours",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 24
+ },
+ "notice_subject": {
+ "name": "notice_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "notice_body": {
+ "name": "notice_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'scheduled'"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled_at": {
+ "name": "cancelled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_count": {
+ "name": "total_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "applied_count": {
+ "name": "applied_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "skipped_count": {
+ "name": "skipped_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "failed_count": {
+ "name": "failed_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_scheduled_actions_status": {
+ "name": "IDX_kiloclaw_scheduled_actions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_actions_action_type": {
+ "name": "IDX_kiloclaw_scheduled_actions_action_type",
+ "columns": [
+ {
+ "expression": "action_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_actions_created_by": {
+ "name": "IDX_kiloclaw_scheduled_actions_created_by",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk": {
+ "name": "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk",
+ "tableFrom": "kiloclaw_scheduled_actions",
+ "tableTo": "kiloclaw_image_catalog",
+ "columnsFrom": [
+ "target_image_tag"
+ ],
+ "columnsTo": [
+ "image_tag"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk": {
+ "name": "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_scheduled_actions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_subscription_change_log": {
+ "name": "kiloclaw_subscription_change_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "before_state": {
+ "name": "before_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "after_state": {
+ "name": "after_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_subscription_change_log_subscription_created_at": {
+ "name": "IDX_kiloclaw_subscription_change_log_subscription_created_at",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscription_change_log_created_at": {
+ "name": "IDX_kiloclaw_subscription_change_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_subscription_change_log",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_subscription_change_log_actor_type_check": {
+ "name": "kiloclaw_subscription_change_log_actor_type_check",
+ "value": "\"kiloclaw_subscription_change_log\".\"actor_type\" IN ('user', 'system')"
+ },
+ "kiloclaw_subscription_change_log_action_check": {
+ "name": "kiloclaw_subscription_change_log_action_check",
+ "value": "\"kiloclaw_subscription_change_log\".\"action\" IN ('created', 'status_changed', 'plan_switched', 'period_advanced', 'canceled', 'reactivated', 'suspended', 'destruction_scheduled', 'reassigned', 'backfilled', 'payment_source_changed', 'schedule_changed', 'admin_override')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_subscriptions": {
+ "name": "kiloclaw_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_schedule_id": {
+ "name": "stripe_schedule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transferred_to_subscription_id": {
+ "name": "transferred_to_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_origin": {
+ "name": "access_origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payment_source": {
+ "name": "payment_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kiloclaw_price_version": {
+ "name": "kiloclaw_price_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_plan": {
+ "name": "scheduled_plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scheduled_by": {
+ "name": "scheduled_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "pending_conversion": {
+ "name": "pending_conversion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "trial_started_at": {
+ "name": "trial_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_start": {
+ "name": "current_period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_renewal_at": {
+ "name": "credit_renewal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "commit_ends_at": {
+ "name": "commit_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "past_due_since": {
+ "name": "past_due_since",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_at": {
+ "name": "suspended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "destruction_deadline": {
+ "name": "destruction_deadline",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_requested_at": {
+ "name": "auto_resume_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_retry_after": {
+ "name": "auto_resume_retry_after",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_attempt_count": {
+ "name": "auto_resume_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "auto_top_up_triggered_for_period": {
+ "name": "auto_top_up_triggered_for_period",
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_subscriptions_status": {
+ "name": "IDX_kiloclaw_subscriptions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_user_id": {
+ "name": "IDX_kiloclaw_subscriptions_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_user_status": {
+ "name": "IDX_kiloclaw_subscriptions_user_status",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_price_version": {
+ "name": "IDX_kiloclaw_subscriptions_price_version",
+ "columns": [
+ {
+ "expression": "kiloclaw_price_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_transferred_to": {
+ "name": "IDX_kiloclaw_subscriptions_transferred_to",
+ "columns": [
+ {
+ "expression": "transferred_to_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_stripe_schedule_id": {
+ "name": "IDX_kiloclaw_subscriptions_stripe_schedule_id",
+ "columns": [
+ {
+ "expression": "stripe_schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_auto_resume_retry_after": {
+ "name": "IDX_kiloclaw_subscriptions_auto_resume_retry_after",
+ "columns": [
+ {
+ "expression": "auto_resume_retry_after",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_subscriptions_instance": {
+ "name": "UQ_kiloclaw_subscriptions_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_subscriptions\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_subscriptions_transferred_to": {
+ "name": "UQ_kiloclaw_subscriptions_transferred_to",
+ "columns": [
+ {
+ "expression": "transferred_to_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_subscriptions\".\"transferred_to_subscription_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_earlybird_origin": {
+ "name": "IDX_kiloclaw_subscriptions_earlybird_origin",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "access_origin",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_subscriptions\".\"access_origin\" = 'earlybird'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_subscriptions_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_subscriptions_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "transferred_to_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_subscriptions_stripe_subscription_id_unique": {
+ "name": "kiloclaw_subscriptions_stripe_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_subscriptions_price_version_check": {
+ "name": "kiloclaw_subscriptions_price_version_check",
+ "value": "\"kiloclaw_subscriptions\".\"kiloclaw_price_version\" IN ('2026-03-19', '2026-05-10')"
+ },
+ "kiloclaw_subscriptions_plan_check": {
+ "name": "kiloclaw_subscriptions_plan_check",
+ "value": "\"kiloclaw_subscriptions\".\"plan\" IN ('trial', 'commit', 'standard')"
+ },
+ "kiloclaw_subscriptions_scheduled_plan_check": {
+ "name": "kiloclaw_subscriptions_scheduled_plan_check",
+ "value": "\"kiloclaw_subscriptions\".\"scheduled_plan\" IN ('commit', 'standard')"
+ },
+ "kiloclaw_subscriptions_scheduled_by_check": {
+ "name": "kiloclaw_subscriptions_scheduled_by_check",
+ "value": "\"kiloclaw_subscriptions\".\"scheduled_by\" IN ('auto', 'user')"
+ },
+ "kiloclaw_subscriptions_status_check": {
+ "name": "kiloclaw_subscriptions_status_check",
+ "value": "\"kiloclaw_subscriptions\".\"status\" IN ('trialing', 'active', 'past_due', 'canceled', 'unpaid')"
+ },
+ "kiloclaw_subscriptions_access_origin_check": {
+ "name": "kiloclaw_subscriptions_access_origin_check",
+ "value": "\"kiloclaw_subscriptions\".\"access_origin\" IN ('earlybird')"
+ },
+ "kiloclaw_subscriptions_payment_source_check": {
+ "name": "kiloclaw_subscriptions_payment_source_check",
+ "value": "\"kiloclaw_subscriptions\".\"payment_source\" IN ('stripe', 'credits')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_terminal_renewal_failures": {
+ "name": "kiloclaw_terminal_renewal_failures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "renewal_boundary": {
+ "name": "renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unresolved'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "first_failure_at": {
+ "name": "first_failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_at": {
+ "name": "last_failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_code": {
+ "name": "last_failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_message": {
+ "name": "last_failure_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_actor_type": {
+ "name": "resolution_actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_actor_id": {
+ "name": "resolution_actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_at": {
+ "name": "resolution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_reason": {
+ "name": "resolution_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary": {
+ "name": "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "renewal_boundary",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_terminal_renewal_failures_unresolved": {
+ "name": "IDX_kiloclaw_terminal_renewal_failures_unresolved",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "renewal_boundary",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_terminal_renewal_failures\".\"status\" = 'unresolved'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at": {
+ "name": "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "last_failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_terminal_renewal_failures",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_terminal_renewal_failures_status_check": {
+ "name": "kiloclaw_terminal_renewal_failures_status_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"status\" IN ('unresolved', 'resolved', 'waived', 'superseded')"
+ },
+ "kiloclaw_terminal_renewal_failures_last_failure_code_check": {
+ "name": "kiloclaw_terminal_renewal_failures_last_failure_code_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"last_failure_code\" IN ('credit_balance_read_failed', 'renewal_transaction_failed', 'auto_top_up_marker_write_failed', 'worker_timeout', 'poison_payload', 'queue_delivery_exhausted')"
+ },
+ "kiloclaw_terminal_renewal_failures_resolution_actor_type_check": {
+ "name": "kiloclaw_terminal_renewal_failures_resolution_actor_type_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"resolution_actor_type\" IN ('operator', 'system')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_version_pins": {
+ "name": "kiloclaw_version_pins",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image_tag": {
+ "name": "image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pinned_by": {
+ "name": "pinned_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk": {
+ "name": "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kiloclaw_image_catalog",
+ "columnsFrom": [
+ "image_tag"
+ ],
+ "columnsTo": [
+ "image_tag"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk": {
+ "name": "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "pinned_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_version_pins_instance_id_unique": {
+ "name": "kiloclaw_version_pins_instance_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "instance_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kilocode_users": {
+ "name": "kilocode_users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "google_user_email": {
+ "name": "google_user_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "google_user_name": {
+ "name": "google_user_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "google_user_image_url": {
+ "name": "google_user_image_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hosted_domain": {
+ "name": "hosted_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "microdollars_used": {
+ "name": "microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "kilo_pass_threshold": {
+ "name": "kilo_pass_threshold",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "app_store_account_token": {
+ "name": "app_store_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_manage_credits": {
+ "name": "can_manage_credits",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "total_microdollars_acquired": {
+ "name": "total_microdollars_acquired",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "next_credit_expiration_at": {
+ "name": "next_credit_expiration_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_validation_stytch": {
+ "name": "has_validation_stytch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_validation_novel_card_with_hold": {
+ "name": "has_validation_novel_card_with_hold",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_at": {
+ "name": "blocked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_by_kilo_user_id": {
+ "name": "blocked_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_token_pepper": {
+ "name": "api_token_pepper",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "web_session_pepper": {
+ "name": "web_session_pepper",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_enabled": {
+ "name": "auto_top_up_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_bot": {
+ "name": "is_bot",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "kiloclaw_early_access": {
+ "name": "kiloclaw_early_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_model": {
+ "name": "default_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cohorts": {
+ "name": "cohorts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "completed_welcome_form": {
+ "name": "completed_welcome_form",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "linkedin_url": {
+ "name": "linkedin_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_url": {
+ "name": "github_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discord_server_membership_verified_at": {
+ "name": "discord_server_membership_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_upstream_safety_identifier": {
+ "name": "openrouter_upstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_downstream_safety_identifier": {
+ "name": "openrouter_downstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_downstream_safety_identifier": {
+ "name": "vercel_downstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "customer_source": {
+ "name": "customer_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signup_ip": {
+ "name": "signup_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_deletion_requested_at": {
+ "name": "account_deletion_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "normalized_email": {
+ "name": "normalized_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_domain": {
+ "name": "email_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kilocode_users_signup_ip_created_at": {
+ "name": "IDX_kilocode_users_signup_ip_created_at",
+ "columns": [
+ {
+ "expression": "signup_ip",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_blocked_at": {
+ "name": "IDX_kilocode_users_blocked_at",
+ "columns": [
+ {
+ "expression": "blocked_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_blocked_by_kilo_user_id": {
+ "name": "IDX_kilocode_users_blocked_by_kilo_user_id",
+ "columns": [
+ {
+ "expression": "blocked_by_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_openrouter_upstream_safety_identifier": {
+ "name": "UQ_kilocode_users_openrouter_upstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "openrouter_upstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"openrouter_upstream_safety_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_openrouter_downstream_safety_identifier": {
+ "name": "UQ_kilocode_users_openrouter_downstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "openrouter_downstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"openrouter_downstream_safety_identifier\" IS NOT NULL",
+ "concurrently": true,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_vercel_downstream_safety_identifier": {
+ "name": "UQ_kilocode_users_vercel_downstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "vercel_downstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"vercel_downstream_safety_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_normalized_email": {
+ "name": "IDX_kilocode_users_normalized_email",
+ "columns": [
+ {
+ "expression": "normalized_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_email_domain": {
+ "name": "IDX_kilocode_users_email_domain",
+ "columns": [
+ {
+ "expression": "email_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilocode_users_app_store_account_token_unique": {
+ "name": "kilocode_users_app_store_account_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "app_store_account_token"
+ ]
+ },
+ "UQ_b1afacbcf43f2c7c4cb9f7e7faa": {
+ "name": "UQ_b1afacbcf43f2c7c4cb9f7e7faa",
+ "nullsNotDistinct": false,
+ "columns": [
+ "google_user_email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "blocked_reason_not_empty": {
+ "name": "blocked_reason_not_empty",
+ "value": "length(blocked_reason) > 0"
+ },
+ "kilocode_users_can_manage_credits_requires_admin_check": {
+ "name": "kilocode_users_can_manage_credits_requires_admin_check",
+ "value": "NOT \"kilocode_users\".\"can_manage_credits\" OR \"kilocode_users\".\"is_admin\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.magic_link_tokens": {
+ "name": "magic_link_tokens",
+ "schema": "",
+ "columns": {
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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": {
+ "idx_magic_link_tokens_email": {
+ "name": "idx_magic_link_tokens_email",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_magic_link_tokens_expires_at": {
+ "name": "idx_magic_link_tokens_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "check_expires_at_future": {
+ "name": "check_expires_at_future",
+ "value": "\"magic_link_tokens\".\"expires_at\" > \"magic_link_tokens\".\"created_at\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_assignments": {
+ "name": "mcp_gateway_assignments",
+ "schema": "",
+ "columns": {
+ "assignment_id": {
+ "name": "assignment_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "assigned_by_kilo_user_id": {
+ "name": "assigned_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "single_user_slot": {
+ "name": "single_user_slot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_assignments_active": {
+ "name": "UQ_mcp_gateway_assignments_active",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_assignments_single_user_slot": {
+ "name": "UQ_mcp_gateway_assignments_single_user_slot",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "single_user_slot",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null and \"mcp_gateway_assignments\".\"single_user_slot\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_assignments_config": {
+ "name": "IDX_mcp_gateway_assignments_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_assignments_user": {
+ "name": "IDX_mcp_gateway_assignments_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "assigned_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_audit_events": {
+ "name": "mcp_gateway_audit_events",
+ "schema": "",
+ "columns": {
+ "audit_event_id": {
+ "name": "audit_event_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "actor_kilo_user_id": {
+ "name": "actor_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connect_resource_id": {
+ "name": "connect_resource_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_metadata": {
+ "name": "correlation_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_mcp_gateway_audit_events_config": {
+ "name": "IDX_mcp_gateway_audit_events_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_audit_events_owner": {
+ "name": "IDX_mcp_gateway_audit_events_owner",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_audit_events_created_at": {
+ "name": "IDX_mcp_gateway_audit_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "actor_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk": {
+ "name": "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_connect_resources",
+ "columnsFrom": [
+ "connect_resource_id"
+ ],
+ "columnsTo": [
+ "connect_resource_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_audit_events_owner_scope": {
+ "name": "mcp_gateway_audit_events_owner_scope",
+ "value": "\"mcp_gateway_audit_events\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_audit_events_outcome": {
+ "name": "mcp_gateway_audit_events_outcome",
+ "value": "\"mcp_gateway_audit_events\".\"outcome\" IN ('success', 'failure', 'blocked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_authorization_codes": {
+ "name": "mcp_gateway_authorization_codes",
+ "schema": "",
+ "columns": {
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uri": {
+ "name": "redirect_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_challenge": {
+ "name": "code_challenge",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge_method": {
+ "name": "code_challenge_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'S256'"
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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": {
+ "UQ_mcp_gateway_authorization_codes_code_hash": {
+ "name": "UQ_mcp_gateway_authorization_codes_code_hash",
+ "columns": [
+ {
+ "expression": "code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_codes_expires_at": {
+ "name": "IDX_mcp_gateway_authorization_codes_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_codes_client": {
+ "name": "IDX_mcp_gateway_authorization_codes_client",
+ "columns": [
+ {
+ "expression": "oauth_client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
+ "name": "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_authorization_requests",
+ "columnsFrom": [
+ "authorization_request_id"
+ ],
+ "columnsTo": [
+ "authorization_request_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_authorization_codes_owner_scope": {
+ "name": "mcp_gateway_authorization_codes_owner_scope",
+ "value": "\"mcp_gateway_authorization_codes\".\"owner_scope\" IN ('personal', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_authorization_requests": {
+ "name": "mcp_gateway_authorization_requests",
+ "schema": "",
+ "columns": {
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "request_state_hash": {
+ "name": "request_state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uri": {
+ "name": "redirect_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_scopes": {
+ "name": "requested_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_state": {
+ "name": "oauth_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge": {
+ "name": "code_challenge",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge_method": {
+ "name": "code_challenge_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'S256'"
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_status": {
+ "name": "request_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_authorization_requests_state_hash": {
+ "name": "UQ_mcp_gateway_authorization_requests_state_hash",
+ "columns": [
+ {
+ "expression": "request_state_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_config": {
+ "name": "IDX_mcp_gateway_authorization_requests_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_user": {
+ "name": "IDX_mcp_gateway_authorization_requests_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_expires_at": {
+ "name": "IDX_mcp_gateway_authorization_requests_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_authorization_requests_owner_scope": {
+ "name": "mcp_gateway_authorization_requests_owner_scope",
+ "value": "\"mcp_gateway_authorization_requests\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_authorization_requests_status": {
+ "name": "mcp_gateway_authorization_requests_status",
+ "value": "\"mcp_gateway_authorization_requests\".\"request_status\" IN ('pending', 'completed', 'error')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_config_secrets": {
+ "name": "mcp_gateway_config_secrets",
+ "schema": "",
+ "columns": {
+ "config_secret_id": {
+ "name": "config_secret_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret_kind": {
+ "name": "secret_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_secret": {
+ "name": "encrypted_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret_version": {
+ "name": "secret_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_config_secrets_active_kind": {
+ "name": "UQ_mcp_gateway_config_secrets_active_kind",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "secret_kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_config_secrets\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_config_secrets_config": {
+ "name": "IDX_mcp_gateway_config_secrets_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_config_secrets",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_config_secrets_version_positive": {
+ "name": "mcp_gateway_config_secrets_version_positive",
+ "value": "\"mcp_gateway_config_secrets\".\"secret_version\" > 0"
+ },
+ "mcp_gateway_config_secrets_kind": {
+ "name": "mcp_gateway_config_secrets_kind",
+ "value": "\"mcp_gateway_config_secrets\".\"secret_kind\" IN ('static_provider_credentials', 'dynamic_registration', 'static_headers')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_configs": {
+ "name": "mcp_gateway_configs",
+ "schema": "",
+ "columns": {
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_url": {
+ "name": "remote_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_mode": {
+ "name": "auth_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sharing_mode": {
+ "name": "sharing_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_scopes": {
+ "name": "provider_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_scope_source": {
+ "name": "provider_scope_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'none'"
+ },
+ "provider_resource": {
+ "name": "provider_resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "path_passthrough": {
+ "name": "path_passthrough",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "config_version": {
+ "name": "config_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "discovered_provider_metadata": {
+ "name": "discovered_provider_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registry_metadata": {
+ "name": "registry_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "auxiliary_headers": {
+ "name": "auxiliary_headers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_mcp_gateway_configs_owner": {
+ "name": "IDX_mcp_gateway_configs_owner",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_configs_enabled": {
+ "name": "IDX_mcp_gateway_configs_enabled",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_configs_remote_url": {
+ "name": "IDX_mcp_gateway_configs_remote_url",
+ "columns": [
+ {
+ "expression": "remote_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_configs_name_not_empty": {
+ "name": "mcp_gateway_configs_name_not_empty",
+ "value": "length(trim(\"mcp_gateway_configs\".\"name\")) > 0"
+ },
+ "mcp_gateway_configs_config_version_positive": {
+ "name": "mcp_gateway_configs_config_version_positive",
+ "value": "\"mcp_gateway_configs\".\"config_version\" > 0"
+ },
+ "mcp_gateway_configs_personal_single_user": {
+ "name": "mcp_gateway_configs_personal_single_user",
+ "value": "\"mcp_gateway_configs\".\"owner_scope\" <> 'personal' OR \"mcp_gateway_configs\".\"sharing_mode\" = 'single_user'"
+ },
+ "mcp_gateway_configs_owner_scope": {
+ "name": "mcp_gateway_configs_owner_scope",
+ "value": "\"mcp_gateway_configs\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_configs_auth_mode": {
+ "name": "mcp_gateway_configs_auth_mode",
+ "value": "\"mcp_gateway_configs\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
+ },
+ "mcp_gateway_configs_sharing_mode": {
+ "name": "mcp_gateway_configs_sharing_mode",
+ "value": "\"mcp_gateway_configs\".\"sharing_mode\" IN ('single_user', 'multi_user')"
+ },
+ "mcp_gateway_configs_provider_scope_source": {
+ "name": "mcp_gateway_configs_provider_scope_source",
+ "value": "\"mcp_gateway_configs\".\"provider_scope_source\" IN ('none', 'discovered', 'override')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_connect_resources": {
+ "name": "mcp_gateway_connect_resources",
+ "schema": "",
+ "columns": {
+ "connect_resource_id": {
+ "name": "connect_resource_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_url": {
+ "name": "canonical_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_status": {
+ "name": "route_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "route_version": {
+ "name": "route_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "rotated_at": {
+ "name": "rotated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_connect_resources_route_key": {
+ "name": "UQ_mcp_gateway_connect_resources_route_key",
+ "columns": [
+ {
+ "expression": "route_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_connect_resources_active_config": {
+ "name": "UQ_mcp_gateway_connect_resources_active_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_connect_resources\".\"route_status\" = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connect_resources_config": {
+ "name": "IDX_mcp_gateway_connect_resources_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connect_resources_canonical_url": {
+ "name": "IDX_mcp_gateway_connect_resources_canonical_url",
+ "columns": [
+ {
+ "expression": "canonical_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_connect_resources",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_connect_resources_route_key_format": {
+ "name": "mcp_gateway_connect_resources_route_key_format",
+ "value": "\"mcp_gateway_connect_resources\".\"route_key\" ~ '^[A-Za-z0-9_-]{32,}$'"
+ },
+ "mcp_gateway_connect_resources_route_version_positive": {
+ "name": "mcp_gateway_connect_resources_route_version_positive",
+ "value": "\"mcp_gateway_connect_resources\".\"route_version\" > 0"
+ },
+ "mcp_gateway_connect_resources_owner_scope": {
+ "name": "mcp_gateway_connect_resources_owner_scope",
+ "value": "\"mcp_gateway_connect_resources\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_connect_resources_route_status": {
+ "name": "mcp_gateway_connect_resources_route_status",
+ "value": "\"mcp_gateway_connect_resources\".\"route_status\" IN ('active', 'rotated', 'revoked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_connection_instances": {
+ "name": "mcp_gateway_connection_instances",
+ "schema": "",
+ "columns": {
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_status": {
+ "name": "instance_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "instance_version": {
+ "name": "instance_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "removed_at": {
+ "name": "removed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_connection_instances_non_terminal": {
+ "name": "UQ_mcp_gateway_connection_instances_non_terminal",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connection_instances_config": {
+ "name": "IDX_mcp_gateway_connection_instances_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connection_instances_user": {
+ "name": "IDX_mcp_gateway_connection_instances_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_connection_instances",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_connection_instances",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_connection_instances_version_positive": {
+ "name": "mcp_gateway_connection_instances_version_positive",
+ "value": "\"mcp_gateway_connection_instances\".\"instance_version\" > 0"
+ },
+ "mcp_gateway_connection_instances_owner_scope": {
+ "name": "mcp_gateway_connection_instances_owner_scope",
+ "value": "\"mcp_gateway_connection_instances\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_connection_instances_status": {
+ "name": "mcp_gateway_connection_instances_status",
+ "value": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth', 'revoked', 'removed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_oauth_clients": {
+ "name": "mcp_gateway_oauth_clients",
+ "schema": "",
+ "columns": {
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_name": {
+ "name": "client_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_token_hash": {
+ "name": "registration_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret_hash": {
+ "name": "client_secret_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_types": {
+ "name": "grant_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "declared_scopes": {
+ "name": "declared_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "registration_access_token_expires_at": {
+ "name": "registration_access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_oauth_clients_client_id": {
+ "name": "UQ_mcp_gateway_oauth_clients_client_id",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_oauth_clients_registration_token_hash": {
+ "name": "UQ_mcp_gateway_oauth_clients_registration_token_hash",
+ "columns": [
+ {
+ "expression": "registration_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_oauth_clients_deleted_at": {
+ "name": "IDX_mcp_gateway_oauth_clients_deleted_at",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_oauth_clients_client_id_format": {
+ "name": "mcp_gateway_oauth_clients_client_id_format",
+ "value": "\"mcp_gateway_oauth_clients\".\"client_id\" ~ '^[A-Za-z0-9._-]+:[A-Za-z0-9._-]+$'"
+ },
+ "mcp_gateway_oauth_clients_auth_method": {
+ "name": "mcp_gateway_oauth_clients_auth_method",
+ "value": "\"mcp_gateway_oauth_clients\".\"token_endpoint_auth_method\" IN ('none', 'client_secret_post', 'client_secret_basic')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_pending_provider_authorizations": {
+ "name": "mcp_gateway_pending_provider_authorizations",
+ "schema": "",
+ "columns": {
+ "pending_provider_authorization_id": {
+ "name": "pending_provider_authorization_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "state_hash": {
+ "name": "state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_url": {
+ "name": "remote_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_mode": {
+ "name": "auth_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_authorization_endpoint": {
+ "name": "provider_authorization_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_token_endpoint": {
+ "name": "provider_token_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_state": {
+ "name": "encrypted_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_version": {
+ "name": "config_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pending_status": {
+ "name": "pending_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_pending_provider_authorizations_state_hash": {
+ "name": "UQ_mcp_gateway_pending_provider_authorizations_state_hash",
+ "columns": [
+ {
+ "expression": "state_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_pending_provider_authorizations_config": {
+ "name": "IDX_mcp_gateway_pending_provider_authorizations_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_pending_provider_authorizations_expires_at": {
+ "name": "IDX_mcp_gateway_pending_provider_authorizations_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_authorization_requests",
+ "columnsFrom": [
+ "authorization_request_id"
+ ],
+ "columnsTo": [
+ "authorization_request_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_pending_provider_authorizations_config_version_positive": {
+ "name": "mcp_gateway_pending_provider_authorizations_config_version_positive",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"config_version\" > 0"
+ },
+ "mcp_gateway_pending_provider_authorizations_owner_scope": {
+ "name": "mcp_gateway_pending_provider_authorizations_owner_scope",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_pending_provider_authorizations_auth_mode": {
+ "name": "mcp_gateway_pending_provider_authorizations_auth_mode",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
+ },
+ "mcp_gateway_pending_provider_authorizations_status": {
+ "name": "mcp_gateway_pending_provider_authorizations_status",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"pending_status\" IN ('pending', 'completed', 'error')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_provider_grants": {
+ "name": "mcp_gateway_provider_grants",
+ "schema": "",
+ "columns": {
+ "provider_grant_id": {
+ "name": "provider_grant_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_grant": {
+ "name": "encrypted_grant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject": {
+ "name": "provider_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_scope": {
+ "name": "grant_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_status": {
+ "name": "grant_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "grant_version": {
+ "name": "grant_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_provider_grants_active_instance": {
+ "name": "UQ_mcp_gateway_provider_grants_active_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_provider_grants\".\"grant_status\" = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_provider_grants_instance": {
+ "name": "IDX_mcp_gateway_provider_grants_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_provider_grants",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_provider_grants_version_positive": {
+ "name": "mcp_gateway_provider_grants_version_positive",
+ "value": "\"mcp_gateway_provider_grants\".\"grant_version\" > 0"
+ },
+ "mcp_gateway_provider_grants_status": {
+ "name": "mcp_gateway_provider_grants_status",
+ "value": "\"mcp_gateway_provider_grants\".\"grant_status\" IN ('active', 'revoked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_rate_limit_windows": {
+ "name": "mcp_gateway_rate_limit_windows",
+ "schema": "",
+ "columns": {
+ "rate_limit_window_id": {
+ "name": "rate_limit_window_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_started_at": {
+ "name": "window_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_count": {
+ "name": "attempt_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_rate_limit_windows_ip_window": {
+ "name": "UQ_mcp_gateway_rate_limit_windows_ip_window",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "window_started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_rate_limit_windows_window": {
+ "name": "IDX_mcp_gateway_rate_limit_windows_window",
+ "columns": [
+ {
+ "expression": "window_started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_rate_limit_windows_attempt_count_non_negative": {
+ "name": "mcp_gateway_rate_limit_windows_attempt_count_non_negative",
+ "value": "\"mcp_gateway_rate_limit_windows\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_refresh_tokens": {
+ "name": "mcp_gateway_refresh_tokens",
+ "schema": "",
+ "columns": {
+ "refresh_token_id": {
+ "name": "refresh_token_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rotated_from_refresh_token_id": {
+ "name": "rotated_from_refresh_token_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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": {
+ "UQ_mcp_gateway_refresh_tokens_token_hash": {
+ "name": "UQ_mcp_gateway_refresh_tokens_token_hash",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_user": {
+ "name": "IDX_mcp_gateway_refresh_tokens_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_config": {
+ "name": "IDX_mcp_gateway_refresh_tokens_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_consumed_at": {
+ "name": "IDX_mcp_gateway_refresh_tokens_consumed_at",
+ "columns": [
+ {
+ "expression": "consumed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_refresh_tokens_owner_scope": {
+ "name": "mcp_gateway_refresh_tokens_owner_scope",
+ "value": "\"mcp_gateway_refresh_tokens\".\"owner_scope\" IN ('personal', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage": {
+ "name": "microdollar_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_write_tokens": {
+ "name": "cache_write_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_hit_tokens": {
+ "name": "cache_hit_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_model": {
+ "name": "requested_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_discount": {
+ "name": "cache_discount",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_error": {
+ "name": "has_error",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "abuse_classification": {
+ "name": "abuse_classification",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_provider": {
+ "name": "inference_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_created_at": {
+ "name": "idx_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_abuse_classification": {
+ "name": "idx_abuse_classification",
+ "columns": [
+ {
+ "expression": "abuse_classification",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_kilo_user_id_created_at2": {
+ "name": "idx_kilo_user_id_created_at2",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_organization_id": {
+ "name": "idx_microdollar_usage_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"microdollar_usage\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage_daily": {
+ "name": "microdollar_usage_daily",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "usage_date": {
+ "name": "usage_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_microdollar_usage_daily_personal": {
+ "name": "idx_microdollar_usage_daily_personal",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"microdollar_usage_daily\".\"organization_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_daily_org": {
+ "name": "idx_microdollar_usage_daily_org",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"microdollar_usage_daily\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage_metadata": {
+ "name": "microdollar_usage_metadata",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "http_user_agent_id": {
+ "name": "http_user_agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_ip_id": {
+ "name": "http_ip_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_city_id": {
+ "name": "vercel_ip_city_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_country_id": {
+ "name": "vercel_ip_country_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_latitude": {
+ "name": "vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_longitude": {
+ "name": "vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ja4_digest_id": {
+ "name": "ja4_digest_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_prompt_prefix": {
+ "name": "user_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_prefix_id": {
+ "name": "system_prompt_prefix_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_length": {
+ "name": "system_prompt_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_tokens": {
+ "name": "max_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_middle_out_transform": {
+ "name": "has_middle_out_transform",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "upstream_id": {
+ "name": "upstream_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finish_reason_id": {
+ "name": "finish_reason_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency": {
+ "name": "latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderation_latency": {
+ "name": "moderation_latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_time": {
+ "name": "generation_time",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_byok": {
+ "name": "is_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_user_byok": {
+ "name": "is_user_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "streamed": {
+ "name": "streamed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled": {
+ "name": "cancelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_name_id": {
+ "name": "editor_name_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_kind_id": {
+ "name": "api_kind_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_tools": {
+ "name": "has_tools",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "machine_id": {
+ "name": "machine_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature_id": {
+ "name": "feature_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode_id": {
+ "name": "mode_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_model_id": {
+ "name": "auto_model_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_cost": {
+ "name": "market_cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_delay": {
+ "name": "abuse_delay",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_downgraded_from": {
+ "name": "abuse_downgraded_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_microdollar_usage_metadata_created_at": {
+ "name": "idx_microdollar_usage_metadata_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_metadata_session_id": {
+ "name": "idx_microdollar_usage_metadata_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"microdollar_usage_metadata\".\"session_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk": {
+ "name": "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "http_user_agent",
+ "columnsFrom": [
+ "http_user_agent_id"
+ ],
+ "columnsTo": [
+ "http_user_agent_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk": {
+ "name": "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "http_ip",
+ "columnsFrom": [
+ "http_ip_id"
+ ],
+ "columnsTo": [
+ "http_ip_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk": {
+ "name": "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "vercel_ip_city",
+ "columnsFrom": [
+ "vercel_ip_city_id"
+ ],
+ "columnsTo": [
+ "vercel_ip_city_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk": {
+ "name": "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "vercel_ip_country",
+ "columnsFrom": [
+ "vercel_ip_country_id"
+ ],
+ "columnsTo": [
+ "vercel_ip_country_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk": {
+ "name": "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "ja4_digest",
+ "columnsFrom": [
+ "ja4_digest_id"
+ ],
+ "columnsTo": [
+ "ja4_digest_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk": {
+ "name": "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "system_prompt_prefix",
+ "columnsFrom": [
+ "system_prompt_prefix_id"
+ ],
+ "columnsTo": [
+ "system_prompt_prefix_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mode": {
+ "name": "mode",
+ "schema": "",
+ "columns": {
+ "mode_id": {
+ "name": "mode_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_mode": {
+ "name": "UQ_mode",
+ "columns": [
+ {
+ "expression": "mode",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_stats": {
+ "name": "model_stats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "is_featured": {
+ "name": "is_featured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_stealth": {
+ "name": "is_stealth",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_recommended": {
+ "name": "is_recommended",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "openrouter_id": {
+ "name": "openrouter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aa_slug": {
+ "name": "aa_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_creator": {
+ "name": "model_creator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creator_slug": {
+ "name": "creator_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release_date": {
+ "name": "release_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_input": {
+ "name": "price_input",
+ "type": "numeric(10, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_output": {
+ "name": "price_output",
+ "type": "numeric(10, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coding_index": {
+ "name": "coding_index",
+ "type": "numeric(5, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "speed_tokens_per_sec": {
+ "name": "speed_tokens_per_sec",
+ "type": "numeric(8, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context_length": {
+ "name": "context_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_output_tokens": {
+ "name": "max_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_modalities": {
+ "name": "input_modalities",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_data": {
+ "name": "openrouter_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "benchmarks": {
+ "name": "benchmarks",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chart_data": {
+ "name": "chart_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_stats_openrouter_id": {
+ "name": "IDX_model_stats_openrouter_id",
+ "columns": [
+ {
+ "expression": "openrouter_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_slug": {
+ "name": "IDX_model_stats_slug",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_is_active": {
+ "name": "IDX_model_stats_is_active",
+ "columns": [
+ {
+ "expression": "is_active",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_creator_slug": {
+ "name": "IDX_model_stats_creator_slug",
+ "columns": [
+ {
+ "expression": "creator_slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_price_input": {
+ "name": "IDX_model_stats_price_input",
+ "columns": [
+ {
+ "expression": "price_input",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_coding_index": {
+ "name": "IDX_model_stats_coding_index",
+ "columns": [
+ {
+ "expression": "coding_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_context_length": {
+ "name": "IDX_model_stats_context_length",
+ "columns": [
+ {
+ "expression": "context_length",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_stats_openrouter_id_unique": {
+ "name": "model_stats_openrouter_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "openrouter_id"
+ ]
+ },
+ "model_stats_slug_unique": {
+ "name": "model_stats_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_eval_ingestions": {
+ "name": "model_eval_ingestions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "bench_eval_name": {
+ "name": "bench_eval_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bench_eval_url": {
+ "name": "bench_eval_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_stats_id": {
+ "name": "model_stats_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "variant": {
+ "name": "variant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_total_trials": {
+ "name": "n_total_trials",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_attempts": {
+ "name": "n_attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_score": {
+ "name": "total_score",
+ "type": "numeric(14, 6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overall_score": {
+ "name": "overall_score",
+ "type": "numeric(12, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_errored": {
+ "name": "n_errored",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "avg_cost_microdollars": {
+ "name": "avg_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_input_tokens": {
+ "name": "avg_input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_input_tokens": {
+ "name": "total_input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_output_tokens": {
+ "name": "avg_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_output_tokens": {
+ "name": "total_output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_cache_read_tokens": {
+ "name": "avg_cache_read_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cache_read_tokens": {
+ "name": "total_cache_read_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_execution_ms": {
+ "name": "avg_execution_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "promoted_at": {
+ "name": "promoted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "promoted_by_email": {
+ "name": "promoted_by_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "promotion_note": {
+ "name": "promotion_note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_eval_ingestions_lookup": {
+ "name": "IDX_model_eval_ingestions_lookup",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "task_source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "promoted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_eval_ingestions_model_stats": {
+ "name": "IDX_model_eval_ingestions_model_stats",
+ "columns": [
+ {
+ "expression": "model_stats_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_eval_ingestions_promoted_by_email_lower": {
+ "name": "IDX_model_eval_ingestions_promoted_by_email_lower",
+ "columns": [
+ {
+ "expression": "LOWER(\"promoted_by_email\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_eval_ingestions_model_stats_id_model_stats_id_fk": {
+ "name": "model_eval_ingestions_model_stats_id_model_stats_id_fk",
+ "tableFrom": "model_eval_ingestions",
+ "tableTo": "model_stats",
+ "columnsFrom": [
+ "model_stats_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_eval_ingestions_bench_eval_name_unique": {
+ "name": "model_eval_ingestions_bench_eval_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "bench_eval_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_experiment": {
+ "name": "model_experiment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "public_model_id": {
+ "name": "public_model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "is_archived": {
+ "name": "is_archived",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_model_experiment_public_model_id_routing": {
+ "name": "UQ_model_experiment_public_model_id_routing",
+ "columns": [
+ {
+ "expression": "public_model_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"model_experiment\".\"status\" IN ('active', 'paused')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_experiment_status": {
+ "name": "IDX_model_experiment_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_created_by_user_id_kilocode_users_id_fk": {
+ "name": "model_experiment_created_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "model_experiment",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_status_valid": {
+ "name": "model_experiment_status_valid",
+ "value": "\"model_experiment\".\"status\" IN ('draft', 'active', 'paused', 'completed')"
+ },
+ "model_experiment_active_not_archived": {
+ "name": "model_experiment_active_not_archived",
+ "value": "\"model_experiment\".\"status\" <> 'active' OR \"model_experiment\".\"is_archived\" = false"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_request": {
+ "name": "model_experiment_request",
+ "schema": "",
+ "columns": {
+ "usage_id": {
+ "name": "usage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "variant_version_id": {
+ "name": "variant_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allocation_subject": {
+ "name": "allocation_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_request_id": {
+ "name": "client_request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_kind": {
+ "name": "request_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_body_sha256": {
+ "name": "request_body_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "was_truncated": {
+ "name": "was_truncated",
+ "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": {
+ "IDX_model_experiment_request_variant_version_created_at": {
+ "name": "IDX_model_experiment_request_variant_version_created_at",
+ "columns": [
+ {
+ "expression": "variant_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_experiment_request_client_request_id": {
+ "name": "IDX_model_experiment_request_client_request_id",
+ "columns": [
+ {
+ "expression": "client_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"model_experiment_request\".\"client_request_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_request_usage_id_microdollar_usage_id_fk": {
+ "name": "model_experiment_request_usage_id_microdollar_usage_id_fk",
+ "tableFrom": "model_experiment_request",
+ "tableTo": "microdollar_usage",
+ "columnsFrom": [
+ "usage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk": {
+ "name": "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk",
+ "tableFrom": "model_experiment_request",
+ "tableTo": "model_experiment_variant_version",
+ "columnsFrom": [
+ "variant_version_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "model_experiment_request_usage_id_created_at_pk": {
+ "name": "model_experiment_request_usage_id_created_at_pk",
+ "columns": [
+ "usage_id",
+ "created_at"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_request_allocation_subject_valid": {
+ "name": "model_experiment_request_allocation_subject_valid",
+ "value": "\"model_experiment_request\".\"allocation_subject\" IN ('user', 'machine', 'ip')"
+ },
+ "model_experiment_request_request_kind_valid": {
+ "name": "model_experiment_request_request_kind_valid",
+ "value": "\"model_experiment_request\".\"request_kind\" IN ('chat_completions', 'messages', 'responses')"
+ },
+ "model_experiment_request_request_body_sha256_format": {
+ "name": "model_experiment_request_request_body_sha256_format",
+ "value": "\"model_experiment_request\".\"request_body_sha256\" ~ '^[0-9a-f]{64}$' OR \"model_experiment_request\".\"request_body_sha256\" IN ('__failed__', '__deleted__')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_variant": {
+ "name": "model_experiment_variant",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "experiment_id": {
+ "name": "experiment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "weight": {
+ "name": "weight",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_experiment_variant_experiment_id": {
+ "name": "IDX_model_experiment_variant_experiment_id",
+ "columns": [
+ {
+ "expression": "experiment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_variant_experiment_id_model_experiment_id_fk": {
+ "name": "model_experiment_variant_experiment_id_model_experiment_id_fk",
+ "tableFrom": "model_experiment_variant",
+ "tableTo": "model_experiment",
+ "columnsFrom": [
+ "experiment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_model_experiment_variant_experiment_label": {
+ "name": "UQ_model_experiment_variant_experiment_label",
+ "nullsNotDistinct": false,
+ "columns": [
+ "experiment_id",
+ "label"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_variant_weight_positive": {
+ "name": "model_experiment_variant_weight_positive",
+ "value": "\"model_experiment_variant\".\"weight\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_variant_version": {
+ "name": "model_experiment_variant_version",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "variant_id": {
+ "name": "variant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "upstream": {
+ "name": "upstream",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_at": {
+ "name": "effective_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_experiment_variant_version_variant_effective": {
+ "name": "IDX_model_experiment_variant_version_variant_effective",
+ "columns": [
+ {
+ "expression": "variant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "effective_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk": {
+ "name": "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk",
+ "tableFrom": "model_experiment_variant_version",
+ "tableTo": "model_experiment_variant",
+ "columnsFrom": [
+ "variant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "model_experiment_variant_version_created_by_kilocode_users_id_fk": {
+ "name": "model_experiment_variant_version_created_by_kilocode_users_id_fk",
+ "tableFrom": "model_experiment_variant_version",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.models_by_provider": {
+ "name": "models_by_provider",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "openrouter": {
+ "name": "openrouter",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel": {
+ "name": "vercel",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_audit_logs": {
+ "name": "organization_audit_logs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_audit_logs_organization_id": {
+ "name": "IDX_organization_audit_logs_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_action": {
+ "name": "IDX_organization_audit_logs_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_actor_id": {
+ "name": "IDX_organization_audit_logs_actor_id",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_created_at": {
+ "name": "IDX_organization_audit_logs_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_invitations": {
+ "name": "organization_invitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by": {
+ "name": "invited_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authentication_requirement": {
+ "name": "authentication_requirement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "sso_source_organization_id": {
+ "name": "sso_source_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_organization_invitations_token": {
+ "name": "UQ_organization_invitations_token",
+ "columns": [
+ {
+ "expression": "token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_org_id": {
+ "name": "IDX_organization_invitations_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_email": {
+ "name": "IDX_organization_invitations_email",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_expires_at": {
+ "name": "IDX_organization_invitations_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_invitations_sso_source_organization_id_organizations_id_fk": {
+ "name": "organization_invitations_sso_source_organization_id_organizations_id_fk",
+ "tableFrom": "organization_invitations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "sso_source_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_membership_removals": {
+ "name": "organization_membership_removals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "removed_at": {
+ "name": "removed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "removed_by": {
+ "name": "removed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_role": {
+ "name": "previous_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "IDX_org_membership_removals_org_id": {
+ "name": "IDX_org_membership_removals_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_org_membership_removals_user_id": {
+ "name": "IDX_org_membership_removals_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_org_membership_removals_org_user": {
+ "name": "UQ_org_membership_removals_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_memberships": {
+ "name": "organization_memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "invited_by": {
+ "name": "invited_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_memberships_org_id": {
+ "name": "IDX_organization_memberships_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_memberships_user_id": {
+ "name": "IDX_organization_memberships_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_memberships_org_user": {
+ "name": "UQ_organization_memberships_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_recommendation_dismissals": {
+ "name": "organization_recommendation_dismissals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_key": {
+ "name": "recommendation_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dismissed_by_user_id": {
+ "name": "dismissed_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dismissed_at": {
+ "name": "dismissed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk": {
+ "name": "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "organization_recommendation_dismissals",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk": {
+ "name": "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "organization_recommendation_dismissals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "dismissed_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_org_recommendation_dismissals_org_key": {
+ "name": "UQ_org_recommendation_dismissals_org_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_organization_id",
+ "recommendation_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_seats_purchases": {
+ "name": "organization_seats_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscription_stripe_id": {
+ "name": "subscription_stripe_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "seat_count": {
+ "name": "seat_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "numeric",
+ "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
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "subscription_status": {
+ "name": "subscription_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "starts_at": {
+ "name": "starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_cycle": {
+ "name": "billing_cycle",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'monthly'"
+ }
+ },
+ "indexes": {
+ "IDX_organization_seats_org_id": {
+ "name": "IDX_organization_seats_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_expires_at": {
+ "name": "IDX_organization_seats_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_created_at": {
+ "name": "IDX_organization_seats_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_updated_at": {
+ "name": "IDX_organization_seats_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_starts_at": {
+ "name": "IDX_organization_seats_starts_at",
+ "columns": [
+ {
+ "expression": "starts_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_seats_idempotency_key": {
+ "name": "UQ_organization_seats_idempotency_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "idempotency_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_user_limits": {
+ "name": "organization_user_limits",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "microdollar_limit": {
+ "name": "microdollar_limit",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_user_limits_org_id": {
+ "name": "IDX_organization_user_limits_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_user_limits_user_id": {
+ "name": "IDX_organization_user_limits_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_user_limits_org_user": {
+ "name": "UQ_organization_user_limits_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "limit_type"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_user_usage": {
+ "name": "organization_user_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "usage_date": {
+ "name": "usage_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "microdollar_usage": {
+ "name": "microdollar_usage",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_user_daily_usage_org_id": {
+ "name": "IDX_organization_user_daily_usage_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_user_daily_usage_user_id": {
+ "name": "IDX_organization_user_daily_usage_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_user_daily_usage_org_user_date": {
+ "name": "UQ_organization_user_daily_usage_org_user_date",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "limit_type",
+ "usage_date"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "microdollars_used": {
+ "name": "microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "microdollars_balance": {
+ "name": "microdollars_balance",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "total_microdollars_acquired": {
+ "name": "total_microdollars_acquired",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "next_credit_expiration_at": {
+ "name": "next_credit_expiration_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_enabled": {
+ "name": "auto_top_up_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "seat_count": {
+ "name": "seat_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "require_seats": {
+ "name": "require_seats",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sso_domain": {
+ "name": "sso_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_organization_id": {
+ "name": "parent_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'teams'"
+ },
+ "free_trial_end_at": {
+ "name": "free_trial_end_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_domain": {
+ "name": "company_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_organizations_sso_domain": {
+ "name": "IDX_organizations_sso_domain",
+ "columns": [
+ {
+ "expression": "sso_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organizations_parent_organization_id": {
+ "name": "IDX_organizations_parent_organization_id",
+ "columns": [
+ {
+ "expression": "parent_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organizations_parent_organization_id_organizations_id_fk": {
+ "name": "organizations_parent_organization_id_organizations_id_fk",
+ "tableFrom": "organizations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "parent_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organizations_slug_unique": {
+ "name": "organizations_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "organizations_name_not_empty_check": {
+ "name": "organizations_name_not_empty_check",
+ "value": "length(trim(\"organizations\".\"name\")) > 0"
+ },
+ "organizations_not_parented_by_self_check": {
+ "name": "organizations_not_parented_by_self_check",
+ "value": "\"organizations\".\"parent_organization_id\" IS NULL OR \"organizations\".\"parent_organization_id\" <> \"organizations\".\"id\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.organization_modes": {
+ "name": "organization_modes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ }
+ },
+ "indexes": {
+ "IDX_organization_modes_organization_id": {
+ "name": "IDX_organization_modes_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_modes_org_id_slug": {
+ "name": "UQ_organization_modes_org_id_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.payment_methods": {
+ "name": "payment_methods",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_fingerprint": {
+ "name": "stripe_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_id": {
+ "name": "stripe_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last4": {
+ "name": "last4",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "brand": {
+ "name": "brand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line1": {
+ "name": "address_line1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line2": {
+ "name": "address_line2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_city": {
+ "name": "address_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_state": {
+ "name": "address_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_zip": {
+ "name": "address_zip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_country": {
+ "name": "address_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "three_d_secure_supported": {
+ "name": "three_d_secure_supported",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "regulated_status": {
+ "name": "regulated_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line1_check_status": {
+ "name": "address_line1_check_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postal_code_check_status": {
+ "name": "postal_code_check_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eligible_for_free_credits": {
+ "name": "eligible_for_free_credits",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_data": {
+ "name": "stripe_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_d7d7fb15569674aaadcfbc0428": {
+ "name": "IDX_d7d7fb15569674aaadcfbc0428",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_e1feb919d0ab8a36381d5d5138": {
+ "name": "IDX_e1feb919d0ab8a36381d5d5138",
+ "columns": [
+ {
+ "expression": "stripe_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_payment_methods_organization_id": {
+ "name": "IDX_payment_methods_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_29df1b0403df5792c96bbbfdbe6": {
+ "name": "UQ_29df1b0403df5792c96bbbfdbe6",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "stripe_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pending_impact_sale_reversals": {
+ "name": "pending_impact_sale_reversals",
+ "schema": "",
+ "columns": {
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "dispute_id": {
+ "name": "dispute_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount": {
+ "name": "amount",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_date": {
+ "name": "event_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_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": {},
+ "policies": {},
+ "checkConstraints": {
+ "pending_impact_sale_reversals_attempt_count_non_negative_check": {
+ "name": "pending_impact_sale_reversals_attempt_count_non_negative_check",
+ "value": "\"pending_impact_sale_reversals\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.platform_access_token_credentials": {
+ "name": "platform_access_token_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_encrypted": {
+ "name": "token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_credential_type": {
+ "name": "provider_credential_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_scopes": {
+ "name": "provider_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_verified_at": {
+ "name": "provider_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_validated_at": {
+ "name": "last_validated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "FK_platform_access_token_credentials_parent": {
+ "name": "FK_platform_access_token_credentials_parent",
+ "tableFrom": "platform_access_token_credentials",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_platform_access_token_credentials_platform_integration_id": {
+ "name": "UQ_platform_access_token_credentials_platform_integration_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "platform_integration_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.platform_integrations": {
+ "name": "platform_integrations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_installation_id": {
+ "name": "platform_installation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_account_id": {
+ "name": "platform_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_account_login": {
+ "name": "platform_account_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_access": {
+ "name": "repository_access",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repositories": {
+ "name": "repositories",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repositories_synced_at": {
+ "name": "repositories_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_invalid_at": {
+ "name": "auth_invalid_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_invalid_reason": {
+ "name": "auth_invalid_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_requester_user_id": {
+ "name": "kilo_requester_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_requester_account_id": {
+ "name": "platform_requester_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "integration_status": {
+ "name": "integration_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_at": {
+ "name": "suspended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_by": {
+ "name": "suspended_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_app_type": {
+ "name": "github_app_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'standard'"
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_platform_integrations_owned_by_org_platform_inst": {
+ "name": "UQ_platform_integrations_owned_by_org_platform_inst",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_owned_by_user_platform_inst": {
+ "name": "UQ_platform_integrations_owned_by_user_platform_inst",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_slack_platform_inst": {
+ "name": "UQ_platform_integrations_slack_platform_inst",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'slack' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_linear_platform_inst": {
+ "name": "UQ_platform_integrations_linear_platform_inst",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'linear' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_user_bitbucket": {
+ "name": "UQ_platform_integrations_user_bitbucket",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_org_bitbucket": {
+ "name": "UQ_platform_integrations_org_bitbucket",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_org_id": {
+ "name": "IDX_platform_integrations_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_user_id": {
+ "name": "IDX_platform_integrations_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform_inst_id": {
+ "name": "IDX_platform_integrations_platform_inst_id",
+ "columns": [
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform": {
+ "name": "IDX_platform_integrations_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_org_platform": {
+ "name": "IDX_platform_integrations_owned_by_org_platform",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_user_platform": {
+ "name": "IDX_platform_integrations_owned_by_user_platform",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_integration_status": {
+ "name": "IDX_platform_integrations_integration_status",
+ "columns": [
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_kilo_requester": {
+ "name": "IDX_platform_integrations_kilo_requester",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_requester_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform_requester": {
+ "name": "IDX_platform_integrations_platform_requester",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_requester_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "platform_integrations_owned_by_organization_id_organizations_id_fk": {
+ "name": "platform_integrations_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "platform_integrations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "platform_integrations_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "platform_integrations_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "platform_integrations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "platform_integrations_owner_check": {
+ "name": "platform_integrations_owner_check",
+ "value": "(\n (\"platform_integrations\".\"owned_by_user_id\" IS NOT NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NULL) OR\n (\"platform_integrations\".\"owned_by_user_id\" IS NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.platform_oauth_credentials": {
+ "name": "platform_oauth_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorized_by_user_id": {
+ "name": "authorized_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject_id": {
+ "name": "provider_subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject_login": {
+ "name": "provider_subject_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_encrypted": {
+ "name": "access_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_reason": {
+ "name": "revocation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_platform_oauth_credentials_platform_integration_id": {
+ "name": "UQ_platform_oauth_credentials_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_oauth_credentials_authorized_by_user_id": {
+ "name": "IDX_platform_oauth_credentials_authorized_by_user_id",
+ "columns": [
+ {
+ "expression": "authorized_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk": {
+ "name": "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "platform_oauth_credentials",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk": {
+ "name": "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "platform_oauth_credentials",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "authorized_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.referral_code_usages": {
+ "name": "referral_code_usages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "referring_kilo_user_id": {
+ "name": "referring_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redeeming_kilo_user_id": {
+ "name": "redeeming_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "paid_at": {
+ "name": "paid_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_referral_code_usages_redeeming_kilo_user_id": {
+ "name": "IDX_referral_code_usages_redeeming_kilo_user_id",
+ "columns": [
+ {
+ "expression": "redeeming_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_referral_code_usages_redeeming_user_id_code": {
+ "name": "UQ_referral_code_usages_redeeming_user_id_code",
+ "nullsNotDistinct": false,
+ "columns": [
+ "redeeming_kilo_user_id",
+ "referring_kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.referral_codes": {
+ "name": "referral_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "max_redemptions": {
+ "name": "max_redemptions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 10
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_referral_codes_kilo_user_id": {
+ "name": "UQ_referral_codes_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_referral_codes_code": {
+ "name": "IDX_referral_codes_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_check_catalog": {
+ "name": "security_advisor_check_catalog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "check_id": {
+ "name": "check_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "explanation": {
+ "name": "explanation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "risk": {
+ "name": "risk",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_check_catalog_check_id_unique": {
+ "name": "security_advisor_check_catalog_check_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "check_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "security_advisor_check_catalog_severity_check": {
+ "name": "security_advisor_check_catalog_severity_check",
+ "value": "\"security_advisor_check_catalog\".\"severity\" in ('critical', 'warn', 'info')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_content": {
+ "name": "security_advisor_content",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_content_key_unique": {
+ "name": "security_advisor_content_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_kiloclaw_coverage": {
+ "name": "security_advisor_kiloclaw_coverage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "area": {
+ "name": "area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "detail": {
+ "name": "detail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "match_check_ids": {
+ "name": "match_check_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_kiloclaw_coverage_area_unique": {
+ "name": "security_advisor_kiloclaw_coverage_area_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "area"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_scans": {
+ "name": "security_advisor_scans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_platform": {
+ "name": "source_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_method": {
+ "name": "source_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plugin_version": {
+ "name": "plugin_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openclaw_version": {
+ "name": "openclaw_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_ip": {
+ "name": "public_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "findings_critical": {
+ "name": "findings_critical",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "findings_warn": {
+ "name": "findings_warn",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "findings_info": {
+ "name": "findings_info",
+ "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": {
+ "idx_security_advisor_scans_user_created_at": {
+ "name": "idx_security_advisor_scans_user_created_at",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_advisor_scans_created_at": {
+ "name": "idx_security_advisor_scans_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_advisor_scans_platform": {
+ "name": "idx_security_advisor_scans_platform",
+ "columns": [
+ {
+ "expression": "source_platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_agent_commands": {
+ "name": "security_agent_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "command_type": {
+ "name": "command_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'accepted'"
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_metadata": {
+ "name": "result_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_security_agent_commands_org_created": {
+ "name": "idx_security_agent_commands_org_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_user_created": {
+ "name": "idx_security_agent_commands_user_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_status_updated": {
+ "name": "idx_security_agent_commands_status_updated",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_finding_created": {
+ "name": "idx_security_agent_commands_finding_created",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_agent_commands_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_agent_commands_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_commands_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_agent_commands_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_commands_finding_id_security_findings_id_fk": {
+ "name": "security_agent_commands_finding_id_security_findings_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_agent_commands_owner_check": {
+ "name": "security_agent_commands_owner_check",
+ "value": "(\n (\"security_agent_commands\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_commands\".\"owned_by_user_id\" IS NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_agent_commands_type_check": {
+ "name": "security_agent_commands_type_check",
+ "value": "\"security_agent_commands\".\"command_type\" IN ('sync', 'dismiss_finding', 'start_analysis', 'apply_auto_remediation')"
+ },
+ "security_agent_commands_origin_check": {
+ "name": "security_agent_commands_origin_check",
+ "value": "\"security_agent_commands\".\"origin\" IN ('manual', 'dashboard_refresh', 'enable_initial_sync', 'settings_include_existing')"
+ },
+ "security_agent_commands_status_check": {
+ "name": "security_agent_commands_status_check",
+ "value": "\"security_agent_commands\".\"status\" IN ('accepted', 'running', 'succeeded', 'failed', 'no_op')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_agent_repository_sync_state": {
+ "name": "security_agent_repository_sync_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_attempted_at": {
+ "name": "last_attempted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_succeeded_at": {
+ "name": "last_succeeded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_failure_code": {
+ "name": "last_failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_agent_repository_sync_state_org_repo": {
+ "name": "UQ_security_agent_repository_sync_state_org_repo",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_agent_repository_sync_state\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_agent_repository_sync_state_user_repo": {
+ "name": "UQ_security_agent_repository_sync_state_user_repo",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_agent_repository_sync_state\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_agent_repository_sync_state",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_agent_repository_sync_state",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_agent_repository_sync_state_owner_check": {
+ "name": "security_agent_repository_sync_state_owner_check",
+ "value": "(\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_analysis_owner_state": {
+ "name": "security_analysis_owner_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_analysis_enabled_at": {
+ "name": "auto_analysis_enabled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_until": {
+ "name": "blocked_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reason": {
+ "name": "block_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consecutive_actor_resolution_failures": {
+ "name": "consecutive_actor_resolution_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_actor_resolution_failure_at": {
+ "name": "last_actor_resolution_failure_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_analysis_owner_state_org_owner": {
+ "name": "UQ_security_analysis_owner_state_org_owner",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_analysis_owner_state\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_analysis_owner_state_user_owner": {
+ "name": "UQ_security_analysis_owner_state_user_owner",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_analysis_owner_state\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_analysis_owner_state",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_analysis_owner_state",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_analysis_owner_state_owner_check": {
+ "name": "security_analysis_owner_state_owner_check",
+ "value": "(\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_analysis_owner_state_block_reason_check": {
+ "name": "security_analysis_owner_state_block_reason_check",
+ "value": "\"security_analysis_owner_state\".\"block_reason\" IS NULL OR \"security_analysis_owner_state\".\"block_reason\" IN ('INSUFFICIENT_CREDITS', 'ACTOR_RESOLUTION_FAILED', 'OPERATOR_PAUSE')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_analysis_queue": {
+ "name": "security_analysis_queue",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "queue_status": {
+ "name": "queue_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity_rank": {
+ "name": "severity_rank",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_by_job_id": {
+ "name": "claimed_by_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claim_token": {
+ "name": "claim_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "reopen_requeue_count": {
+ "name": "reopen_requeue_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_analysis_queue_finding_id": {
+ "name": "UQ_security_analysis_queue_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_claim_path_org": {
+ "name": "idx_security_analysis_queue_claim_path_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "severity_rank",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_claim_path_user": {
+ "name": "idx_security_analysis_queue_claim_path_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "severity_rank",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_in_flight_org": {
+ "name": "idx_security_analysis_queue_in_flight_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queue_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_in_flight_user": {
+ "name": "idx_security_analysis_queue_in_flight_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queue_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_lag_dashboards": {
+ "name": "idx_security_analysis_queue_lag_dashboards",
+ "columns": [
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_pending_reconciliation": {
+ "name": "idx_security_analysis_queue_pending_reconciliation",
+ "columns": [
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_running_reconciliation": {
+ "name": "idx_security_analysis_queue_running_reconciliation",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'running'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_failure_trend": {
+ "name": "idx_security_analysis_queue_failure_trend",
+ "columns": [
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"failure_code\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_analysis_queue_finding_id_security_findings_id_fk": {
+ "name": "security_analysis_queue_finding_id_security_findings_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_queue_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_analysis_queue_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_analysis_queue_owner_check": {
+ "name": "security_analysis_queue_owner_check",
+ "value": "(\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_analysis_queue_status_check": {
+ "name": "security_analysis_queue_status_check",
+ "value": "\"security_analysis_queue\".\"queue_status\" IN ('queued', 'pending', 'running', 'failed', 'completed')"
+ },
+ "security_analysis_queue_claim_token_required_check": {
+ "name": "security_analysis_queue_claim_token_required_check",
+ "value": "\"security_analysis_queue\".\"queue_status\" NOT IN ('pending', 'running') OR \"security_analysis_queue\".\"claim_token\" IS NOT NULL"
+ },
+ "security_analysis_queue_attempt_count_non_negative_check": {
+ "name": "security_analysis_queue_attempt_count_non_negative_check",
+ "value": "\"security_analysis_queue\".\"attempt_count\" >= 0"
+ },
+ "security_analysis_queue_reopen_requeue_count_non_negative_check": {
+ "name": "security_analysis_queue_reopen_requeue_count_non_negative_check",
+ "value": "\"security_analysis_queue\".\"reopen_requeue_count\" >= 0"
+ },
+ "security_analysis_queue_severity_rank_check": {
+ "name": "security_analysis_queue_severity_rank_check",
+ "value": "\"security_analysis_queue\".\"severity_rank\" IN (0, 1, 2, 3)"
+ },
+ "security_analysis_queue_failure_code_check": {
+ "name": "security_analysis_queue_failure_code_check",
+ "value": "\"security_analysis_queue\".\"failure_code\" IS NULL OR \"security_analysis_queue\".\"failure_code\" IN (\n 'NETWORK_TIMEOUT',\n 'UPSTREAM_5XX',\n 'TEMP_TOKEN_FAILURE',\n 'START_CALL_AMBIGUOUS',\n 'REQUEUE_TEMPORARY_PRECONDITION',\n 'ACTOR_RESOLUTION_FAILED',\n 'GITHUB_TOKEN_UNAVAILABLE',\n 'INVALID_CONFIG',\n 'MISSING_OWNERSHIP',\n 'PERMISSION_DENIED_PERMANENT',\n 'UNSUPPORTED_SEVERITY',\n 'INSUFFICIENT_CREDITS',\n 'STATE_GUARD_REJECTED',\n 'SKIPPED_ALREADY_IN_PROGRESS',\n 'SKIPPED_NO_LONGER_ELIGIBLE',\n 'REOPEN_LOOP_GUARD',\n 'RUN_LOST'\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_audit_log": {
+ "name": "security_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "before_state": {
+ "name": "before_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "after_state": {
+ "name": "after_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_occurred_at": {
+ "name": "source_occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_key": {
+ "name": "event_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_version": {
+ "name": "schema_version",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_snapshot": {
+ "name": "finding_snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_context": {
+ "name": "source_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_security_audit_log_org_created": {
+ "name": "IDX_security_audit_log_org_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_user_created": {
+ "name": "IDX_security_audit_log_user_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_resource": {
+ "name": "IDX_security_audit_log_resource",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_actor": {
+ "name": "IDX_security_audit_log_actor",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_action": {
+ "name": "IDX_security_audit_log_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_audit_log_org_event_key": {
+ "name": "UQ_security_audit_log_org_event_key",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_audit_log_user_event_key": {
+ "name": "UQ_security_audit_log_user_event_key",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_org_occurred": {
+ "name": "IDX_security_audit_log_org_occurred",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_user_occurred": {
+ "name": "IDX_security_audit_log_user_occurred",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_audit_log_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_audit_log_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_audit_log",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_audit_log_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_audit_log_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_audit_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_audit_log_owner_check": {
+ "name": "security_audit_log_owner_check",
+ "value": "(\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NULL) OR (\"security_audit_log\".\"owned_by_user_id\" IS NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL)"
+ },
+ "security_audit_log_action_check": {
+ "name": "security_audit_log_action_check",
+ "value": "\"security_audit_log\".\"action\" IN ('security.finding.created', 'security.finding.severity_changed', 'security.finding.status_change', 'security.finding.dismissed', 'security.finding.auto_dismissed', 'security.finding.superseded', 'security.finding.analysis_started', 'security.finding.analysis_completed', 'security.finding.analysis_failed', 'security.remediation.queued', 'security.remediation.started', 'security.remediation.pr_opened', 'security.remediation.failed', 'security.remediation.blocked', 'security.remediation.no_changes_needed', 'security.remediation.cancelled', 'security.remediation.retried', 'security.finding.deleted', 'security.config.enabled', 'security.config.disabled', 'security.config.updated', 'security.sync.triggered', 'security.sync.completed', 'security.audit_log.exported', 'security.audit_report.generated')"
+ },
+ "security_audit_log_actor_type_check": {
+ "name": "security_audit_log_actor_type_check",
+ "value": "\"security_audit_log\".\"actor_type\" IN ('customer_user', 'kilo_admin', 'system')"
+ },
+ "security_audit_log_source_context_check": {
+ "name": "security_audit_log_source_context_check",
+ "value": "\"security_audit_log\".\"source_context\" IN ('security_sync', 'web', 'analysis_worker', 'remediation_callback', 'rollout_baseline')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_finding_notifications": {
+ "name": "security_finding_notifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient_user_id": {
+ "name": "recipient_user_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": "'staged'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_security_finding_notifications_finding_recipient_kind": {
+ "name": "uq_security_finding_notifications_finding_recipient_kind",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recipient_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_pending": {
+ "name": "idx_security_finding_notifications_pending",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_finding_notifications\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_staged": {
+ "name": "idx_security_finding_notifications_staged",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_finding_notifications\".\"status\" = 'staged'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_finding_id": {
+ "name": "idx_security_finding_notifications_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_recipient_user_id": {
+ "name": "idx_security_finding_notifications_recipient_user_id",
+ "columns": [
+ {
+ "expression": "recipient_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_finding_notifications_finding_fk": {
+ "name": "security_finding_notifications_finding_fk",
+ "tableFrom": "security_finding_notifications",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_finding_notifications_recipient_fk": {
+ "name": "security_finding_notifications_recipient_fk",
+ "tableFrom": "security_finding_notifications",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "recipient_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_finding_notifications_kind_check": {
+ "name": "security_finding_notifications_kind_check",
+ "value": "\"security_finding_notifications\".\"kind\" IN ('new_finding', 'sla_warning', 'sla_breach')"
+ },
+ "security_finding_notifications_status_check": {
+ "name": "security_finding_notifications_status_check",
+ "value": "\"security_finding_notifications\".\"status\" IN ('staged', 'pending', 'sending', 'sent', 'failed', 'cancelled')"
+ },
+ "security_finding_notifications_attempt_count_check": {
+ "name": "security_finding_notifications_attempt_count_check",
+ "value": "\"security_finding_notifications\".\"attempt_count\" >= 0"
+ },
+ "security_finding_notifications_claimed_at_check": {
+ "name": "security_finding_notifications_claimed_at_check",
+ "value": "(\n (\"security_finding_notifications\".\"status\" = 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NULL)\n )"
+ },
+ "security_finding_notifications_sent_at_check": {
+ "name": "security_finding_notifications_sent_at_check",
+ "value": "(\n (\"security_finding_notifications\".\"status\" = 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NULL)\n )"
+ },
+ "security_finding_notifications_error_message_length_check": {
+ "name": "security_finding_notifications_error_message_length_check",
+ "value": "\"security_finding_notifications\".\"error_message\" IS NULL OR length(\"security_finding_notifications\".\"error_message\") <= 500"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_findings": {
+ "name": "security_findings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ghsa_id": {
+ "name": "ghsa_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cve_id": {
+ "name": "cve_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "package_name": {
+ "name": "package_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "package_ecosystem": {
+ "name": "package_ecosystem",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "vulnerable_version_range": {
+ "name": "vulnerable_version_range",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patched_version": {
+ "name": "patched_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manifest_path": {
+ "name": "manifest_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "ignored_reason": {
+ "name": "ignored_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ignored_by": {
+ "name": "ignored_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_at": {
+ "name": "fixed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sla_due_at": {
+ "name": "sla_due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dependabot_html_url": {
+ "name": "dependabot_html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cwe_ids": {
+ "name": "cwe_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cvss_score": {
+ "name": "cvss_score",
+ "type": "numeric(3, 1)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dependency_scope": {
+ "name": "dependency_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_status": {
+ "name": "analysis_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_started_at": {
+ "name": "analysis_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_completed_at": {
+ "name": "analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_error": {
+ "name": "analysis_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis": {
+ "name": "analysis",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_data": {
+ "name": "raw_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_detected_at": {
+ "name": "first_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_security_findings_user_source": {
+ "name": "uq_security_findings_user_source",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_findings\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "uq_security_findings_org_source": {
+ "name": "uq_security_findings_org_source",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_findings\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_org_id": {
+ "name": "idx_security_findings_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_user_id": {
+ "name": "idx_security_findings_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_repo": {
+ "name": "idx_security_findings_repo",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_severity": {
+ "name": "idx_security_findings_severity",
+ "columns": [
+ {
+ "expression": "severity",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_status": {
+ "name": "idx_security_findings_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_package": {
+ "name": "idx_security_findings_package",
+ "columns": [
+ {
+ "expression": "package_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_sla_due_at": {
+ "name": "idx_security_findings_sla_due_at",
+ "columns": [
+ {
+ "expression": "sla_due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_session_id": {
+ "name": "idx_security_findings_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_cli_session_id": {
+ "name": "idx_security_findings_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_analysis_status": {
+ "name": "idx_security_findings_analysis_status",
+ "columns": [
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_org_analysis_in_flight": {
+ "name": "idx_security_findings_org_analysis_in_flight",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_user_analysis_in_flight": {
+ "name": "idx_security_findings_user_analysis_in_flight",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_findings_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_findings_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_findings_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_findings_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_findings_platform_integration_id_platform_integrations_id_fk": {
+ "name": "security_findings_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_findings_owner_check": {
+ "name": "security_findings_owner_check",
+ "value": "(\n (\"security_findings\".\"owned_by_user_id\" IS NOT NULL AND \"security_findings\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_findings\".\"owned_by_user_id\" IS NULL AND \"security_findings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_remediation_attempts": {
+ "name": "security_remediation_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "remediation_id": {
+ "name": "remediation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_number": {
+ "name": "attempt_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "retry_of_attempt_id": {
+ "name": "retry_of_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_by_user_id": {
+ "name": "requested_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_fingerprint": {
+ "name": "analysis_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "analysis_completed_at": {
+ "name": "analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remediation_model_slug": {
+ "name": "remediation_model_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 50
+ },
+ "claim_token": {
+ "name": "claim_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_by_job_id": {
+ "name": "claimed_by_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "launch_attempt_count": {
+ "name": "launch_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "callback_attempt_token_hash": {
+ "name": "callback_attempt_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "structured_result": {
+ "name": "structured_result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_assistant_message": {
+ "name": "final_assistant_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "validation_evidence": {
+ "name": "validation_evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "risk_notes": {
+ "name": "risk_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draft_reason": {
+ "name": "draft_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_draft": {
+ "name": "pr_draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_branch": {
+ "name": "pr_head_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_base_branch": {
+ "name": "pr_base_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_requested_at": {
+ "name": "cancellation_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_requested_by_user_id": {
+ "name": "cancellation_requested_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "launched_at": {
+ "name": "launched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_remediation_attempts_number": {
+ "name": "UQ_security_remediation_attempts_number",
+ "columns": [
+ {
+ "expression": "remediation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "attempt_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_active_finding": {
+ "name": "UQ_security_remediation_attempts_active_finding",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_active_remediation": {
+ "name": "UQ_security_remediation_attempts_active_remediation",
+ "columns": [
+ {
+ "expression": "remediation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_finding_fingerprint_terminal": {
+ "name": "UQ_security_remediation_attempts_finding_fingerprint_terminal",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_org_claim": {
+ "name": "idx_security_remediation_attempts_org_claim",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_user_claim": {
+ "name": "idx_security_remediation_attempts_user_claim",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_repo_claim": {
+ "name": "idx_security_remediation_attempts_repo_claim",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_org_inflight": {
+ "name": "idx_security_remediation_attempts_org_inflight",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_user_inflight": {
+ "name": "idx_security_remediation_attempts_user_inflight",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_repo_inflight": {
+ "name": "idx_security_remediation_attempts_repo_inflight",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_cloud_agent_session": {
+ "name": "idx_security_remediation_attempts_cloud_agent_session",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_finding_fingerprint": {
+ "name": "idx_security_remediation_attempts_finding_fingerprint",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_remediation_attempts_remediation_id_security_remediations_id_fk": {
+ "name": "security_remediation_attempts_remediation_id_security_remediations_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "security_remediations",
+ "columnsFrom": [
+ "remediation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_finding_id_security_findings_id_fk": {
+ "name": "security_remediation_attempts_finding_id_security_findings_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_remediation_attempts_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "requested_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "cancellation_requested_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_remediation_attempts_owner_check": {
+ "name": "security_remediation_attempts_owner_check",
+ "value": "(\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_remediation_attempts_status_check": {
+ "name": "security_remediation_attempts_status_check",
+ "value": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
+ },
+ "security_remediation_attempts_origin_check": {
+ "name": "security_remediation_attempts_origin_check",
+ "value": "\"security_remediation_attempts\".\"origin\" IN ('auto_policy', 'bulk_existing', 'manual')"
+ },
+ "security_remediation_attempts_attempt_number_check": {
+ "name": "security_remediation_attempts_attempt_number_check",
+ "value": "\"security_remediation_attempts\".\"attempt_number\" >= 1"
+ },
+ "security_remediation_attempts_launch_attempt_count_check": {
+ "name": "security_remediation_attempts_launch_attempt_count_check",
+ "value": "\"security_remediation_attempts\".\"launch_attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_remediations": {
+ "name": "security_remediations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "latest_attempt_id": {
+ "name": "latest_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latest_analysis_fingerprint": {
+ "name": "latest_analysis_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latest_analysis_completed_at": {
+ "name": "latest_analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_draft": {
+ "name": "pr_draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_branch": {
+ "name": "pr_head_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_base_branch": {
+ "name": "pr_base_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_summary": {
+ "name": "outcome_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_remediations_finding_id": {
+ "name": "UQ_security_remediations_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_org_status": {
+ "name": "idx_security_remediations_org_status",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_user_status": {
+ "name": "idx_security_remediations_user_status",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_repo_status": {
+ "name": "idx_security_remediations_repo_status",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_latest_attempt": {
+ "name": "idx_security_remediations_latest_attempt",
+ "columns": [
+ {
+ "expression": "latest_attempt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_remediations_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_remediations_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediations_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediations_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediations_finding_id_security_findings_id_fk": {
+ "name": "security_remediations_finding_id_security_findings_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_remediations_owner_check": {
+ "name": "security_remediations_owner_check",
+ "value": "(\n (\"security_remediations\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediations\".\"owned_by_user_id\" IS NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_remediations_status_check": {
+ "name": "security_remediations_status_check",
+ "value": "\"security_remediations\".\"status\" IN ('queued', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.shared_cli_sessions": {
+ "name": "shared_cli_sessions",
+ "schema": "",
+ "columns": {
+ "share_id": {
+ "name": "share_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "shared_state": {
+ "name": "shared_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "api_conversation_history_blob_url": {
+ "name": "api_conversation_history_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_metadata_blob_url": {
+ "name": "task_metadata_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ui_messages_blob_url": {
+ "name": "ui_messages_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_state_blob_url": {
+ "name": "git_state_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_shared_cli_sessions_session_id": {
+ "name": "IDX_shared_cli_sessions_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_shared_cli_sessions_created_at": {
+ "name": "IDX_shared_cli_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_cli_sessions_session_id_cli_sessions_session_id_fk": {
+ "name": "shared_cli_sessions_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "shared_cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "shared_cli_sessions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "shared_cli_sessions_shared_state_check": {
+ "name": "shared_cli_sessions_shared_state_check",
+ "value": "\"shared_cli_sessions\".\"shared_state\" IN ('public', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.slack_bot_requests": {
+ "name": "slack_bot_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slack_team_id": {
+ "name": "slack_team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_team_name": {
+ "name": "slack_team_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slack_channel_id": {
+ "name": "slack_channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_user_id": {
+ "name": "slack_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_thread_ts": {
+ "name": "slack_thread_ts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message": {
+ "name": "user_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message_truncated": {
+ "name": "user_message_truncated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_used": {
+ "name": "model_used",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_calls_made": {
+ "name": "tool_calls_made",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_slack_bot_requests_created_at": {
+ "name": "idx_slack_bot_requests_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_slack_team_id": {
+ "name": "idx_slack_bot_requests_slack_team_id",
+ "columns": [
+ {
+ "expression": "slack_team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_owned_by_org_id": {
+ "name": "idx_slack_bot_requests_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_owned_by_user_id": {
+ "name": "idx_slack_bot_requests_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_status": {
+ "name": "idx_slack_bot_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_event_type": {
+ "name": "idx_slack_bot_requests_event_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_team_created": {
+ "name": "idx_slack_bot_requests_team_created",
+ "columns": [
+ {
+ "expression": "slack_team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "slack_bot_requests_owned_by_organization_id_organizations_id_fk": {
+ "name": "slack_bot_requests_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "slack_bot_requests_platform_integration_id_platform_integrations_id_fk": {
+ "name": "slack_bot_requests_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "slack_bot_requests_owner_check": {
+ "name": "slack_bot_requests_owner_check",
+ "value": "(\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NOT NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NOT NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.source_embeddings": {
+ "name": "source_embeddings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "embedding": {
+ "name": "embedding",
+ "type": "vector(1536)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_hash": {
+ "name": "file_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_line": {
+ "name": "start_line",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_line": {
+ "name": "end_line",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "is_base_branch": {
+ "name": "is_base_branch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_source_embeddings_organization_id": {
+ "name": "IDX_source_embeddings_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_kilo_user_id": {
+ "name": "IDX_source_embeddings_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_project_id": {
+ "name": "IDX_source_embeddings_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_created_at": {
+ "name": "IDX_source_embeddings_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_updated_at": {
+ "name": "IDX_source_embeddings_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_file_path_lower": {
+ "name": "IDX_source_embeddings_file_path_lower",
+ "columns": [
+ {
+ "expression": "LOWER(\"file_path\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_git_branch": {
+ "name": "IDX_source_embeddings_git_branch",
+ "columns": [
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_org_project_branch": {
+ "name": "IDX_source_embeddings_org_project_branch",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "source_embeddings_organization_id_organizations_id_fk": {
+ "name": "source_embeddings_organization_id_organizations_id_fk",
+ "tableFrom": "source_embeddings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "source_embeddings_kilo_user_id_kilocode_users_id_fk": {
+ "name": "source_embeddings_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "source_embeddings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_source_embeddings_org_project_branch_file_lines": {
+ "name": "UQ_source_embeddings_org_project_branch_file_lines",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "project_id",
+ "git_branch",
+ "file_path",
+ "start_line",
+ "end_line"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.stripe_dispute_actions": {
+ "name": "stripe_dispute_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "case_id": {
+ "name": "case_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_key": {
+ "name": "target_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_reference_id": {
+ "name": "result_reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_dispute_actions_case_id": {
+ "name": "IDX_stripe_dispute_actions_case_id",
+ "columns": [
+ {
+ "expression": "case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_actions_claim_path": {
+ "name": "IDX_stripe_dispute_actions_claim_path",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk": {
+ "name": "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk",
+ "tableFrom": "stripe_dispute_actions",
+ "tableTo": "stripe_dispute_cases",
+ "columnsFrom": [
+ "case_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_dispute_actions_case_type_target": {
+ "name": "UQ_stripe_dispute_actions_case_type_target",
+ "nullsNotDistinct": false,
+ "columns": [
+ "case_id",
+ "action_type",
+ "target_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_dispute_actions_action_type_check": {
+ "name": "stripe_dispute_actions_action_type_check",
+ "value": "\"stripe_dispute_actions\".\"action_type\" IN ('stripe_acceptance', 'user_block', 'auto_top_up_disable', 'credit_balance_reset', 'subscription_cancellation', 'access_termination', 'kiloclaw_suspension')"
+ },
+ "stripe_dispute_actions_status_check": {
+ "name": "stripe_dispute_actions_status_check",
+ "value": "\"stripe_dispute_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'skipped')"
+ },
+ "stripe_dispute_actions_attempt_count_non_negative_check": {
+ "name": "stripe_dispute_actions_attempt_count_non_negative_check",
+ "value": "\"stripe_dispute_actions\".\"attempt_count\" >= 0"
+ },
+ "stripe_dispute_actions_target_key_not_empty_check": {
+ "name": "stripe_dispute_actions_target_key_not_empty_check",
+ "value": "length(\"stripe_dispute_actions\".\"target_key\") > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_dispute_cases": {
+ "name": "stripe_dispute_cases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_dispute_id": {
+ "name": "stripe_dispute_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_event_created_at": {
+ "name": "stripe_event_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_intent_id": {
+ "name": "stripe_payment_intent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_minor_units": {
+ "name": "amount_minor_units",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dispute_reason": {
+ "name": "dispute_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_status": {
+ "name": "stripe_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_classification": {
+ "name": "owner_classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'needs_action'"
+ },
+ "status_reason": {
+ "name": "status_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_created_at": {
+ "name": "stripe_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence_due_by": {
+ "name": "evidence_due_by",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by_kilo_user_id": {
+ "name": "accepted_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "acceptance_started_at": {
+ "name": "acceptance_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enforcement_completed_at": {
+ "name": "enforcement_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_required_at": {
+ "name": "review_required_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_dispute_cases_event_id": {
+ "name": "IDX_stripe_dispute_cases_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_charge_id": {
+ "name": "IDX_stripe_dispute_cases_charge_id",
+ "columns": [
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_payment_intent_id": {
+ "name": "IDX_stripe_dispute_cases_payment_intent_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_intent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_customer_id": {
+ "name": "IDX_stripe_dispute_cases_customer_id",
+ "columns": [
+ {
+ "expression": "stripe_customer_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_kilo_user_id": {
+ "name": "IDX_stripe_dispute_cases_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_organization_id": {
+ "name": "IDX_stripe_dispute_cases_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_status_due_by": {
+ "name": "IDX_stripe_dispute_cases_status_due_by",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "evidence_due_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stripe_created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_dispute_cases_organization_id_organizations_id_fk": {
+ "name": "stripe_dispute_cases_organization_id_organizations_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "accepted_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_dispute_cases_dispute_id": {
+ "name": "UQ_stripe_dispute_cases_dispute_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_dispute_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_dispute_cases_owner_classification_check": {
+ "name": "stripe_dispute_cases_owner_classification_check",
+ "value": "\"stripe_dispute_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
+ },
+ "stripe_dispute_cases_status_check": {
+ "name": "stripe_dispute_cases_status_check",
+ "value": "\"stripe_dispute_cases\".\"status\" IN ('needs_action', 'processing', 'accepted', 'acceptance_failed', 'enforcement_failed', 'review_required', 'closed')"
+ },
+ "stripe_dispute_cases_amount_minor_units_non_negative_check": {
+ "name": "stripe_dispute_cases_amount_minor_units_non_negative_check",
+ "value": "\"stripe_dispute_cases\".\"amount_minor_units\" IS NULL OR \"stripe_dispute_cases\".\"amount_minor_units\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_early_fraud_warning_actions": {
+ "name": "stripe_early_fraud_warning_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "case_id": {
+ "name": "case_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_key": {
+ "name": "target_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_reference_id": {
+ "name": "result_reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_early_fraud_warning_actions_case_id": {
+ "name": "IDX_stripe_early_fraud_warning_actions_case_id",
+ "columns": [
+ {
+ "expression": "case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_actions_claim_path": {
+ "name": "IDX_stripe_early_fraud_warning_actions_claim_path",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk": {
+ "name": "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_actions",
+ "tableTo": "stripe_early_fraud_warning_cases",
+ "columnsFrom": [
+ "case_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_early_fraud_warning_actions_case_type_target": {
+ "name": "UQ_stripe_early_fraud_warning_actions_case_type_target",
+ "nullsNotDistinct": false,
+ "columns": [
+ "case_id",
+ "action_type",
+ "target_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_early_fraud_warning_actions_action_type_check": {
+ "name": "stripe_early_fraud_warning_actions_action_type_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"action_type\" IN ('containment', 'refund', 'payment_value_clawback', 'subscription_termination', 'access_termination', 'kiloclaw_suspension', 'affiliate_payout_reversal', 'referral_reward_reversal', 'user_notice')"
+ },
+ "stripe_early_fraud_warning_actions_status_check": {
+ "name": "stripe_early_fraud_warning_actions_status_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'review_required', 'dismissed')"
+ },
+ "stripe_early_fraud_warning_actions_attempt_count_non_negative_check": {
+ "name": "stripe_early_fraud_warning_actions_attempt_count_non_negative_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"attempt_count\" >= 0"
+ },
+ "stripe_early_fraud_warning_actions_target_key_not_empty_check": {
+ "name": "stripe_early_fraud_warning_actions_target_key_not_empty_check",
+ "value": "length(\"stripe_early_fraud_warning_actions\".\"target_key\") > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_early_fraud_warning_cases": {
+ "name": "stripe_early_fraud_warning_cases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_early_fraud_warning_id": {
+ "name": "stripe_early_fraud_warning_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_intent_id": {
+ "name": "stripe_payment_intent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_minor_units": {
+ "name": "amount_minor_units",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_classification": {
+ "name": "owner_classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warning_created_at": {
+ "name": "warning_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contained_at": {
+ "name": "contained_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processing_started_at": {
+ "name": "processing_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_required_at": {
+ "name": "review_required_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remediated_at": {
+ "name": "remediated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dismissed_at": {
+ "name": "dismissed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_early_fraud_warning_cases_event_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_charge_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_charge_id",
+ "columns": [
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_payment_intent_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_payment_intent_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_intent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_customer_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_customer_id",
+ "columns": [
+ {
+ "expression": "stripe_customer_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_kilo_user_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_organization_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_status_created_at": {
+ "name": "IDX_stripe_early_fraud_warning_cases_status_created_at",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk": {
+ "name": "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_cases",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_early_fraud_warning_cases_warning_id": {
+ "name": "UQ_stripe_early_fraud_warning_cases_warning_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_early_fraud_warning_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_early_fraud_warning_cases_owner_classification_check": {
+ "name": "stripe_early_fraud_warning_cases_owner_classification_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
+ },
+ "stripe_early_fraud_warning_cases_status_check": {
+ "name": "stripe_early_fraud_warning_cases_status_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"status\" IN ('queued', 'contained', 'processing', 'completed', 'review_required', 'failed', 'remediated', 'dismissed')"
+ },
+ "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check": {
+ "name": "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"amount_minor_units\" IS NULL OR \"stripe_early_fraud_warning_cases\".\"amount_minor_units\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stytch_fingerprints": {
+ "name": "stytch_fingerprints",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visitor_fingerprint": {
+ "name": "visitor_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "browser_fingerprint": {
+ "name": "browser_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "browser_id": {
+ "name": "browser_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hardware_fingerprint": {
+ "name": "hardware_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "network_fingerprint": {
+ "name": "network_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visitor_id": {
+ "name": "visitor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verdict_action": {
+ "name": "verdict_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "detected_device_type": {
+ "name": "detected_device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_authentic_device": {
+ "name": "is_authentic_device",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reasons": {
+ "name": "reasons",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{\"\"}'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fingerprint_data": {
+ "name": "fingerprint_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_free_tier_allowed": {
+ "name": "kilo_free_tier_allowed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_hardware_fingerprint": {
+ "name": "idx_hardware_fingerprint",
+ "columns": [
+ {
+ "expression": "hardware_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_kilo_user_id": {
+ "name": "idx_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_stytch_fingerprints_reasons_gin": {
+ "name": "idx_stytch_fingerprints_reasons_gin",
+ "columns": [
+ {
+ "expression": "reasons",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ },
+ "idx_verdict_action": {
+ "name": "idx_verdict_action",
+ "columns": [
+ {
+ "expression": "verdict_action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_visitor_fingerprint": {
+ "name": "idx_visitor_fingerprint",
+ "columns": [
+ {
+ "expression": "visitor_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "schema": "",
+ "columns": {
+ "system_prompt_prefix_id": {
+ "name": "system_prompt_prefix_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_system_prompt_prefix": {
+ "name": "UQ_system_prompt_prefix",
+ "columns": [
+ {
+ "expression": "system_prompt_prefix",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.transactional_email_log": {
+ "name": "transactional_email_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_type": {
+ "name": "email_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_transactional_email_log_type_idempotency_key": {
+ "name": "UQ_transactional_email_log_type_idempotency_key",
+ "columns": [
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_transactional_email_log_user_id": {
+ "name": "IDX_transactional_email_log_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_transactional_email_log_organization_id": {
+ "name": "IDX_transactional_email_log_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "transactional_email_log_user_id_kilocode_users_id_fk": {
+ "name": "transactional_email_log_user_id_kilocode_users_id_fk",
+ "tableFrom": "transactional_email_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "transactional_email_log_organization_id_organizations_id_fk": {
+ "name": "transactional_email_log_organization_id_organizations_id_fk",
+ "tableFrom": "transactional_email_log",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_transactional_email_log_owner": {
+ "name": "CHK_transactional_email_log_owner",
+ "value": "\"transactional_email_log\".\"user_id\" IS NOT NULL OR \"transactional_email_log\".\"organization_id\" IS NOT NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_admin_notes": {
+ "name": "user_admin_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note_content": {
+ "name": "note_content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "admin_kilo_user_id": {
+ "name": "admin_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_34517df0b385234babc38fe81b": {
+ "name": "IDX_34517df0b385234babc38fe81b",
+ "columns": [
+ {
+ "expression": "admin_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_ccbde98c4c14046daa5682ec4f": {
+ "name": "IDX_ccbde98c4c14046daa5682ec4f",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_d0270eb24ef6442d65a0b7853c": {
+ "name": "IDX_d0270eb24ef6442d65a0b7853c",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_affiliate_attributions": {
+ "name": "user_affiliate_attributions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tracking_id": {
+ "name": "tracking_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_affiliate_attributions_user_id": {
+ "name": "IDX_user_affiliate_attributions_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_affiliate_attributions_user_id_kilocode_users_id_fk": {
+ "name": "user_affiliate_attributions_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_affiliate_attributions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_user_affiliate_attributions_user_provider": {
+ "name": "UQ_user_affiliate_attributions_user_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "provider"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "user_affiliate_attributions_provider_check": {
+ "name": "user_affiliate_attributions_provider_check",
+ "value": "\"user_affiliate_attributions\".\"provider\" IN ('impact')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_affiliate_events": {
+ "name": "user_affiliate_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_event_id": {
+ "name": "parent_event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delivery_state": {
+ "name": "delivery_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_action_id": {
+ "name": "impact_action_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_submission_uri": {
+ "name": "impact_submission_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_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": {
+ "IDX_user_affiliate_events_claim_path": {
+ "name": "IDX_user_affiliate_events_claim_path",
+ "columns": [
+ {
+ "expression": "delivery_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_affiliate_events_parent_event_id": {
+ "name": "IDX_user_affiliate_events_parent_event_id",
+ "columns": [
+ {
+ "expression": "parent_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_affiliate_events_provider_event_type_charge": {
+ "name": "IDX_user_affiliate_events_provider_event_type_charge",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_affiliate_events_user_id_kilocode_users_id_fk": {
+ "name": "user_affiliate_events_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_affiliate_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_affiliate_events_parent_event_id_fk": {
+ "name": "user_affiliate_events_parent_event_id_fk",
+ "tableFrom": "user_affiliate_events",
+ "tableTo": "user_affiliate_events",
+ "columnsFrom": [
+ "parent_event_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_user_affiliate_events_dedupe_key": {
+ "name": "UQ_user_affiliate_events_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "user_affiliate_events_provider_check": {
+ "name": "user_affiliate_events_provider_check",
+ "value": "\"user_affiliate_events\".\"provider\" IN ('impact')"
+ },
+ "user_affiliate_events_event_type_check": {
+ "name": "user_affiliate_events_event_type_check",
+ "value": "\"user_affiliate_events\".\"event_type\" IN ('signup', 'trial_start', 'trial_end', 'sale', 'sale_reversal')"
+ },
+ "user_affiliate_events_delivery_state_check": {
+ "name": "user_affiliate_events_delivery_state_check",
+ "value": "\"user_affiliate_events\".\"delivery_state\" IN ('queued', 'blocked', 'sending', 'delivered', 'failed')"
+ },
+ "user_affiliate_events_attempt_count_non_negative_check": {
+ "name": "user_affiliate_events_attempt_count_non_negative_check",
+ "value": "\"user_affiliate_events\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_auth_provider": {
+ "name": "user_auth_provider",
+ "schema": "",
+ "columns": {
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_account_id": {
+ "name": "provider_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hosted_domain": {
+ "name": "hosted_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_auth_provider_kilo_user_id": {
+ "name": "IDX_user_auth_provider_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_auth_provider_hosted_domain": {
+ "name": "IDX_user_auth_provider_hosted_domain",
+ "columns": [
+ {
+ "expression": "hosted_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "user_auth_provider_provider_provider_account_id_pk": {
+ "name": "user_auth_provider_provider_provider_account_id_pk",
+ "columns": [
+ "provider",
+ "provider_account_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feedback": {
+ "name": "user_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feedback_for": {
+ "name": "feedback_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "feedback_batch": {
+ "name": "feedback_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "context_json": {
+ "name": "context_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_feedback_created_at": {
+ "name": "IDX_user_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_kilo_user_id": {
+ "name": "IDX_user_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_feedback_for": {
+ "name": "IDX_user_feedback_feedback_for",
+ "columns": [
+ {
+ "expression": "feedback_for",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_feedback_batch": {
+ "name": "IDX_user_feedback_feedback_batch",
+ "columns": [
+ {
+ "expression": "feedback_batch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_source": {
+ "name": "IDX_user_feedback_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_github_app_tokens": {
+ "name": "user_github_app_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_app_type": {
+ "name": "github_app_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'standard'"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_encrypted": {
+ "name": "access_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_reason": {
+ "name": "revocation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_user_github_app_tokens_user_app": {
+ "name": "UQ_user_github_app_tokens_user_app",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "github_app_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_github_app_tokens_github_user_app": {
+ "name": "UQ_user_github_app_tokens_github_user_app",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "github_app_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_github_app_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_github_app_tokens_app_type_check": {
+ "name": "user_github_app_tokens_app_type_check",
+ "value": "\"user_github_app_tokens\".\"github_app_type\" IN ('standard', 'lite')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_period_cache": {
+ "name": "user_period_cache",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_type": {
+ "name": "cache_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_type": {
+ "name": "period_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_key": {
+ "name": "period_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "computed_at": {
+ "name": "computed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "shared_url_token": {
+ "name": "shared_url_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "shared_at": {
+ "name": "shared_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_user_period_cache_kilo_user_id": {
+ "name": "IDX_user_period_cache_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_period_cache": {
+ "name": "UQ_user_period_cache",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "cache_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_period_cache_lookup": {
+ "name": "IDX_user_period_cache_lookup",
+ "columns": [
+ {
+ "expression": "cache_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_period_cache_share_token": {
+ "name": "UQ_user_period_cache_share_token",
+ "columns": [
+ {
+ "expression": "shared_url_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_period_cache\".\"shared_url_token\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_period_cache_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_period_cache_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_period_cache",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_period_cache_period_type_check": {
+ "name": "user_period_cache_period_type_check",
+ "value": "\"user_period_cache\".\"period_type\" IN ('year', 'quarter', 'month', 'week', 'custom')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_push_tokens": {
+ "name": "user_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_user_push_tokens_token": {
+ "name": "UQ_user_push_tokens_token",
+ "columns": [
+ {
+ "expression": "token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_push_tokens_user_id": {
+ "name": "IDX_user_push_tokens_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_push_tokens_user_id_kilocode_users_id_fk": {
+ "name": "user_push_tokens_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_push_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.vercel_ip_city": {
+ "name": "vercel_ip_city",
+ "schema": "",
+ "columns": {
+ "vercel_ip_city_id": {
+ "name": "vercel_ip_city_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "vercel_ip_city": {
+ "name": "vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_vercel_ip_city": {
+ "name": "UQ_vercel_ip_city",
+ "columns": [
+ {
+ "expression": "vercel_ip_city",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.vercel_ip_country": {
+ "name": "vercel_ip_country",
+ "schema": "",
+ "columns": {
+ "vercel_ip_country_id": {
+ "name": "vercel_ip_country_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "vercel_ip_country": {
+ "name": "vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_vercel_ip_country": {
+ "name": "UQ_vercel_ip_country",
+ "columns": [
+ {
+ "expression": "vercel_ip_country",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook_events": {
+ "name": "webhook_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_action": {
+ "name": "event_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "headers": {
+ "name": "headers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "processed": {
+ "name": "processed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "handlers_triggered": {
+ "name": "handlers_triggered",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "errors": {
+ "name": "errors",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_signature": {
+ "name": "event_signature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_webhook_events_owned_by_org_id": {
+ "name": "IDX_webhook_events_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_owned_by_user_id": {
+ "name": "IDX_webhook_events_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_platform": {
+ "name": "IDX_webhook_events_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_event_type": {
+ "name": "IDX_webhook_events_event_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_created_at": {
+ "name": "IDX_webhook_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_events_owned_by_organization_id_organizations_id_fk": {
+ "name": "webhook_events_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "webhook_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "webhook_events_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "webhook_events_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "webhook_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_webhook_events_signature": {
+ "name": "UQ_webhook_events_signature",
+ "nullsNotDistinct": false,
+ "columns": [
+ "event_signature"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "webhook_events_owner_check": {
+ "name": "webhook_events_owner_check",
+ "value": "(\n (\"webhook_events\".\"owned_by_user_id\" IS NOT NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"webhook_events\".\"owned_by_user_id\" IS NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {
+ "public.microdollar_usage_view": {
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_write_tokens": {
+ "name": "cache_write_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_hit_tokens": {
+ "name": "cache_hit_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_model": {
+ "name": "requested_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_prompt_prefix": {
+ "name": "user_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_length": {
+ "name": "system_prompt_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_discount": {
+ "name": "cache_discount",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_tokens": {
+ "name": "max_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_middle_out_transform": {
+ "name": "has_middle_out_transform",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_error": {
+ "name": "has_error",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "abuse_classification": {
+ "name": "abuse_classification",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_provider": {
+ "name": "inference_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "upstream_id": {
+ "name": "upstream_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finish_reason": {
+ "name": "finish_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency": {
+ "name": "latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderation_latency": {
+ "name": "moderation_latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_time": {
+ "name": "generation_time",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_byok": {
+ "name": "is_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_user_byok": {
+ "name": "is_user_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "streamed": {
+ "name": "streamed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled": {
+ "name": "cancelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_name": {
+ "name": "editor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_kind": {
+ "name": "api_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_tools": {
+ "name": "has_tools",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "machine_id": {
+ "name": "machine_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_model": {
+ "name": "auto_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_cost": {
+ "name": "market_cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_delay": {
+ "name": "abuse_delay",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_downgraded_from": {
+ "name": "abuse_downgraded_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "definition": "\n SELECT\n mu.id,\n mu.kilo_user_id,\n meta.message_id,\n mu.cost,\n mu.input_tokens,\n mu.output_tokens,\n mu.cache_write_tokens,\n mu.cache_hit_tokens,\n mu.created_at,\n ip.http_ip AS http_x_forwarded_for,\n city.vercel_ip_city AS http_x_vercel_ip_city,\n country.vercel_ip_country AS http_x_vercel_ip_country,\n meta.vercel_ip_latitude AS http_x_vercel_ip_latitude,\n meta.vercel_ip_longitude AS http_x_vercel_ip_longitude,\n ja4.ja4_digest AS http_x_vercel_ja4_digest,\n mu.provider,\n mu.model,\n mu.requested_model,\n meta.user_prompt_prefix,\n spp.system_prompt_prefix,\n meta.system_prompt_length,\n ua.http_user_agent,\n mu.cache_discount,\n meta.max_tokens,\n meta.has_middle_out_transform,\n mu.has_error,\n mu.abuse_classification,\n mu.organization_id,\n mu.inference_provider,\n mu.project_id,\n meta.status_code,\n meta.upstream_id,\n frfr.finish_reason,\n meta.latency,\n meta.moderation_latency,\n meta.generation_time,\n meta.is_byok,\n meta.is_user_byok,\n meta.streamed,\n meta.cancelled,\n edit.editor_name,\n ak.api_kind,\n meta.has_tools,\n meta.machine_id,\n feat.feature,\n meta.session_id,\n md.mode,\n am.auto_model,\n meta.market_cost,\n meta.is_free,\n meta.abuse_delay,\n meta.abuse_downgraded_from\n FROM \"microdollar_usage\" mu\n LEFT JOIN \"microdollar_usage_metadata\" meta ON mu.id = meta.id\n LEFT JOIN \"http_ip\" ip ON meta.http_ip_id = ip.http_ip_id\n LEFT JOIN \"vercel_ip_city\" city ON meta.vercel_ip_city_id = city.vercel_ip_city_id\n LEFT JOIN \"vercel_ip_country\" country ON meta.vercel_ip_country_id = country.vercel_ip_country_id\n LEFT JOIN \"ja4_digest\" ja4 ON meta.ja4_digest_id = ja4.ja4_digest_id\n LEFT JOIN \"system_prompt_prefix\" spp ON meta.system_prompt_prefix_id = spp.system_prompt_prefix_id\n LEFT JOIN \"http_user_agent\" ua ON meta.http_user_agent_id = ua.http_user_agent_id\n LEFT JOIN \"finish_reason\" frfr ON meta.finish_reason_id = frfr.finish_reason_id\n LEFT JOIN \"editor_name\" edit ON meta.editor_name_id = edit.editor_name_id\n LEFT JOIN \"api_kind\" ak ON meta.api_kind_id = ak.api_kind_id\n LEFT JOIN \"feature\" feat ON meta.feature_id = feat.feature_id\n LEFT JOIN \"mode\" md ON meta.mode_id = md.mode_id\n LEFT JOIN \"auto_model\" am ON meta.auto_model_id = am.auto_model_id\n",
+ "name": "microdollar_usage_view",
+ "schema": "public",
+ "isExisting": false,
+ "materialized": false
+ }
+ },
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.json
index 819761c75c..c2f94e49f4 100644
--- a/packages/db/src/migrations/meta/_journal.json
+++ b/packages/db/src/migrations/meta/_journal.json
@@ -1219,6 +1219,13 @@
"when": 1782381719017,
"tag": "0173_lowly_venom",
"breakpoints": true
+ },
+ {
+ "idx": 174,
+ "version": "7",
+ "when": 1782399504008,
+ "tag": "0174_massive_drax",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts
index 0a2d453346..9d797df9aa 100644
--- a/packages/db/src/schema.ts
+++ b/packages/db/src/schema.ts
@@ -2621,6 +2621,7 @@ export const organizations = pgTable(
{
id: idPrimaryKeyColumn,
name: text().notNull(),
+ slug: text().unique(),
created_at: timestamp({ withTimezone: true, mode: 'string' }).defaultNow().notNull(),
updated_at: timestamp({ withTimezone: true, mode: 'string' })
.defaultNow()
From 4d088870499fb21e0f06fbd01244ecd3c740e6a2 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 10:55:29 -0500
Subject: [PATCH 02/33] Undo migration
---
.../db/src/migrations/0174_massive_drax.sql | 2 -
.../db/src/migrations/meta/0174_snapshot.json | 32112 ----------------
packages/db/src/migrations/meta/_journal.json | 7 -
packages/db/src/schema.ts | 3 +-
4 files changed, 2 insertions(+), 32122 deletions(-)
delete mode 100644 packages/db/src/migrations/0174_massive_drax.sql
delete mode 100644 packages/db/src/migrations/meta/0174_snapshot.json
diff --git a/packages/db/src/migrations/0174_massive_drax.sql b/packages/db/src/migrations/0174_massive_drax.sql
deleted file mode 100644
index 513810a08e..0000000000
--- a/packages/db/src/migrations/0174_massive_drax.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE "organizations" ADD COLUMN "slug" text;--> statement-breakpoint
-ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_unique" UNIQUE("slug");
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/0174_snapshot.json b/packages/db/src/migrations/meta/0174_snapshot.json
deleted file mode 100644
index 6ed208920e..0000000000
--- a/packages/db/src/migrations/meta/0174_snapshot.json
+++ /dev/null
@@ -1,32112 +0,0 @@
-{
- "id": "3cf41bc8-067b-4620-8dbe-522443a39b69",
- "prevId": "06265fd6-428e-4b7d-9092-dba307d6255e",
- "version": "7",
- "dialect": "postgresql",
- "tables": {
- "public.agent_configs": {
- "name": "agent_configs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "agent_type": {
- "name": "agent_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "is_enabled": {
- "name": "is_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "runtime_state": {
- "name": "runtime_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false,
- "default": "'{}'::jsonb"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_configs_org_id": {
- "name": "IDX_agent_configs_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_configs_owned_by_user_id": {
- "name": "IDX_agent_configs_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_configs_agent_type": {
- "name": "IDX_agent_configs_agent_type",
- "columns": [
- {
- "expression": "agent_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_configs_platform": {
- "name": "IDX_agent_configs_platform",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_configs_owned_by_organization_id_organizations_id_fk": {
- "name": "agent_configs_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "agent_configs",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_configs_owned_by_user_id_kilocode_users_id_fk": {
- "name": "agent_configs_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "agent_configs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_configs_org_agent_platform": {
- "name": "UQ_agent_configs_org_agent_platform",
- "nullsNotDistinct": false,
- "columns": [
- "owned_by_organization_id",
- "agent_type",
- "platform"
- ]
- },
- "UQ_agent_configs_user_agent_platform": {
- "name": "UQ_agent_configs_user_agent_platform",
- "nullsNotDistinct": false,
- "columns": [
- "owned_by_user_id",
- "agent_type",
- "platform"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "agent_configs_owner_check": {
- "name": "agent_configs_owner_check",
- "value": "(\n (\"agent_configs\".\"owned_by_user_id\" IS NOT NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_configs\".\"owned_by_user_id\" IS NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "agent_configs_agent_type_check": {
- "name": "agent_configs_agent_type_check",
- "value": "\"agent_configs\".\"agent_type\" IN ('code_review', 'auto_triage', 'auto_fix', 'security_scan')"
- }
- },
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_agents": {
- "name": "agent_environment_profile_agents",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_agents_profile_id": {
- "name": "IDX_agent_env_profile_agents_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_agents",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_agents_profile_slug": {
- "name": "UQ_agent_env_profile_agents_profile_slug",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_commands": {
- "name": "agent_environment_profile_commands",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "sequence": {
- "name": "sequence",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "command": {
- "name": "command",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_commands_profile_id": {
- "name": "IDX_agent_env_profile_commands_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_commands",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_commands_profile_sequence": {
- "name": "UQ_agent_env_profile_commands_profile_sequence",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "sequence"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_kilo_commands": {
- "name": "agent_environment_profile_kilo_commands",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "template": {
- "name": "template",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "agent": {
- "name": "agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "subtask": {
- "name": "subtask",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "sort_order": {
- "name": "sort_order",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_kilo_cmds_profile_id": {
- "name": "IDX_agent_env_profile_kilo_cmds_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_kilo_commands",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_kilo_cmds_profile_name": {
- "name": "UQ_agent_env_profile_kilo_cmds_profile_name",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_mcp_servers": {
- "name": "agent_environment_profile_mcp_servers",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "timeout": {
- "name": "timeout",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_mcp_servers_profile_id": {
- "name": "IDX_agent_env_profile_mcp_servers_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_mcp_servers",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_mcp_servers_profile_name": {
- "name": "UQ_agent_env_profile_mcp_servers_profile_name",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_repo_bindings": {
- "name": "agent_environment_profile_repo_bindings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_agent_env_profile_repo_bindings_user": {
- "name": "UQ_agent_env_profile_repo_bindings_user",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profile_repo_bindings_org": {
- "name": "UQ_agent_env_profile_repo_bindings_org",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_repo_bindings",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk": {
- "name": "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "agent_environment_profile_repo_bindings",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk": {
- "name": "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "agent_environment_profile_repo_bindings",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "agent_env_profile_repo_bindings_owner_check": {
- "name": "agent_env_profile_repo_bindings_owner_check",
- "value": "(\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_skills": {
- "name": "agent_environment_profile_skills",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_type": {
- "name": "source_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_url": {
- "name": "source_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "raw_markdown": {
- "name": "raw_markdown",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "files": {
- "name": "files",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_skills_profile_id": {
- "name": "IDX_agent_env_profile_skills_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_skills",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_skills_profile_name": {
- "name": "UQ_agent_env_profile_skills_profile_name",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_vars": {
- "name": "agent_environment_profile_vars",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "key": {
- "name": "key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_secret": {
- "name": "is_secret",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_vars_profile_id": {
- "name": "IDX_agent_env_profile_vars_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_vars",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_vars_profile_key": {
- "name": "UQ_agent_env_profile_vars_profile_key",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profiles": {
- "name": "agent_environment_profiles",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_default": {
- "name": "is_default",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_agent_env_profiles_org_name": {
- "name": "UQ_agent_env_profiles_org_name",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profiles_user_name": {
- "name": "UQ_agent_env_profiles_user_name",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profiles_org_default": {
- "name": "UQ_agent_env_profiles_org_default",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profiles_user_default": {
- "name": "UQ_agent_env_profiles_user_default",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_env_profiles_org_id": {
- "name": "IDX_agent_env_profiles_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_env_profiles_user_id": {
- "name": "IDX_agent_env_profiles_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_env_profiles_created_by_user_id": {
- "name": "IDX_agent_env_profiles_created_by_user_id",
- "columns": [
- {
- "expression": "created_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profiles_owned_by_organization_id_organizations_id_fk": {
- "name": "agent_environment_profiles_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "agent_environment_profiles",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk": {
- "name": "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "agent_environment_profiles",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "agent_env_profiles_owner_check": {
- "name": "agent_env_profiles_owner_check",
- "value": "(\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.api_kind": {
- "name": "api_kind",
- "schema": "",
- "columns": {
- "api_kind_id": {
- "name": "api_kind_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "api_kind": {
- "name": "api_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_api_kind": {
- "name": "UQ_api_kind",
- "columns": [
- {
- "expression": "api_kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.api_request_compress_log": {
- "name": "api_request_compress_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "bigserial",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "request": {
- "name": "request",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "result": {
- "name": "result",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "idx_api_request_compress_log_created_at": {
- "name": "idx_api_request_compress_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.api_request_log": {
- "name": "api_request_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "bigserial",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status_code": {
- "name": "status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "request": {
- "name": "request",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response": {
- "name": "response",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error": {
- "name": "error",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_api_request_log_created_at": {
- "name": "idx_api_request_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_builder_feedback": {
- "name": "app_builder_feedback",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "preview_status": {
- "name": "preview_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_streaming": {
- "name": "is_streaming",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "message_count": {
- "name": "message_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "feedback_text": {
- "name": "feedback_text",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "recent_messages": {
- "name": "recent_messages",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_app_builder_feedback_created_at": {
- "name": "IDX_app_builder_feedback_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_feedback_kilo_user_id": {
- "name": "IDX_app_builder_feedback_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_feedback_project_id": {
- "name": "IDX_app_builder_feedback_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "app_builder_feedback_kilo_user_id_kilocode_users_id_fk": {
- "name": "app_builder_feedback_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "app_builder_feedback",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "app_builder_feedback_project_id_app_builder_projects_id_fk": {
- "name": "app_builder_feedback_project_id_app_builder_projects_id_fk",
- "tableFrom": "app_builder_feedback",
- "tableTo": "app_builder_projects",
- "columnsFrom": [
- "project_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_builder_project_sessions": {
- "name": "app_builder_project_sessions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "project_id": {
- "name": "project_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_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
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "worker_version": {
- "name": "worker_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'v2'"
- }
- },
- "indexes": {
- "IDX_app_builder_project_sessions_project_id": {
- "name": "IDX_app_builder_project_sessions_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "app_builder_project_sessions_project_id_app_builder_projects_id_fk": {
- "name": "app_builder_project_sessions_project_id_app_builder_projects_id_fk",
- "tableFrom": "app_builder_project_sessions",
- "tableTo": "app_builder_projects",
- "columnsFrom": [
- "project_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_app_builder_project_sessions_cloud_agent_session_id": {
- "name": "UQ_app_builder_project_sessions_cloud_agent_session_id",
- "nullsNotDistinct": false,
- "columns": [
- "cloud_agent_session_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_builder_projects": {
- "name": "app_builder_projects",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model_id": {
- "name": "model_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "template": {
- "name": "template",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "last_message_at": {
- "name": "last_message_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "git_repo_full_name": {
- "name": "git_repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_platform_integration_id": {
- "name": "git_platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "migrated_at": {
- "name": "migrated_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_app_builder_projects_created_by_user_id": {
- "name": "IDX_app_builder_projects_created_by_user_id",
- "columns": [
- {
- "expression": "created_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_owned_by_user_id": {
- "name": "IDX_app_builder_projects_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_owned_by_organization_id": {
- "name": "IDX_app_builder_projects_owned_by_organization_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_created_at": {
- "name": "IDX_app_builder_projects_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_last_message_at": {
- "name": "IDX_app_builder_projects_last_message_at",
- "columns": [
- {
- "expression": "last_message_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_git_repo_integration": {
- "name": "IDX_app_builder_projects_git_repo_integration",
- "columns": [
- {
- "expression": "git_repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"app_builder_projects\".\"git_repo_full_name\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "app_builder_projects_owned_by_user_id_kilocode_users_id_fk": {
- "name": "app_builder_projects_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "app_builder_projects_owned_by_organization_id_organizations_id_fk": {
- "name": "app_builder_projects_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "app_builder_projects_deployment_id_deployments_id_fk": {
- "name": "app_builder_projects_deployment_id_deployments_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk": {
- "name": "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "git_platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "app_builder_projects_owner_check": {
- "name": "app_builder_projects_owner_check",
- "value": "(\n (\"app_builder_projects\".\"owned_by_user_id\" IS NOT NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NULL) OR\n (\"app_builder_projects\".\"owned_by_user_id\" IS NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.app_min_versions": {
- "name": "app_min_versions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "ios_min_version": {
- "name": "ios_min_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'1.0.0'"
- },
- "android_min_version": {
- "name": "android_min_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'1.0.0'"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_reported_messages": {
- "name": "app_reported_messages",
- "schema": "",
- "columns": {
- "report_id": {
- "name": "report_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "report_type": {
- "name": "report_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "signature": {
- "name": "signature",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "message": {
- "name": "message",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "app_reported_messages_cli_session_id_cli_sessions_session_id_fk": {
- "name": "app_reported_messages_cli_session_id_cli_sessions_session_id_fk",
- "tableFrom": "app_reported_messages",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "cli_session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.auto_fix_tickets": {
- "name": "auto_fix_tickets",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "triage_ticket_id": {
- "name": "triage_ticket_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_number": {
- "name": "issue_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "issue_url": {
- "name": "issue_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_title": {
- "name": "issue_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_body": {
- "name": "issue_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "issue_author": {
- "name": "issue_author",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_labels": {
- "name": "issue_labels",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false,
- "default": "'{}'"
- },
- "trigger_source": {
- "name": "trigger_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'label'"
- },
- "review_comment_id": {
- "name": "review_comment_id",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "review_comment_body": {
- "name": "review_comment_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "file_path": {
- "name": "file_path",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "line_number": {
- "name": "line_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "diff_hunk": {
- "name": "diff_hunk",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_ref": {
- "name": "pr_head_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "classification": {
- "name": "classification",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "confidence": {
- "name": "confidence",
- "type": "numeric(3, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "intent_summary": {
- "name": "intent_summary",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "related_files": {
- "name": "related_files",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_branch": {
- "name": "pr_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_auto_fix_tickets_repo_issue": {
- "name": "UQ_auto_fix_tickets_repo_issue",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "issue_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_fix_tickets\".\"trigger_source\" = 'label'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_auto_fix_tickets_repo_review_comment": {
- "name": "UQ_auto_fix_tickets_repo_review_comment",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "review_comment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_fix_tickets\".\"review_comment_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_owned_by_org": {
- "name": "IDX_auto_fix_tickets_owned_by_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_owned_by_user": {
- "name": "IDX_auto_fix_tickets_owned_by_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_status": {
- "name": "IDX_auto_fix_tickets_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_created_at": {
- "name": "IDX_auto_fix_tickets_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_triage_ticket_id": {
- "name": "IDX_auto_fix_tickets_triage_ticket_id",
- "columns": [
- {
- "expression": "triage_ticket_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_session_id": {
- "name": "IDX_auto_fix_tickets_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "auto_fix_tickets_owned_by_organization_id_organizations_id_fk": {
- "name": "auto_fix_tickets_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk": {
- "name": "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk": {
- "name": "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk": {
- "name": "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "auto_triage_tickets",
- "columnsFrom": [
- "triage_ticket_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk": {
- "name": "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "cli_session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "auto_fix_tickets_owner_check": {
- "name": "auto_fix_tickets_owner_check",
- "value": "(\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "auto_fix_tickets_status_check": {
- "name": "auto_fix_tickets_status_check",
- "value": "\"auto_fix_tickets\".\"status\" IN ('pending', 'running', 'completed', 'failed', 'cancelled')"
- },
- "auto_fix_tickets_classification_check": {
- "name": "auto_fix_tickets_classification_check",
- "value": "\"auto_fix_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'unclear')"
- },
- "auto_fix_tickets_confidence_check": {
- "name": "auto_fix_tickets_confidence_check",
- "value": "\"auto_fix_tickets\".\"confidence\" >= 0 AND \"auto_fix_tickets\".\"confidence\" <= 1"
- },
- "auto_fix_tickets_trigger_source_check": {
- "name": "auto_fix_tickets_trigger_source_check",
- "value": "\"auto_fix_tickets\".\"trigger_source\" IN ('label', 'review_comment')"
- }
- },
- "isRLSEnabled": false
- },
- "public.auto_model": {
- "name": "auto_model",
- "schema": "",
- "columns": {
- "auto_model_id": {
- "name": "auto_model_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "auto_model": {
- "name": "auto_model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_auto_model": {
- "name": "UQ_auto_model",
- "columns": [
- {
- "expression": "auto_model",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.auto_top_up_configs": {
- "name": "auto_top_up_configs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_method_id": {
- "name": "stripe_payment_method_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_cents": {
- "name": "amount_cents",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 5000
- },
- "last_auto_top_up_at": {
- "name": "last_auto_top_up_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_started_at": {
- "name": "attempt_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "disabled_reason": {
- "name": "disabled_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_auto_top_up_configs_owned_by_user_id": {
- "name": "UQ_auto_top_up_configs_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_auto_top_up_configs_owned_by_organization_id": {
- "name": "UQ_auto_top_up_configs_owned_by_organization_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk": {
- "name": "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "auto_top_up_configs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "auto_top_up_configs_owned_by_organization_id_organizations_id_fk": {
- "name": "auto_top_up_configs_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "auto_top_up_configs",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "auto_top_up_configs_exactly_one_owner": {
- "name": "auto_top_up_configs_exactly_one_owner",
- "value": "(\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NULL) OR (\"auto_top_up_configs\".\"owned_by_user_id\" IS NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.auto_triage_tickets": {
- "name": "auto_triage_tickets",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_number": {
- "name": "issue_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "issue_url": {
- "name": "issue_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_title": {
- "name": "issue_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_body": {
- "name": "issue_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "issue_author": {
- "name": "issue_author",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_type": {
- "name": "issue_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_labels": {
- "name": "issue_labels",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false,
- "default": "'{}'"
- },
- "classification": {
- "name": "classification",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "confidence": {
- "name": "confidence",
- "type": "numeric(3, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "intent_summary": {
- "name": "intent_summary",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "related_files": {
- "name": "related_files",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "is_duplicate": {
- "name": "is_duplicate",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false,
- "default": false
- },
- "duplicate_of_ticket_id": {
- "name": "duplicate_of_ticket_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "similarity_score": {
- "name": "similarity_score",
- "type": "numeric(3, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "qdrant_point_id": {
- "name": "qdrant_point_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "should_auto_fix": {
- "name": "should_auto_fix",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false,
- "default": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "action_taken": {
- "name": "action_taken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "action_metadata": {
- "name": "action_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_auto_triage_tickets_repo_issue": {
- "name": "UQ_auto_triage_tickets_repo_issue",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "issue_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_owned_by_org": {
- "name": "IDX_auto_triage_tickets_owned_by_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_owned_by_user": {
- "name": "IDX_auto_triage_tickets_owned_by_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_status": {
- "name": "IDX_auto_triage_tickets_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_created_at": {
- "name": "IDX_auto_triage_tickets_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_qdrant_point_id": {
- "name": "IDX_auto_triage_tickets_qdrant_point_id",
- "columns": [
- {
- "expression": "qdrant_point_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_owner_status_created": {
- "name": "IDX_auto_triage_tickets_owner_status_created",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_user_status_created": {
- "name": "IDX_auto_triage_tickets_user_status_created",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_repo_classification": {
- "name": "IDX_auto_triage_tickets_repo_classification",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "classification",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "auto_triage_tickets_owned_by_organization_id_organizations_id_fk": {
- "name": "auto_triage_tickets_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk": {
- "name": "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk": {
- "name": "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk": {
- "name": "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "auto_triage_tickets",
- "columnsFrom": [
- "duplicate_of_ticket_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "auto_triage_tickets_owner_check": {
- "name": "auto_triage_tickets_owner_check",
- "value": "(\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "auto_triage_tickets_issue_type_check": {
- "name": "auto_triage_tickets_issue_type_check",
- "value": "\"auto_triage_tickets\".\"issue_type\" IN ('issue', 'pull_request')"
- },
- "auto_triage_tickets_classification_check": {
- "name": "auto_triage_tickets_classification_check",
- "value": "\"auto_triage_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'duplicate', 'unclear')"
- },
- "auto_triage_tickets_confidence_check": {
- "name": "auto_triage_tickets_confidence_check",
- "value": "\"auto_triage_tickets\".\"confidence\" >= 0 AND \"auto_triage_tickets\".\"confidence\" <= 1"
- },
- "auto_triage_tickets_similarity_score_check": {
- "name": "auto_triage_tickets_similarity_score_check",
- "value": "\"auto_triage_tickets\".\"similarity_score\" >= 0 AND \"auto_triage_tickets\".\"similarity_score\" <= 1"
- },
- "auto_triage_tickets_status_check": {
- "name": "auto_triage_tickets_status_check",
- "value": "\"auto_triage_tickets\".\"status\" IN ('pending', 'analyzing', 'actioned', 'failed', 'skipped')"
- },
- "auto_triage_tickets_action_taken_check": {
- "name": "auto_triage_tickets_action_taken_check",
- "value": "\"auto_triage_tickets\".\"action_taken\" IN ('pr_created', 'comment_posted', 'closed_duplicate', 'needs_clarification')"
- }
- },
- "isRLSEnabled": false
- },
- "public.bot_request_cloud_agent_sessions": {
- "name": "bot_request_cloud_agent_sessions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "bot_request_id": {
- "name": "bot_request_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "spawn_group_id": {
- "name": "spawn_group_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_session_id": {
- "name": "kilo_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "execution_id": {
- "name": "execution_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'running'"
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "github_repo": {
- "name": "github_repo",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "gitlab_project": {
- "name": "gitlab_project",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "callback_step": {
- "name": "callback_step",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "final_message": {
- "name": "final_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "final_message_fetched_at": {
- "name": "final_message_fetched_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "final_message_error": {
- "name": "final_message_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "continuation_started_at": {
- "name": "continuation_started_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_bot_request_cas_cloud_agent_session_id": {
- "name": "UQ_bot_request_cas_cloud_agent_session_id",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_request_cas_bot_request_id": {
- "name": "IDX_bot_request_cas_bot_request_id",
- "columns": [
- {
- "expression": "bot_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_request_cas_bot_request_id_spawn_group_id": {
- "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id",
- "columns": [
- {
- "expression": "bot_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "spawn_group_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_request_cas_bot_request_id_spawn_group_id_status": {
- "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id_status",
- "columns": [
- {
- "expression": "bot_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "spawn_group_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk": {
- "name": "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk",
- "tableFrom": "bot_request_cloud_agent_sessions",
- "tableTo": "bot_requests",
- "columnsFrom": [
- "bot_request_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.bot_requests": {
- "name": "bot_requests",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_thread_id": {
- "name": "platform_thread_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_message_id": {
- "name": "platform_message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_message": {
- "name": "user_message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model_used": {
- "name": "model_used",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "steps": {
- "name": "steps",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "response_time_ms": {
- "name": "response_time_ms",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_bot_requests_created_at": {
- "name": "IDX_bot_requests_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_created_by": {
- "name": "IDX_bot_requests_created_by",
- "columns": [
- {
- "expression": "created_by",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_organization_id": {
- "name": "IDX_bot_requests_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_platform_integration_id": {
- "name": "IDX_bot_requests_platform_integration_id",
- "columns": [
- {
- "expression": "platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_status": {
- "name": "IDX_bot_requests_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "bot_requests_created_by_kilocode_users_id_fk": {
- "name": "bot_requests_created_by_kilocode_users_id_fk",
- "tableFrom": "bot_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "bot_requests_organization_id_organizations_id_fk": {
- "name": "bot_requests_organization_id_organizations_id_fk",
- "tableFrom": "bot_requests",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "bot_requests_platform_integration_id_platform_integrations_id_fk": {
- "name": "bot_requests_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "bot_requests",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.byok_api_keys": {
- "name": "byok_api_keys",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider_id": {
- "name": "provider_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_api_key": {
- "name": "encrypted_api_key",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "management_source": {
- "name": "management_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'user'"
- },
- "is_enabled": {
- "name": "is_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "IDX_byok_api_keys_organization_id": {
- "name": "IDX_byok_api_keys_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_byok_api_keys_kilo_user_id": {
- "name": "IDX_byok_api_keys_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_byok_api_keys_provider_id": {
- "name": "IDX_byok_api_keys_provider_id",
- "columns": [
- {
- "expression": "provider_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "byok_api_keys_organization_id_organizations_id_fk": {
- "name": "byok_api_keys_organization_id_organizations_id_fk",
- "tableFrom": "byok_api_keys",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "byok_api_keys_kilo_user_id_kilocode_users_id_fk": {
- "name": "byok_api_keys_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "byok_api_keys",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_byok_api_keys_org_provider": {
- "name": "UQ_byok_api_keys_org_provider",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "provider_id"
- ]
- },
- "UQ_byok_api_keys_user_provider": {
- "name": "UQ_byok_api_keys_user_provider",
- "nullsNotDistinct": false,
- "columns": [
- "kilo_user_id",
- "provider_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "byok_api_keys_management_source_check": {
- "name": "byok_api_keys_management_source_check",
- "value": "\"byok_api_keys\".\"management_source\" IN ('user', 'coding_plan')"
- },
- "byok_api_keys_owner_check": {
- "name": "byok_api_keys_owner_check",
- "value": "(\n (\"byok_api_keys\".\"kilo_user_id\" IS NOT NULL AND \"byok_api_keys\".\"organization_id\" IS NULL) OR\n (\"byok_api_keys\".\"kilo_user_id\" IS NULL AND \"byok_api_keys\".\"organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.cli_sessions": {
- "name": "cli_sessions",
- "schema": "",
- "columns": {
- "session_id": {
- "name": "session_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_on_platform": {
- "name": "created_on_platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "api_conversation_history_blob_url": {
- "name": "api_conversation_history_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "task_metadata_blob_url": {
- "name": "task_metadata_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ui_messages_blob_url": {
- "name": "ui_messages_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_state_blob_url": {
- "name": "git_state_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_url": {
- "name": "git_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "forked_from": {
- "name": "forked_from",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "parent_session_id": {
- "name": "parent_session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "last_mode": {
- "name": "last_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_model": {
- "name": "last_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_cli_sessions_kilo_user_id": {
- "name": "IDX_cli_sessions_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_created_at": {
- "name": "IDX_cli_sessions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_updated_at": {
- "name": "IDX_cli_sessions_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_organization_id": {
- "name": "IDX_cli_sessions_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_user_updated": {
- "name": "IDX_cli_sessions_user_updated",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cli_sessions_kilo_user_id_kilocode_users_id_fk": {
- "name": "cli_sessions_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "cli_sessions_forked_from_cli_sessions_session_id_fk": {
- "name": "cli_sessions_forked_from_cli_sessions_session_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "forked_from"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "cli_sessions_parent_session_id_cli_sessions_session_id_fk": {
- "name": "cli_sessions_parent_session_id_cli_sessions_session_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "parent_session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "cli_sessions_organization_id_organizations_id_fk": {
- "name": "cli_sessions_organization_id_organizations_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "cli_sessions_cloud_agent_session_id_unique": {
- "name": "cli_sessions_cloud_agent_session_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "cloud_agent_session_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.cli_sessions_v2": {
- "name": "cli_sessions_v2",
- "schema": "",
- "columns": {
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "version": {
- "name": "version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "public_id": {
- "name": "public_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "parent_session_id": {
- "name": "parent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_on_platform": {
- "name": "created_on_platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "git_url": {
- "name": "git_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status_updated_at": {
- "name": "status_updated_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_cli_sessions_v2_parent_session_id_kilo_user_id": {
- "name": "IDX_cli_sessions_v2_parent_session_id_kilo_user_id",
- "columns": [
- {
- "expression": "parent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cli_sessions_v2_public_id": {
- "name": "UQ_cli_sessions_v2_public_id",
- "columns": [
- {
- "expression": "public_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cli_sessions_v2\".\"public_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cli_sessions_v2_cloud_agent_session_id": {
- "name": "UQ_cli_sessions_v2_cloud_agent_session_id",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cli_sessions_v2\".\"cloud_agent_session_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_organization_id": {
- "name": "IDX_cli_sessions_v2_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_kilo_user_id": {
- "name": "IDX_cli_sessions_v2_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_created_at": {
- "name": "IDX_cli_sessions_v2_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_user_updated": {
- "name": "IDX_cli_sessions_v2_user_updated",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "cli_sessions_v2_git_url_branch_idx": {
- "name": "cli_sessions_v2_git_url_branch_idx",
- "columns": [
- {
- "expression": "git_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk": {
- "name": "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "cli_sessions_v2",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "cli_sessions_v2_organization_id_organizations_id_fk": {
- "name": "cli_sessions_v2_organization_id_organizations_id_fk",
- "tableFrom": "cli_sessions_v2",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "cli_sessions_v2_parent_session_id_kilo_user_id_fk": {
- "name": "cli_sessions_v2_parent_session_id_kilo_user_id_fk",
- "tableFrom": "cli_sessions_v2",
- "tableTo": "cli_sessions_v2",
- "columnsFrom": [
- "parent_session_id",
- "kilo_user_id"
- ],
- "columnsTo": [
- "session_id",
- "kilo_user_id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "cli_sessions_v2_session_id_kilo_user_id_pk": {
- "name": "cli_sessions_v2_session_id_kilo_user_id_pk",
- "columns": [
- "session_id",
- "kilo_user_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.cloud_agent_code_review_attempts": {
- "name": "cloud_agent_code_review_attempts",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code_review_id": {
- "name": "code_review_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "attempt_number": {
- "name": "attempt_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "retry_of_attempt_id": {
- "name": "retry_of_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "retry_reason": {
- "name": "retry_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "execution_id": {
- "name": "execution_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analytics_enabled_at_dispatch": {
- "name": "analytics_enabled_at_dispatch",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_reason": {
- "name": "terminal_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_cloud_agent_code_review_attempts_review_attempt_number": {
- "name": "UQ_cloud_agent_code_review_attempts_review_attempt_number",
- "columns": [
- {
- "expression": "code_review_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "attempt_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_code_review_id": {
- "name": "idx_cloud_agent_code_review_attempts_code_review_id",
- "columns": [
- {
- "expression": "code_review_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_session_id": {
- "name": "idx_cloud_agent_code_review_attempts_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_cli_session_id": {
- "name": "idx_cloud_agent_code_review_attempts_cli_session_id",
- "columns": [
- {
- "expression": "cli_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_status": {
- "name": "idx_cloud_agent_code_review_attempts_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_retry_reason": {
- "name": "idx_cloud_agent_code_review_attempts_retry_reason",
- "columns": [
- {
- "expression": "retry_reason",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk": {
- "name": "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk",
- "tableFrom": "cloud_agent_code_review_attempts",
- "tableTo": "cloud_agent_code_reviews",
- "columnsFrom": [
- "code_review_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk": {
- "name": "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk",
- "tableFrom": "cloud_agent_code_review_attempts",
- "tableTo": "cloud_agent_code_review_attempts",
- "columnsFrom": [
- "retry_of_attempt_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_code_review_attempts_attempt_number_check": {
- "name": "cloud_agent_code_review_attempts_attempt_number_check",
- "value": "\"cloud_agent_code_review_attempts\".\"attempt_number\" >= 1"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_code_reviews": {
- "name": "cloud_agent_code_reviews",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_title": {
- "name": "pr_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_author": {
- "name": "pr_author",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_author_github_id": {
- "name": "pr_author_github_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "base_ref": {
- "name": "base_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "head_ref": {
- "name": "head_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "head_sha": {
- "name": "head_sha",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "platform_project_id": {
- "name": "platform_project_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "dispatch_reservation_id": {
- "name": "dispatch_reservation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_reason": {
- "name": "terminal_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "agent_version": {
- "name": "agent_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'v1'"
- },
- "check_run_id": {
- "name": "check_run_id",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "repository_review_instructions_used": {
- "name": "repository_review_instructions_used",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "repository_review_instructions_ref": {
- "name": "repository_review_instructions_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repository_review_instructions_truncated": {
- "name": "repository_review_instructions_truncated",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "previous_summary_body": {
- "name": "previous_summary_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "previous_summary_head_sha": {
- "name": "previous_summary_head_sha",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "total_tokens_in": {
- "name": "total_tokens_in",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_tokens_out": {
- "name": "total_tokens_out",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_cost_musd": {
- "name": "total_cost_musd",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_cloud_agent_code_reviews_repo_pr_sha": {
- "name": "UQ_cloud_agent_code_reviews_repo_pr_sha",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "pr_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "head_sha",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_owned_by_org_id": {
- "name": "idx_cloud_agent_code_reviews_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_owned_by_user_id": {
- "name": "idx_cloud_agent_code_reviews_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_session_id": {
- "name": "idx_cloud_agent_code_reviews_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_cli_session_id": {
- "name": "idx_cloud_agent_code_reviews_cli_session_id",
- "columns": [
- {
- "expression": "cli_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_status": {
- "name": "idx_cloud_agent_code_reviews_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_repo": {
- "name": "idx_cloud_agent_code_reviews_repo",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_pr_number": {
- "name": "idx_cloud_agent_code_reviews_pr_number",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "pr_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_created_at": {
- "name": "idx_cloud_agent_code_reviews_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_pr_author_github_id": {
- "name": "idx_cloud_agent_code_reviews_pr_author_github_id",
- "columns": [
- {
- "expression": "pr_author_github_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk": {
- "name": "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "cloud_agent_code_reviews",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk": {
- "name": "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "cloud_agent_code_reviews",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk": {
- "name": "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "cloud_agent_code_reviews",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_code_reviews_owner_check": {
- "name": "cloud_agent_code_reviews_owner_check",
- "value": "(\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NOT NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NULL) OR\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_feedback": {
- "name": "cloud_agent_feedback",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repository": {
- "name": "repository",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_streaming": {
- "name": "is_streaming",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "message_count": {
- "name": "message_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "feedback_text": {
- "name": "feedback_text",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "recent_messages": {
- "name": "recent_messages",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_cloud_agent_feedback_created_at": {
- "name": "IDX_cloud_agent_feedback_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_feedback_kilo_user_id": {
- "name": "IDX_cloud_agent_feedback_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_feedback_cloud_agent_session_id": {
- "name": "IDX_cloud_agent_feedback_cloud_agent_session_id",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk": {
- "name": "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "cloud_agent_feedback",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "cloud_agent_feedback_organization_id_organizations_id_fk": {
- "name": "cloud_agent_feedback_organization_id_organizations_id_fk",
- "tableFrom": "cloud_agent_feedback",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.cloud_agent_session_runs": {
- "name": "cloud_agent_session_runs",
- "schema": "",
- "columns": {
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "message_id": {
- "name": "message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "wrapper_run_id": {
- "name": "wrapper_run_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "queued_at": {
- "name": "queued_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "dispatch_accepted_at": {
- "name": "dispatch_accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "agent_activity_observed_at": {
- "name": "agent_activity_observed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "failure_stage": {
- "name": "failure_stage",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message_redacted": {
- "name": "error_message_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_expires_at": {
- "name": "error_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_cloud_agent_session_runs_wrapper_run_id": {
- "name": "IDX_cloud_agent_session_runs_wrapper_run_id",
- "columns": [
- {
- "expression": "wrapper_run_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_session_runs\".\"wrapper_run_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_session_queued": {
- "name": "IDX_cloud_agent_session_runs_session_queued",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_queued_at": {
- "name": "IDX_cloud_agent_session_runs_queued_at",
- "columns": [
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_terminal_at": {
- "name": "IDX_cloud_agent_session_runs_terminal_at",
- "columns": [
- {
- "expression": "terminal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_status_terminal": {
- "name": "IDX_cloud_agent_session_runs_status_terminal",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "terminal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_failure_terminal": {
- "name": "IDX_cloud_agent_session_runs_failure_terminal",
- "columns": [
- {
- "expression": "failure_stage",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "terminal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_error_expires_at": {
- "name": "IDX_cloud_agent_session_runs_error_expires_at",
- "columns": [
- {
- "expression": "error_expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_session_runs\".\"error_expires_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk": {
- "name": "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk",
- "tableFrom": "cloud_agent_session_runs",
- "tableTo": "cloud_agent_sessions",
- "columnsFrom": [
- "cloud_agent_session_id"
- ],
- "columnsTo": [
- "cloud_agent_session_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk": {
- "name": "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk",
- "columns": [
- "cloud_agent_session_id",
- "message_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_session_runs_status_check": {
- "name": "cloud_agent_session_runs_status_check",
- "value": "\"cloud_agent_session_runs\".\"status\" IN ('queued', 'accepted', 'completed', 'failed', 'interrupted')"
- },
- "cloud_agent_session_runs_failure_classification_check": {
- "name": "cloud_agent_session_runs_failure_classification_check",
- "value": "(\"cloud_agent_session_runs\".\"failure_stage\" IS NULL AND \"cloud_agent_session_runs\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'pre_dispatch' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('sandbox_connect_failed', 'workspace_setup_failed', 'kilo_server_failed', 'wrapper_start_failed', 'invalid_delivery_request', 'session_metadata_missing', 'model_missing', 'delivery_failure_unknown')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'post_dispatch_no_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('wrapper_disconnected', 'wrapper_no_output', 'wrapper_ping_timeout', 'wrapper_error_before_activity', 'missing_assistant_reply')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'agent_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('assistant_error', 'wrapper_error_after_activity')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'interruption' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('user_interrupt', 'container_shutdown', 'system_interrupt')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'unknown' AND \"cloud_agent_session_runs\".\"failure_code\" = 'unclassified')"
- },
- "cloud_agent_session_runs_error_message_bounded_check": {
- "name": "cloud_agent_session_runs_error_message_bounded_check",
- "value": "\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_session_runs\".\"error_message_redacted\") <= 4096"
- },
- "cloud_agent_session_runs_error_expiry_check": {
- "name": "cloud_agent_session_runs_error_expiry_check",
- "value": "(\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_sessions": {
- "name": "cloud_agent_sessions",
- "schema": "",
- "columns": {
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "kilo_session_id": {
- "name": "kilo_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "initial_message_id": {
- "name": "initial_message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sandbox_id": {
- "name": "sandbox_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "failure_at": {
- "name": "failure_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "failure_stage": {
- "name": "failure_stage",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message_redacted": {
- "name": "error_message_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_expires_at": {
- "name": "error_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_cloud_agent_sessions_kilo_session_id": {
- "name": "UQ_cloud_agent_sessions_kilo_session_id",
- "columns": [
- {
- "expression": "kilo_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cloud_agent_sessions_initial_message_id": {
- "name": "UQ_cloud_agent_sessions_initial_message_id",
- "columns": [
- {
- "expression": "initial_message_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_sandbox_id": {
- "name": "IDX_cloud_agent_sessions_sandbox_id",
- "columns": [
- {
- "expression": "sandbox_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"sandbox_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_created_at": {
- "name": "IDX_cloud_agent_sessions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_failure_created": {
- "name": "IDX_cloud_agent_sessions_failure_created",
- "columns": [
- {
- "expression": "failure_stage",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_failure_at": {
- "name": "IDX_cloud_agent_sessions_failure_at",
- "columns": [
- {
- "expression": "failure_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_failure_classification_at": {
- "name": "IDX_cloud_agent_sessions_failure_classification_at",
- "columns": [
- {
- "expression": "failure_stage",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_error_expires_at": {
- "name": "IDX_cloud_agent_sessions_error_expires_at",
- "columns": [
- {
- "expression": "error_expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"error_expires_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_sessions_failure_classification_check": {
- "name": "cloud_agent_sessions_failure_classification_check",
- "value": "(\"cloud_agent_sessions\".\"failure_at\" IS NULL AND \"cloud_agent_sessions\".\"failure_stage\" IS NULL AND \"cloud_agent_sessions\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'sandbox_identity' AND \"cloud_agent_sessions\".\"failure_code\" = 'sandbox_id_derivation_failed') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'registration' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_registration_rejected') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'initial_admission' AND \"cloud_agent_sessions\".\"failure_code\" IN ('initial_admission_rejected', 'initial_queue_full', 'invalid_initial_intent')) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'transport' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_rpc_outcome_unknown')"
- },
- "cloud_agent_sessions_error_message_bounded_check": {
- "name": "cloud_agent_sessions_error_message_bounded_check",
- "value": "\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_sessions\".\"error_message_redacted\") <= 4096"
- },
- "cloud_agent_sessions_error_expiry_check": {
- "name": "cloud_agent_sessions_error_expiry_check",
- "value": "(\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_sessions\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_webhook_triggers": {
- "name": "cloud_agent_webhook_triggers",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "trigger_id": {
- "name": "trigger_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "target_type": {
- "name": "target_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'cloud_agent'"
- },
- "kiloclaw_instance_id": {
- "name": "kiloclaw_instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "activation_mode": {
- "name": "activation_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'webhook'"
- },
- "cron_expression": {
- "name": "cron_expression",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cron_timezone": {
- "name": "cron_timezone",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'UTC'"
- },
- "github_repo": {
- "name": "github_repo",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_cloud_agent_webhook_triggers_user_trigger": {
- "name": "UQ_cloud_agent_webhook_triggers_user_trigger",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "trigger_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cloud_agent_webhook_triggers\".\"user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cloud_agent_webhook_triggers_org_trigger": {
- "name": "UQ_cloud_agent_webhook_triggers_org_trigger",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "trigger_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cloud_agent_webhook_triggers\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_user": {
- "name": "IDX_cloud_agent_webhook_triggers_user",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_org": {
- "name": "IDX_cloud_agent_webhook_triggers_org",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_active": {
- "name": "IDX_cloud_agent_webhook_triggers_active",
- "columns": [
- {
- "expression": "is_active",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_profile": {
- "name": "IDX_cloud_agent_webhook_triggers_profile",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk": {
- "name": "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_webhook_triggers_organization_id_organizations_id_fk": {
- "name": "cloud_agent_webhook_triggers_organization_id_organizations_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk": {
- "name": "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "kiloclaw_instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk": {
- "name": "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "CHK_cloud_agent_webhook_triggers_owner": {
- "name": "CHK_cloud_agent_webhook_triggers_owner",
- "value": "(\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NULL) OR\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NOT NULL)\n )"
- },
- "CHK_cloud_agent_webhook_triggers_cloud_agent_fields": {
- "name": "CHK_cloud_agent_webhook_triggers_cloud_agent_fields",
- "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'cloud_agent' OR\n (\"cloud_agent_webhook_triggers\".\"github_repo\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"profile_id\" IS NOT NULL)\n )"
- },
- "CHK_cloud_agent_webhook_triggers_kiloclaw_fields": {
- "name": "CHK_cloud_agent_webhook_triggers_kiloclaw_fields",
- "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'kiloclaw_chat' OR\n \"cloud_agent_webhook_triggers\".\"kiloclaw_instance_id\" IS NOT NULL\n )"
- },
- "CHK_cloud_agent_webhook_triggers_scheduled_fields": {
- "name": "CHK_cloud_agent_webhook_triggers_scheduled_fields",
- "value": "(\n \"cloud_agent_webhook_triggers\".\"activation_mode\" != 'scheduled' OR\n \"cloud_agent_webhook_triggers\".\"cron_expression\" IS NOT NULL\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_indexing_manifest": {
- "name": "code_indexing_manifest",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "file_hash": {
- "name": "file_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "file_path": {
- "name": "file_path",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "chunk_count": {
- "name": "chunk_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "total_lines": {
- "name": "total_lines",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_ai_lines": {
- "name": "total_ai_lines",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_code_indexing_manifest_organization_id": {
- "name": "IDX_code_indexing_manifest_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_kilo_user_id": {
- "name": "IDX_code_indexing_manifest_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_project_id": {
- "name": "IDX_code_indexing_manifest_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_git_branch": {
- "name": "IDX_code_indexing_manifest_git_branch",
- "columns": [
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_created_at": {
- "name": "IDX_code_indexing_manifest_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk": {
- "name": "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "code_indexing_manifest",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_indexing_manifest_org_user_project_hash_branch": {
- "name": "UQ_code_indexing_manifest_org_user_project_hash_branch",
- "nullsNotDistinct": true,
- "columns": [
- "organization_id",
- "kilo_user_id",
- "project_id",
- "file_path",
- "git_branch"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.code_indexing_search": {
- "name": "code_indexing_search",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "query": {
- "name": "query",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_code_indexing_search_organization_id": {
- "name": "IDX_code_indexing_search_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_search_kilo_user_id": {
- "name": "IDX_code_indexing_search_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_search_project_id": {
- "name": "IDX_code_indexing_search_project_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_search_created_at": {
- "name": "IDX_code_indexing_search_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_indexing_search_kilo_user_id_kilocode_users_id_fk": {
- "name": "code_indexing_search_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "code_indexing_search",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.code_review_analytics_findings": {
- "name": "code_review_analytics_findings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "analytics_result_id": {
- "name": "analytics_result_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "ordinal": {
- "name": "ordinal",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "severity": {
- "name": "severity",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "category": {
- "name": "category",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "security_class": {
- "name": "security_class",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk": {
- "name": "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk",
- "tableFrom": "code_review_analytics_findings",
- "tableTo": "code_review_analytics_results",
- "columnsFrom": [
- "analytics_result_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_review_analytics_findings_result_ordinal": {
- "name": "UQ_code_review_analytics_findings_result_ordinal",
- "nullsNotDistinct": false,
- "columns": [
- "analytics_result_id",
- "ordinal"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "code_review_analytics_findings_severity_check": {
- "name": "code_review_analytics_findings_severity_check",
- "value": "\"code_review_analytics_findings\".\"severity\" IN ('critical', 'warning', 'suggestion')"
- },
- "code_review_analytics_findings_category_check": {
- "name": "code_review_analytics_findings_category_check",
- "value": "\"code_review_analytics_findings\".\"category\" IN ('security', 'correctness', 'reliability', 'data_integrity', 'performance', 'compatibility', 'maintainability', 'test_quality', 'documentation', 'accessibility', 'other')"
- },
- "code_review_analytics_findings_security_class_check": {
- "name": "code_review_analytics_findings_security_class_check",
- "value": "\"code_review_analytics_findings\".\"security_class\" IN ('auth_access', 'injection', 'data_protection', 'request_resource_boundary', 'deserialization_object_integrity', 'dependency_supply_chain', 'memory_safety', 'availability', 'concurrency', 'security_configuration', 'other')"
- },
- "code_review_analytics_findings_ordinal_check": {
- "name": "code_review_analytics_findings_ordinal_check",
- "value": "\"code_review_analytics_findings\".\"ordinal\" >= 0"
- },
- "code_review_analytics_findings_security_class_presence_check": {
- "name": "code_review_analytics_findings_security_class_presence_check",
- "value": "(\n (\"code_review_analytics_findings\".\"category\" = 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NOT NULL) OR\n (\"code_review_analytics_findings\".\"category\" <> 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_review_analytics_results": {
- "name": "code_review_analytics_results",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code_review_id": {
- "name": "code_review_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "source_attempt_id": {
- "name": "source_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "capture_status": {
- "name": "capture_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "schema_version": {
- "name": "schema_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "taxonomy_version": {
- "name": "taxonomy_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "change_type": {
- "name": "change_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "impact_level": {
- "name": "impact_level",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "complexity_level": {
- "name": "complexity_level",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "classification_confidence": {
- "name": "classification_confidence",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finalized_at": {
- "name": "finalized_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_code_review_analytics_results_source_attempt_id": {
- "name": "idx_code_review_analytics_results_source_attempt_id",
- "columns": [
- {
- "expression": "source_attempt_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_analytics_results_finalized_at": {
- "name": "idx_code_review_analytics_results_finalized_at",
- "columns": [
- {
- "expression": "finalized_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk": {
- "name": "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk",
- "tableFrom": "code_review_analytics_results",
- "tableTo": "cloud_agent_code_reviews",
- "columnsFrom": [
- "code_review_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk": {
- "name": "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk",
- "tableFrom": "code_review_analytics_results",
- "tableTo": "cloud_agent_code_review_attempts",
- "columnsFrom": [
- "source_attempt_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_review_analytics_results_code_review_id": {
- "name": "UQ_code_review_analytics_results_code_review_id",
- "nullsNotDistinct": false,
- "columns": [
- "code_review_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "code_review_analytics_results_capture_status_check": {
- "name": "code_review_analytics_results_capture_status_check",
- "value": "\"code_review_analytics_results\".\"capture_status\" IN ('captured', 'missing', 'invalid', 'omitted')"
- },
- "code_review_analytics_results_change_type_check": {
- "name": "code_review_analytics_results_change_type_check",
- "value": "\"code_review_analytics_results\".\"change_type\" IN ('bug_fix', 'feature', 'refactor', 'maintenance', 'dependency', 'test', 'documentation', 'mixed', 'other')"
- },
- "code_review_analytics_results_impact_level_check": {
- "name": "code_review_analytics_results_impact_level_check",
- "value": "\"code_review_analytics_results\".\"impact_level\" IN ('low', 'medium', 'high')"
- },
- "code_review_analytics_results_complexity_level_check": {
- "name": "code_review_analytics_results_complexity_level_check",
- "value": "\"code_review_analytics_results\".\"complexity_level\" IN ('low', 'medium', 'high')"
- },
- "code_review_analytics_results_classification_confidence_check": {
- "name": "code_review_analytics_results_classification_confidence_check",
- "value": "\"code_review_analytics_results\".\"classification_confidence\" IN ('low', 'medium', 'high')"
- },
- "code_review_analytics_results_classification_presence_check": {
- "name": "code_review_analytics_results_classification_presence_check",
- "value": "(\n (\n \"code_review_analytics_results\".\"capture_status\" = 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NOT NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NOT NULL\n ) OR (\n \"code_review_analytics_results\".\"capture_status\" <> 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NULL\n )\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_review_feedback_events": {
- "name": "code_review_feedback_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_comment_id": {
- "name": "kilo_comment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reply_excerpt": {
- "name": "reply_excerpt",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_comment_excerpt": {
- "name": "kilo_comment_excerpt",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "dedupe_hash": {
- "name": "dedupe_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "occurred_at": {
- "name": "occurred_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_code_review_feedback_events_owned_by_org_id": {
- "name": "idx_code_review_feedback_events_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_feedback_events_owned_by_user_id": {
- "name": "idx_code_review_feedback_events_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_feedback_events_platform_repo": {
- "name": "idx_code_review_feedback_events_platform_repo",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_feedback_events_created_at": {
- "name": "idx_code_review_feedback_events_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_review_feedback_events_owned_by_organization_id_organizations_id_fk": {
- "name": "code_review_feedback_events_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "code_review_feedback_events",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk": {
- "name": "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "code_review_feedback_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_review_feedback_events_dedupe_hash": {
- "name": "UQ_code_review_feedback_events_dedupe_hash",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_hash"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "code_review_feedback_events_owner_check": {
- "name": "code_review_feedback_events_owner_check",
- "value": "(\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_review_memory_proposals": {
- "name": "code_review_memory_proposals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'open'"
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "rationale": {
- "name": "rationale",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "proposed_markdown": {
- "name": "proposed_markdown",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "evidence": {
- "name": "evidence",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'[]'::jsonb"
- },
- "positive_count": {
- "name": "positive_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "negative_count": {
- "name": "negative_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "neutral_count": {
- "name": "neutral_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "change_request_url": {
- "name": "change_request_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_code_review_memory_proposals_owned_by_org_id": {
- "name": "idx_code_review_memory_proposals_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_memory_proposals_owned_by_user_id": {
- "name": "idx_code_review_memory_proposals_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_memory_proposals_platform_repo_status": {
- "name": "idx_code_review_memory_proposals_platform_repo_status",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_memory_proposals_updated_at": {
- "name": "idx_code_review_memory_proposals_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_code_review_memory_proposals_org_active_scope": {
- "name": "UQ_code_review_memory_proposals_org_active_scope",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_code_review_memory_proposals_user_active_scope": {
- "name": "UQ_code_review_memory_proposals_user_active_scope",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk": {
- "name": "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "code_review_memory_proposals",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk": {
- "name": "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "code_review_memory_proposals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "code_review_memory_proposals_owner_check": {
- "name": "code_review_memory_proposals_owner_check",
- "value": "(\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.coding_plan_availability_intents": {
- "name": "coding_plan_availability_intents",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_availability_intents_user_plan": {
- "name": "UQ_coding_plan_availability_intents_user_plan",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_availability_intents_plan": {
- "name": "IDX_coding_plan_availability_intents_plan",
- "columns": [
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_availability_intents_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_availability_intents_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_availability_intents",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.coding_plan_key_inventory": {
- "name": "coding_plan_key_inventory",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_id": {
- "name": "provider_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "upstream_plan_id": {
- "name": "upstream_plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_api_key": {
- "name": "encrypted_api_key",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "credential_fingerprint": {
- "name": "credential_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'available'"
- },
- "assigned_to_user_id": {
- "name": "assigned_to_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "assigned_at": {
- "name": "assigned_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_requested_at": {
- "name": "revocation_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_attempt_count": {
- "name": "revocation_attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "last_revocation_error": {
- "name": "last_revocation_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_key_inv_fingerprint": {
- "name": "UQ_coding_plan_key_inv_fingerprint",
- "columns": [
- {
- "expression": "credential_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_key_inv_plan_status": {
- "name": "IDX_coding_plan_key_inv_plan_status",
- "columns": [
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_key_inv_available": {
- "name": "IDX_coding_plan_key_inv_available",
- "columns": [
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"coding_plan_key_inventory\".\"status\" = 'available'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_key_inventory",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "assigned_to_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "coding_plan_key_inventory_status_check": {
- "name": "coding_plan_key_inventory_status_check",
- "value": "\"coding_plan_key_inventory\".\"status\" IN ('available', 'assigned', 'revocation_pending', 'revoked', 'revocation_failed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.coding_plan_subscriptions": {
- "name": "coding_plan_subscriptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_id": {
- "name": "provider_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "key_inventory_id": {
- "name": "key_inventory_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "installed_byok_key_id": {
- "name": "installed_byok_key_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cost_microdollars": {
- "name": "cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "billing_period_days": {
- "name": "billing_period_days",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "current_period_start": {
- "name": "current_period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "current_period_end": {
- "name": "current_period_end",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "credit_renewal_at": {
- "name": "credit_renewal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "cancel_at_period_end": {
- "name": "cancel_at_period_end",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "past_due_started_at": {
- "name": "past_due_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "payment_grace_expires_at": {
- "name": "payment_grace_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_top_up_attempted_for_due": {
- "name": "auto_top_up_attempted_for_due",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "canceled_at": {
- "name": "canceled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "cancellation_reason": {
- "name": "cancellation_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_sub_live_user_plan": {
- "name": "UQ_coding_plan_sub_live_user_plan",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_sub_status": {
- "name": "IDX_coding_plan_sub_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_sub_renewal": {
- "name": "IDX_coding_plan_sub_renewal",
- "columns": [
- {
- "expression": "credit_renewal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_sub_inventory": {
- "name": "IDX_coding_plan_sub_inventory",
- "columns": [
- {
- "expression": "key_inventory_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_subscriptions_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_subscriptions_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_subscriptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk": {
- "name": "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk",
- "tableFrom": "coding_plan_subscriptions",
- "tableTo": "coding_plan_key_inventory",
- "columnsFrom": [
- "key_inventory_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk": {
- "name": "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk",
- "tableFrom": "coding_plan_subscriptions",
- "tableTo": "byok_api_keys",
- "columnsFrom": [
- "installed_byok_key_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "coding_plan_subscriptions_status_check": {
- "name": "coding_plan_subscriptions_status_check",
- "value": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due', 'canceled')"
- },
- "coding_plan_subscriptions_live_access_check": {
- "name": "coding_plan_subscriptions_live_access_check",
- "value": "\"coding_plan_subscriptions\".\"status\" = 'canceled' OR \"coding_plan_subscriptions\".\"key_inventory_id\" IS NOT NULL"
- }
- },
- "isRLSEnabled": false
- },
- "public.coding_plan_terms": {
- "name": "coding_plan_terms",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kind": {
- "name": "kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_start": {
- "name": "period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "period_end": {
- "name": "period_end",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "cost_microdollars": {
- "name": "cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "credit_transaction_id": {
- "name": "credit_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_terms_request": {
- "name": "UQ_coding_plan_terms_request",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "idempotency_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_terms_subscription": {
- "name": "IDX_coding_plan_terms_subscription",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk": {
- "name": "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk",
- "tableFrom": "coding_plan_terms",
- "tableTo": "coding_plan_subscriptions",
- "columnsFrom": [
- "subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "coding_plan_terms_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_terms_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_terms",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk": {
- "name": "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk",
- "tableFrom": "coding_plan_terms",
- "tableTo": "credit_transactions",
- "columnsFrom": [
- "credit_transaction_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "coding_plan_terms_kind_check": {
- "name": "coding_plan_terms_kind_check",
- "value": "\"coding_plan_terms\".\"kind\" IN ('activation', 'extension', 'renewal')"
- }
- },
- "isRLSEnabled": false
- },
- "public.contributor_champion_contributors": {
- "name": "contributor_champion_contributors",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "github_login": {
- "name": "github_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_profile_url": {
- "name": "github_profile_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_user_id": {
- "name": "github_user_id",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "first_contribution_at": {
- "name": "first_contribution_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_contribution_at": {
- "name": "last_contribution_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "all_time_contributions": {
- "name": "all_time_contributions",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "manual_email": {
- "name": "manual_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_contributor_champion_contributors_last_contribution_at": {
- "name": "IDX_contributor_champion_contributors_last_contribution_at",
- "columns": [
- {
- "expression": "last_contribution_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_contributors_manual_email": {
- "name": "IDX_contributor_champion_contributors_manual_email",
- "columns": [
- {
- "expression": "manual_email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_contributor_champion_contributors_github_login": {
- "name": "UQ_contributor_champion_contributors_github_login",
- "nullsNotDistinct": false,
- "columns": [
- "github_login"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.contributor_champion_events": {
- "name": "contributor_champion_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "contributor_id": {
- "name": "contributor_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_pr_number": {
- "name": "github_pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "github_pr_url": {
- "name": "github_pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_pr_title": {
- "name": "github_pr_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_author_login": {
- "name": "github_author_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_author_email": {
- "name": "github_author_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "merged_at": {
- "name": "merged_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_contributor_champion_events_contributor_id": {
- "name": "IDX_contributor_champion_events_contributor_id",
- "columns": [
- {
- "expression": "contributor_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_events_merged_at": {
- "name": "IDX_contributor_champion_events_merged_at",
- "columns": [
- {
- "expression": "merged_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_events_author_email": {
- "name": "IDX_contributor_champion_events_author_email",
- "columns": [
- {
- "expression": "github_author_email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk": {
- "name": "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk",
- "tableFrom": "contributor_champion_events",
- "tableTo": "contributor_champion_contributors",
- "columnsFrom": [
- "contributor_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_contributor_champion_events_repo_pr": {
- "name": "UQ_contributor_champion_events_repo_pr",
- "nullsNotDistinct": false,
- "columns": [
- "repo_full_name",
- "github_pr_number"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.contributor_champion_memberships": {
- "name": "contributor_champion_memberships",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "contributor_id": {
- "name": "contributor_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "selected_tier": {
- "name": "selected_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "enrolled_tier": {
- "name": "enrolled_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "enrolled_at": {
- "name": "enrolled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "credit_amount_microdollars": {
- "name": "credit_amount_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "credits_last_granted_at": {
- "name": "credits_last_granted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "linked_kilo_user_id": {
- "name": "linked_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_contributor_champion_memberships_credits_due": {
- "name": "IDX_contributor_champion_memberships_credits_due",
- "columns": [
- {
- "expression": "credits_last_granted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NOT NULL AND \"contributor_champion_memberships\".\"credit_amount_microdollars\" > 0",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_memberships_linked_kilo_user_id": {
- "name": "IDX_contributor_champion_memberships_linked_kilo_user_id",
- "columns": [
- {
- "expression": "linked_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk": {
- "name": "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk",
- "tableFrom": "contributor_champion_memberships",
- "tableTo": "contributor_champion_contributors",
- "columnsFrom": [
- "contributor_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk": {
- "name": "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "contributor_champion_memberships",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "linked_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_contributor_champion_memberships_contributor_id": {
- "name": "UQ_contributor_champion_memberships_contributor_id",
- "nullsNotDistinct": false,
- "columns": [
- "contributor_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "contributor_champion_memberships_selected_tier_check": {
- "name": "contributor_champion_memberships_selected_tier_check",
- "value": "\"contributor_champion_memberships\".\"selected_tier\" IS NULL OR \"contributor_champion_memberships\".\"selected_tier\" IN ('contributor', 'ambassador', 'champion')"
- },
- "contributor_champion_memberships_enrolled_tier_check": {
- "name": "contributor_champion_memberships_enrolled_tier_check",
- "value": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NULL OR \"contributor_champion_memberships\".\"enrolled_tier\" IN ('contributor', 'ambassador', 'champion')"
- }
- },
- "isRLSEnabled": false
- },
- "public.contributor_champion_sync_state": {
- "name": "contributor_champion_sync_state",
- "schema": "",
- "columns": {
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "last_merged_at": {
- "name": "last_merged_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_synced_at": {
- "name": "last_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.credit_campaigns": {
- "name": "credit_campaigns",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "credit_category": {
- "name": "credit_category",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_microdollars": {
- "name": "amount_microdollars",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "credit_expiry_hours": {
- "name": "credit_expiry_hours",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "campaign_ends_at": {
- "name": "campaign_ends_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "total_redemptions_allowed": {
- "name": "total_redemptions_allowed",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "active": {
- "name": "active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_credit_campaigns_slug": {
- "name": "UQ_credit_campaigns_slug",
- "columns": [
- {
- "expression": "slug",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_credit_campaigns_credit_category": {
- "name": "UQ_credit_campaigns_credit_category",
- "columns": [
- {
- "expression": "credit_category",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "credit_campaigns_slug_format_check": {
- "name": "credit_campaigns_slug_format_check",
- "value": "\"credit_campaigns\".\"slug\" ~ '^[a-z0-9-]{5,40}$'"
- },
- "credit_campaigns_amount_positive_check": {
- "name": "credit_campaigns_amount_positive_check",
- "value": "\"credit_campaigns\".\"amount_microdollars\" > 0"
- },
- "credit_campaigns_credit_expiry_hours_positive_check": {
- "name": "credit_campaigns_credit_expiry_hours_positive_check",
- "value": "\"credit_campaigns\".\"credit_expiry_hours\" IS NULL OR \"credit_campaigns\".\"credit_expiry_hours\" > 0"
- },
- "credit_campaigns_total_redemptions_allowed_positive_check": {
- "name": "credit_campaigns_total_redemptions_allowed_positive_check",
- "value": "\"credit_campaigns\".\"total_redemptions_allowed\" > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.credit_transactions": {
- "name": "credit_transactions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_microdollars": {
- "name": "amount_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "expiration_baseline_microdollars_used": {
- "name": "expiration_baseline_microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "original_baseline_microdollars_used": {
- "name": "original_baseline_microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "is_free": {
- "name": "is_free",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "original_transaction_id": {
- "name": "original_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_id": {
- "name": "stripe_payment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "coinbase_credit_block_id": {
- "name": "coinbase_credit_block_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "credit_category": {
- "name": "credit_category",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "expiry_date": {
- "name": "expiry_date",
- "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()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "check_category_uniqueness": {
- "name": "check_category_uniqueness",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- }
- },
- "indexes": {
- "IDX_credit_transactions_created_at": {
- "name": "IDX_credit_transactions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_is_free": {
- "name": "IDX_credit_transactions_is_free",
- "columns": [
- {
- "expression": "is_free",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_kilo_user_id": {
- "name": "IDX_credit_transactions_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_credit_category": {
- "name": "IDX_credit_transactions_credit_category",
- "columns": [
- {
- "expression": "credit_category",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_stripe_payment_id": {
- "name": "IDX_credit_transactions_stripe_payment_id",
- "columns": [
- {
- "expression": "stripe_payment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_original_transaction_id": {
- "name": "IDX_credit_transactions_original_transaction_id",
- "columns": [
- {
- "expression": "original_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_coinbase_credit_block_id": {
- "name": "IDX_credit_transactions_coinbase_credit_block_id",
- "columns": [
- {
- "expression": "coinbase_credit_block_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_organization_id": {
- "name": "IDX_credit_transactions_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_unique_category": {
- "name": "IDX_credit_transactions_unique_category",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "credit_category",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"credit_transactions\".\"check_category_uniqueness\" = TRUE",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "credit_transactions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.custom_llm2": {
- "name": "custom_llm2",
- "schema": "",
- "columns": {
- "public_id": {
- "name": "public_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "definition": {
- "name": "definition",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deleted_user_email_tombstones": {
- "name": "deleted_user_email_tombstones",
- "schema": "",
- "columns": {
- "normalized_email_hash": {
- "name": "normalized_email_hash",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_builds": {
- "name": "deployment_builds",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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": {
- "idx_deployment_builds_deployment_id": {
- "name": "idx_deployment_builds_deployment_id",
- "columns": [
- {
- "expression": "deployment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_builds_status": {
- "name": "idx_deployment_builds_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_builds_deployment_id_deployments_id_fk": {
- "name": "deployment_builds_deployment_id_deployments_id_fk",
- "tableFrom": "deployment_builds",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_env_vars": {
- "name": "deployment_env_vars",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "key": {
- "name": "key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_secret": {
- "name": "is_secret",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_deployment_env_vars_deployment_id": {
- "name": "idx_deployment_env_vars_deployment_id",
- "columns": [
- {
- "expression": "deployment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_env_vars_deployment_id_deployments_id_fk": {
- "name": "deployment_env_vars_deployment_id_deployments_id_fk",
- "tableFrom": "deployment_env_vars",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_deployment_env_vars_deployment_key": {
- "name": "UQ_deployment_env_vars_deployment_key",
- "nullsNotDistinct": false,
- "columns": [
- "deployment_id",
- "key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_events": {
- "name": "deployment_events",
- "schema": "",
- "columns": {
- "build_id": {
- "name": "build_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "event_id": {
- "name": "event_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'log'"
- },
- "timestamp": {
- "name": "timestamp",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "payload": {
- "name": "payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "idx_deployment_events_build_id": {
- "name": "idx_deployment_events_build_id",
- "columns": [
- {
- "expression": "build_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_events_timestamp": {
- "name": "idx_deployment_events_timestamp",
- "columns": [
- {
- "expression": "timestamp",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_events_type": {
- "name": "idx_deployment_events_type",
- "columns": [
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_events_build_id_deployment_builds_id_fk": {
- "name": "deployment_events_build_id_deployment_builds_id_fk",
- "tableFrom": "deployment_events",
- "tableTo": "deployment_builds",
- "columnsFrom": [
- "build_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "deployment_events_build_id_event_id_pk": {
- "name": "deployment_events_build_id_event_id_pk",
- "columns": [
- "build_id",
- "event_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_threat_detections": {
- "name": "deployment_threat_detections",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "build_id": {
- "name": "build_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "threat_type": {
- "name": "threat_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_deployment_threat_detections_deployment_id": {
- "name": "idx_deployment_threat_detections_deployment_id",
- "columns": [
- {
- "expression": "deployment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_threat_detections_created_at": {
- "name": "idx_deployment_threat_detections_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_threat_detections_deployment_id_deployments_id_fk": {
- "name": "deployment_threat_detections_deployment_id_deployments_id_fk",
- "tableFrom": "deployment_threat_detections",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "deployment_threat_detections_build_id_deployment_builds_id_fk": {
- "name": "deployment_threat_detections_build_id_deployment_builds_id_fk",
- "tableFrom": "deployment_threat_detections",
- "tableTo": "deployment_builds",
- "columnsFrom": [
- "build_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployments": {
- "name": "deployments",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "deployment_slug": {
- "name": "deployment_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "internal_worker_name": {
- "name": "internal_worker_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "repository_source": {
- "name": "repository_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "branch": {
- "name": "branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "deployment_url": {
- "name": "deployment_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "source_type": {
- "name": "source_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "git_auth_token": {
- "name": "git_auth_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "last_deployed_at": {
- "name": "last_deployed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_build_id": {
- "name": "last_build_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "threat_status": {
- "name": "threat_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_from": {
- "name": "created_from",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_deployments_owned_by_user_id": {
- "name": "idx_deployments_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_owned_by_organization_id": {
- "name": "idx_deployments_owned_by_organization_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_platform_integration_id": {
- "name": "idx_deployments_platform_integration_id",
- "columns": [
- {
- "expression": "platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_repository_source_branch": {
- "name": "idx_deployments_repository_source_branch",
- "columns": [
- {
- "expression": "repository_source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_threat_status_pending": {
- "name": "idx_deployments_threat_status_pending",
- "columns": [
- {
- "expression": "threat_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"deployments\".\"threat_status\" = 'pending_scan'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployments_owned_by_user_id_kilocode_users_id_fk": {
- "name": "deployments_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "deployments",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "deployments_owned_by_organization_id_organizations_id_fk": {
- "name": "deployments_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "deployments",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_deployments_deployment_slug": {
- "name": "UQ_deployments_deployment_slug",
- "nullsNotDistinct": false,
- "columns": [
- "deployment_slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "deployments_owner_check": {
- "name": "deployments_owner_check",
- "value": "(\n (\"deployments\".\"owned_by_user_id\" IS NOT NULL AND \"deployments\".\"owned_by_organization_id\" IS NULL) OR\n (\"deployments\".\"owned_by_user_id\" IS NULL AND \"deployments\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "deployments_source_type_check": {
- "name": "deployments_source_type_check",
- "value": "\"deployments\".\"source_type\" IN ('github', 'git', 'app-builder')"
- }
- },
- "isRLSEnabled": false
- },
- "public.deployments_ephemeral": {
- "name": "deployments_ephemeral",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_type": {
- "name": "source_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "internal_worker_name": {
- "name": "internal_worker_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "deployment_slug": {
- "name": "deployment_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "next_cleanup_at": {
- "name": "next_cleanup_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "cleanup_claim_token": {
- "name": "cleanup_claim_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cleanup_claimed_until": {
- "name": "cleanup_claimed_until",
- "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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_deployments_ephemeral_owned_by_user_id": {
- "name": "idx_deployments_ephemeral_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_ephemeral_next_cleanup_at": {
- "name": "idx_deployments_ephemeral_next_cleanup_at",
- "columns": [
- {
- "expression": "next_cleanup_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk": {
- "name": "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "deployments_ephemeral",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_deployments_ephemeral_internal_worker_name": {
- "name": "UQ_deployments_ephemeral_internal_worker_name",
- "nullsNotDistinct": false,
- "columns": [
- "internal_worker_name"
- ]
- },
- "UQ_deployments_ephemeral_deployment_slug": {
- "name": "UQ_deployments_ephemeral_deployment_slug",
- "nullsNotDistinct": false,
- "columns": [
- "deployment_slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "deployments_ephemeral_source_type_check": {
- "name": "deployments_ephemeral_source_type_check",
- "value": "\"deployments_ephemeral\".\"source_type\" IN ('html')"
- },
- "deployments_ephemeral_status_check": {
- "name": "deployments_ephemeral_status_check",
- "value": "\"deployments_ephemeral\".\"status\" IN ('pending', 'active', 'cleanup_retry')"
- },
- "deployments_ephemeral_claim_fields_check": {
- "name": "deployments_ephemeral_claim_fields_check",
- "value": "(\"deployments_ephemeral\".\"cleanup_claim_token\" IS NULL) = (\"deployments_ephemeral\".\"cleanup_claimed_until\" IS NULL)"
- },
- "deployments_ephemeral_active_fields_check": {
- "name": "deployments_ephemeral_active_fields_check",
- "value": "\"deployments_ephemeral\".\"status\" <> 'active' OR (\"deployments_ephemeral\".\"deployment_slug\" IS NOT NULL AND \"deployments_ephemeral\".\"expires_at\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.device_auth_requests": {
- "name": "device_auth_requests",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "approved_at": {
- "name": "approved_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "user_agent": {
- "name": "user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ip_address": {
- "name": "ip_address",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_device_auth_requests_code": {
- "name": "UQ_device_auth_requests_code",
- "columns": [
- {
- "expression": "code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_device_auth_requests_status": {
- "name": "IDX_device_auth_requests_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_device_auth_requests_expires_at": {
- "name": "IDX_device_auth_requests_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_device_auth_requests_kilo_user_id": {
- "name": "IDX_device_auth_requests_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "device_auth_requests_kilo_user_id_kilocode_users_id_fk": {
- "name": "device_auth_requests_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "device_auth_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.discord_gateway_listener": {
- "name": "discord_gateway_listener",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "default": 1
- },
- "listener_id": {
- "name": "listener_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "started_at": {
- "name": "started_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": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.editor_name": {
- "name": "editor_name",
- "schema": "",
- "columns": {
- "editor_name_id": {
- "name": "editor_name_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "editor_name": {
- "name": "editor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_editor_name": {
- "name": "UQ_editor_name",
- "columns": [
- {
- "expression": "editor_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.enrichment_data": {
- "name": "enrichment_data",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_enrichment_data": {
- "name": "github_enrichment_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "linkedin_enrichment_data": {
- "name": "linkedin_enrichment_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "clay_enrichment_data": {
- "name": "clay_enrichment_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_enrichment_data_user_id": {
- "name": "IDX_enrichment_data_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "enrichment_data_user_id_kilocode_users_id_fk": {
- "name": "enrichment_data_user_id_kilocode_users_id_fk",
- "tableFrom": "enrichment_data",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_enrichment_data_user_id": {
- "name": "UQ_enrichment_data_user_id",
- "nullsNotDistinct": false,
- "columns": [
- "user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.exa_monthly_usage": {
- "name": "exa_monthly_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "month": {
- "name": "month",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "total_cost_microdollars": {
- "name": "total_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "total_charged_microdollars": {
- "name": "total_charged_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "request_count": {
- "name": "request_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "free_allowance_microdollars": {
- "name": "free_allowance_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 10000000
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_exa_monthly_usage_personal": {
- "name": "idx_exa_monthly_usage_personal",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "month",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"exa_monthly_usage\".\"organization_id\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_exa_monthly_usage_org": {
- "name": "idx_exa_monthly_usage_org",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "month",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"exa_monthly_usage\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.exa_usage_log": {
- "name": "exa_usage_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "path": {
- "name": "path",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cost_microdollars": {
- "name": "cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "charged_to_balance": {
- "name": "charged_to_balance",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "feature_id": {
- "name": "feature_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_exa_usage_log_user_created": {
- "name": "idx_exa_usage_log_user_created",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {
- "exa_usage_log_id_created_at_pk": {
- "name": "exa_usage_log_id_created_at_pk",
- "columns": [
- "id",
- "created_at"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.feature": {
- "name": "feature",
- "schema": "",
- "columns": {
- "feature_id": {
- "name": "feature_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "feature": {
- "name": "feature",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_feature": {
- "name": "UQ_feature",
- "columns": [
- {
- "expression": "feature",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.finish_reason": {
- "name": "finish_reason",
- "schema": "",
- "columns": {
- "finish_reason_id": {
- "name": "finish_reason_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "finish_reason": {
- "name": "finish_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_finish_reason": {
- "name": "UQ_finish_reason",
- "columns": [
- {
- "expression": "finish_reason",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.free_model_usage": {
- "name": "free_model_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "ip_address": {
- "name": "ip_address",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_free_model_usage_ip_created_at": {
- "name": "idx_free_model_usage_ip_created_at",
- "columns": [
- {
- "expression": "ip_address",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_free_model_usage_created_at": {
- "name": "idx_free_model_usage_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.github_branch_pull_requests": {
- "name": "github_branch_pull_requests",
- "schema": "",
- "columns": {
- "git_url": {
- "name": "git_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_state": {
- "name": "pr_state",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_title": {
- "name": "pr_title",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_sha": {
- "name": "pr_head_sha",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_review_decision": {
- "name": "pr_review_decision",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "review_decision_pending": {
- "name": "review_decision_pending",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "review_decision_fetching_at": {
- "name": "review_decision_fetching_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "pr_last_synced_at": {
- "name": "pr_last_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_github_branch_prs_org": {
- "name": "UQ_github_branch_prs_org",
- "columns": [
- {
- "expression": "git_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"github_branch_pull_requests\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_github_branch_prs_user": {
- "name": "UQ_github_branch_prs_user",
- "columns": [
- {
- "expression": "git_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"github_branch_pull_requests\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk": {
- "name": "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "github_branch_pull_requests",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk": {
- "name": "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "github_branch_pull_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "github_branch_pull_requests_owner_check": {
- "name": "github_branch_pull_requests_owner_check",
- "value": "(\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NOT NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NULL) OR\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NOT NULL)\n )"
- },
- "github_branch_pull_requests_review_decision_check": {
- "name": "github_branch_pull_requests_review_decision_check",
- "value": "\"github_branch_pull_requests\".\"pr_review_decision\" IS NULL OR \"github_branch_pull_requests\".\"pr_review_decision\" IN ('approved', 'changes_requested', 'review_required')"
- }
- },
- "isRLSEnabled": false
- },
- "public.http_ip": {
- "name": "http_ip",
- "schema": "",
- "columns": {
- "http_ip_id": {
- "name": "http_ip_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "http_ip": {
- "name": "http_ip",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_http_ip": {
- "name": "UQ_http_ip",
- "columns": [
- {
- "expression": "http_ip",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.http_user_agent": {
- "name": "http_user_agent",
- "schema": "",
- "columns": {
- "http_user_agent_id": {
- "name": "http_user_agent_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "http_user_agent": {
- "name": "http_user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_http_user_agent": {
- "name": "UQ_http_user_agent",
- "columns": [
- {
- "expression": "http_user_agent",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.impact_advocate_participants": {
- "name": "impact_advocate_participants",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "program_key": {
- "name": "program_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "advocate_id": {
- "name": "advocate_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "advocate_account_id": {
- "name": "advocate_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "opaque_referral_identifier": {
- "name": "opaque_referral_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "contact_email": {
- "name": "contact_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "locale": {
- "name": "locale",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "country_code": {
- "name": "country_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "registration_state": {
- "name": "registration_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "registered_at": {
- "name": "registered_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_registration_attempt_at": {
- "name": "last_registration_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_code": {
- "name": "last_error_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_message": {
- "name": "last_error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_impact_advocate_participants_program_referral_identifier": {
- "name": "UQ_impact_advocate_participants_program_referral_identifier",
- "columns": [
- {
- "expression": "program_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "opaque_referral_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"impact_advocate_participants\".\"opaque_referral_identifier\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_advocate_participants_registration_state": {
- "name": "IDX_impact_advocate_participants_registration_state",
- "columns": [
- {
- "expression": "registration_state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_advocate_participants_user_id_kilocode_users_id_fk": {
- "name": "impact_advocate_participants_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_advocate_participants",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_advocate_participants_program_user": {
- "name": "UQ_impact_advocate_participants_program_user",
- "nullsNotDistinct": false,
- "columns": [
- "program_key",
- "user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_advocate_participants_program_key_check": {
- "name": "impact_advocate_participants_program_key_check",
- "value": "\"impact_advocate_participants\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_advocate_participants_registration_state_check": {
- "name": "impact_advocate_participants_registration_state_check",
- "value": "\"impact_advocate_participants\".\"registration_state\" IN ('pending', 'retrying', 'registered', 'failed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_advocate_registration_attempts": {
- "name": "impact_advocate_registration_attempts",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "program_key": {
- "name": "program_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "participant_id": {
- "name": "participant_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "opaque_cookie_value": {
- "name": "opaque_cookie_value",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cookie_value_length": {
- "name": "cookie_value_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "delivery_state": {
- "name": "delivery_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "request_payload": {
- "name": "request_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_payload": {
- "name": "response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_status_code": {
- "name": "response_status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_advocate_registration_attempts_participant_id": {
- "name": "IDX_impact_advocate_registration_attempts_participant_id",
- "columns": [
- {
- "expression": "participant_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_advocate_registration_attempts_delivery_state": {
- "name": "IDX_impact_advocate_registration_attempts_delivery_state",
- "columns": [
- {
- "expression": "delivery_state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk": {
- "name": "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk",
- "tableFrom": "impact_advocate_registration_attempts",
- "tableTo": "impact_advocate_participants",
- "columnsFrom": [
- "participant_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_advocate_registration_attempts_dedupe_key": {
- "name": "UQ_impact_advocate_registration_attempts_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_advocate_registration_attempts_program_key_check": {
- "name": "impact_advocate_registration_attempts_program_key_check",
- "value": "\"impact_advocate_registration_attempts\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_advocate_registration_attempts_delivery_state_check": {
- "name": "impact_advocate_registration_attempts_delivery_state_check",
- "value": "\"impact_advocate_registration_attempts\".\"delivery_state\" IN ('queued', 'sending', 'succeeded', 'failed')"
- },
- "impact_advocate_registration_attempts_cookie_value_length_non_negative_check": {
- "name": "impact_advocate_registration_attempts_cookie_value_length_non_negative_check",
- "value": "\"impact_advocate_registration_attempts\".\"cookie_value_length\" >= 0"
- },
- "impact_advocate_registration_attempts_attempt_count_non_negative_check": {
- "name": "impact_advocate_registration_attempts_attempt_count_non_negative_check",
- "value": "\"impact_advocate_registration_attempts\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_advocate_reward_redemptions": {
- "name": "impact_advocate_reward_redemptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "reward_id": {
- "name": "reward_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "state": {
- "name": "state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "impact_reward_id": {
- "name": "impact_reward_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "request_payload": {
- "name": "request_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "lookup_response_payload": {
- "name": "lookup_response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "redeem_response_payload": {
- "name": "redeem_response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_status_code": {
- "name": "response_status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "redeemed_at": {
- "name": "redeemed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_advocate_reward_redemptions_beneficiary_user_id": {
- "name": "IDX_impact_advocate_reward_redemptions_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_advocate_reward_redemptions_state": {
- "name": "IDX_impact_advocate_reward_redemptions_state",
- "columns": [
- {
- "expression": "state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk": {
- "name": "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk",
- "tableFrom": "impact_advocate_reward_redemptions",
- "tableTo": "impact_referral_rewards",
- "columnsFrom": [
- "reward_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_advocate_reward_redemptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_advocate_reward_redemptions_reward_id": {
- "name": "UQ_impact_advocate_reward_redemptions_reward_id",
- "nullsNotDistinct": false,
- "columns": [
- "reward_id"
- ]
- },
- "UQ_impact_advocate_reward_redemptions_dedupe_key": {
- "name": "UQ_impact_advocate_reward_redemptions_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_advocate_reward_redemptions_state_check": {
- "name": "impact_advocate_reward_redemptions_state_check",
- "value": "\"impact_advocate_reward_redemptions\".\"state\" IN ('queued', 'retrying', 'redeemed', 'failed')"
- },
- "impact_advocate_reward_redemptions_attempt_count_non_negative_check": {
- "name": "impact_advocate_reward_redemptions_attempt_count_non_negative_check",
- "value": "\"impact_advocate_reward_redemptions\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_attribution_touches": {
- "name": "impact_attribution_touches",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "program_key": {
- "name": "program_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'kiloclaw'"
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "anonymous_id": {
- "name": "anonymous_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "touch_type": {
- "name": "touch_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "opaque_tracking_value": {
- "name": "opaque_tracking_value",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "tracking_value_length": {
- "name": "tracking_value_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "is_tracking_value_accepted": {
- "name": "is_tracking_value_accepted",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "rs_code": {
- "name": "rs_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "rs_share_medium": {
- "name": "rs_share_medium",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "rs_engagement_medium": {
- "name": "rs_engagement_medium",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "im_ref": {
- "name": "im_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "landing_path": {
- "name": "landing_path",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_source": {
- "name": "utm_source",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_medium": {
- "name": "utm_medium",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_campaign": {
- "name": "utm_campaign",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_term": {
- "name": "utm_term",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_content": {
- "name": "utm_content",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "touched_at": {
- "name": "touched_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "sale_attributed_at": {
- "name": "sale_attributed_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": {
- "IDX_impact_attribution_touches_product_user_id": {
- "name": "IDX_impact_attribution_touches_product_user_id",
- "columns": [
- {
- "expression": "product",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_user_id": {
- "name": "IDX_impact_attribution_touches_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_anonymous_id": {
- "name": "IDX_impact_attribution_touches_anonymous_id",
- "columns": [
- {
- "expression": "anonymous_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_expires_at": {
- "name": "IDX_impact_attribution_touches_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_sale_attributed_at": {
- "name": "IDX_impact_attribution_touches_sale_attributed_at",
- "columns": [
- {
- "expression": "sale_attributed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_attribution_touches_user_id_kilocode_users_id_fk": {
- "name": "impact_attribution_touches_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_attribution_touches",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_attribution_touches_dedupe_key": {
- "name": "UQ_impact_attribution_touches_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_attribution_touches_product_check": {
- "name": "impact_attribution_touches_product_check",
- "value": "\"impact_attribution_touches\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_attribution_touches_program_key_check": {
- "name": "impact_attribution_touches_program_key_check",
- "value": "\"impact_attribution_touches\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_attribution_touches_touch_type_check": {
- "name": "impact_attribution_touches_touch_type_check",
- "value": "\"impact_attribution_touches\".\"touch_type\" IN ('affiliate', 'referral')"
- },
- "impact_attribution_touches_provider_check": {
- "name": "impact_attribution_touches_provider_check",
- "value": "\"impact_attribution_touches\".\"provider\" IN ('impact_performance', 'impact_advocate')"
- },
- "impact_attribution_touches_tracking_value_length_non_negative_check": {
- "name": "impact_attribution_touches_tracking_value_length_non_negative_check",
- "value": "\"impact_attribution_touches\".\"tracking_value_length\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_conversion_reports": {
- "name": "impact_conversion_reports",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "conversion_id": {
- "name": "conversion_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "action_tracker_id": {
- "name": "action_tracker_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "order_id": {
- "name": "order_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "state": {
- "name": "state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "request_payload": {
- "name": "request_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_payload": {
- "name": "response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_status_code": {
- "name": "response_status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "delivered_at": {
- "name": "delivered_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_conversion_reports_conversion_id": {
- "name": "IDX_impact_conversion_reports_conversion_id",
- "columns": [
- {
- "expression": "conversion_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_conversion_reports_state": {
- "name": "IDX_impact_conversion_reports_state",
- "columns": [
- {
- "expression": "state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk": {
- "name": "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk",
- "tableFrom": "impact_conversion_reports",
- "tableTo": "impact_referral_conversions",
- "columnsFrom": [
- "conversion_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_conversion_reports_dedupe_key": {
- "name": "UQ_impact_conversion_reports_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_conversion_reports_state_check": {
- "name": "impact_conversion_reports_state_check",
- "value": "\"impact_conversion_reports\".\"state\" IN ('queued', 'retrying', 'delivered', 'failed')"
- },
- "impact_conversion_reports_attempt_count_non_negative_check": {
- "name": "impact_conversion_reports_attempt_count_non_negative_check",
- "value": "\"impact_conversion_reports\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_conversions": {
- "name": "impact_referral_conversions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "referee_user_id": {
- "name": "referee_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "referrer_user_id": {
- "name": "referrer_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_touch_id": {
- "name": "source_touch_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "winning_touch_type": {
- "name": "winning_touch_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'credits'"
- },
- "source_payment_id": {
- "name": "source_payment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "qualified": {
- "name": "qualified",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "disqualification_reason": {
- "name": "disqualification_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "converted_at": {
- "name": "converted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_conversions_referee_user_id": {
- "name": "IDX_impact_referral_conversions_referee_user_id",
- "columns": [
- {
- "expression": "referee_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referral_conversions_referrer_user_id": {
- "name": "IDX_impact_referral_conversions_referrer_user_id",
- "columns": [
- {
- "expression": "referrer_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_conversions_referee_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_conversions_referee_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_conversions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referee_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_conversions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referrer_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk": {
- "name": "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk",
- "tableFrom": "impact_referral_conversions",
- "tableTo": "impact_attribution_touches",
- "columnsFrom": [
- "source_touch_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referral_conversions_product_payment_source": {
- "name": "UQ_impact_referral_conversions_product_payment_source",
- "nullsNotDistinct": false,
- "columns": [
- "product",
- "payment_provider",
- "source_payment_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referral_conversions_product_check": {
- "name": "impact_referral_conversions_product_check",
- "value": "\"impact_referral_conversions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_referral_conversions_winning_touch_type_check": {
- "name": "impact_referral_conversions_winning_touch_type_check",
- "value": "\"impact_referral_conversions\".\"winning_touch_type\" IN ('referral', 'affiliate', 'none')"
- },
- "impact_referral_conversions_payment_provider_check": {
- "name": "impact_referral_conversions_payment_provider_check",
- "value": "\"impact_referral_conversions\".\"payment_provider\" IN ('stripe', 'credits', 'app_store', 'google_play')"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_reward_applications": {
- "name": "impact_referral_reward_applications",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "reward_id": {
- "name": "reward_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "previous_renewal_boundary": {
- "name": "previous_renewal_boundary",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "new_renewal_boundary": {
- "name": "new_renewal_boundary",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "local_operation_id": {
- "name": "local_operation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_operation_id": {
- "name": "stripe_operation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_idempotency_key": {
- "name": "stripe_idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "applied_at": {
- "name": "applied_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_reward_applications_reward_id": {
- "name": "IDX_impact_referral_reward_applications_reward_id",
- "columns": [
- {
- "expression": "reward_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referral_reward_applications_beneficiary_user_id": {
- "name": "IDX_impact_referral_reward_applications_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk": {
- "name": "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk",
- "tableFrom": "impact_referral_reward_applications",
- "tableTo": "impact_referral_rewards",
- "columnsFrom": [
- "reward_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_reward_applications",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "impact_referral_reward_applications_product_check": {
- "name": "impact_referral_reward_applications_product_check",
- "value": "\"impact_referral_reward_applications\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_reward_decisions": {
- "name": "impact_referral_reward_decisions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "conversion_id": {
- "name": "conversion_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_role": {
- "name": "beneficiary_role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "outcome": {
- "name": "outcome",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "reward_kind": {
- "name": "reward_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw_free_month'"
- },
- "months_granted": {
- "name": "months_granted",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "reward_percent": {
- "name": "reward_percent",
- "type": "numeric(6, 4)",
- "primaryKey": false,
- "notNull": false
- },
- "source_tier": {
- "name": "source_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "reward_amount_usd": {
- "name": "reward_amount_usd",
- "type": "numeric(12, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_reward_decisions_beneficiary_user_id": {
- "name": "IDX_impact_referral_reward_decisions_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk": {
- "name": "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk",
- "tableFrom": "impact_referral_reward_decisions",
- "tableTo": "impact_referral_conversions",
- "columnsFrom": [
- "conversion_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_reward_decisions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referral_reward_decisions_conversion_role": {
- "name": "UQ_impact_referral_reward_decisions_conversion_role",
- "nullsNotDistinct": false,
- "columns": [
- "conversion_id",
- "beneficiary_role"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referral_reward_decisions_product_check": {
- "name": "impact_referral_reward_decisions_product_check",
- "value": "\"impact_referral_reward_decisions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_referral_reward_decisions_beneficiary_role_check": {
- "name": "impact_referral_reward_decisions_beneficiary_role_check",
- "value": "\"impact_referral_reward_decisions\".\"beneficiary_role\" IN ('referrer', 'referee')"
- },
- "impact_referral_reward_decisions_outcome_check": {
- "name": "impact_referral_reward_decisions_outcome_check",
- "value": "\"impact_referral_reward_decisions\".\"outcome\" IN ('granted', 'cap_limited', 'disqualified')"
- },
- "impact_referral_reward_decisions_reward_kind_check": {
- "name": "impact_referral_reward_decisions_reward_kind_check",
- "value": "\"impact_referral_reward_decisions\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
- },
- "impact_referral_reward_decisions_months_granted_non_negative_check": {
- "name": "impact_referral_reward_decisions_months_granted_non_negative_check",
- "value": "\"impact_referral_reward_decisions\".\"months_granted\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_rewards": {
- "name": "impact_referral_rewards",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "conversion_id": {
- "name": "conversion_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "decision_id": {
- "name": "decision_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_role": {
- "name": "beneficiary_role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reward_kind": {
- "name": "reward_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw_free_month'"
- },
- "months_granted": {
- "name": "months_granted",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "reward_percent": {
- "name": "reward_percent",
- "type": "numeric(6, 4)",
- "primaryKey": false,
- "notNull": false
- },
- "source_tier": {
- "name": "source_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "reward_amount_usd": {
- "name": "reward_amount_usd",
- "type": "numeric(12, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "applies_to_subscription_id": {
- "name": "applies_to_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "applies_to_kilo_pass_subscription_id": {
- "name": "applies_to_kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "consumed_kilo_pass_issuance_id": {
- "name": "consumed_kilo_pass_issuance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "consumed_kilo_pass_issuance_item_id": {
- "name": "consumed_kilo_pass_issuance_item_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "earned_at": {
- "name": "earned_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "applied_at": {
- "name": "applied_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "reversed_at": {
- "name": "reversed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "review_reason": {
- "name": "review_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_rewards_beneficiary_user_id": {
- "name": "IDX_impact_referral_rewards_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referral_rewards_status": {
- "name": "IDX_impact_referral_rewards_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk": {
- "name": "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "impact_referral_conversions",
- "columnsFrom": [
- "conversion_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk": {
- "name": "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "impact_referral_reward_decisions",
- "columnsFrom": [
- "decision_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "FK_impact_referral_rewards_kilo_pass_subscription": {
- "name": "FK_impact_referral_rewards_kilo_pass_subscription",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "applies_to_kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "FK_impact_referral_rewards_kilo_pass_issuance": {
- "name": "FK_impact_referral_rewards_kilo_pass_issuance",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilo_pass_issuances",
- "columnsFrom": [
- "consumed_kilo_pass_issuance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "FK_impact_referral_rewards_kilo_pass_issuance_item": {
- "name": "FK_impact_referral_rewards_kilo_pass_issuance_item",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilo_pass_issuance_items",
- "columnsFrom": [
- "consumed_kilo_pass_issuance_item_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referral_rewards_conversion_role": {
- "name": "UQ_impact_referral_rewards_conversion_role",
- "nullsNotDistinct": false,
- "columns": [
- "conversion_id",
- "beneficiary_role"
- ]
- },
- "UQ_impact_referral_rewards_decision_id": {
- "name": "UQ_impact_referral_rewards_decision_id",
- "nullsNotDistinct": false,
- "columns": [
- "decision_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referral_rewards_product_check": {
- "name": "impact_referral_rewards_product_check",
- "value": "\"impact_referral_rewards\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_referral_rewards_beneficiary_role_check": {
- "name": "impact_referral_rewards_beneficiary_role_check",
- "value": "\"impact_referral_rewards\".\"beneficiary_role\" IN ('referrer', 'referee')"
- },
- "impact_referral_rewards_reward_kind_check": {
- "name": "impact_referral_rewards_reward_kind_check",
- "value": "\"impact_referral_rewards\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
- },
- "impact_referral_rewards_status_check": {
- "name": "impact_referral_rewards_status_check",
- "value": "\"impact_referral_rewards\".\"status\" IN ('pending', 'earned', 'applied', 'reversed', 'expired', 'canceled', 'review_required')"
- },
- "impact_referral_rewards_months_granted_non_negative_check": {
- "name": "impact_referral_rewards_months_granted_non_negative_check",
- "value": "\"impact_referral_rewards\".\"months_granted\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referrals": {
- "name": "impact_referrals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "referee_user_id": {
- "name": "referee_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "referrer_user_id": {
- "name": "referrer_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_touch_id": {
- "name": "source_touch_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "impact_referral_id": {
- "name": "impact_referral_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referrals_referrer_user_id": {
- "name": "IDX_impact_referrals_referrer_user_id",
- "columns": [
- {
- "expression": "referrer_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referrals_source_touch_id": {
- "name": "IDX_impact_referrals_source_touch_id",
- "columns": [
- {
- "expression": "source_touch_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referrals_referee_user_id_kilocode_users_id_fk": {
- "name": "impact_referrals_referee_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referrals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referee_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referrals_referrer_user_id_kilocode_users_id_fk": {
- "name": "impact_referrals_referrer_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referrals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referrer_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "impact_referrals_source_touch_id_impact_attribution_touches_id_fk": {
- "name": "impact_referrals_source_touch_id_impact_attribution_touches_id_fk",
- "tableFrom": "impact_referrals",
- "tableTo": "impact_attribution_touches",
- "columnsFrom": [
- "source_touch_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referrals_product_referee_user_id": {
- "name": "UQ_impact_referrals_product_referee_user_id",
- "nullsNotDistinct": false,
- "columns": [
- "product",
- "referee_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referrals_product_check": {
- "name": "impact_referrals_product_check",
- "value": "\"impact_referrals\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- }
- },
- "isRLSEnabled": false
- },
- "public.ja4_digest": {
- "name": "ja4_digest",
- "schema": "",
- "columns": {
- "ja4_digest_id": {
- "name": "ja4_digest_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "ja4_digest": {
- "name": "ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_ja4_digest": {
- "name": "UQ_ja4_digest",
- "columns": [
- {
- "expression": "ja4_digest",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kilo_pass_audit_log": {
- "name": "kilo_pass_audit_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "result": {
- "name": "result",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_event_id": {
- "name": "stripe_event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_invoice_id": {
- "name": "stripe_invoice_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "related_credit_transaction_id": {
- "name": "related_credit_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "related_monthly_issuance_id": {
- "name": "related_monthly_issuance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "payload_json": {
- "name": "payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- }
- },
- "indexes": {
- "IDX_kilo_pass_audit_log_created_at": {
- "name": "IDX_kilo_pass_audit_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_kilo_user_id": {
- "name": "IDX_kilo_pass_audit_log_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_kilo_pass_subscription_id": {
- "name": "IDX_kilo_pass_audit_log_kilo_pass_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_action": {
- "name": "IDX_kilo_pass_audit_log_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_result": {
- "name": "IDX_kilo_pass_audit_log_result",
- "columns": [
- {
- "expression": "result",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_idempotency_key": {
- "name": "IDX_kilo_pass_audit_log_idempotency_key",
- "columns": [
- {
- "expression": "idempotency_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_stripe_event_id": {
- "name": "IDX_kilo_pass_audit_log_stripe_event_id",
- "columns": [
- {
- "expression": "stripe_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_stripe_invoice_id": {
- "name": "IDX_kilo_pass_audit_log_stripe_invoice_id",
- "columns": [
- {
- "expression": "stripe_invoice_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_stripe_subscription_id": {
- "name": "IDX_kilo_pass_audit_log_stripe_subscription_id",
- "columns": [
- {
- "expression": "stripe_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_related_credit_transaction_id": {
- "name": "IDX_kilo_pass_audit_log_related_credit_transaction_id",
- "columns": [
- {
- "expression": "related_credit_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_related_monthly_issuance_id": {
- "name": "IDX_kilo_pass_audit_log_related_monthly_issuance_id",
- "columns": [
- {
- "expression": "related_monthly_issuance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk": {
- "name": "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "credit_transactions",
- "columnsFrom": [
- "related_credit_transaction_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk": {
- "name": "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "kilo_pass_issuances",
- "columnsFrom": [
- "related_monthly_issuance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_audit_log_action_check": {
- "name": "kilo_pass_audit_log_action_check",
- "value": "\"kilo_pass_audit_log\".\"action\" IN ('stripe_webhook_received', 'kilo_pass_invoice_paid_handled', 'store_purchase_completed', 'store_notification_received', 'store_subscription_renewed', 'store_subscription_canceled', 'store_subscription_expired', 'store_subscription_refunded', 'base_credits_issued', 'bonus_credits_issued', 'bonus_credits_skipped_idempotent', 'first_month_50pct_promo_issued', 'yearly_monthly_base_cron_started', 'yearly_monthly_base_cron_completed', 'issue_yearly_remaining_credits', 'duplicate_card_subscription_canceled', 'yearly_monthly_bonus_cron_started', 'yearly_monthly_bonus_cron_completed')"
- },
- "kilo_pass_audit_log_result_check": {
- "name": "kilo_pass_audit_log_result_check",
- "value": "\"kilo_pass_audit_log\".\"result\" IN ('success', 'skipped_idempotent', 'failed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_issuance_items": {
- "name": "kilo_pass_issuance_items",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_issuance_id": {
- "name": "kilo_pass_issuance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kind": {
- "name": "kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "credit_transaction_id": {
- "name": "credit_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "amount_usd": {
- "name": "amount_usd",
- "type": "numeric(12, 2)",
- "primaryKey": false,
- "notNull": true
- },
- "bonus_percent_applied": {
- "name": "bonus_percent_applied",
- "type": "numeric(6, 4)",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_issuance_items_issuance_id": {
- "name": "IDX_kilo_pass_issuance_items_issuance_id",
- "columns": [
- {
- "expression": "kilo_pass_issuance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_issuance_items_credit_transaction_id": {
- "name": "IDX_kilo_pass_issuance_items_credit_transaction_id",
- "columns": [
- {
- "expression": "credit_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk": {
- "name": "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk",
- "tableFrom": "kilo_pass_issuance_items",
- "tableTo": "kilo_pass_issuances",
- "columnsFrom": [
- "kilo_pass_issuance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk": {
- "name": "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk",
- "tableFrom": "kilo_pass_issuance_items",
- "tableTo": "credit_transactions",
- "columnsFrom": [
- "credit_transaction_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kilo_pass_issuance_items_credit_transaction_id_unique": {
- "name": "kilo_pass_issuance_items_credit_transaction_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "credit_transaction_id"
- ]
- },
- "UQ_kilo_pass_issuance_items_issuance_kind": {
- "name": "UQ_kilo_pass_issuance_items_issuance_kind",
- "nullsNotDistinct": false,
- "columns": [
- "kilo_pass_issuance_id",
- "kind"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_issuance_items_bonus_percent_applied_range_check": {
- "name": "kilo_pass_issuance_items_bonus_percent_applied_range_check",
- "value": "\"kilo_pass_issuance_items\".\"bonus_percent_applied\" IS NULL OR (\"kilo_pass_issuance_items\".\"bonus_percent_applied\" >= 0 AND \"kilo_pass_issuance_items\".\"bonus_percent_applied\" <= 1)"
- },
- "kilo_pass_issuance_items_amount_usd_non_negative_check": {
- "name": "kilo_pass_issuance_items_amount_usd_non_negative_check",
- "value": "\"kilo_pass_issuance_items\".\"amount_usd\" >= 0"
- },
- "kilo_pass_issuance_items_kind_check": {
- "name": "kilo_pass_issuance_items_kind_check",
- "value": "\"kilo_pass_issuance_items\".\"kind\" IN ('base', 'bonus', 'promo_first_month_50pct', 'referral_bonus')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_issuances": {
- "name": "kilo_pass_issuances",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "issue_month": {
- "name": "issue_month",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "source": {
- "name": "source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_invoice_id": {
- "name": "stripe_invoice_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "initial_welcome_promo_eligibility_reason": {
- "name": "initial_welcome_promo_eligibility_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kilo_pass_issuances_stripe_invoice_id": {
- "name": "UQ_kilo_pass_issuances_stripe_invoice_id",
- "columns": [
- {
- "expression": "stripe_invoice_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_issuances\".\"stripe_invoice_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_issuances_subscription_id": {
- "name": "IDX_kilo_pass_issuances_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_issuances_issue_month": {
- "name": "IDX_kilo_pass_issuances_issue_month",
- "columns": [
- {
- "expression": "issue_month",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_issuances",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_kilo_pass_issuances_subscription_issue_month": {
- "name": "UQ_kilo_pass_issuances_subscription_issue_month",
- "nullsNotDistinct": false,
- "columns": [
- "kilo_pass_subscription_id",
- "issue_month"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_issuances_issue_month_day_one_check": {
- "name": "kilo_pass_issuances_issue_month_day_one_check",
- "value": "EXTRACT(DAY FROM \"kilo_pass_issuances\".\"issue_month\") = 1"
- },
- "kilo_pass_issuances_source_check": {
- "name": "kilo_pass_issuances_source_check",
- "value": "\"kilo_pass_issuances\".\"source\" IN ('stripe_invoice', 'app_store_transaction', 'google_play_transaction', 'cron')"
- },
- "kilo_pass_issuances_initial_welcome_promo_reason_check": {
- "name": "kilo_pass_issuances_initial_welcome_promo_reason_check",
- "value": "\"kilo_pass_issuances\".\"initial_welcome_promo_eligibility_reason\" IN ('first_payment_fingerprint_claim', 'fingerprint_previously_claimed', 'missing_fingerprint', 'no_supported_fingerprint', 'no_positive_settlement', 'settlement_unresolved')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_pause_events": {
- "name": "kilo_pass_pause_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "paused_at": {
- "name": "paused_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "resumes_at": {
- "name": "resumes_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "resumed_at": {
- "name": "resumed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_pause_events_subscription_id": {
- "name": "IDX_kilo_pass_pause_events_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_pause_events_one_open_per_sub": {
- "name": "UQ_kilo_pass_pause_events_one_open_per_sub",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_pause_events",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_pause_events_resumed_at_after_paused_at_check": {
- "name": "kilo_pass_pause_events_resumed_at_after_paused_at_check",
- "value": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL OR \"kilo_pass_pause_events\".\"resumed_at\" >= \"kilo_pass_pause_events\".\"paused_at\""
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_scheduled_changes": {
- "name": "kilo_pass_scheduled_changes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "from_tier": {
- "name": "from_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "from_cadence": {
- "name": "from_cadence",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "to_tier": {
- "name": "to_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "to_cadence": {
- "name": "to_cadence",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_schedule_id": {
- "name": "stripe_schedule_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "effective_at": {
- "name": "effective_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "deleted_at": {
- "name": "deleted_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_scheduled_changes_kilo_user_id": {
- "name": "IDX_kilo_pass_scheduled_changes_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_status": {
- "name": "IDX_kilo_pass_scheduled_changes_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_stripe_subscription_id": {
- "name": "IDX_kilo_pass_scheduled_changes_stripe_subscription_id",
- "columns": [
- {
- "expression": "stripe_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id": {
- "name": "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id",
- "columns": [
- {
- "expression": "stripe_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_scheduled_changes\".\"deleted_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_effective_at": {
- "name": "IDX_kilo_pass_scheduled_changes_effective_at",
- "columns": [
- {
- "expression": "effective_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_deleted_at": {
- "name": "IDX_kilo_pass_scheduled_changes_deleted_at",
- "columns": [
- {
- "expression": "deleted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_scheduled_changes",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk": {
- "name": "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk",
- "tableFrom": "kilo_pass_scheduled_changes",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "stripe_subscription_id"
- ],
- "columnsTo": [
- "stripe_subscription_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_scheduled_changes_from_tier_check": {
- "name": "kilo_pass_scheduled_changes_from_tier_check",
- "value": "\"kilo_pass_scheduled_changes\".\"from_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
- },
- "kilo_pass_scheduled_changes_from_cadence_check": {
- "name": "kilo_pass_scheduled_changes_from_cadence_check",
- "value": "\"kilo_pass_scheduled_changes\".\"from_cadence\" IN ('monthly', 'yearly')"
- },
- "kilo_pass_scheduled_changes_to_tier_check": {
- "name": "kilo_pass_scheduled_changes_to_tier_check",
- "value": "\"kilo_pass_scheduled_changes\".\"to_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
- },
- "kilo_pass_scheduled_changes_to_cadence_check": {
- "name": "kilo_pass_scheduled_changes_to_cadence_check",
- "value": "\"kilo_pass_scheduled_changes\".\"to_cadence\" IN ('monthly', 'yearly')"
- },
- "kilo_pass_scheduled_changes_status_check": {
- "name": "kilo_pass_scheduled_changes_status_check",
- "value": "\"kilo_pass_scheduled_changes\".\"status\" IN ('not_started', 'active', 'completed', 'released', 'canceled')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_store_events": {
- "name": "kilo_pass_store_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_id": {
- "name": "event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subscription_id": {
- "name": "provider_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider_transaction_id": {
- "name": "provider_transaction_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "app_account_token": {
- "name": "app_account_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "product_id": {
- "name": "product_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "environment": {
- "name": "environment",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payload_json": {
- "name": "payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "processing_started_at": {
- "name": "processing_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "processed_at": {
- "name": "processed_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": {
- "UQ_kilo_pass_store_events_provider_event": {
- "name": "UQ_kilo_pass_store_events_provider_event",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_events_provider_subscription": {
- "name": "IDX_kilo_pass_store_events_provider_subscription",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_events_app_account_token": {
- "name": "IDX_kilo_pass_store_events_app_account_token",
- "columns": [
- {
- "expression": "app_account_token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_store_events_payment_provider_check": {
- "name": "kilo_pass_store_events_payment_provider_check",
- "value": "\"kilo_pass_store_events\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_store_purchases": {
- "name": "kilo_pass_store_purchases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "product_id": {
- "name": "product_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subscription_id": {
- "name": "provider_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_transaction_id": {
- "name": "provider_transaction_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_original_transaction_id": {
- "name": "provider_original_transaction_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "app_account_token": {
- "name": "app_account_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "purchase_token": {
- "name": "purchase_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "environment": {
- "name": "environment",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "purchased_at": {
- "name": "purchased_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "raw_payload_json": {
- "name": "raw_payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kilo_pass_store_purchases_provider_transaction": {
- "name": "UQ_kilo_pass_store_purchases_provider_transaction",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_subscription_id": {
- "name": "IDX_kilo_pass_store_purchases_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_user_id": {
- "name": "IDX_kilo_pass_store_purchases_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_app_account_token": {
- "name": "IDX_kilo_pass_store_purchases_app_account_token",
- "columns": [
- {
- "expression": "app_account_token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_latest_subscription_purchase": {
- "name": "IDX_kilo_pass_store_purchases_latest_subscription_purchase",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "purchased_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_store_purchases",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_store_purchases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "FK_kilo_pass_store_purchases_subscription_owner_provider": {
- "name": "FK_kilo_pass_store_purchases_subscription_owner_provider",
- "tableFrom": "kilo_pass_store_purchases",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id",
- "kilo_user_id",
- "payment_provider",
- "provider_subscription_id"
- ],
- "columnsTo": [
- "id",
- "kilo_user_id",
- "payment_provider",
- "provider_subscription_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_store_purchases_store_provider_check": {
- "name": "kilo_pass_store_purchases_store_provider_check",
- "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('app_store', 'google_play')"
- },
- "kilo_pass_store_purchases_payment_provider_check": {
- "name": "kilo_pass_store_purchases_payment_provider_check",
- "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_subscriptions": {
- "name": "kilo_pass_subscriptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'stripe'"
- },
- "provider_subscription_id": {
- "name": "provider_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "tier": {
- "name": "tier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cadence": {
- "name": "cadence",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cancel_at_period_end": {
- "name": "cancel_at_period_end",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "ended_at": {
- "name": "ended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "current_streak_months": {
- "name": "current_streak_months",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_yearly_issue_at": {
- "name": "next_yearly_issue_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_subscriptions_kilo_user_id": {
- "name": "IDX_kilo_pass_subscriptions_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_subscriptions_payment_provider": {
- "name": "IDX_kilo_pass_subscriptions_payment_provider",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_subscriptions_status": {
- "name": "IDX_kilo_pass_subscriptions_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_subscriptions_cadence": {
- "name": "IDX_kilo_pass_subscriptions_cadence",
- "columns": [
- {
- "expression": "cadence",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_subscriptions_provider_subscription": {
- "name": "UQ_kilo_pass_subscriptions_provider_subscription",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_subscriptions_store_purchase_reference": {
- "name": "UQ_kilo_pass_subscriptions_store_purchase_reference",
- "columns": [
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_subscriptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kilo_pass_subscriptions_stripe_subscription_id_unique": {
- "name": "kilo_pass_subscriptions_stripe_subscription_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_subscription_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_subscriptions_current_streak_months_non_negative_check": {
- "name": "kilo_pass_subscriptions_current_streak_months_non_negative_check",
- "value": "\"kilo_pass_subscriptions\".\"current_streak_months\" >= 0"
- },
- "kilo_pass_subscriptions_provider_ids_check": {
- "name": "kilo_pass_subscriptions_provider_ids_check",
- "value": "(\n \"kilo_pass_subscriptions\".\"payment_provider\" = 'stripe'\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" = \"kilo_pass_subscriptions\".\"stripe_subscription_id\"\n ) OR (\n \"kilo_pass_subscriptions\".\"payment_provider\" IN ('app_store', 'google_play')\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NULL\n )"
- },
- "kilo_pass_subscriptions_payment_provider_check": {
- "name": "kilo_pass_subscriptions_payment_provider_check",
- "value": "\"kilo_pass_subscriptions\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
- },
- "kilo_pass_subscriptions_tier_check": {
- "name": "kilo_pass_subscriptions_tier_check",
- "value": "\"kilo_pass_subscriptions\".\"tier\" IN ('tier_19', 'tier_49', 'tier_199')"
- },
- "kilo_pass_subscriptions_cadence_check": {
- "name": "kilo_pass_subscriptions_cadence_check",
- "value": "\"kilo_pass_subscriptions\".\"cadence\" IN ('monthly', 'yearly')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_welcome_promo_payment_fingerprint_claims": {
- "name": "kilo_pass_welcome_promo_payment_fingerprint_claims",
- "schema": "",
- "columns": {
- "stripe_payment_method_type": {
- "name": "stripe_payment_method_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_fingerprint": {
- "name": "stripe_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_stripe_invoice_id": {
- "name": "source_stripe_invoice_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {
- "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk": {
- "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk",
- "columns": [
- "stripe_payment_method_type",
- "stripe_fingerprint"
- ]
- }
- },
- "uniqueConstraints": {
- "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id": {
- "name": "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id",
- "nullsNotDistinct": false,
- "columns": [
- "source_stripe_invoice_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check": {
- "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check",
- "value": "\"kilo_pass_welcome_promo_payment_fingerprint_claims\".\"stripe_payment_method_type\" IN ('card', 'sepa_debit', 'us_bank_account', 'bacs_debit', 'au_becs_debit')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_access_codes": {
- "name": "kiloclaw_access_codes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "redeemed_at": {
- "name": "redeemed_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": {
- "UQ_kiloclaw_access_codes_code": {
- "name": "UQ_kiloclaw_access_codes_code",
- "columns": [
- {
- "expression": "code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_access_codes_user_status": {
- "name": "IDX_kiloclaw_access_codes_user_status",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_access_codes_one_active_per_user": {
- "name": "UQ_kiloclaw_access_codes_one_active_per_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "status = 'active'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_access_codes",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_admin_audit_logs": {
- "name": "kiloclaw_admin_audit_logs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_email": {
- "name": "actor_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_name": {
- "name": "actor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "target_user_id": {
- "name": "target_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "message": {
- "name": "message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kiloclaw_admin_audit_logs_target_user_id": {
- "name": "IDX_kiloclaw_admin_audit_logs_target_user_id",
- "columns": [
- {
- "expression": "target_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_admin_audit_logs_action": {
- "name": "IDX_kiloclaw_admin_audit_logs_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_admin_audit_logs_created_at": {
- "name": "IDX_kiloclaw_admin_audit_logs_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_cli_runs": {
- "name": "kiloclaw_cli_runs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "initiated_by_admin_id": {
- "name": "initiated_by_admin_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "prompt": {
- "name": "prompt",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'running'"
- },
- "exit_code": {
- "name": "exit_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "output": {
- "name": "output",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_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": {
- "IDX_kiloclaw_cli_runs_user_id": {
- "name": "IDX_kiloclaw_cli_runs_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_cli_runs_started_at": {
- "name": "IDX_kiloclaw_cli_runs_started_at",
- "columns": [
- {
- "expression": "started_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_cli_runs_instance_id": {
- "name": "IDX_kiloclaw_cli_runs_instance_id",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_cli_runs_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_cli_runs_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_cli_runs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_cli_runs",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk": {
- "name": "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_cli_runs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "initiated_by_admin_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_earlybird_purchases": {
- "name": "kiloclaw_earlybird_purchases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "manual_payment_id": {
- "name": "manual_payment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "amount_cents": {
- "name": "amount_cents",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_earlybird_purchases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_earlybird_purchases_user_id_unique": {
- "name": "kiloclaw_earlybird_purchases_user_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "user_id"
- ]
- },
- "kiloclaw_earlybird_purchases_stripe_charge_id_unique": {
- "name": "kiloclaw_earlybird_purchases_stripe_charge_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_charge_id"
- ]
- },
- "kiloclaw_earlybird_purchases_manual_payment_id_unique": {
- "name": "kiloclaw_earlybird_purchases_manual_payment_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "manual_payment_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_email_log": {
- "name": "kiloclaw_email_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "email_type": {
- "name": "email_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_start": {
- "name": "period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "'epoch'"
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kiloclaw_email_log_user_type_global": {
- "name": "UQ_kiloclaw_email_log_user_type_global",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_email_log\".\"instance_id\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_email_log_user_instance_type_period": {
- "name": "UQ_kiloclaw_email_log_user_instance_type_period",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_start",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_email_log_type_sent_instance": {
- "name": "IDX_kiloclaw_email_log_type_sent_instance",
- "columns": [
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "sent_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_email_log_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_email_log_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_email_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_email_log",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_google_oauth_connections": {
- "name": "kiloclaw_google_oauth_connections",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'google'"
- },
- "account_email": {
- "name": "account_email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "account_subject": {
- "name": "account_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_secret_encrypted": {
- "name": "oauth_client_secret_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "credential_profile": {
- "name": "credential_profile",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kilo_owned'"
- },
- "refresh_token_encrypted": {
- "name": "refresh_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "scopes": {
- "name": "scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "grants_by_source": {
- "name": "grants_by_source",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "capabilities": {
- "name": "capabilities",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "last_error": {
- "name": "last_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_at": {
- "name": "last_error_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "connected_at": {
- "name": "connected_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kiloclaw_google_oauth_connections_instance": {
- "name": "UQ_kiloclaw_google_oauth_connections_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_google_oauth_connections_status": {
- "name": "IDX_kiloclaw_google_oauth_connections_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_google_oauth_connections_provider": {
- "name": "IDX_kiloclaw_google_oauth_connections_provider",
- "columns": [
- {
- "expression": "provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_google_oauth_connections",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kiloclaw_google_oauth_connections_status_check": {
- "name": "kiloclaw_google_oauth_connections_status_check",
- "value": "\"kiloclaw_google_oauth_connections\".\"status\" IN ('active', 'action_required', 'disconnected')"
- },
- "kiloclaw_google_oauth_connections_credential_profile_check": {
- "name": "kiloclaw_google_oauth_connections_credential_profile_check",
- "value": "\"kiloclaw_google_oauth_connections\".\"credential_profile\" IN ('legacy', 'kilo_owned')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_image_catalog": {
- "name": "kiloclaw_image_catalog",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "openclaw_version": {
- "name": "openclaw_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "variant": {
- "name": "variant",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'default'"
- },
- "image_tag": {
- "name": "image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "image_digest": {
- "name": "image_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'available'"
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "updated_by": {
- "name": "updated_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "published_at": {
- "name": "published_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "synced_at": {
- "name": "synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "rollout_percent": {
- "name": "rollout_percent",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "is_latest": {
- "name": "is_latest",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- }
- },
- "indexes": {
- "IDX_kiloclaw_image_catalog_status": {
- "name": "IDX_kiloclaw_image_catalog_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_image_catalog_variant": {
- "name": "IDX_kiloclaw_image_catalog_variant",
- "columns": [
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_image_catalog_one_latest_per_variant": {
- "name": "UQ_kiloclaw_image_catalog_one_latest_per_variant",
- "columns": [
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_image_catalog\".\"is_latest\" = true",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_image_catalog_one_candidate_per_variant": {
- "name": "UQ_kiloclaw_image_catalog_one_candidate_per_variant",
- "columns": [
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_image_catalog\".\"is_latest\" = false AND \"kiloclaw_image_catalog\".\"rollout_percent\" > 0 AND \"kiloclaw_image_catalog\".\"status\" = 'available'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_image_catalog_image_tag_unique": {
- "name": "kiloclaw_image_catalog_image_tag_unique",
- "nullsNotDistinct": false,
- "columns": [
- "image_tag"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_inbound_email_aliases": {
- "name": "kiloclaw_inbound_email_aliases",
- "schema": "",
- "columns": {
- "alias": {
- "name": "alias",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "retired_at": {
- "name": "retired_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_kiloclaw_inbound_email_aliases_instance_id": {
- "name": "IDX_kiloclaw_inbound_email_aliases_instance_id",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_inbound_email_aliases_active_instance": {
- "name": "UQ_kiloclaw_inbound_email_aliases_active_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_inbound_email_aliases\".\"retired_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_inbound_email_aliases",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_inbound_email_reserved_aliases": {
- "name": "kiloclaw_inbound_email_reserved_aliases",
- "schema": "",
- "columns": {
- "alias": {
- "name": "alias",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_instances": {
- "name": "kiloclaw_instances",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sandbox_id": {
- "name": "sandbox_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'fly'"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "inbound_email_enabled": {
- "name": "inbound_email_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "inactive_trial_stopped_at": {
- "name": "inactive_trial_stopped_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()"
- },
- "destroyed_at": {
- "name": "destroyed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "tracked_image_tag": {
- "name": "tracked_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "instance_type": {
- "name": "instance_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "admin_size_override": {
- "name": "admin_size_override",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_kiloclaw_instances_active": {
- "name": "UQ_kiloclaw_instances_active",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "sandbox_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_active_personal_by_user": {
- "name": "IDX_kiloclaw_instances_active_personal_by_user",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"organization_id\" IS NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_active_org_by_user_org": {
- "name": "IDX_kiloclaw_instances_active_org_by_user_org",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_active_org_by_org_created": {
- "name": "IDX_kiloclaw_instances_active_org_by_org_created",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_user_id_created_at": {
- "name": "IDX_kiloclaw_instances_user_id_created_at",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_tracked_image_tag": {
- "name": "IDX_kiloclaw_instances_tracked_image_tag",
- "columns": [
- {
- "expression": "tracked_image_tag",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_instance_type": {
- "name": "IDX_kiloclaw_instances_instance_type",
- "columns": [
- {
- "expression": "instance_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_admin_size_override": {
- "name": "IDX_kiloclaw_instances_admin_size_override",
- "columns": [
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"admin_size_override\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_instances_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_instances_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_instances",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_instances_organization_id_organizations_id_fk": {
- "name": "kiloclaw_instances_organization_id_organizations_id_fk",
- "tableFrom": "kiloclaw_instances",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "CHK_kiloclaw_instances_instance_type": {
- "name": "CHK_kiloclaw_instances_instance_type",
- "value": "\"kiloclaw_instances\".\"instance_type\" IS NULL OR \"kiloclaw_instances\".\"instance_type\" IN ('perf-1-3', 'perf-4-8', 'perf-4-16', 'shared-2-3', 'shared-2-4', 'custom')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_morning_briefing_configs": {
- "name": "kiloclaw_morning_briefing_configs",
- "schema": "",
- "columns": {
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "cron": {
- "name": "cron",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'0 7 * * *'"
- },
- "timezone": {
- "name": "timezone",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'UTC'"
- },
- "interest_topics": {
- "name": "interest_topics",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kiloclaw_morning_briefing_configs_enabled": {
- "name": "IDX_kiloclaw_morning_briefing_configs_enabled",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_morning_briefing_configs\".\"enabled\" = true",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_morning_briefing_configs",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_action_notifications": {
- "name": "kiloclaw_scheduled_action_notifications",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "target_id": {
- "name": "target_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "channel": {
- "name": "channel",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kind": {
- "name": "kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'notice'"
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel": {
- "name": "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel",
- "columns": [
- {
- "expression": "target_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "channel",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_notifications_pending": {
- "name": "IDX_kiloclaw_scheduled_action_notifications_pending",
- "columns": [
- {
- "expression": "target_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_scheduled_action_notifications\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk": {
- "name": "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_notifications",
- "tableTo": "kiloclaw_scheduled_action_targets",
- "columnsFrom": [
- "target_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_action_stages": {
- "name": "kiloclaw_scheduled_action_stages",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "scheduled_action_id": {
- "name": "scheduled_action_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "stage_index": {
- "name": "stage_index",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "scheduled_at": {
- "name": "scheduled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "notice_sent_at": {
- "name": "notice_sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "applied_count": {
- "name": "applied_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "skipped_count": {
- "name": "skipped_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "failed_count": {
- "name": "failed_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- }
- },
- "indexes": {
- "UQ_kiloclaw_scheduled_action_stages_parent_index": {
- "name": "UQ_kiloclaw_scheduled_action_stages_parent_index",
- "columns": [
- {
- "expression": "scheduled_action_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "stage_index",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_stages_notice_due": {
- "name": "IDX_kiloclaw_scheduled_action_stages_notice_due",
- "columns": [
- {
- "expression": "scheduled_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_scheduled_action_stages\".\"notice_sent_at\" IS NULL AND \"kiloclaw_scheduled_action_stages\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
- "name": "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_stages",
- "tableTo": "kiloclaw_scheduled_actions",
- "columnsFrom": [
- "scheduled_action_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_action_targets": {
- "name": "kiloclaw_scheduled_action_targets",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "scheduled_action_id": {
- "name": "scheduled_action_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "stage_id": {
- "name": "stage_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "source_image_tag": {
- "name": "source_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "target_image_tag": {
- "name": "target_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "applied_at": {
- "name": "applied_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "skip_reason": {
- "name": "skip_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_kiloclaw_scheduled_action_targets_parent_instance": {
- "name": "UQ_kiloclaw_scheduled_action_targets_parent_instance",
- "columns": [
- {
- "expression": "scheduled_action_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_targets_stage": {
- "name": "IDX_kiloclaw_scheduled_action_targets_stage",
- "columns": [
- {
- "expression": "stage_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_targets_pending_by_instance": {
- "name": "IDX_kiloclaw_scheduled_action_targets_pending_by_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_scheduled_action_targets\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kiloclaw_scheduled_actions",
- "columnsFrom": [
- "scheduled_action_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kiloclaw_scheduled_action_stages",
- "columnsFrom": [
- "stage_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_actions": {
- "name": "kiloclaw_scheduled_actions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "action_type": {
- "name": "action_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "target_image_tag": {
- "name": "target_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "override_pins": {
- "name": "override_pins",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "notice_lead_hours": {
- "name": "notice_lead_hours",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 24
- },
- "notice_subject": {
- "name": "notice_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "''"
- },
- "notice_body": {
- "name": "notice_body",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "''"
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'scheduled'"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "cancelled_at": {
- "name": "cancelled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "total_count": {
- "name": "total_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "applied_count": {
- "name": "applied_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "skipped_count": {
- "name": "skipped_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "failed_count": {
- "name": "failed_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- }
- },
- "indexes": {
- "IDX_kiloclaw_scheduled_actions_status": {
- "name": "IDX_kiloclaw_scheduled_actions_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_actions_action_type": {
- "name": "IDX_kiloclaw_scheduled_actions_action_type",
- "columns": [
- {
- "expression": "action_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_actions_created_by": {
- "name": "IDX_kiloclaw_scheduled_actions_created_by",
- "columns": [
- {
- "expression": "created_by",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk": {
- "name": "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk",
- "tableFrom": "kiloclaw_scheduled_actions",
- "tableTo": "kiloclaw_image_catalog",
- "columnsFrom": [
- "target_image_tag"
- ],
- "columnsTo": [
- "image_tag"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk": {
- "name": "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_scheduled_actions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_subscription_change_log": {
- "name": "kiloclaw_subscription_change_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "actor_type": {
- "name": "actor_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "before_state": {
- "name": "before_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "after_state": {
- "name": "after_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_kiloclaw_subscription_change_log_subscription_created_at": {
- "name": "IDX_kiloclaw_subscription_change_log_subscription_created_at",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscription_change_log_created_at": {
- "name": "IDX_kiloclaw_subscription_change_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk": {
- "name": "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk",
- "tableFrom": "kiloclaw_subscription_change_log",
- "tableTo": "kiloclaw_subscriptions",
- "columnsFrom": [
- "subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kiloclaw_subscription_change_log_actor_type_check": {
- "name": "kiloclaw_subscription_change_log_actor_type_check",
- "value": "\"kiloclaw_subscription_change_log\".\"actor_type\" IN ('user', 'system')"
- },
- "kiloclaw_subscription_change_log_action_check": {
- "name": "kiloclaw_subscription_change_log_action_check",
- "value": "\"kiloclaw_subscription_change_log\".\"action\" IN ('created', 'status_changed', 'plan_switched', 'period_advanced', 'canceled', 'reactivated', 'suspended', 'destruction_scheduled', 'reassigned', 'backfilled', 'payment_source_changed', 'schedule_changed', 'admin_override')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_subscriptions": {
- "name": "kiloclaw_subscriptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_schedule_id": {
- "name": "stripe_schedule_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "transferred_to_subscription_id": {
- "name": "transferred_to_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "access_origin": {
- "name": "access_origin",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "payment_source": {
- "name": "payment_source",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "kiloclaw_price_version": {
- "name": "kiloclaw_price_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan": {
- "name": "plan",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "scheduled_plan": {
- "name": "scheduled_plan",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "scheduled_by": {
- "name": "scheduled_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cancel_at_period_end": {
- "name": "cancel_at_period_end",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "pending_conversion": {
- "name": "pending_conversion",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "trial_started_at": {
- "name": "trial_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "trial_ends_at": {
- "name": "trial_ends_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "current_period_start": {
- "name": "current_period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "current_period_end": {
- "name": "current_period_end",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "credit_renewal_at": {
- "name": "credit_renewal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "commit_ends_at": {
- "name": "commit_ends_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "past_due_since": {
- "name": "past_due_since",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "suspended_at": {
- "name": "suspended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "destruction_deadline": {
- "name": "destruction_deadline",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_resume_requested_at": {
- "name": "auto_resume_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_resume_retry_after": {
- "name": "auto_resume_retry_after",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_resume_attempt_count": {
- "name": "auto_resume_attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "auto_top_up_triggered_for_period": {
- "name": "auto_top_up_triggered_for_period",
- "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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kiloclaw_subscriptions_status": {
- "name": "IDX_kiloclaw_subscriptions_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_user_id": {
- "name": "IDX_kiloclaw_subscriptions_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_user_status": {
- "name": "IDX_kiloclaw_subscriptions_user_status",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_price_version": {
- "name": "IDX_kiloclaw_subscriptions_price_version",
- "columns": [
- {
- "expression": "kiloclaw_price_version",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_transferred_to": {
- "name": "IDX_kiloclaw_subscriptions_transferred_to",
- "columns": [
- {
- "expression": "transferred_to_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_stripe_schedule_id": {
- "name": "IDX_kiloclaw_subscriptions_stripe_schedule_id",
- "columns": [
- {
- "expression": "stripe_schedule_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_auto_resume_retry_after": {
- "name": "IDX_kiloclaw_subscriptions_auto_resume_retry_after",
- "columns": [
- {
- "expression": "auto_resume_retry_after",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_subscriptions_instance": {
- "name": "UQ_kiloclaw_subscriptions_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_subscriptions\".\"instance_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_subscriptions_transferred_to": {
- "name": "UQ_kiloclaw_subscriptions_transferred_to",
- "columns": [
- {
- "expression": "transferred_to_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_subscriptions\".\"transferred_to_subscription_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_earlybird_origin": {
- "name": "IDX_kiloclaw_subscriptions_earlybird_origin",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "access_origin",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_subscriptions\".\"access_origin\" = 'earlybird'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_subscriptions_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_subscriptions_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_subscriptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk": {
- "name": "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk",
- "tableFrom": "kiloclaw_subscriptions",
- "tableTo": "kiloclaw_subscriptions",
- "columnsFrom": [
- "transferred_to_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_subscriptions",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_subscriptions_stripe_subscription_id_unique": {
- "name": "kiloclaw_subscriptions_stripe_subscription_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_subscription_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kiloclaw_subscriptions_price_version_check": {
- "name": "kiloclaw_subscriptions_price_version_check",
- "value": "\"kiloclaw_subscriptions\".\"kiloclaw_price_version\" IN ('2026-03-19', '2026-05-10')"
- },
- "kiloclaw_subscriptions_plan_check": {
- "name": "kiloclaw_subscriptions_plan_check",
- "value": "\"kiloclaw_subscriptions\".\"plan\" IN ('trial', 'commit', 'standard')"
- },
- "kiloclaw_subscriptions_scheduled_plan_check": {
- "name": "kiloclaw_subscriptions_scheduled_plan_check",
- "value": "\"kiloclaw_subscriptions\".\"scheduled_plan\" IN ('commit', 'standard')"
- },
- "kiloclaw_subscriptions_scheduled_by_check": {
- "name": "kiloclaw_subscriptions_scheduled_by_check",
- "value": "\"kiloclaw_subscriptions\".\"scheduled_by\" IN ('auto', 'user')"
- },
- "kiloclaw_subscriptions_status_check": {
- "name": "kiloclaw_subscriptions_status_check",
- "value": "\"kiloclaw_subscriptions\".\"status\" IN ('trialing', 'active', 'past_due', 'canceled', 'unpaid')"
- },
- "kiloclaw_subscriptions_access_origin_check": {
- "name": "kiloclaw_subscriptions_access_origin_check",
- "value": "\"kiloclaw_subscriptions\".\"access_origin\" IN ('earlybird')"
- },
- "kiloclaw_subscriptions_payment_source_check": {
- "name": "kiloclaw_subscriptions_payment_source_check",
- "value": "\"kiloclaw_subscriptions\".\"payment_source\" IN ('stripe', 'credits')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_terminal_renewal_failures": {
- "name": "kiloclaw_terminal_renewal_failures",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "renewal_boundary": {
- "name": "renewal_boundary",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unresolved'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "first_failure_at": {
- "name": "first_failure_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_failure_at": {
- "name": "last_failure_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_failure_code": {
- "name": "last_failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "last_failure_message": {
- "name": "last_failure_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_actor_type": {
- "name": "resolution_actor_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_actor_id": {
- "name": "resolution_actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_at": {
- "name": "resolution_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_reason": {
- "name": "resolution_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary": {
- "name": "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "renewal_boundary",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_terminal_renewal_failures_unresolved": {
- "name": "IDX_kiloclaw_terminal_renewal_failures_unresolved",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "renewal_boundary",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_terminal_renewal_failures\".\"status\" = 'unresolved'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at": {
- "name": "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "last_failure_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk": {
- "name": "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk",
- "tableFrom": "kiloclaw_terminal_renewal_failures",
- "tableTo": "kiloclaw_subscriptions",
- "columnsFrom": [
- "subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kiloclaw_terminal_renewal_failures_status_check": {
- "name": "kiloclaw_terminal_renewal_failures_status_check",
- "value": "\"kiloclaw_terminal_renewal_failures\".\"status\" IN ('unresolved', 'resolved', 'waived', 'superseded')"
- },
- "kiloclaw_terminal_renewal_failures_last_failure_code_check": {
- "name": "kiloclaw_terminal_renewal_failures_last_failure_code_check",
- "value": "\"kiloclaw_terminal_renewal_failures\".\"last_failure_code\" IN ('credit_balance_read_failed', 'renewal_transaction_failed', 'auto_top_up_marker_write_failed', 'worker_timeout', 'poison_payload', 'queue_delivery_exhausted')"
- },
- "kiloclaw_terminal_renewal_failures_resolution_actor_type_check": {
- "name": "kiloclaw_terminal_renewal_failures_resolution_actor_type_check",
- "value": "\"kiloclaw_terminal_renewal_failures\".\"resolution_actor_type\" IN ('operator', 'system')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_version_pins": {
- "name": "kiloclaw_version_pins",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "image_tag": {
- "name": "image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pinned_by": {
- "name": "pinned_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_version_pins",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk": {
- "name": "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk",
- "tableFrom": "kiloclaw_version_pins",
- "tableTo": "kiloclaw_image_catalog",
- "columnsFrom": [
- "image_tag"
- ],
- "columnsTo": [
- "image_tag"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk": {
- "name": "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_version_pins",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "pinned_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_version_pins_instance_id_unique": {
- "name": "kiloclaw_version_pins_instance_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "instance_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kilocode_users": {
- "name": "kilocode_users",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "google_user_email": {
- "name": "google_user_email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "google_user_name": {
- "name": "google_user_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "google_user_image_url": {
- "name": "google_user_image_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "hosted_domain": {
- "name": "hosted_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "microdollars_used": {
- "name": "microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "kilo_pass_threshold": {
- "name": "kilo_pass_threshold",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "app_store_account_token": {
- "name": "app_store_account_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "is_admin": {
- "name": "is_admin",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "can_manage_credits": {
- "name": "can_manage_credits",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "total_microdollars_acquired": {
- "name": "total_microdollars_acquired",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "next_credit_expiration_at": {
- "name": "next_credit_expiration_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "has_validation_stytch": {
- "name": "has_validation_stytch",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "has_validation_novel_card_with_hold": {
- "name": "has_validation_novel_card_with_hold",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "blocked_reason": {
- "name": "blocked_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_at": {
- "name": "blocked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_by_kilo_user_id": {
- "name": "blocked_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "api_token_pepper": {
- "name": "api_token_pepper",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "web_session_pepper": {
- "name": "web_session_pepper",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_top_up_enabled": {
- "name": "auto_top_up_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "is_bot": {
- "name": "is_bot",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "kiloclaw_early_access": {
- "name": "kiloclaw_early_access",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "default_model": {
- "name": "default_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cohorts": {
- "name": "cohorts",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "completed_welcome_form": {
- "name": "completed_welcome_form",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "linkedin_url": {
- "name": "linkedin_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "github_url": {
- "name": "github_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "discord_server_membership_verified_at": {
- "name": "discord_server_membership_verified_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "openrouter_upstream_safety_identifier": {
- "name": "openrouter_upstream_safety_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "openrouter_downstream_safety_identifier": {
- "name": "openrouter_downstream_safety_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_downstream_safety_identifier": {
- "name": "vercel_downstream_safety_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "customer_source": {
- "name": "customer_source",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "signup_ip": {
- "name": "signup_ip",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "account_deletion_requested_at": {
- "name": "account_deletion_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "normalized_email": {
- "name": "normalized_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "email_domain": {
- "name": "email_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_kilocode_users_signup_ip_created_at": {
- "name": "IDX_kilocode_users_signup_ip_created_at",
- "columns": [
- {
- "expression": "signup_ip",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_blocked_at": {
- "name": "IDX_kilocode_users_blocked_at",
- "columns": [
- {
- "expression": "blocked_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_blocked_by_kilo_user_id": {
- "name": "IDX_kilocode_users_blocked_by_kilo_user_id",
- "columns": [
- {
- "expression": "blocked_by_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilocode_users_openrouter_upstream_safety_identifier": {
- "name": "UQ_kilocode_users_openrouter_upstream_safety_identifier",
- "columns": [
- {
- "expression": "openrouter_upstream_safety_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilocode_users\".\"openrouter_upstream_safety_identifier\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilocode_users_openrouter_downstream_safety_identifier": {
- "name": "UQ_kilocode_users_openrouter_downstream_safety_identifier",
- "columns": [
- {
- "expression": "openrouter_downstream_safety_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilocode_users\".\"openrouter_downstream_safety_identifier\" IS NOT NULL",
- "concurrently": true,
- "method": "btree",
- "with": {}
- },
- "UQ_kilocode_users_vercel_downstream_safety_identifier": {
- "name": "UQ_kilocode_users_vercel_downstream_safety_identifier",
- "columns": [
- {
- "expression": "vercel_downstream_safety_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilocode_users\".\"vercel_downstream_safety_identifier\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_normalized_email": {
- "name": "IDX_kilocode_users_normalized_email",
- "columns": [
- {
- "expression": "normalized_email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_email_domain": {
- "name": "IDX_kilocode_users_email_domain",
- "columns": [
- {
- "expression": "email_domain",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kilocode_users_app_store_account_token_unique": {
- "name": "kilocode_users_app_store_account_token_unique",
- "nullsNotDistinct": false,
- "columns": [
- "app_store_account_token"
- ]
- },
- "UQ_b1afacbcf43f2c7c4cb9f7e7faa": {
- "name": "UQ_b1afacbcf43f2c7c4cb9f7e7faa",
- "nullsNotDistinct": false,
- "columns": [
- "google_user_email"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "blocked_reason_not_empty": {
- "name": "blocked_reason_not_empty",
- "value": "length(blocked_reason) > 0"
- },
- "kilocode_users_can_manage_credits_requires_admin_check": {
- "name": "kilocode_users_can_manage_credits_requires_admin_check",
- "value": "NOT \"kilocode_users\".\"can_manage_credits\" OR \"kilocode_users\".\"is_admin\""
- }
- },
- "isRLSEnabled": false
- },
- "public.magic_link_tokens": {
- "name": "magic_link_tokens",
- "schema": "",
- "columns": {
- "token_hash": {
- "name": "token_hash",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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": {
- "idx_magic_link_tokens_email": {
- "name": "idx_magic_link_tokens_email",
- "columns": [
- {
- "expression": "email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_magic_link_tokens_expires_at": {
- "name": "idx_magic_link_tokens_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "check_expires_at_future": {
- "name": "check_expires_at_future",
- "value": "\"magic_link_tokens\".\"expires_at\" > \"magic_link_tokens\".\"created_at\""
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_assignments": {
- "name": "mcp_gateway_assignments",
- "schema": "",
- "columns": {
- "assignment_id": {
- "name": "assignment_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "assigned_by_kilo_user_id": {
- "name": "assigned_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "single_user_slot": {
- "name": "single_user_slot",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_assignments_active": {
- "name": "UQ_mcp_gateway_assignments_active",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_mcp_gateway_assignments_single_user_slot": {
- "name": "UQ_mcp_gateway_assignments_single_user_slot",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "single_user_slot",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null and \"mcp_gateway_assignments\".\"single_user_slot\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_assignments_config": {
- "name": "IDX_mcp_gateway_assignments_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_assignments_user": {
- "name": "IDX_mcp_gateway_assignments_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_assignments",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_assignments",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_assignments",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "assigned_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.mcp_gateway_audit_events": {
- "name": "mcp_gateway_audit_events",
- "schema": "",
- "columns": {
- "audit_event_id": {
- "name": "audit_event_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "actor_kilo_user_id": {
- "name": "actor_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "connect_resource_id": {
- "name": "connect_resource_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "outcome": {
- "name": "outcome",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "correlation_metadata": {
- "name": "correlation_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_mcp_gateway_audit_events_config": {
- "name": "IDX_mcp_gateway_audit_events_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_audit_events_owner": {
- "name": "IDX_mcp_gateway_audit_events_owner",
- "columns": [
- {
- "expression": "owner_scope",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owner_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_audit_events_created_at": {
- "name": "IDX_mcp_gateway_audit_events_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "actor_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk": {
- "name": "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "mcp_gateway_connect_resources",
- "columnsFrom": [
- "connect_resource_id"
- ],
- "columnsTo": [
- "connect_resource_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_audit_events_owner_scope": {
- "name": "mcp_gateway_audit_events_owner_scope",
- "value": "\"mcp_gateway_audit_events\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_audit_events_outcome": {
- "name": "mcp_gateway_audit_events_outcome",
- "value": "\"mcp_gateway_audit_events\".\"outcome\" IN ('success', 'failure', 'blocked')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_authorization_codes": {
- "name": "mcp_gateway_authorization_codes",
- "schema": "",
- "columns": {
- "authorization_code_id": {
- "name": "authorization_code_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code_hash": {
- "name": "code_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "authorization_request_id": {
- "name": "authorization_request_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redirect_uri": {
- "name": "redirect_uri",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "granted_scopes": {
- "name": "granted_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "code_challenge": {
- "name": "code_challenge",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "code_challenge_method": {
- "name": "code_challenge_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'S256'"
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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": {
- "UQ_mcp_gateway_authorization_codes_code_hash": {
- "name": "UQ_mcp_gateway_authorization_codes_code_hash",
- "columns": [
- {
- "expression": "code_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_codes_expires_at": {
- "name": "IDX_mcp_gateway_authorization_codes_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_codes_client": {
- "name": "IDX_mcp_gateway_authorization_codes_client",
- "columns": [
- {
- "expression": "oauth_client_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
- "name": "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_authorization_requests",
- "columnsFrom": [
- "authorization_request_id"
- ],
- "columnsTo": [
- "authorization_request_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
- "name": "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_oauth_clients",
- "columnsFrom": [
- "oauth_client_id"
- ],
- "columnsTo": [
- "oauth_client_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_authorization_codes_owner_scope": {
- "name": "mcp_gateway_authorization_codes_owner_scope",
- "value": "\"mcp_gateway_authorization_codes\".\"owner_scope\" IN ('personal', 'organization')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_authorization_requests": {
- "name": "mcp_gateway_authorization_requests",
- "schema": "",
- "columns": {
- "authorization_request_id": {
- "name": "authorization_request_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "request_state_hash": {
- "name": "request_state_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redirect_uri": {
- "name": "redirect_uri",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "requested_scopes": {
- "name": "requested_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "granted_scopes": {
- "name": "granted_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_state": {
- "name": "oauth_state",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "code_challenge": {
- "name": "code_challenge",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "code_challenge_method": {
- "name": "code_challenge_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'S256'"
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "request_status": {
- "name": "request_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_authorization_requests_state_hash": {
- "name": "UQ_mcp_gateway_authorization_requests_state_hash",
- "columns": [
- {
- "expression": "request_state_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_requests_config": {
- "name": "IDX_mcp_gateway_authorization_requests_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_requests_user": {
- "name": "IDX_mcp_gateway_authorization_requests_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_requests_expires_at": {
- "name": "IDX_mcp_gateway_authorization_requests_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
- "name": "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "mcp_gateway_oauth_clients",
- "columnsFrom": [
- "oauth_client_id"
- ],
- "columnsTo": [
- "oauth_client_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_authorization_requests_owner_scope": {
- "name": "mcp_gateway_authorization_requests_owner_scope",
- "value": "\"mcp_gateway_authorization_requests\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_authorization_requests_status": {
- "name": "mcp_gateway_authorization_requests_status",
- "value": "\"mcp_gateway_authorization_requests\".\"request_status\" IN ('pending', 'completed', 'error')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_config_secrets": {
- "name": "mcp_gateway_config_secrets",
- "schema": "",
- "columns": {
- "config_secret_id": {
- "name": "config_secret_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "secret_kind": {
- "name": "secret_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_secret": {
- "name": "encrypted_secret",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "secret_version": {
- "name": "secret_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_config_secrets_active_kind": {
- "name": "UQ_mcp_gateway_config_secrets_active_kind",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "secret_kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_config_secrets\".\"revoked_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_config_secrets_config": {
- "name": "IDX_mcp_gateway_config_secrets_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_config_secrets",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_config_secrets_version_positive": {
- "name": "mcp_gateway_config_secrets_version_positive",
- "value": "\"mcp_gateway_config_secrets\".\"secret_version\" > 0"
- },
- "mcp_gateway_config_secrets_kind": {
- "name": "mcp_gateway_config_secrets_kind",
- "value": "\"mcp_gateway_config_secrets\".\"secret_kind\" IN ('static_provider_credentials', 'dynamic_registration', 'static_headers')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_configs": {
- "name": "mcp_gateway_configs",
- "schema": "",
- "columns": {
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "remote_url": {
- "name": "remote_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "auth_mode": {
- "name": "auth_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sharing_mode": {
- "name": "sharing_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_scopes": {
- "name": "provider_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "provider_scope_source": {
- "name": "provider_scope_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'none'"
- },
- "provider_resource": {
- "name": "provider_resource",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "path_passthrough": {
- "name": "path_passthrough",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "config_version": {
- "name": "config_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "discovered_provider_metadata": {
- "name": "discovered_provider_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "registry_metadata": {
- "name": "registry_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "auxiliary_headers": {
- "name": "auxiliary_headers",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "deleted_at": {
- "name": "deleted_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_mcp_gateway_configs_owner": {
- "name": "IDX_mcp_gateway_configs_owner",
- "columns": [
- {
- "expression": "owner_scope",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owner_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_configs_enabled": {
- "name": "IDX_mcp_gateway_configs_enabled",
- "columns": [
- {
- "expression": "enabled",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_configs_remote_url": {
- "name": "IDX_mcp_gateway_configs_remote_url",
- "columns": [
- {
- "expression": "remote_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_configs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_configs_name_not_empty": {
- "name": "mcp_gateway_configs_name_not_empty",
- "value": "length(trim(\"mcp_gateway_configs\".\"name\")) > 0"
- },
- "mcp_gateway_configs_config_version_positive": {
- "name": "mcp_gateway_configs_config_version_positive",
- "value": "\"mcp_gateway_configs\".\"config_version\" > 0"
- },
- "mcp_gateway_configs_personal_single_user": {
- "name": "mcp_gateway_configs_personal_single_user",
- "value": "\"mcp_gateway_configs\".\"owner_scope\" <> 'personal' OR \"mcp_gateway_configs\".\"sharing_mode\" = 'single_user'"
- },
- "mcp_gateway_configs_owner_scope": {
- "name": "mcp_gateway_configs_owner_scope",
- "value": "\"mcp_gateway_configs\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_configs_auth_mode": {
- "name": "mcp_gateway_configs_auth_mode",
- "value": "\"mcp_gateway_configs\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
- },
- "mcp_gateway_configs_sharing_mode": {
- "name": "mcp_gateway_configs_sharing_mode",
- "value": "\"mcp_gateway_configs\".\"sharing_mode\" IN ('single_user', 'multi_user')"
- },
- "mcp_gateway_configs_provider_scope_source": {
- "name": "mcp_gateway_configs_provider_scope_source",
- "value": "\"mcp_gateway_configs\".\"provider_scope_source\" IN ('none', 'discovered', 'override')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_connect_resources": {
- "name": "mcp_gateway_connect_resources",
- "schema": "",
- "columns": {
- "connect_resource_id": {
- "name": "connect_resource_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_url": {
- "name": "canonical_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "route_status": {
- "name": "route_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "route_version": {
- "name": "route_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "rotated_at": {
- "name": "rotated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_connect_resources_route_key": {
- "name": "UQ_mcp_gateway_connect_resources_route_key",
- "columns": [
- {
- "expression": "route_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_mcp_gateway_connect_resources_active_config": {
- "name": "UQ_mcp_gateway_connect_resources_active_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_connect_resources\".\"route_status\" = 'active'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connect_resources_config": {
- "name": "IDX_mcp_gateway_connect_resources_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connect_resources_canonical_url": {
- "name": "IDX_mcp_gateway_connect_resources_canonical_url",
- "columns": [
- {
- "expression": "canonical_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_connect_resources",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_connect_resources_route_key_format": {
- "name": "mcp_gateway_connect_resources_route_key_format",
- "value": "\"mcp_gateway_connect_resources\".\"route_key\" ~ '^[A-Za-z0-9_-]{32,}$'"
- },
- "mcp_gateway_connect_resources_route_version_positive": {
- "name": "mcp_gateway_connect_resources_route_version_positive",
- "value": "\"mcp_gateway_connect_resources\".\"route_version\" > 0"
- },
- "mcp_gateway_connect_resources_owner_scope": {
- "name": "mcp_gateway_connect_resources_owner_scope",
- "value": "\"mcp_gateway_connect_resources\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_connect_resources_route_status": {
- "name": "mcp_gateway_connect_resources_route_status",
- "value": "\"mcp_gateway_connect_resources\".\"route_status\" IN ('active', 'rotated', 'revoked')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_connection_instances": {
- "name": "mcp_gateway_connection_instances",
- "schema": "",
- "columns": {
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_status": {
- "name": "instance_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "instance_version": {
- "name": "instance_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "last_used_at": {
- "name": "last_used_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "removed_at": {
- "name": "removed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_connection_instances_non_terminal": {
- "name": "UQ_mcp_gateway_connection_instances_non_terminal",
- "columns": [
- {
- "expression": "owner_scope",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owner_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connection_instances_config": {
- "name": "IDX_mcp_gateway_connection_instances_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connection_instances_user": {
- "name": "IDX_mcp_gateway_connection_instances_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_connection_instances",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_connection_instances",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_connection_instances_version_positive": {
- "name": "mcp_gateway_connection_instances_version_positive",
- "value": "\"mcp_gateway_connection_instances\".\"instance_version\" > 0"
- },
- "mcp_gateway_connection_instances_owner_scope": {
- "name": "mcp_gateway_connection_instances_owner_scope",
- "value": "\"mcp_gateway_connection_instances\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_connection_instances_status": {
- "name": "mcp_gateway_connection_instances_status",
- "value": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth', 'revoked', 'removed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_oauth_clients": {
- "name": "mcp_gateway_oauth_clients",
- "schema": "",
- "columns": {
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "client_name": {
- "name": "client_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "registration_token_hash": {
- "name": "registration_token_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "client_secret_hash": {
- "name": "client_secret_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "token_endpoint_auth_method": {
- "name": "token_endpoint_auth_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redirect_uris": {
- "name": "redirect_uris",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "grant_types": {
- "name": "grant_types",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "response_types": {
- "name": "response_types",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "declared_scopes": {
- "name": "declared_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "registration_access_token_expires_at": {
- "name": "registration_access_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "deleted_at": {
- "name": "deleted_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_oauth_clients_client_id": {
- "name": "UQ_mcp_gateway_oauth_clients_client_id",
- "columns": [
- {
- "expression": "client_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_mcp_gateway_oauth_clients_registration_token_hash": {
- "name": "UQ_mcp_gateway_oauth_clients_registration_token_hash",
- "columns": [
- {
- "expression": "registration_token_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_oauth_clients_deleted_at": {
- "name": "IDX_mcp_gateway_oauth_clients_deleted_at",
- "columns": [
- {
- "expression": "deleted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_oauth_clients_client_id_format": {
- "name": "mcp_gateway_oauth_clients_client_id_format",
- "value": "\"mcp_gateway_oauth_clients\".\"client_id\" ~ '^[A-Za-z0-9._-]+:[A-Za-z0-9._-]+$'"
- },
- "mcp_gateway_oauth_clients_auth_method": {
- "name": "mcp_gateway_oauth_clients_auth_method",
- "value": "\"mcp_gateway_oauth_clients\".\"token_endpoint_auth_method\" IN ('none', 'client_secret_post', 'client_secret_basic')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_pending_provider_authorizations": {
- "name": "mcp_gateway_pending_provider_authorizations",
- "schema": "",
- "columns": {
- "pending_provider_authorization_id": {
- "name": "pending_provider_authorization_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "state_hash": {
- "name": "state_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "authorization_request_id": {
- "name": "authorization_request_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "remote_url": {
- "name": "remote_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "auth_mode": {
- "name": "auth_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_authorization_endpoint": {
- "name": "provider_authorization_endpoint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_token_endpoint": {
- "name": "provider_token_endpoint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_state": {
- "name": "encrypted_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "config_version": {
- "name": "config_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "pending_status": {
- "name": "pending_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_pending_provider_authorizations_state_hash": {
- "name": "UQ_mcp_gateway_pending_provider_authorizations_state_hash",
- "columns": [
- {
- "expression": "state_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_pending_provider_authorizations_config": {
- "name": "IDX_mcp_gateway_pending_provider_authorizations_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_pending_provider_authorizations_expires_at": {
- "name": "IDX_mcp_gateway_pending_provider_authorizations_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "mcp_gateway_authorization_requests",
- "columnsFrom": [
- "authorization_request_id"
- ],
- "columnsTo": [
- "authorization_request_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_pending_provider_authorizations_config_version_positive": {
- "name": "mcp_gateway_pending_provider_authorizations_config_version_positive",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"config_version\" > 0"
- },
- "mcp_gateway_pending_provider_authorizations_owner_scope": {
- "name": "mcp_gateway_pending_provider_authorizations_owner_scope",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_pending_provider_authorizations_auth_mode": {
- "name": "mcp_gateway_pending_provider_authorizations_auth_mode",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
- },
- "mcp_gateway_pending_provider_authorizations_status": {
- "name": "mcp_gateway_pending_provider_authorizations_status",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"pending_status\" IN ('pending', 'completed', 'error')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_provider_grants": {
- "name": "mcp_gateway_provider_grants",
- "schema": "",
- "columns": {
- "provider_grant_id": {
- "name": "provider_grant_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_grant": {
- "name": "encrypted_grant",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subject": {
- "name": "provider_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "grant_scope": {
- "name": "grant_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "grant_status": {
- "name": "grant_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "grant_version": {
- "name": "grant_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "last_used_at": {
- "name": "last_used_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_provider_grants_active_instance": {
- "name": "UQ_mcp_gateway_provider_grants_active_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_provider_grants\".\"grant_status\" = 'active'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_provider_grants_instance": {
- "name": "IDX_mcp_gateway_provider_grants_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_provider_grants",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_provider_grants_version_positive": {
- "name": "mcp_gateway_provider_grants_version_positive",
- "value": "\"mcp_gateway_provider_grants\".\"grant_version\" > 0"
- },
- "mcp_gateway_provider_grants_status": {
- "name": "mcp_gateway_provider_grants_status",
- "value": "\"mcp_gateway_provider_grants\".\"grant_status\" IN ('active', 'revoked')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_rate_limit_windows": {
- "name": "mcp_gateway_rate_limit_windows",
- "schema": "",
- "columns": {
- "rate_limit_window_id": {
- "name": "rate_limit_window_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "ip_hash": {
- "name": "ip_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "window_started_at": {
- "name": "window_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "attempt_count": {
- "name": "attempt_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_rate_limit_windows_ip_window": {
- "name": "UQ_mcp_gateway_rate_limit_windows_ip_window",
- "columns": [
- {
- "expression": "ip_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "window_started_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_rate_limit_windows_window": {
- "name": "IDX_mcp_gateway_rate_limit_windows_window",
- "columns": [
- {
- "expression": "window_started_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_rate_limit_windows_attempt_count_non_negative": {
- "name": "mcp_gateway_rate_limit_windows_attempt_count_non_negative",
- "value": "\"mcp_gateway_rate_limit_windows\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_refresh_tokens": {
- "name": "mcp_gateway_refresh_tokens",
- "schema": "",
- "columns": {
- "refresh_token_id": {
- "name": "refresh_token_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "token_hash": {
- "name": "token_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "rotated_from_refresh_token_id": {
- "name": "rotated_from_refresh_token_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "granted_scopes": {
- "name": "granted_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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": {
- "UQ_mcp_gateway_refresh_tokens_token_hash": {
- "name": "UQ_mcp_gateway_refresh_tokens_token_hash",
- "columns": [
- {
- "expression": "token_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_refresh_tokens_user": {
- "name": "IDX_mcp_gateway_refresh_tokens_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_refresh_tokens_config": {
- "name": "IDX_mcp_gateway_refresh_tokens_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_refresh_tokens_consumed_at": {
- "name": "IDX_mcp_gateway_refresh_tokens_consumed_at",
- "columns": [
- {
- "expression": "consumed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
- "name": "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "mcp_gateway_oauth_clients",
- "columnsFrom": [
- "oauth_client_id"
- ],
- "columnsTo": [
- "oauth_client_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_refresh_tokens_owner_scope": {
- "name": "mcp_gateway_refresh_tokens_owner_scope",
- "value": "\"mcp_gateway_refresh_tokens\".\"owner_scope\" IN ('personal', 'organization')"
- }
- },
- "isRLSEnabled": false
- },
- "public.microdollar_usage": {
- "name": "microdollar_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cost": {
- "name": "cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "input_tokens": {
- "name": "input_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "output_tokens": {
- "name": "output_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_write_tokens": {
- "name": "cache_write_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_hit_tokens": {
- "name": "cache_hit_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "requested_model": {
- "name": "requested_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cache_discount": {
- "name": "cache_discount",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "has_error": {
- "name": "has_error",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "abuse_classification": {
- "name": "abuse_classification",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "inference_provider": {
- "name": "inference_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_created_at": {
- "name": "idx_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_abuse_classification": {
- "name": "idx_abuse_classification",
- "columns": [
- {
- "expression": "abuse_classification",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_kilo_user_id_created_at2": {
- "name": "idx_kilo_user_id_created_at2",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_microdollar_usage_organization_id": {
- "name": "idx_microdollar_usage_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"microdollar_usage\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.microdollar_usage_daily": {
- "name": "microdollar_usage_daily",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "usage_date": {
- "name": "usage_date",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "total_cost_microdollars": {
- "name": "total_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_microdollar_usage_daily_personal": {
- "name": "idx_microdollar_usage_daily_personal",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "usage_date",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"microdollar_usage_daily\".\"organization_id\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_microdollar_usage_daily_org": {
- "name": "idx_microdollar_usage_daily_org",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "usage_date",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"microdollar_usage_daily\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.microdollar_usage_metadata": {
- "name": "microdollar_usage_metadata",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "message_id": {
- "name": "message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "http_user_agent_id": {
- "name": "http_user_agent_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "http_ip_id": {
- "name": "http_ip_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_city_id": {
- "name": "vercel_ip_city_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_country_id": {
- "name": "vercel_ip_country_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_latitude": {
- "name": "vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_longitude": {
- "name": "vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "ja4_digest_id": {
- "name": "ja4_digest_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "user_prompt_prefix": {
- "name": "user_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_prefix_id": {
- "name": "system_prompt_prefix_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_length": {
- "name": "system_prompt_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "max_tokens": {
- "name": "max_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "has_middle_out_transform": {
- "name": "has_middle_out_transform",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "status_code": {
- "name": "status_code",
- "type": "smallint",
- "primaryKey": false,
- "notNull": false
- },
- "upstream_id": {
- "name": "upstream_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finish_reason_id": {
- "name": "finish_reason_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "latency": {
- "name": "latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "moderation_latency": {
- "name": "moderation_latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "generation_time": {
- "name": "generation_time",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "is_byok": {
- "name": "is_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "is_user_byok": {
- "name": "is_user_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "streamed": {
- "name": "streamed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "cancelled": {
- "name": "cancelled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "editor_name_id": {
- "name": "editor_name_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "api_kind_id": {
- "name": "api_kind_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "has_tools": {
- "name": "has_tools",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "machine_id": {
- "name": "machine_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "feature_id": {
- "name": "feature_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "mode_id": {
- "name": "mode_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "auto_model_id": {
- "name": "auto_model_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "market_cost": {
- "name": "market_cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "is_free": {
- "name": "is_free",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_delay": {
- "name": "abuse_delay",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_downgraded_from": {
- "name": "abuse_downgraded_from",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_microdollar_usage_metadata_created_at": {
- "name": "idx_microdollar_usage_metadata_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_microdollar_usage_metadata_session_id": {
- "name": "idx_microdollar_usage_metadata_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"microdollar_usage_metadata\".\"session_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk": {
- "name": "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "http_user_agent",
- "columnsFrom": [
- "http_user_agent_id"
- ],
- "columnsTo": [
- "http_user_agent_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk": {
- "name": "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "http_ip",
- "columnsFrom": [
- "http_ip_id"
- ],
- "columnsTo": [
- "http_ip_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk": {
- "name": "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "vercel_ip_city",
- "columnsFrom": [
- "vercel_ip_city_id"
- ],
- "columnsTo": [
- "vercel_ip_city_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk": {
- "name": "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "vercel_ip_country",
- "columnsFrom": [
- "vercel_ip_country_id"
- ],
- "columnsTo": [
- "vercel_ip_country_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk": {
- "name": "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "ja4_digest",
- "columnsFrom": [
- "ja4_digest_id"
- ],
- "columnsTo": [
- "ja4_digest_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk": {
- "name": "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "system_prompt_prefix",
- "columnsFrom": [
- "system_prompt_prefix_id"
- ],
- "columnsTo": [
- "system_prompt_prefix_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.mode": {
- "name": "mode",
- "schema": "",
- "columns": {
- "mode_id": {
- "name": "mode_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_mode": {
- "name": "UQ_mode",
- "columns": [
- {
- "expression": "mode",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.model_stats": {
- "name": "model_stats",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false,
- "default": true
- },
- "is_featured": {
- "name": "is_featured",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "is_stealth": {
- "name": "is_stealth",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "is_recommended": {
- "name": "is_recommended",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "openrouter_id": {
- "name": "openrouter_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "aa_slug": {
- "name": "aa_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model_creator": {
- "name": "model_creator",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "creator_slug": {
- "name": "creator_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "release_date": {
- "name": "release_date",
- "type": "date",
- "primaryKey": false,
- "notNull": false
- },
- "price_input": {
- "name": "price_input",
- "type": "numeric(10, 6)",
- "primaryKey": false,
- "notNull": false
- },
- "price_output": {
- "name": "price_output",
- "type": "numeric(10, 6)",
- "primaryKey": false,
- "notNull": false
- },
- "coding_index": {
- "name": "coding_index",
- "type": "numeric(5, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "speed_tokens_per_sec": {
- "name": "speed_tokens_per_sec",
- "type": "numeric(8, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "context_length": {
- "name": "context_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "max_output_tokens": {
- "name": "max_output_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "input_modalities": {
- "name": "input_modalities",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "openrouter_data": {
- "name": "openrouter_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "benchmarks": {
- "name": "benchmarks",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "chart_data": {
- "name": "chart_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_stats_openrouter_id": {
- "name": "IDX_model_stats_openrouter_id",
- "columns": [
- {
- "expression": "openrouter_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_slug": {
- "name": "IDX_model_stats_slug",
- "columns": [
- {
- "expression": "slug",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_is_active": {
- "name": "IDX_model_stats_is_active",
- "columns": [
- {
- "expression": "is_active",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_creator_slug": {
- "name": "IDX_model_stats_creator_slug",
- "columns": [
- {
- "expression": "creator_slug",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_price_input": {
- "name": "IDX_model_stats_price_input",
- "columns": [
- {
- "expression": "price_input",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_coding_index": {
- "name": "IDX_model_stats_coding_index",
- "columns": [
- {
- "expression": "coding_index",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_context_length": {
- "name": "IDX_model_stats_context_length",
- "columns": [
- {
- "expression": "context_length",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "model_stats_openrouter_id_unique": {
- "name": "model_stats_openrouter_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "openrouter_id"
- ]
- },
- "model_stats_slug_unique": {
- "name": "model_stats_slug_unique",
- "nullsNotDistinct": false,
- "columns": [
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.model_eval_ingestions": {
- "name": "model_eval_ingestions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "bench_eval_name": {
- "name": "bench_eval_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "bench_eval_url": {
- "name": "bench_eval_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model_stats_id": {
- "name": "model_stats_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "variant": {
- "name": "variant",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "task_source": {
- "name": "task_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "n_total_trials": {
- "name": "n_total_trials",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "n_attempts": {
- "name": "n_attempts",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_score": {
- "name": "total_score",
- "type": "numeric(14, 6)",
- "primaryKey": false,
- "notNull": true
- },
- "overall_score": {
- "name": "overall_score",
- "type": "numeric(12, 8)",
- "primaryKey": false,
- "notNull": true
- },
- "n_errored": {
- "name": "n_errored",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "avg_cost_microdollars": {
- "name": "avg_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "total_cost_microdollars": {
- "name": "total_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_input_tokens": {
- "name": "avg_input_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_input_tokens": {
- "name": "total_input_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_output_tokens": {
- "name": "avg_output_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_output_tokens": {
- "name": "total_output_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_cache_read_tokens": {
- "name": "avg_cache_read_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_cache_read_tokens": {
- "name": "total_cache_read_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_execution_ms": {
- "name": "avg_execution_ms",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "promoted_at": {
- "name": "promoted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "promoted_by_email": {
- "name": "promoted_by_email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "promotion_note": {
- "name": "promotion_note",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_eval_ingestions_lookup": {
- "name": "IDX_model_eval_ingestions_lookup",
- "columns": [
- {
- "expression": "provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "model",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "task_source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "promoted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_eval_ingestions_model_stats": {
- "name": "IDX_model_eval_ingestions_model_stats",
- "columns": [
- {
- "expression": "model_stats_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_eval_ingestions_promoted_by_email_lower": {
- "name": "IDX_model_eval_ingestions_promoted_by_email_lower",
- "columns": [
- {
- "expression": "LOWER(\"promoted_by_email\")",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_eval_ingestions_model_stats_id_model_stats_id_fk": {
- "name": "model_eval_ingestions_model_stats_id_model_stats_id_fk",
- "tableFrom": "model_eval_ingestions",
- "tableTo": "model_stats",
- "columnsFrom": [
- "model_stats_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "model_eval_ingestions_bench_eval_name_unique": {
- "name": "model_eval_ingestions_bench_eval_name_unique",
- "nullsNotDistinct": false,
- "columns": [
- "bench_eval_name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.model_experiment": {
- "name": "model_experiment",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "public_model_id": {
- "name": "public_model_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'draft'"
- },
- "is_archived": {
- "name": "is_archived",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "ended_at": {
- "name": "ended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_model_experiment_public_model_id_routing": {
- "name": "UQ_model_experiment_public_model_id_routing",
- "columns": [
- {
- "expression": "public_model_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"model_experiment\".\"status\" IN ('active', 'paused')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_experiment_status": {
- "name": "IDX_model_experiment_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_created_by_user_id_kilocode_users_id_fk": {
- "name": "model_experiment_created_by_user_id_kilocode_users_id_fk",
- "tableFrom": "model_experiment",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "model_experiment_status_valid": {
- "name": "model_experiment_status_valid",
- "value": "\"model_experiment\".\"status\" IN ('draft', 'active', 'paused', 'completed')"
- },
- "model_experiment_active_not_archived": {
- "name": "model_experiment_active_not_archived",
- "value": "\"model_experiment\".\"status\" <> 'active' OR \"model_experiment\".\"is_archived\" = false"
- }
- },
- "isRLSEnabled": false
- },
- "public.model_experiment_request": {
- "name": "model_experiment_request",
- "schema": "",
- "columns": {
- "usage_id": {
- "name": "usage_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "variant_version_id": {
- "name": "variant_version_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "allocation_subject": {
- "name": "allocation_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "client_request_id": {
- "name": "client_request_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "request_kind": {
- "name": "request_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "request_body_sha256": {
- "name": "request_body_sha256",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "was_truncated": {
- "name": "was_truncated",
- "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": {
- "IDX_model_experiment_request_variant_version_created_at": {
- "name": "IDX_model_experiment_request_variant_version_created_at",
- "columns": [
- {
- "expression": "variant_version_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_experiment_request_client_request_id": {
- "name": "IDX_model_experiment_request_client_request_id",
- "columns": [
- {
- "expression": "client_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"model_experiment_request\".\"client_request_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_request_usage_id_microdollar_usage_id_fk": {
- "name": "model_experiment_request_usage_id_microdollar_usage_id_fk",
- "tableFrom": "model_experiment_request",
- "tableTo": "microdollar_usage",
- "columnsFrom": [
- "usage_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk": {
- "name": "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk",
- "tableFrom": "model_experiment_request",
- "tableTo": "model_experiment_variant_version",
- "columnsFrom": [
- "variant_version_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "model_experiment_request_usage_id_created_at_pk": {
- "name": "model_experiment_request_usage_id_created_at_pk",
- "columns": [
- "usage_id",
- "created_at"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "model_experiment_request_allocation_subject_valid": {
- "name": "model_experiment_request_allocation_subject_valid",
- "value": "\"model_experiment_request\".\"allocation_subject\" IN ('user', 'machine', 'ip')"
- },
- "model_experiment_request_request_kind_valid": {
- "name": "model_experiment_request_request_kind_valid",
- "value": "\"model_experiment_request\".\"request_kind\" IN ('chat_completions', 'messages', 'responses')"
- },
- "model_experiment_request_request_body_sha256_format": {
- "name": "model_experiment_request_request_body_sha256_format",
- "value": "\"model_experiment_request\".\"request_body_sha256\" ~ '^[0-9a-f]{64}$' OR \"model_experiment_request\".\"request_body_sha256\" IN ('__failed__', '__deleted__')"
- }
- },
- "isRLSEnabled": false
- },
- "public.model_experiment_variant": {
- "name": "model_experiment_variant",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "experiment_id": {
- "name": "experiment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "label": {
- "name": "label",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "weight": {
- "name": "weight",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_experiment_variant_experiment_id": {
- "name": "IDX_model_experiment_variant_experiment_id",
- "columns": [
- {
- "expression": "experiment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_variant_experiment_id_model_experiment_id_fk": {
- "name": "model_experiment_variant_experiment_id_model_experiment_id_fk",
- "tableFrom": "model_experiment_variant",
- "tableTo": "model_experiment",
- "columnsFrom": [
- "experiment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_model_experiment_variant_experiment_label": {
- "name": "UQ_model_experiment_variant_experiment_label",
- "nullsNotDistinct": false,
- "columns": [
- "experiment_id",
- "label"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "model_experiment_variant_weight_positive": {
- "name": "model_experiment_variant_weight_positive",
- "value": "\"model_experiment_variant\".\"weight\" > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.model_experiment_variant_version": {
- "name": "model_experiment_variant_version",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "variant_id": {
- "name": "variant_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "upstream": {
- "name": "upstream",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_api_key": {
- "name": "encrypted_api_key",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "effective_at": {
- "name": "effective_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_experiment_variant_version_variant_effective": {
- "name": "IDX_model_experiment_variant_version_variant_effective",
- "columns": [
- {
- "expression": "variant_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "effective_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk": {
- "name": "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk",
- "tableFrom": "model_experiment_variant_version",
- "tableTo": "model_experiment_variant",
- "columnsFrom": [
- "variant_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "model_experiment_variant_version_created_by_kilocode_users_id_fk": {
- "name": "model_experiment_variant_version_created_by_kilocode_users_id_fk",
- "tableFrom": "model_experiment_variant_version",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.models_by_provider": {
- "name": "models_by_provider",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "data": {
- "name": "data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "openrouter": {
- "name": "openrouter",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "vercel": {
- "name": "vercel",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_audit_logs": {
- "name": "organization_audit_logs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_email": {
- "name": "actor_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_name": {
- "name": "actor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "message": {
- "name": "message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_audit_logs_organization_id": {
- "name": "IDX_organization_audit_logs_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_audit_logs_action": {
- "name": "IDX_organization_audit_logs_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_audit_logs_actor_id": {
- "name": "IDX_organization_audit_logs_actor_id",
- "columns": [
- {
- "expression": "actor_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_audit_logs_created_at": {
- "name": "IDX_organization_audit_logs_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_invitations": {
- "name": "organization_invitations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "invited_by": {
- "name": "invited_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "token": {
- "name": "token",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "accepted_at": {
- "name": "accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "authentication_requirement": {
- "name": "authentication_requirement",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'default'"
- },
- "sso_source_organization_id": {
- "name": "sso_source_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_organization_invitations_token": {
- "name": "UQ_organization_invitations_token",
- "columns": [
- {
- "expression": "token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_invitations_org_id": {
- "name": "IDX_organization_invitations_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_invitations_email": {
- "name": "IDX_organization_invitations_email",
- "columns": [
- {
- "expression": "email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_invitations_expires_at": {
- "name": "IDX_organization_invitations_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "organization_invitations_sso_source_organization_id_organizations_id_fk": {
- "name": "organization_invitations_sso_source_organization_id_organizations_id_fk",
- "tableFrom": "organization_invitations",
- "tableTo": "organizations",
- "columnsFrom": [
- "sso_source_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_membership_removals": {
- "name": "organization_membership_removals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "removed_at": {
- "name": "removed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "removed_by": {
- "name": "removed_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "previous_role": {
- "name": "previous_role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "IDX_org_membership_removals_org_id": {
- "name": "IDX_org_membership_removals_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_org_membership_removals_user_id": {
- "name": "IDX_org_membership_removals_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_org_membership_removals_org_user": {
- "name": "UQ_org_membership_removals_org_user",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_memberships": {
- "name": "organization_memberships",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "joined_at": {
- "name": "joined_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "invited_by": {
- "name": "invited_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_memberships_org_id": {
- "name": "IDX_organization_memberships_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_memberships_user_id": {
- "name": "IDX_organization_memberships_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_memberships_org_user": {
- "name": "UQ_organization_memberships_org_user",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_recommendation_dismissals": {
- "name": "organization_recommendation_dismissals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "recommendation_key": {
- "name": "recommendation_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "dismissed_by_user_id": {
- "name": "dismissed_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "dismissed_at": {
- "name": "dismissed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk": {
- "name": "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "organization_recommendation_dismissals",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk": {
- "name": "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk",
- "tableFrom": "organization_recommendation_dismissals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "dismissed_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_org_recommendation_dismissals_org_key": {
- "name": "UQ_org_recommendation_dismissals_org_key",
- "nullsNotDistinct": false,
- "columns": [
- "owned_by_organization_id",
- "recommendation_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_seats_purchases": {
- "name": "organization_seats_purchases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "subscription_stripe_id": {
- "name": "subscription_stripe_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "seat_count": {
- "name": "seat_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "amount_usd": {
- "name": "amount_usd",
- "type": "numeric",
- "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
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "subscription_status": {
- "name": "subscription_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "starts_at": {
- "name": "starts_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "billing_cycle": {
- "name": "billing_cycle",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'monthly'"
- }
- },
- "indexes": {
- "IDX_organization_seats_org_id": {
- "name": "IDX_organization_seats_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_expires_at": {
- "name": "IDX_organization_seats_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_created_at": {
- "name": "IDX_organization_seats_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_updated_at": {
- "name": "IDX_organization_seats_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_starts_at": {
- "name": "IDX_organization_seats_starts_at",
- "columns": [
- {
- "expression": "starts_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_seats_idempotency_key": {
- "name": "UQ_organization_seats_idempotency_key",
- "nullsNotDistinct": false,
- "columns": [
- "idempotency_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_user_limits": {
- "name": "organization_user_limits",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "limit_type": {
- "name": "limit_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "microdollar_limit": {
- "name": "microdollar_limit",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_user_limits_org_id": {
- "name": "IDX_organization_user_limits_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_user_limits_user_id": {
- "name": "IDX_organization_user_limits_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_user_limits_org_user": {
- "name": "UQ_organization_user_limits_org_user",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id",
- "limit_type"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_user_usage": {
- "name": "organization_user_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "usage_date": {
- "name": "usage_date",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "limit_type": {
- "name": "limit_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "microdollar_usage": {
- "name": "microdollar_usage",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_user_daily_usage_org_id": {
- "name": "IDX_organization_user_daily_usage_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_user_daily_usage_user_id": {
- "name": "IDX_organization_user_daily_usage_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_user_daily_usage_org_user_date": {
- "name": "UQ_organization_user_daily_usage_org_user_date",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id",
- "limit_type",
- "usage_date"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organizations": {
- "name": "organizations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "microdollars_used": {
- "name": "microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "microdollars_balance": {
- "name": "microdollars_balance",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "total_microdollars_acquired": {
- "name": "total_microdollars_acquired",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "next_credit_expiration_at": {
- "name": "next_credit_expiration_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_top_up_enabled": {
- "name": "auto_top_up_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "settings": {
- "name": "settings",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "seat_count": {
- "name": "seat_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "require_seats": {
- "name": "require_seats",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sso_domain": {
- "name": "sso_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "parent_organization_id": {
- "name": "parent_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "plan": {
- "name": "plan",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'teams'"
- },
- "free_trial_end_at": {
- "name": "free_trial_end_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "company_domain": {
- "name": "company_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_organizations_sso_domain": {
- "name": "IDX_organizations_sso_domain",
- "columns": [
- {
- "expression": "sso_domain",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organizations_parent_organization_id": {
- "name": "IDX_organizations_parent_organization_id",
- "columns": [
- {
- "expression": "parent_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "organizations_parent_organization_id_organizations_id_fk": {
- "name": "organizations_parent_organization_id_organizations_id_fk",
- "tableFrom": "organizations",
- "tableTo": "organizations",
- "columnsFrom": [
- "parent_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "organizations_slug_unique": {
- "name": "organizations_slug_unique",
- "nullsNotDistinct": false,
- "columns": [
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "organizations_name_not_empty_check": {
- "name": "organizations_name_not_empty_check",
- "value": "length(trim(\"organizations\".\"name\")) > 0"
- },
- "organizations_not_parented_by_self_check": {
- "name": "organizations_not_parented_by_self_check",
- "value": "\"organizations\".\"parent_organization_id\" IS NULL OR \"organizations\".\"parent_organization_id\" <> \"organizations\".\"id\""
- }
- },
- "isRLSEnabled": false
- },
- "public.organization_modes": {
- "name": "organization_modes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- }
- },
- "indexes": {
- "IDX_organization_modes_organization_id": {
- "name": "IDX_organization_modes_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_modes_org_id_slug": {
- "name": "UQ_organization_modes_org_id_slug",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.payment_methods": {
- "name": "payment_methods",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "stripe_fingerprint": {
- "name": "stripe_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_id": {
- "name": "stripe_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "last4": {
- "name": "last4",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "brand": {
- "name": "brand",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_line1": {
- "name": "address_line1",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_line2": {
- "name": "address_line2",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_city": {
- "name": "address_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_state": {
- "name": "address_state",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_zip": {
- "name": "address_zip",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_country": {
- "name": "address_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "three_d_secure_supported": {
- "name": "three_d_secure_supported",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "funding": {
- "name": "funding",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "regulated_status": {
- "name": "regulated_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_line1_check_status": {
- "name": "address_line1_check_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "postal_code_check_status": {
- "name": "postal_code_check_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_forwarded_for": {
- "name": "http_x_forwarded_for",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_city": {
- "name": "http_x_vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_country": {
- "name": "http_x_vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_latitude": {
- "name": "http_x_vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_longitude": {
- "name": "http_x_vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ja4_digest": {
- "name": "http_x_vercel_ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "eligible_for_free_credits": {
- "name": "eligible_for_free_credits",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_data": {
- "name": "stripe_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_d7d7fb15569674aaadcfbc0428": {
- "name": "IDX_d7d7fb15569674aaadcfbc0428",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_e1feb919d0ab8a36381d5d5138": {
- "name": "IDX_e1feb919d0ab8a36381d5d5138",
- "columns": [
- {
- "expression": "stripe_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_payment_methods_organization_id": {
- "name": "IDX_payment_methods_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_29df1b0403df5792c96bbbfdbe6": {
- "name": "UQ_29df1b0403df5792c96bbbfdbe6",
- "nullsNotDistinct": false,
- "columns": [
- "user_id",
- "stripe_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.pending_impact_sale_reversals": {
- "name": "pending_impact_sale_reversals",
- "schema": "",
- "columns": {
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "dispute_id": {
- "name": "dispute_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount": {
- "name": "amount",
- "type": "real",
- "primaryKey": false,
- "notNull": true
- },
- "currency": {
- "name": "currency",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_date": {
- "name": "event_date",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "last_attempt_at": {
- "name": "last_attempt_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": {},
- "policies": {},
- "checkConstraints": {
- "pending_impact_sale_reversals_attempt_count_non_negative_check": {
- "name": "pending_impact_sale_reversals_attempt_count_non_negative_check",
- "value": "\"pending_impact_sale_reversals\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.platform_access_token_credentials": {
- "name": "platform_access_token_credentials",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "integration_type": {
- "name": "integration_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "token_encrypted": {
- "name": "token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "provider_credential_type": {
- "name": "provider_credential_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_scopes": {
- "name": "provider_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "provider_verified_at": {
- "name": "provider_verified_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "credential_version": {
- "name": "credential_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "last_validated_at": {
- "name": "last_validated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_used_at": {
- "name": "last_used_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "FK_platform_access_token_credentials_parent": {
- "name": "FK_platform_access_token_credentials_parent",
- "tableFrom": "platform_access_token_credentials",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_platform_access_token_credentials_platform_integration_id": {
- "name": "UQ_platform_access_token_credentials_platform_integration_id",
- "nullsNotDistinct": false,
- "columns": [
- "platform_integration_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.platform_integrations": {
- "name": "platform_integrations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "integration_type": {
- "name": "integration_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_installation_id": {
- "name": "platform_installation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_account_id": {
- "name": "platform_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_account_login": {
- "name": "platform_account_login",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "permissions": {
- "name": "permissions",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "scopes": {
- "name": "scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "repository_access": {
- "name": "repository_access",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repositories": {
- "name": "repositories",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "repositories_synced_at": {
- "name": "repositories_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auth_invalid_at": {
- "name": "auth_invalid_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auth_invalid_reason": {
- "name": "auth_invalid_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_requester_user_id": {
- "name": "kilo_requester_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_requester_account_id": {
- "name": "platform_requester_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "integration_status": {
- "name": "integration_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "suspended_at": {
- "name": "suspended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "suspended_by": {
- "name": "suspended_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "github_app_type": {
- "name": "github_app_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'standard'"
- },
- "installed_at": {
- "name": "installed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_platform_integrations_owned_by_org_platform_inst": {
- "name": "UQ_platform_integrations_owned_by_org_platform_inst",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_owned_by_user_platform_inst": {
- "name": "UQ_platform_integrations_owned_by_user_platform_inst",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_slack_platform_inst": {
- "name": "UQ_platform_integrations_slack_platform_inst",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'slack' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_linear_platform_inst": {
- "name": "UQ_platform_integrations_linear_platform_inst",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'linear' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_user_bitbucket": {
- "name": "UQ_platform_integrations_user_bitbucket",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_org_bitbucket": {
- "name": "UQ_platform_integrations_org_bitbucket",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_org_id": {
- "name": "IDX_platform_integrations_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_user_id": {
- "name": "IDX_platform_integrations_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_platform_inst_id": {
- "name": "IDX_platform_integrations_platform_inst_id",
- "columns": [
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_platform": {
- "name": "IDX_platform_integrations_platform",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_org_platform": {
- "name": "IDX_platform_integrations_owned_by_org_platform",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_user_platform": {
- "name": "IDX_platform_integrations_owned_by_user_platform",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_integration_status": {
- "name": "IDX_platform_integrations_integration_status",
- "columns": [
- {
- "expression": "integration_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_kilo_requester": {
- "name": "IDX_platform_integrations_kilo_requester",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_requester_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "integration_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_platform_requester": {
- "name": "IDX_platform_integrations_platform_requester",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_requester_account_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "integration_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "platform_integrations_owned_by_organization_id_organizations_id_fk": {
- "name": "platform_integrations_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "platform_integrations",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "platform_integrations_owned_by_user_id_kilocode_users_id_fk": {
- "name": "platform_integrations_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "platform_integrations",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "platform_integrations_owner_check": {
- "name": "platform_integrations_owner_check",
- "value": "(\n (\"platform_integrations\".\"owned_by_user_id\" IS NOT NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NULL) OR\n (\"platform_integrations\".\"owned_by_user_id\" IS NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.platform_oauth_credentials": {
- "name": "platform_oauth_credentials",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "authorized_by_user_id": {
- "name": "authorized_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subject_id": {
- "name": "provider_subject_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subject_login": {
- "name": "provider_subject_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_encrypted": {
- "name": "access_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_expires_at": {
- "name": "access_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "refresh_token_encrypted": {
- "name": "refresh_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "refresh_token_expires_at": {
- "name": "refresh_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "credential_version": {
- "name": "credential_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_reason": {
- "name": "revocation_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_used_at": {
- "name": "last_used_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_platform_oauth_credentials_platform_integration_id": {
- "name": "UQ_platform_oauth_credentials_platform_integration_id",
- "columns": [
- {
- "expression": "platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_oauth_credentials_authorized_by_user_id": {
- "name": "IDX_platform_oauth_credentials_authorized_by_user_id",
- "columns": [
- {
- "expression": "authorized_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk": {
- "name": "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "platform_oauth_credentials",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk": {
- "name": "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk",
- "tableFrom": "platform_oauth_credentials",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "authorized_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.referral_code_usages": {
- "name": "referral_code_usages",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "referring_kilo_user_id": {
- "name": "referring_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redeeming_kilo_user_id": {
- "name": "redeeming_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_usd": {
- "name": "amount_usd",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "paid_at": {
- "name": "paid_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_referral_code_usages_redeeming_kilo_user_id": {
- "name": "IDX_referral_code_usages_redeeming_kilo_user_id",
- "columns": [
- {
- "expression": "redeeming_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_referral_code_usages_redeeming_user_id_code": {
- "name": "UQ_referral_code_usages_redeeming_user_id_code",
- "nullsNotDistinct": false,
- "columns": [
- "redeeming_kilo_user_id",
- "referring_kilo_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.referral_codes": {
- "name": "referral_codes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "max_redemptions": {
- "name": "max_redemptions",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 10
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_referral_codes_kilo_user_id": {
- "name": "UQ_referral_codes_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_referral_codes_code": {
- "name": "IDX_referral_codes_code",
- "columns": [
- {
- "expression": "code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_advisor_check_catalog": {
- "name": "security_advisor_check_catalog",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "check_id": {
- "name": "check_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "severity": {
- "name": "severity",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "explanation": {
- "name": "explanation",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "risk": {
- "name": "risk",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "security_advisor_check_catalog_check_id_unique": {
- "name": "security_advisor_check_catalog_check_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "check_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "security_advisor_check_catalog_severity_check": {
- "name": "security_advisor_check_catalog_severity_check",
- "value": "\"security_advisor_check_catalog\".\"severity\" in ('critical', 'warn', 'info')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_advisor_content": {
- "name": "security_advisor_content",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "key": {
- "name": "key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "''"
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "security_advisor_content_key_unique": {
- "name": "security_advisor_content_key_unique",
- "nullsNotDistinct": false,
- "columns": [
- "key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_advisor_kiloclaw_coverage": {
- "name": "security_advisor_kiloclaw_coverage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "area": {
- "name": "area",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "summary": {
- "name": "summary",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "detail": {
- "name": "detail",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "match_check_ids": {
- "name": "match_check_ids",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "security_advisor_kiloclaw_coverage_area_unique": {
- "name": "security_advisor_kiloclaw_coverage_area_unique",
- "nullsNotDistinct": false,
- "columns": [
- "area"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_advisor_scans": {
- "name": "security_advisor_scans",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_platform": {
- "name": "source_platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_method": {
- "name": "source_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plugin_version": {
- "name": "plugin_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "openclaw_version": {
- "name": "openclaw_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "public_ip": {
- "name": "public_ip",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "findings_critical": {
- "name": "findings_critical",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "findings_warn": {
- "name": "findings_warn",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "findings_info": {
- "name": "findings_info",
- "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": {
- "idx_security_advisor_scans_user_created_at": {
- "name": "idx_security_advisor_scans_user_created_at",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_advisor_scans_created_at": {
- "name": "idx_security_advisor_scans_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_advisor_scans_platform": {
- "name": "idx_security_advisor_scans_platform",
- "columns": [
- {
- "expression": "source_platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_agent_commands": {
- "name": "security_agent_commands",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "command_type": {
- "name": "command_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "origin": {
- "name": "origin",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'accepted'"
- },
- "result_code": {
- "name": "result_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "result_metadata": {
- "name": "result_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_redacted": {
- "name": "last_error_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "accepted_at": {
- "name": "accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_security_agent_commands_org_created": {
- "name": "idx_security_agent_commands_org_created",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_agent_commands_user_created": {
- "name": "idx_security_agent_commands_user_created",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_agent_commands_status_updated": {
- "name": "idx_security_agent_commands_status_updated",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_agent_commands_finding_created": {
- "name": "idx_security_agent_commands_finding_created",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_agent_commands_owned_by_organization_id_organizations_id_fk": {
- "name": "security_agent_commands_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_agent_commands",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_agent_commands_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_agent_commands_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_agent_commands",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_agent_commands_finding_id_security_findings_id_fk": {
- "name": "security_agent_commands_finding_id_security_findings_id_fk",
- "tableFrom": "security_agent_commands",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_agent_commands_owner_check": {
- "name": "security_agent_commands_owner_check",
- "value": "(\n (\"security_agent_commands\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_commands\".\"owned_by_user_id\" IS NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_agent_commands_type_check": {
- "name": "security_agent_commands_type_check",
- "value": "\"security_agent_commands\".\"command_type\" IN ('sync', 'dismiss_finding', 'start_analysis', 'apply_auto_remediation')"
- },
- "security_agent_commands_origin_check": {
- "name": "security_agent_commands_origin_check",
- "value": "\"security_agent_commands\".\"origin\" IN ('manual', 'dashboard_refresh', 'enable_initial_sync', 'settings_include_existing')"
- },
- "security_agent_commands_status_check": {
- "name": "security_agent_commands_status_check",
- "value": "\"security_agent_commands\".\"status\" IN ('accepted', 'running', 'succeeded', 'failed', 'no_op')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_agent_repository_sync_state": {
- "name": "security_agent_repository_sync_state",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "last_attempted_at": {
- "name": "last_attempted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_succeeded_at": {
- "name": "last_succeeded_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_failure_code": {
- "name": "last_failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_agent_repository_sync_state_org_repo": {
- "name": "UQ_security_agent_repository_sync_state_org_repo",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_agent_repository_sync_state\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_agent_repository_sync_state_user_repo": {
- "name": "UQ_security_agent_repository_sync_state_user_repo",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_agent_repository_sync_state\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk": {
- "name": "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_agent_repository_sync_state",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_agent_repository_sync_state",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_agent_repository_sync_state_owner_check": {
- "name": "security_agent_repository_sync_state_owner_check",
- "value": "(\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_analysis_owner_state": {
- "name": "security_analysis_owner_state",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_analysis_enabled_at": {
- "name": "auto_analysis_enabled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_until": {
- "name": "blocked_until",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "block_reason": {
- "name": "block_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "consecutive_actor_resolution_failures": {
- "name": "consecutive_actor_resolution_failures",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "last_actor_resolution_failure_at": {
- "name": "last_actor_resolution_failure_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_analysis_owner_state_org_owner": {
- "name": "UQ_security_analysis_owner_state_org_owner",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_analysis_owner_state\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_analysis_owner_state_user_owner": {
- "name": "UQ_security_analysis_owner_state_user_owner",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_analysis_owner_state\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk": {
- "name": "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_analysis_owner_state",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_analysis_owner_state",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_analysis_owner_state_owner_check": {
- "name": "security_analysis_owner_state_owner_check",
- "value": "(\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_analysis_owner_state_block_reason_check": {
- "name": "security_analysis_owner_state_block_reason_check",
- "value": "\"security_analysis_owner_state\".\"block_reason\" IS NULL OR \"security_analysis_owner_state\".\"block_reason\" IN ('INSUFFICIENT_CREDITS', 'ACTOR_RESOLUTION_FAILED', 'OPERATOR_PAUSE')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_analysis_queue": {
- "name": "security_analysis_queue",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "queue_status": {
- "name": "queue_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "severity_rank": {
- "name": "severity_rank",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true
- },
- "queued_at": {
- "name": "queued_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_by_job_id": {
- "name": "claimed_by_job_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "claim_token": {
- "name": "claim_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "reopen_requeue_count": {
- "name": "reopen_requeue_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_redacted": {
- "name": "last_error_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_analysis_queue_finding_id": {
- "name": "UQ_security_analysis_queue_finding_id",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_claim_path_org": {
- "name": "idx_security_analysis_queue_claim_path_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "severity_rank",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_claim_path_user": {
- "name": "idx_security_analysis_queue_claim_path_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "severity_rank",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_in_flight_org": {
- "name": "idx_security_analysis_queue_in_flight_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queue_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_in_flight_user": {
- "name": "idx_security_analysis_queue_in_flight_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queue_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_lag_dashboards": {
- "name": "idx_security_analysis_queue_lag_dashboards",
- "columns": [
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_pending_reconciliation": {
- "name": "idx_security_analysis_queue_pending_reconciliation",
- "columns": [
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_running_reconciliation": {
- "name": "idx_security_analysis_queue_running_reconciliation",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'running'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_failure_trend": {
- "name": "idx_security_analysis_queue_failure_trend",
- "columns": [
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"failure_code\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_analysis_queue_finding_id_security_findings_id_fk": {
- "name": "security_analysis_queue_finding_id_security_findings_id_fk",
- "tableFrom": "security_analysis_queue",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_analysis_queue_owned_by_organization_id_organizations_id_fk": {
- "name": "security_analysis_queue_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_analysis_queue",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_analysis_queue",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_analysis_queue_owner_check": {
- "name": "security_analysis_queue_owner_check",
- "value": "(\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_analysis_queue_status_check": {
- "name": "security_analysis_queue_status_check",
- "value": "\"security_analysis_queue\".\"queue_status\" IN ('queued', 'pending', 'running', 'failed', 'completed')"
- },
- "security_analysis_queue_claim_token_required_check": {
- "name": "security_analysis_queue_claim_token_required_check",
- "value": "\"security_analysis_queue\".\"queue_status\" NOT IN ('pending', 'running') OR \"security_analysis_queue\".\"claim_token\" IS NOT NULL"
- },
- "security_analysis_queue_attempt_count_non_negative_check": {
- "name": "security_analysis_queue_attempt_count_non_negative_check",
- "value": "\"security_analysis_queue\".\"attempt_count\" >= 0"
- },
- "security_analysis_queue_reopen_requeue_count_non_negative_check": {
- "name": "security_analysis_queue_reopen_requeue_count_non_negative_check",
- "value": "\"security_analysis_queue\".\"reopen_requeue_count\" >= 0"
- },
- "security_analysis_queue_severity_rank_check": {
- "name": "security_analysis_queue_severity_rank_check",
- "value": "\"security_analysis_queue\".\"severity_rank\" IN (0, 1, 2, 3)"
- },
- "security_analysis_queue_failure_code_check": {
- "name": "security_analysis_queue_failure_code_check",
- "value": "\"security_analysis_queue\".\"failure_code\" IS NULL OR \"security_analysis_queue\".\"failure_code\" IN (\n 'NETWORK_TIMEOUT',\n 'UPSTREAM_5XX',\n 'TEMP_TOKEN_FAILURE',\n 'START_CALL_AMBIGUOUS',\n 'REQUEUE_TEMPORARY_PRECONDITION',\n 'ACTOR_RESOLUTION_FAILED',\n 'GITHUB_TOKEN_UNAVAILABLE',\n 'INVALID_CONFIG',\n 'MISSING_OWNERSHIP',\n 'PERMISSION_DENIED_PERMANENT',\n 'UNSUPPORTED_SEVERITY',\n 'INSUFFICIENT_CREDITS',\n 'STATE_GUARD_REJECTED',\n 'SKIPPED_ALREADY_IN_PROGRESS',\n 'SKIPPED_NO_LONGER_ELIGIBLE',\n 'REOPEN_LOOP_GUARD',\n 'RUN_LOST'\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_audit_log": {
- "name": "security_audit_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_email": {
- "name": "actor_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_name": {
- "name": "actor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_type": {
- "name": "actor_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "resource_type": {
- "name": "resource_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "resource_id": {
- "name": "resource_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "before_state": {
- "name": "before_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "after_state": {
- "name": "after_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "occurred_at": {
- "name": "occurred_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "source_occurred_at": {
- "name": "source_occurred_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "event_key": {
- "name": "event_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "schema_version": {
- "name": "schema_version",
- "type": "smallint",
- "primaryKey": false,
- "notNull": false
- },
- "finding_snapshot": {
- "name": "finding_snapshot",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "source_context": {
- "name": "source_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_security_audit_log_org_created": {
- "name": "IDX_security_audit_log_org_created",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_user_created": {
- "name": "IDX_security_audit_log_user_created",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_resource": {
- "name": "IDX_security_audit_log_resource",
- "columns": [
- {
- "expression": "resource_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "resource_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_actor": {
- "name": "IDX_security_audit_log_actor",
- "columns": [
- {
- "expression": "actor_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_action": {
- "name": "IDX_security_audit_log_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_audit_log_org_event_key": {
- "name": "UQ_security_audit_log_org_event_key",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_audit_log_user_event_key": {
- "name": "UQ_security_audit_log_user_event_key",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_org_occurred": {
- "name": "IDX_security_audit_log_org_occurred",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "occurred_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_user_occurred": {
- "name": "IDX_security_audit_log_user_occurred",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "occurred_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_audit_log_owned_by_organization_id_organizations_id_fk": {
- "name": "security_audit_log_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_audit_log",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_audit_log_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_audit_log_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_audit_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_audit_log_owner_check": {
- "name": "security_audit_log_owner_check",
- "value": "(\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NULL) OR (\"security_audit_log\".\"owned_by_user_id\" IS NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL)"
- },
- "security_audit_log_action_check": {
- "name": "security_audit_log_action_check",
- "value": "\"security_audit_log\".\"action\" IN ('security.finding.created', 'security.finding.severity_changed', 'security.finding.status_change', 'security.finding.dismissed', 'security.finding.auto_dismissed', 'security.finding.superseded', 'security.finding.analysis_started', 'security.finding.analysis_completed', 'security.finding.analysis_failed', 'security.remediation.queued', 'security.remediation.started', 'security.remediation.pr_opened', 'security.remediation.failed', 'security.remediation.blocked', 'security.remediation.no_changes_needed', 'security.remediation.cancelled', 'security.remediation.retried', 'security.finding.deleted', 'security.config.enabled', 'security.config.disabled', 'security.config.updated', 'security.sync.triggered', 'security.sync.completed', 'security.audit_log.exported', 'security.audit_report.generated')"
- },
- "security_audit_log_actor_type_check": {
- "name": "security_audit_log_actor_type_check",
- "value": "\"security_audit_log\".\"actor_type\" IN ('customer_user', 'kilo_admin', 'system')"
- },
- "security_audit_log_source_context_check": {
- "name": "security_audit_log_source_context_check",
- "value": "\"security_audit_log\".\"source_context\" IN ('security_sync', 'web', 'analysis_worker', 'remediation_callback', 'rollout_baseline')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_finding_notifications": {
- "name": "security_finding_notifications",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "recipient_user_id": {
- "name": "recipient_user_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": "'staged'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_attempt_at": {
- "name": "next_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "uq_security_finding_notifications_finding_recipient_kind": {
- "name": "uq_security_finding_notifications_finding_recipient_kind",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "recipient_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_pending": {
- "name": "idx_security_finding_notifications_pending",
- "columns": [
- {
- "expression": "next_attempt_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_finding_notifications\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_staged": {
- "name": "idx_security_finding_notifications_staged",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_finding_notifications\".\"status\" = 'staged'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_finding_id": {
- "name": "idx_security_finding_notifications_finding_id",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_recipient_user_id": {
- "name": "idx_security_finding_notifications_recipient_user_id",
- "columns": [
- {
- "expression": "recipient_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_finding_notifications_finding_fk": {
- "name": "security_finding_notifications_finding_fk",
- "tableFrom": "security_finding_notifications",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_finding_notifications_recipient_fk": {
- "name": "security_finding_notifications_recipient_fk",
- "tableFrom": "security_finding_notifications",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "recipient_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_finding_notifications_kind_check": {
- "name": "security_finding_notifications_kind_check",
- "value": "\"security_finding_notifications\".\"kind\" IN ('new_finding', 'sla_warning', 'sla_breach')"
- },
- "security_finding_notifications_status_check": {
- "name": "security_finding_notifications_status_check",
- "value": "\"security_finding_notifications\".\"status\" IN ('staged', 'pending', 'sending', 'sent', 'failed', 'cancelled')"
- },
- "security_finding_notifications_attempt_count_check": {
- "name": "security_finding_notifications_attempt_count_check",
- "value": "\"security_finding_notifications\".\"attempt_count\" >= 0"
- },
- "security_finding_notifications_claimed_at_check": {
- "name": "security_finding_notifications_claimed_at_check",
- "value": "(\n (\"security_finding_notifications\".\"status\" = 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NULL)\n )"
- },
- "security_finding_notifications_sent_at_check": {
- "name": "security_finding_notifications_sent_at_check",
- "value": "(\n (\"security_finding_notifications\".\"status\" = 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NULL)\n )"
- },
- "security_finding_notifications_error_message_length_check": {
- "name": "security_finding_notifications_error_message_length_check",
- "value": "\"security_finding_notifications\".\"error_message\" IS NULL OR length(\"security_finding_notifications\".\"error_message\") <= 500"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_findings": {
- "name": "security_findings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source": {
- "name": "source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_id": {
- "name": "source_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "severity": {
- "name": "severity",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "ghsa_id": {
- "name": "ghsa_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cve_id": {
- "name": "cve_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "package_name": {
- "name": "package_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "package_ecosystem": {
- "name": "package_ecosystem",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "vulnerable_version_range": {
- "name": "vulnerable_version_range",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "patched_version": {
- "name": "patched_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "manifest_path": {
- "name": "manifest_path",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'open'"
- },
- "ignored_reason": {
- "name": "ignored_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ignored_by": {
- "name": "ignored_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "fixed_at": {
- "name": "fixed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sla_due_at": {
- "name": "sla_due_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "dependabot_html_url": {
- "name": "dependabot_html_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cwe_ids": {
- "name": "cwe_ids",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "cvss_score": {
- "name": "cvss_score",
- "type": "numeric(3, 1)",
- "primaryKey": false,
- "notNull": false
- },
- "dependency_scope": {
- "name": "dependency_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_status": {
- "name": "analysis_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_started_at": {
- "name": "analysis_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_completed_at": {
- "name": "analysis_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_error": {
- "name": "analysis_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis": {
- "name": "analysis",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "raw_data": {
- "name": "raw_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "first_detected_at": {
- "name": "first_detected_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "last_synced_at": {
- "name": "last_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "uq_security_findings_user_source": {
- "name": "uq_security_findings_user_source",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_findings\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "uq_security_findings_org_source": {
- "name": "uq_security_findings_org_source",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_findings\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_org_id": {
- "name": "idx_security_findings_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_user_id": {
- "name": "idx_security_findings_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_repo": {
- "name": "idx_security_findings_repo",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_severity": {
- "name": "idx_security_findings_severity",
- "columns": [
- {
- "expression": "severity",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_status": {
- "name": "idx_security_findings_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_package": {
- "name": "idx_security_findings_package",
- "columns": [
- {
- "expression": "package_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_sla_due_at": {
- "name": "idx_security_findings_sla_due_at",
- "columns": [
- {
- "expression": "sla_due_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_session_id": {
- "name": "idx_security_findings_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_cli_session_id": {
- "name": "idx_security_findings_cli_session_id",
- "columns": [
- {
- "expression": "cli_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_analysis_status": {
- "name": "idx_security_findings_analysis_status",
- "columns": [
- {
- "expression": "analysis_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_org_analysis_in_flight": {
- "name": "idx_security_findings_org_analysis_in_flight",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_user_analysis_in_flight": {
- "name": "idx_security_findings_user_analysis_in_flight",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_findings_owned_by_organization_id_organizations_id_fk": {
- "name": "security_findings_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_findings",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_findings_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_findings_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_findings",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_findings_platform_integration_id_platform_integrations_id_fk": {
- "name": "security_findings_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "security_findings",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_findings_owner_check": {
- "name": "security_findings_owner_check",
- "value": "(\n (\"security_findings\".\"owned_by_user_id\" IS NOT NULL AND \"security_findings\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_findings\".\"owned_by_user_id\" IS NULL AND \"security_findings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_remediation_attempts": {
- "name": "security_remediation_attempts",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "remediation_id": {
- "name": "remediation_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "origin": {
- "name": "origin",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "attempt_number": {
- "name": "attempt_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "retry_of_attempt_id": {
- "name": "retry_of_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "requested_by_user_id": {
- "name": "requested_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_fingerprint": {
- "name": "analysis_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "analysis_completed_at": {
- "name": "analysis_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "remediation_model_slug": {
- "name": "remediation_model_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "branch_name": {
- "name": "branch_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_session_id": {
- "name": "kilo_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "execution_id": {
- "name": "execution_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "priority": {
- "name": "priority",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true,
- "default": 50
- },
- "claim_token": {
- "name": "claim_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_by_job_id": {
- "name": "claimed_by_job_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "launch_attempt_count": {
- "name": "launch_attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "callback_attempt_token_hash": {
- "name": "callback_attempt_token_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_reason": {
- "name": "blocked_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_redacted": {
- "name": "last_error_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "structured_result": {
- "name": "structured_result",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "final_assistant_message": {
- "name": "final_assistant_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "validation_evidence": {
- "name": "validation_evidence",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "risk_notes": {
- "name": "risk_notes",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "draft_reason": {
- "name": "draft_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_draft": {
- "name": "pr_draft",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_branch": {
- "name": "pr_head_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_base_branch": {
- "name": "pr_base_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cancellation_requested_at": {
- "name": "cancellation_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "cancellation_requested_by_user_id": {
- "name": "cancellation_requested_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "queued_at": {
- "name": "queued_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "launched_at": {
- "name": "launched_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_remediation_attempts_number": {
- "name": "UQ_security_remediation_attempts_number",
- "columns": [
- {
- "expression": "remediation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "attempt_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_remediation_attempts_active_finding": {
- "name": "UQ_security_remediation_attempts_active_finding",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_remediation_attempts_active_remediation": {
- "name": "UQ_security_remediation_attempts_active_remediation",
- "columns": [
- {
- "expression": "remediation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_remediation_attempts_finding_fingerprint_terminal": {
- "name": "UQ_security_remediation_attempts_finding_fingerprint_terminal",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_org_claim": {
- "name": "idx_security_remediation_attempts_org_claim",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "priority",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_user_claim": {
- "name": "idx_security_remediation_attempts_user_claim",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "priority",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_repo_claim": {
- "name": "idx_security_remediation_attempts_repo_claim",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "priority",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_org_inflight": {
- "name": "idx_security_remediation_attempts_org_inflight",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_user_inflight": {
- "name": "idx_security_remediation_attempts_user_inflight",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_repo_inflight": {
- "name": "idx_security_remediation_attempts_repo_inflight",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_cloud_agent_session": {
- "name": "idx_security_remediation_attempts_cloud_agent_session",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_finding_fingerprint": {
- "name": "idx_security_remediation_attempts_finding_fingerprint",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_remediation_attempts_remediation_id_security_remediations_id_fk": {
- "name": "security_remediation_attempts_remediation_id_security_remediations_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "security_remediations",
- "columnsFrom": [
- "remediation_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_finding_id_security_findings_id_fk": {
- "name": "security_remediation_attempts_finding_id_security_findings_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_owned_by_organization_id_organizations_id_fk": {
- "name": "security_remediation_attempts_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "requested_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "cancellation_requested_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_remediation_attempts_owner_check": {
- "name": "security_remediation_attempts_owner_check",
- "value": "(\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_remediation_attempts_status_check": {
- "name": "security_remediation_attempts_status_check",
- "value": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
- },
- "security_remediation_attempts_origin_check": {
- "name": "security_remediation_attempts_origin_check",
- "value": "\"security_remediation_attempts\".\"origin\" IN ('auto_policy', 'bulk_existing', 'manual')"
- },
- "security_remediation_attempts_attempt_number_check": {
- "name": "security_remediation_attempts_attempt_number_check",
- "value": "\"security_remediation_attempts\".\"attempt_number\" >= 1"
- },
- "security_remediation_attempts_launch_attempt_count_check": {
- "name": "security_remediation_attempts_launch_attempt_count_check",
- "value": "\"security_remediation_attempts\".\"launch_attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_remediations": {
- "name": "security_remediations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "latest_attempt_id": {
- "name": "latest_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "latest_analysis_fingerprint": {
- "name": "latest_analysis_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "latest_analysis_completed_at": {
- "name": "latest_analysis_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_draft": {
- "name": "pr_draft",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_branch": {
- "name": "pr_head_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_base_branch": {
- "name": "pr_base_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_reason": {
- "name": "blocked_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "outcome_summary": {
- "name": "outcome_summary",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_remediations_finding_id": {
- "name": "UQ_security_remediations_finding_id",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_org_status": {
- "name": "idx_security_remediations_org_status",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_user_status": {
- "name": "idx_security_remediations_user_status",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_repo_status": {
- "name": "idx_security_remediations_repo_status",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_latest_attempt": {
- "name": "idx_security_remediations_latest_attempt",
- "columns": [
- {
- "expression": "latest_attempt_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_remediations_owned_by_organization_id_organizations_id_fk": {
- "name": "security_remediations_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_remediations",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediations_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediations_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediations",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediations_finding_id_security_findings_id_fk": {
- "name": "security_remediations_finding_id_security_findings_id_fk",
- "tableFrom": "security_remediations",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_remediations_owner_check": {
- "name": "security_remediations_owner_check",
- "value": "(\n (\"security_remediations\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediations\".\"owned_by_user_id\" IS NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_remediations_status_check": {
- "name": "security_remediations_status_check",
- "value": "\"security_remediations\".\"status\" IN ('queued', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
- }
- },
- "isRLSEnabled": false
- },
- "public.shared_cli_sessions": {
- "name": "shared_cli_sessions",
- "schema": "",
- "columns": {
- "share_id": {
- "name": "share_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "session_id": {
- "name": "session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "shared_state": {
- "name": "shared_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'public'"
- },
- "api_conversation_history_blob_url": {
- "name": "api_conversation_history_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "task_metadata_blob_url": {
- "name": "task_metadata_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ui_messages_blob_url": {
- "name": "ui_messages_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_state_blob_url": {
- "name": "git_state_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_shared_cli_sessions_session_id": {
- "name": "IDX_shared_cli_sessions_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_shared_cli_sessions_created_at": {
- "name": "IDX_shared_cli_sessions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "shared_cli_sessions_session_id_cli_sessions_session_id_fk": {
- "name": "shared_cli_sessions_session_id_cli_sessions_session_id_fk",
- "tableFrom": "shared_cli_sessions",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk": {
- "name": "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "shared_cli_sessions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "shared_cli_sessions_shared_state_check": {
- "name": "shared_cli_sessions_shared_state_check",
- "value": "\"shared_cli_sessions\".\"shared_state\" IN ('public', 'organization')"
- }
- },
- "isRLSEnabled": false
- },
- "public.slack_bot_requests": {
- "name": "slack_bot_requests",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "slack_team_id": {
- "name": "slack_team_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slack_team_name": {
- "name": "slack_team_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "slack_channel_id": {
- "name": "slack_channel_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slack_user_id": {
- "name": "slack_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slack_thread_ts": {
- "name": "slack_thread_ts",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_message": {
- "name": "user_message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_message_truncated": {
- "name": "user_message_truncated",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "response_time_ms": {
- "name": "response_time_ms",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "model_used": {
- "name": "model_used",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "tool_calls_made": {
- "name": "tool_calls_made",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_slack_bot_requests_created_at": {
- "name": "idx_slack_bot_requests_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_slack_team_id": {
- "name": "idx_slack_bot_requests_slack_team_id",
- "columns": [
- {
- "expression": "slack_team_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_owned_by_org_id": {
- "name": "idx_slack_bot_requests_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_owned_by_user_id": {
- "name": "idx_slack_bot_requests_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_status": {
- "name": "idx_slack_bot_requests_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_event_type": {
- "name": "idx_slack_bot_requests_event_type",
- "columns": [
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_team_created": {
- "name": "idx_slack_bot_requests_team_created",
- "columns": [
- {
- "expression": "slack_team_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "slack_bot_requests_owned_by_organization_id_organizations_id_fk": {
- "name": "slack_bot_requests_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "slack_bot_requests",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk": {
- "name": "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "slack_bot_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "slack_bot_requests_platform_integration_id_platform_integrations_id_fk": {
- "name": "slack_bot_requests_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "slack_bot_requests",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "slack_bot_requests_owner_check": {
- "name": "slack_bot_requests_owner_check",
- "value": "(\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NOT NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NOT NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.source_embeddings": {
- "name": "source_embeddings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "embedding": {
- "name": "embedding",
- "type": "vector(1536)",
- "primaryKey": false,
- "notNull": true
- },
- "file_path": {
- "name": "file_path",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "file_hash": {
- "name": "file_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "start_line": {
- "name": "start_line",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "end_line": {
- "name": "end_line",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'main'"
- },
- "is_base_branch": {
- "name": "is_base_branch",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_source_embeddings_organization_id": {
- "name": "IDX_source_embeddings_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_kilo_user_id": {
- "name": "IDX_source_embeddings_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_project_id": {
- "name": "IDX_source_embeddings_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_created_at": {
- "name": "IDX_source_embeddings_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_updated_at": {
- "name": "IDX_source_embeddings_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_file_path_lower": {
- "name": "IDX_source_embeddings_file_path_lower",
- "columns": [
- {
- "expression": "LOWER(\"file_path\")",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_git_branch": {
- "name": "IDX_source_embeddings_git_branch",
- "columns": [
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_org_project_branch": {
- "name": "IDX_source_embeddings_org_project_branch",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "source_embeddings_organization_id_organizations_id_fk": {
- "name": "source_embeddings_organization_id_organizations_id_fk",
- "tableFrom": "source_embeddings",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "source_embeddings_kilo_user_id_kilocode_users_id_fk": {
- "name": "source_embeddings_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "source_embeddings",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_source_embeddings_org_project_branch_file_lines": {
- "name": "UQ_source_embeddings_org_project_branch_file_lines",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "project_id",
- "git_branch",
- "file_path",
- "start_line",
- "end_line"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.stripe_dispute_actions": {
- "name": "stripe_dispute_actions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "case_id": {
- "name": "case_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "action_type": {
- "name": "action_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "target_key": {
- "name": "target_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_attempt_at": {
- "name": "last_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "result_code": {
- "name": "result_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "result_reference_id": {
- "name": "result_reference_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_dispute_actions_case_id": {
- "name": "IDX_stripe_dispute_actions_case_id",
- "columns": [
- {
- "expression": "case_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_actions_claim_path": {
- "name": "IDX_stripe_dispute_actions_claim_path",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk": {
- "name": "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk",
- "tableFrom": "stripe_dispute_actions",
- "tableTo": "stripe_dispute_cases",
- "columnsFrom": [
- "case_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_dispute_actions_case_type_target": {
- "name": "UQ_stripe_dispute_actions_case_type_target",
- "nullsNotDistinct": false,
- "columns": [
- "case_id",
- "action_type",
- "target_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_dispute_actions_action_type_check": {
- "name": "stripe_dispute_actions_action_type_check",
- "value": "\"stripe_dispute_actions\".\"action_type\" IN ('stripe_acceptance', 'user_block', 'auto_top_up_disable', 'credit_balance_reset', 'subscription_cancellation', 'access_termination', 'kiloclaw_suspension')"
- },
- "stripe_dispute_actions_status_check": {
- "name": "stripe_dispute_actions_status_check",
- "value": "\"stripe_dispute_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'skipped')"
- },
- "stripe_dispute_actions_attempt_count_non_negative_check": {
- "name": "stripe_dispute_actions_attempt_count_non_negative_check",
- "value": "\"stripe_dispute_actions\".\"attempt_count\" >= 0"
- },
- "stripe_dispute_actions_target_key_not_empty_check": {
- "name": "stripe_dispute_actions_target_key_not_empty_check",
- "value": "length(\"stripe_dispute_actions\".\"target_key\") > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stripe_dispute_cases": {
- "name": "stripe_dispute_cases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "stripe_dispute_id": {
- "name": "stripe_dispute_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_event_id": {
- "name": "stripe_event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_event_created_at": {
- "name": "stripe_event_created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_intent_id": {
- "name": "stripe_payment_intent_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "amount_minor_units": {
- "name": "amount_minor_units",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "currency": {
- "name": "currency",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "dispute_reason": {
- "name": "dispute_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_status": {
- "name": "stripe_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owner_classification": {
- "name": "owner_classification",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'needs_action'"
- },
- "status_reason": {
- "name": "status_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_created_at": {
- "name": "stripe_created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "evidence_due_by": {
- "name": "evidence_due_by",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "synced_at": {
- "name": "synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "accepted_by_kilo_user_id": {
- "name": "accepted_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "acceptance_started_at": {
- "name": "acceptance_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "accepted_at": {
- "name": "accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "enforcement_completed_at": {
- "name": "enforcement_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "review_required_at": {
- "name": "review_required_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "closed_at": {
- "name": "closed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_dispute_cases_event_id": {
- "name": "IDX_stripe_dispute_cases_event_id",
- "columns": [
- {
- "expression": "stripe_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_charge_id": {
- "name": "IDX_stripe_dispute_cases_charge_id",
- "columns": [
- {
- "expression": "stripe_charge_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_payment_intent_id": {
- "name": "IDX_stripe_dispute_cases_payment_intent_id",
- "columns": [
- {
- "expression": "stripe_payment_intent_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_customer_id": {
- "name": "IDX_stripe_dispute_cases_customer_id",
- "columns": [
- {
- "expression": "stripe_customer_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_kilo_user_id": {
- "name": "IDX_stripe_dispute_cases_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_organization_id": {
- "name": "IDX_stripe_dispute_cases_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_status_due_by": {
- "name": "IDX_stripe_dispute_cases_status_due_by",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "evidence_due_by",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "stripe_created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk": {
- "name": "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "stripe_dispute_cases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "stripe_dispute_cases_organization_id_organizations_id_fk": {
- "name": "stripe_dispute_cases_organization_id_organizations_id_fk",
- "tableFrom": "stripe_dispute_cases",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "stripe_dispute_cases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "accepted_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_dispute_cases_dispute_id": {
- "name": "UQ_stripe_dispute_cases_dispute_id",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_dispute_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_dispute_cases_owner_classification_check": {
- "name": "stripe_dispute_cases_owner_classification_check",
- "value": "\"stripe_dispute_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
- },
- "stripe_dispute_cases_status_check": {
- "name": "stripe_dispute_cases_status_check",
- "value": "\"stripe_dispute_cases\".\"status\" IN ('needs_action', 'processing', 'accepted', 'acceptance_failed', 'enforcement_failed', 'review_required', 'closed')"
- },
- "stripe_dispute_cases_amount_minor_units_non_negative_check": {
- "name": "stripe_dispute_cases_amount_minor_units_non_negative_check",
- "value": "\"stripe_dispute_cases\".\"amount_minor_units\" IS NULL OR \"stripe_dispute_cases\".\"amount_minor_units\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stripe_early_fraud_warning_actions": {
- "name": "stripe_early_fraud_warning_actions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "case_id": {
- "name": "case_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "action_type": {
- "name": "action_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "target_key": {
- "name": "target_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_attempt_at": {
- "name": "last_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "result_code": {
- "name": "result_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "result_reference_id": {
- "name": "result_reference_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_early_fraud_warning_actions_case_id": {
- "name": "IDX_stripe_early_fraud_warning_actions_case_id",
- "columns": [
- {
- "expression": "case_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_actions_claim_path": {
- "name": "IDX_stripe_early_fraud_warning_actions_claim_path",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk": {
- "name": "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk",
- "tableFrom": "stripe_early_fraud_warning_actions",
- "tableTo": "stripe_early_fraud_warning_cases",
- "columnsFrom": [
- "case_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_early_fraud_warning_actions_case_type_target": {
- "name": "UQ_stripe_early_fraud_warning_actions_case_type_target",
- "nullsNotDistinct": false,
- "columns": [
- "case_id",
- "action_type",
- "target_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_early_fraud_warning_actions_action_type_check": {
- "name": "stripe_early_fraud_warning_actions_action_type_check",
- "value": "\"stripe_early_fraud_warning_actions\".\"action_type\" IN ('containment', 'refund', 'payment_value_clawback', 'subscription_termination', 'access_termination', 'kiloclaw_suspension', 'affiliate_payout_reversal', 'referral_reward_reversal', 'user_notice')"
- },
- "stripe_early_fraud_warning_actions_status_check": {
- "name": "stripe_early_fraud_warning_actions_status_check",
- "value": "\"stripe_early_fraud_warning_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'review_required', 'dismissed')"
- },
- "stripe_early_fraud_warning_actions_attempt_count_non_negative_check": {
- "name": "stripe_early_fraud_warning_actions_attempt_count_non_negative_check",
- "value": "\"stripe_early_fraud_warning_actions\".\"attempt_count\" >= 0"
- },
- "stripe_early_fraud_warning_actions_target_key_not_empty_check": {
- "name": "stripe_early_fraud_warning_actions_target_key_not_empty_check",
- "value": "length(\"stripe_early_fraud_warning_actions\".\"target_key\") > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stripe_early_fraud_warning_cases": {
- "name": "stripe_early_fraud_warning_cases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "stripe_early_fraud_warning_id": {
- "name": "stripe_early_fraud_warning_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_event_id": {
- "name": "stripe_event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_intent_id": {
- "name": "stripe_payment_intent_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "amount_minor_units": {
- "name": "amount_minor_units",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "currency": {
- "name": "currency",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owner_classification": {
- "name": "owner_classification",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "warning_created_at": {
- "name": "warning_created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "contained_at": {
- "name": "contained_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "processing_started_at": {
- "name": "processing_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "review_required_at": {
- "name": "review_required_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "remediated_at": {
- "name": "remediated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "dismissed_at": {
- "name": "dismissed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_early_fraud_warning_cases_event_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_event_id",
- "columns": [
- {
- "expression": "stripe_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_charge_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_charge_id",
- "columns": [
- {
- "expression": "stripe_charge_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_payment_intent_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_payment_intent_id",
- "columns": [
- {
- "expression": "stripe_payment_intent_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_customer_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_customer_id",
- "columns": [
- {
- "expression": "stripe_customer_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_kilo_user_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_organization_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_status_created_at": {
- "name": "IDX_stripe_early_fraud_warning_cases_status_created_at",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk": {
- "name": "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "stripe_early_fraud_warning_cases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk": {
- "name": "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk",
- "tableFrom": "stripe_early_fraud_warning_cases",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_early_fraud_warning_cases_warning_id": {
- "name": "UQ_stripe_early_fraud_warning_cases_warning_id",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_early_fraud_warning_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_early_fraud_warning_cases_owner_classification_check": {
- "name": "stripe_early_fraud_warning_cases_owner_classification_check",
- "value": "\"stripe_early_fraud_warning_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
- },
- "stripe_early_fraud_warning_cases_status_check": {
- "name": "stripe_early_fraud_warning_cases_status_check",
- "value": "\"stripe_early_fraud_warning_cases\".\"status\" IN ('queued', 'contained', 'processing', 'completed', 'review_required', 'failed', 'remediated', 'dismissed')"
- },
- "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check": {
- "name": "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check",
- "value": "\"stripe_early_fraud_warning_cases\".\"amount_minor_units\" IS NULL OR \"stripe_early_fraud_warning_cases\".\"amount_minor_units\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stytch_fingerprints": {
- "name": "stytch_fingerprints",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "visitor_fingerprint": {
- "name": "visitor_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "browser_fingerprint": {
- "name": "browser_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "browser_id": {
- "name": "browser_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "hardware_fingerprint": {
- "name": "hardware_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "network_fingerprint": {
- "name": "network_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "visitor_id": {
- "name": "visitor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "verdict_action": {
- "name": "verdict_action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "detected_device_type": {
- "name": "detected_device_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_authentic_device": {
- "name": "is_authentic_device",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "reasons": {
- "name": "reasons",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{\"\"}'"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "status_code": {
- "name": "status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "fingerprint_data": {
- "name": "fingerprint_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_free_tier_allowed": {
- "name": "kilo_free_tier_allowed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "http_x_forwarded_for": {
- "name": "http_x_forwarded_for",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_city": {
- "name": "http_x_vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_country": {
- "name": "http_x_vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_latitude": {
- "name": "http_x_vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_longitude": {
- "name": "http_x_vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ja4_digest": {
- "name": "http_x_vercel_ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_user_agent": {
- "name": "http_user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_hardware_fingerprint": {
- "name": "idx_hardware_fingerprint",
- "columns": [
- {
- "expression": "hardware_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_kilo_user_id": {
- "name": "idx_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_stytch_fingerprints_reasons_gin": {
- "name": "idx_stytch_fingerprints_reasons_gin",
- "columns": [
- {
- "expression": "reasons",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "gin",
- "with": {}
- },
- "idx_verdict_action": {
- "name": "idx_verdict_action",
- "columns": [
- {
- "expression": "verdict_action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_visitor_fingerprint": {
- "name": "idx_visitor_fingerprint",
- "columns": [
- {
- "expression": "visitor_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.system_prompt_prefix": {
- "name": "system_prompt_prefix",
- "schema": "",
- "columns": {
- "system_prompt_prefix_id": {
- "name": "system_prompt_prefix_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "system_prompt_prefix": {
- "name": "system_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_system_prompt_prefix": {
- "name": "UQ_system_prompt_prefix",
- "columns": [
- {
- "expression": "system_prompt_prefix",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.transactional_email_log": {
- "name": "transactional_email_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "email_type": {
- "name": "email_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_transactional_email_log_type_idempotency_key": {
- "name": "UQ_transactional_email_log_type_idempotency_key",
- "columns": [
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "idempotency_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_transactional_email_log_user_id": {
- "name": "IDX_transactional_email_log_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_transactional_email_log_organization_id": {
- "name": "IDX_transactional_email_log_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "transactional_email_log_user_id_kilocode_users_id_fk": {
- "name": "transactional_email_log_user_id_kilocode_users_id_fk",
- "tableFrom": "transactional_email_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "transactional_email_log_organization_id_organizations_id_fk": {
- "name": "transactional_email_log_organization_id_organizations_id_fk",
- "tableFrom": "transactional_email_log",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "CHK_transactional_email_log_owner": {
- "name": "CHK_transactional_email_log_owner",
- "value": "\"transactional_email_log\".\"user_id\" IS NOT NULL OR \"transactional_email_log\".\"organization_id\" IS NOT NULL"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_admin_notes": {
- "name": "user_admin_notes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "note_content": {
- "name": "note_content",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "admin_kilo_user_id": {
- "name": "admin_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_34517df0b385234babc38fe81b": {
- "name": "IDX_34517df0b385234babc38fe81b",
- "columns": [
- {
- "expression": "admin_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_ccbde98c4c14046daa5682ec4f": {
- "name": "IDX_ccbde98c4c14046daa5682ec4f",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_d0270eb24ef6442d65a0b7853c": {
- "name": "IDX_d0270eb24ef6442d65a0b7853c",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_affiliate_attributions": {
- "name": "user_affiliate_attributions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "tracking_id": {
- "name": "tracking_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_user_affiliate_attributions_user_id": {
- "name": "IDX_user_affiliate_attributions_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_affiliate_attributions_user_id_kilocode_users_id_fk": {
- "name": "user_affiliate_attributions_user_id_kilocode_users_id_fk",
- "tableFrom": "user_affiliate_attributions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_user_affiliate_attributions_user_provider": {
- "name": "UQ_user_affiliate_attributions_user_provider",
- "nullsNotDistinct": false,
- "columns": [
- "user_id",
- "provider"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "user_affiliate_attributions_provider_check": {
- "name": "user_affiliate_attributions_provider_check",
- "value": "\"user_affiliate_attributions\".\"provider\" IN ('impact')"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_affiliate_events": {
- "name": "user_affiliate_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "parent_event_id": {
- "name": "parent_event_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "delivery_state": {
- "name": "delivery_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "payload_json": {
- "name": "payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "impact_action_id": {
- "name": "impact_action_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "impact_submission_uri": {
- "name": "impact_submission_uri",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_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": {
- "IDX_user_affiliate_events_claim_path": {
- "name": "IDX_user_affiliate_events_claim_path",
- "columns": [
- {
- "expression": "delivery_state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_affiliate_events_parent_event_id": {
- "name": "IDX_user_affiliate_events_parent_event_id",
- "columns": [
- {
- "expression": "parent_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_affiliate_events_provider_event_type_charge": {
- "name": "IDX_user_affiliate_events_provider_event_type_charge",
- "columns": [
- {
- "expression": "provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "stripe_charge_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_affiliate_events_user_id_kilocode_users_id_fk": {
- "name": "user_affiliate_events_user_id_kilocode_users_id_fk",
- "tableFrom": "user_affiliate_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "user_affiliate_events_parent_event_id_fk": {
- "name": "user_affiliate_events_parent_event_id_fk",
- "tableFrom": "user_affiliate_events",
- "tableTo": "user_affiliate_events",
- "columnsFrom": [
- "parent_event_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_user_affiliate_events_dedupe_key": {
- "name": "UQ_user_affiliate_events_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "user_affiliate_events_provider_check": {
- "name": "user_affiliate_events_provider_check",
- "value": "\"user_affiliate_events\".\"provider\" IN ('impact')"
- },
- "user_affiliate_events_event_type_check": {
- "name": "user_affiliate_events_event_type_check",
- "value": "\"user_affiliate_events\".\"event_type\" IN ('signup', 'trial_start', 'trial_end', 'sale', 'sale_reversal')"
- },
- "user_affiliate_events_delivery_state_check": {
- "name": "user_affiliate_events_delivery_state_check",
- "value": "\"user_affiliate_events\".\"delivery_state\" IN ('queued', 'blocked', 'sending', 'delivered', 'failed')"
- },
- "user_affiliate_events_attempt_count_non_negative_check": {
- "name": "user_affiliate_events_attempt_count_non_negative_check",
- "value": "\"user_affiliate_events\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_auth_provider": {
- "name": "user_auth_provider",
- "schema": "",
- "columns": {
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_account_id": {
- "name": "provider_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "avatar_url": {
- "name": "avatar_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "display_name": {
- "name": "display_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "hosted_domain": {
- "name": "hosted_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_user_auth_provider_kilo_user_id": {
- "name": "IDX_user_auth_provider_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_auth_provider_hosted_domain": {
- "name": "IDX_user_auth_provider_hosted_domain",
- "columns": [
- {
- "expression": "hosted_domain",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {
- "user_auth_provider_provider_provider_account_id_pk": {
- "name": "user_auth_provider_provider_provider_account_id_pk",
- "columns": [
- "provider",
- "provider_account_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_feedback": {
- "name": "user_feedback",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "feedback_text": {
- "name": "feedback_text",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "feedback_for": {
- "name": "feedback_for",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "feedback_batch": {
- "name": "feedback_batch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source": {
- "name": "source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "context_json": {
- "name": "context_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_user_feedback_created_at": {
- "name": "IDX_user_feedback_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_kilo_user_id": {
- "name": "IDX_user_feedback_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_feedback_for": {
- "name": "IDX_user_feedback_feedback_for",
- "columns": [
- {
- "expression": "feedback_for",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_feedback_batch": {
- "name": "IDX_user_feedback_feedback_batch",
- "columns": [
- {
- "expression": "feedback_batch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_source": {
- "name": "IDX_user_feedback_source",
- "columns": [
- {
- "expression": "source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_feedback_kilo_user_id_kilocode_users_id_fk": {
- "name": "user_feedback_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "user_feedback",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_github_app_tokens": {
- "name": "user_github_app_tokens",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_app_type": {
- "name": "github_app_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'standard'"
- },
- "github_user_id": {
- "name": "github_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_login": {
- "name": "github_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_encrypted": {
- "name": "access_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_expires_at": {
- "name": "access_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "refresh_token_encrypted": {
- "name": "refresh_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "refresh_token_expires_at": {
- "name": "refresh_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "credential_version": {
- "name": "credential_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_reason": {
- "name": "revocation_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_used_at": {
- "name": "last_used_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_user_github_app_tokens_user_app": {
- "name": "UQ_user_github_app_tokens_user_app",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "github_app_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_user_github_app_tokens_github_user_app": {
- "name": "UQ_user_github_app_tokens_github_user_app",
- "columns": [
- {
- "expression": "github_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "github_app_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk": {
- "name": "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "user_github_app_tokens",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "user_github_app_tokens_app_type_check": {
- "name": "user_github_app_tokens_app_type_check",
- "value": "\"user_github_app_tokens\".\"github_app_type\" IN ('standard', 'lite')"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_period_cache": {
- "name": "user_period_cache",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cache_type": {
- "name": "cache_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_type": {
- "name": "period_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_key": {
- "name": "period_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "data": {
- "name": "data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "computed_at": {
- "name": "computed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "version": {
- "name": "version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "shared_url_token": {
- "name": "shared_url_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "shared_at": {
- "name": "shared_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_user_period_cache_kilo_user_id": {
- "name": "IDX_user_period_cache_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_user_period_cache": {
- "name": "UQ_user_period_cache",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "cache_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_period_cache_lookup": {
- "name": "IDX_user_period_cache_lookup",
- "columns": [
- {
- "expression": "cache_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_user_period_cache_share_token": {
- "name": "UQ_user_period_cache_share_token",
- "columns": [
- {
- "expression": "shared_url_token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"user_period_cache\".\"shared_url_token\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_period_cache_kilo_user_id_kilocode_users_id_fk": {
- "name": "user_period_cache_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "user_period_cache",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "user_period_cache_period_type_check": {
- "name": "user_period_cache_period_type_check",
- "value": "\"user_period_cache\".\"period_type\" IN ('year', 'quarter', 'month', 'week', 'custom')"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_push_tokens": {
- "name": "user_push_tokens",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "token": {
- "name": "token",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_user_push_tokens_token": {
- "name": "UQ_user_push_tokens_token",
- "columns": [
- {
- "expression": "token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_push_tokens_user_id": {
- "name": "IDX_user_push_tokens_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_push_tokens_user_id_kilocode_users_id_fk": {
- "name": "user_push_tokens_user_id_kilocode_users_id_fk",
- "tableFrom": "user_push_tokens",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.vercel_ip_city": {
- "name": "vercel_ip_city",
- "schema": "",
- "columns": {
- "vercel_ip_city_id": {
- "name": "vercel_ip_city_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "vercel_ip_city": {
- "name": "vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_vercel_ip_city": {
- "name": "UQ_vercel_ip_city",
- "columns": [
- {
- "expression": "vercel_ip_city",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.vercel_ip_country": {
- "name": "vercel_ip_country",
- "schema": "",
- "columns": {
- "vercel_ip_country_id": {
- "name": "vercel_ip_country_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "vercel_ip_country": {
- "name": "vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_vercel_ip_country": {
- "name": "UQ_vercel_ip_country",
- "columns": [
- {
- "expression": "vercel_ip_country",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.webhook_events": {
- "name": "webhook_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_action": {
- "name": "event_action",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "payload": {
- "name": "payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "headers": {
- "name": "headers",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "processed": {
- "name": "processed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "processed_at": {
- "name": "processed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "handlers_triggered": {
- "name": "handlers_triggered",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'"
- },
- "errors": {
- "name": "errors",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "event_signature": {
- "name": "event_signature",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_webhook_events_owned_by_org_id": {
- "name": "IDX_webhook_events_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_owned_by_user_id": {
- "name": "IDX_webhook_events_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_platform": {
- "name": "IDX_webhook_events_platform",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_event_type": {
- "name": "IDX_webhook_events_event_type",
- "columns": [
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_created_at": {
- "name": "IDX_webhook_events_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "webhook_events_owned_by_organization_id_organizations_id_fk": {
- "name": "webhook_events_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "webhook_events",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "webhook_events_owned_by_user_id_kilocode_users_id_fk": {
- "name": "webhook_events_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "webhook_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_webhook_events_signature": {
- "name": "UQ_webhook_events_signature",
- "nullsNotDistinct": false,
- "columns": [
- "event_signature"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "webhook_events_owner_check": {
- "name": "webhook_events_owner_check",
- "value": "(\n (\"webhook_events\".\"owned_by_user_id\" IS NOT NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"webhook_events\".\"owned_by_user_id\" IS NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- }
- },
- "enums": {},
- "schemas": {},
- "sequences": {},
- "roles": {},
- "policies": {},
- "views": {
- "public.microdollar_usage_view": {
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "message_id": {
- "name": "message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cost": {
- "name": "cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "input_tokens": {
- "name": "input_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "output_tokens": {
- "name": "output_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_write_tokens": {
- "name": "cache_write_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_hit_tokens": {
- "name": "cache_hit_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "http_x_forwarded_for": {
- "name": "http_x_forwarded_for",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_city": {
- "name": "http_x_vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_country": {
- "name": "http_x_vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_latitude": {
- "name": "http_x_vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_longitude": {
- "name": "http_x_vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ja4_digest": {
- "name": "http_x_vercel_ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "requested_model": {
- "name": "requested_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_prompt_prefix": {
- "name": "user_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_prefix": {
- "name": "system_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_length": {
- "name": "system_prompt_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "http_user_agent": {
- "name": "http_user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cache_discount": {
- "name": "cache_discount",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "max_tokens": {
- "name": "max_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "has_middle_out_transform": {
- "name": "has_middle_out_transform",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "has_error": {
- "name": "has_error",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "abuse_classification": {
- "name": "abuse_classification",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "inference_provider": {
- "name": "inference_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status_code": {
- "name": "status_code",
- "type": "smallint",
- "primaryKey": false,
- "notNull": false
- },
- "upstream_id": {
- "name": "upstream_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finish_reason": {
- "name": "finish_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "latency": {
- "name": "latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "moderation_latency": {
- "name": "moderation_latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "generation_time": {
- "name": "generation_time",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "is_byok": {
- "name": "is_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "is_user_byok": {
- "name": "is_user_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "streamed": {
- "name": "streamed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "cancelled": {
- "name": "cancelled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "editor_name": {
- "name": "editor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "api_kind": {
- "name": "api_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "has_tools": {
- "name": "has_tools",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "machine_id": {
- "name": "machine_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "feature": {
- "name": "feature",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_model": {
- "name": "auto_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "market_cost": {
- "name": "market_cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "is_free": {
- "name": "is_free",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_delay": {
- "name": "abuse_delay",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_downgraded_from": {
- "name": "abuse_downgraded_from",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "definition": "\n SELECT\n mu.id,\n mu.kilo_user_id,\n meta.message_id,\n mu.cost,\n mu.input_tokens,\n mu.output_tokens,\n mu.cache_write_tokens,\n mu.cache_hit_tokens,\n mu.created_at,\n ip.http_ip AS http_x_forwarded_for,\n city.vercel_ip_city AS http_x_vercel_ip_city,\n country.vercel_ip_country AS http_x_vercel_ip_country,\n meta.vercel_ip_latitude AS http_x_vercel_ip_latitude,\n meta.vercel_ip_longitude AS http_x_vercel_ip_longitude,\n ja4.ja4_digest AS http_x_vercel_ja4_digest,\n mu.provider,\n mu.model,\n mu.requested_model,\n meta.user_prompt_prefix,\n spp.system_prompt_prefix,\n meta.system_prompt_length,\n ua.http_user_agent,\n mu.cache_discount,\n meta.max_tokens,\n meta.has_middle_out_transform,\n mu.has_error,\n mu.abuse_classification,\n mu.organization_id,\n mu.inference_provider,\n mu.project_id,\n meta.status_code,\n meta.upstream_id,\n frfr.finish_reason,\n meta.latency,\n meta.moderation_latency,\n meta.generation_time,\n meta.is_byok,\n meta.is_user_byok,\n meta.streamed,\n meta.cancelled,\n edit.editor_name,\n ak.api_kind,\n meta.has_tools,\n meta.machine_id,\n feat.feature,\n meta.session_id,\n md.mode,\n am.auto_model,\n meta.market_cost,\n meta.is_free,\n meta.abuse_delay,\n meta.abuse_downgraded_from\n FROM \"microdollar_usage\" mu\n LEFT JOIN \"microdollar_usage_metadata\" meta ON mu.id = meta.id\n LEFT JOIN \"http_ip\" ip ON meta.http_ip_id = ip.http_ip_id\n LEFT JOIN \"vercel_ip_city\" city ON meta.vercel_ip_city_id = city.vercel_ip_city_id\n LEFT JOIN \"vercel_ip_country\" country ON meta.vercel_ip_country_id = country.vercel_ip_country_id\n LEFT JOIN \"ja4_digest\" ja4 ON meta.ja4_digest_id = ja4.ja4_digest_id\n LEFT JOIN \"system_prompt_prefix\" spp ON meta.system_prompt_prefix_id = spp.system_prompt_prefix_id\n LEFT JOIN \"http_user_agent\" ua ON meta.http_user_agent_id = ua.http_user_agent_id\n LEFT JOIN \"finish_reason\" frfr ON meta.finish_reason_id = frfr.finish_reason_id\n LEFT JOIN \"editor_name\" edit ON meta.editor_name_id = edit.editor_name_id\n LEFT JOIN \"api_kind\" ak ON meta.api_kind_id = ak.api_kind_id\n LEFT JOIN \"feature\" feat ON meta.feature_id = feat.feature_id\n LEFT JOIN \"mode\" md ON meta.mode_id = md.mode_id\n LEFT JOIN \"auto_model\" am ON meta.auto_model_id = am.auto_model_id\n",
- "name": "microdollar_usage_view",
- "schema": "public",
- "isExisting": false,
- "materialized": false
- }
- },
- "_meta": {
- "columns": {},
- "schemas": {},
- "tables": {}
- }
-}
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.json
index c2f94e49f4..819761c75c 100644
--- a/packages/db/src/migrations/meta/_journal.json
+++ b/packages/db/src/migrations/meta/_journal.json
@@ -1219,13 +1219,6 @@
"when": 1782381719017,
"tag": "0173_lowly_venom",
"breakpoints": true
- },
- {
- "idx": 174,
- "version": "7",
- "when": 1782399504008,
- "tag": "0174_massive_drax",
- "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts
index 9d797df9aa..bfb957e643 100644
--- a/packages/db/src/schema.ts
+++ b/packages/db/src/schema.ts
@@ -2621,7 +2621,6 @@ export const organizations = pgTable(
{
id: idPrimaryKeyColumn,
name: text().notNull(),
- slug: text().unique(),
created_at: timestamp({ withTimezone: true, mode: 'string' }).defaultNow().notNull(),
updated_at: timestamp({ withTimezone: true, mode: 'string' })
.defaultNow()
@@ -2656,6 +2655,8 @@ export const organizations = pgTable(
plan: text().$type().notNull().default('teams'),
free_trial_end_at: timestamp({ withTimezone: true, mode: 'string' }),
company_domain: text(),
+ slug: text().unique(),
+ requested_slug: text(),
},
table => [
check('organizations_name_not_empty_check', sql`length(trim(${table.name})) > 0`),
From 826fb2f5e81f8eb09c103bff93a3786c641bdba4 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 10:56:40 -0500
Subject: [PATCH 03/33] Add migration for two new columns on organizations
table: slug, requested_slug
---
.../organizations/OrganizationInfoCard.tsx | 4 +
.../lib/organizations/organization-types.ts | 2 +
.../migrations/0174_omniscient_tenebrous.sql | 3 +
.../db/src/migrations/meta/0174_snapshot.json | 32118 ++++++++++++++++
packages/db/src/migrations/meta/_journal.json | 7 +
5 files changed, 32134 insertions(+)
create mode 100644 packages/db/src/migrations/0174_omniscient_tenebrous.sql
create mode 100644 packages/db/src/migrations/meta/0174_snapshot.json
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index 102f8ba35e..79356ad1f8 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -352,6 +352,10 @@ function Inner(props: InnerProps) {
)}
+
Company Domain
{isEditingDomain ? (
diff --git a/apps/web/src/lib/organizations/organization-types.ts b/apps/web/src/lib/organizations/organization-types.ts
index d37c6e18a2..1d56bc1579 100644
--- a/apps/web/src/lib/organizations/organization-types.ts
+++ b/apps/web/src/lib/organizations/organization-types.ts
@@ -56,6 +56,8 @@ export const OrganizationCreateRequestSchema = z.object({
export const OrganizationSchema = z.object({
id: z.string(),
name: z.string(),
+ slug: z.string().nullable(),
+ requested_slug: z.string().nullable(),
created_at: z.string(),
updated_at: z.string(),
microdollars_used: z.number(),
diff --git a/packages/db/src/migrations/0174_omniscient_tenebrous.sql b/packages/db/src/migrations/0174_omniscient_tenebrous.sql
new file mode 100644
index 0000000000..8c99291408
--- /dev/null
+++ b/packages/db/src/migrations/0174_omniscient_tenebrous.sql
@@ -0,0 +1,3 @@
+ALTER TABLE "organizations" ADD COLUMN "slug" text;--> statement-breakpoint
+ALTER TABLE "organizations" ADD COLUMN "requested_slug" text;--> statement-breakpoint
+ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_unique" UNIQUE("slug");
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/0174_snapshot.json b/packages/db/src/migrations/meta/0174_snapshot.json
new file mode 100644
index 0000000000..9a78c54ebb
--- /dev/null
+++ b/packages/db/src/migrations/meta/0174_snapshot.json
@@ -0,0 +1,32118 @@
+{
+ "id": "ae36098e-33f9-4138-895b-c0e0098b822a",
+ "prevId": "06265fd6-428e-4b7d-9092-dba307d6255e",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.agent_configs": {
+ "name": "agent_configs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_type": {
+ "name": "agent_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_configs_org_id": {
+ "name": "IDX_agent_configs_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_owned_by_user_id": {
+ "name": "IDX_agent_configs_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_agent_type": {
+ "name": "IDX_agent_configs_agent_type",
+ "columns": [
+ {
+ "expression": "agent_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_platform": {
+ "name": "IDX_agent_configs_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_configs_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_configs_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_configs",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_configs_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_configs_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_configs_org_agent_platform": {
+ "name": "UQ_agent_configs_org_agent_platform",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_organization_id",
+ "agent_type",
+ "platform"
+ ]
+ },
+ "UQ_agent_configs_user_agent_platform": {
+ "name": "UQ_agent_configs_user_agent_platform",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_user_id",
+ "agent_type",
+ "platform"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_configs_owner_check": {
+ "name": "agent_configs_owner_check",
+ "value": "(\n (\"agent_configs\".\"owned_by_user_id\" IS NOT NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_configs\".\"owned_by_user_id\" IS NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "agent_configs_agent_type_check": {
+ "name": "agent_configs_agent_type_check",
+ "value": "\"agent_configs\".\"agent_type\" IN ('code_review', 'auto_triage', 'auto_fix', 'security_scan')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_agents": {
+ "name": "agent_environment_profile_agents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_agents_profile_id": {
+ "name": "IDX_agent_env_profile_agents_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_agents",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_agents_profile_slug": {
+ "name": "UQ_agent_env_profile_agents_profile_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_commands": {
+ "name": "agent_environment_profile_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "command": {
+ "name": "command",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_commands_profile_id": {
+ "name": "IDX_agent_env_profile_commands_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_commands",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_commands_profile_sequence": {
+ "name": "UQ_agent_env_profile_commands_profile_sequence",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "sequence"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_kilo_commands": {
+ "name": "agent_environment_profile_kilo_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "template": {
+ "name": "template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent": {
+ "name": "agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subtask": {
+ "name": "subtask",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_kilo_cmds_profile_id": {
+ "name": "IDX_agent_env_profile_kilo_cmds_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_kilo_commands",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_kilo_cmds_profile_name": {
+ "name": "UQ_agent_env_profile_kilo_cmds_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_mcp_servers": {
+ "name": "agent_environment_profile_mcp_servers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "timeout": {
+ "name": "timeout",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_mcp_servers_profile_id": {
+ "name": "IDX_agent_env_profile_mcp_servers_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_mcp_servers",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_mcp_servers_profile_name": {
+ "name": "UQ_agent_env_profile_mcp_servers_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_repo_bindings": {
+ "name": "agent_environment_profile_repo_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_agent_env_profile_repo_bindings_user": {
+ "name": "UQ_agent_env_profile_repo_bindings_user",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profile_repo_bindings_org": {
+ "name": "UQ_agent_env_profile_repo_bindings_org",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_env_profile_repo_bindings_owner_check": {
+ "name": "agent_env_profile_repo_bindings_owner_check",
+ "value": "(\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_skills": {
+ "name": "agent_environment_profile_skills",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_markdown": {
+ "name": "raw_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "files": {
+ "name": "files",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_skills_profile_id": {
+ "name": "IDX_agent_env_profile_skills_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_skills",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_skills_profile_name": {
+ "name": "UQ_agent_env_profile_skills_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_vars": {
+ "name": "agent_environment_profile_vars",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_secret": {
+ "name": "is_secret",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_vars_profile_id": {
+ "name": "IDX_agent_env_profile_vars_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_vars",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_vars_profile_key": {
+ "name": "UQ_agent_env_profile_vars_profile_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profiles": {
+ "name": "agent_environment_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_agent_env_profiles_org_name": {
+ "name": "UQ_agent_env_profiles_org_name",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_user_name": {
+ "name": "UQ_agent_env_profiles_user_name",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_org_default": {
+ "name": "UQ_agent_env_profiles_org_default",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_user_default": {
+ "name": "UQ_agent_env_profiles_user_default",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_org_id": {
+ "name": "IDX_agent_env_profiles_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_user_id": {
+ "name": "IDX_agent_env_profiles_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_created_by_user_id": {
+ "name": "IDX_agent_env_profiles_created_by_user_id",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profiles_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_environment_profiles_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_environment_profiles",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_environment_profiles",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_env_profiles_owner_check": {
+ "name": "agent_env_profiles_owner_check",
+ "value": "(\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.api_kind": {
+ "name": "api_kind",
+ "schema": "",
+ "columns": {
+ "api_kind_id": {
+ "name": "api_kind_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "api_kind": {
+ "name": "api_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_api_kind": {
+ "name": "UQ_api_kind",
+ "columns": [
+ {
+ "expression": "api_kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.api_request_compress_log": {
+ "name": "api_request_compress_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request": {
+ "name": "request",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_api_request_compress_log_created_at": {
+ "name": "idx_api_request_compress_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.api_request_log": {
+ "name": "api_request_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request": {
+ "name": "request",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response": {
+ "name": "response",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_api_request_log_created_at": {
+ "name": "idx_api_request_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_feedback": {
+ "name": "app_builder_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "preview_status": {
+ "name": "preview_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_streaming": {
+ "name": "is_streaming",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_count": {
+ "name": "message_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recent_messages": {
+ "name": "recent_messages",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_feedback_created_at": {
+ "name": "IDX_app_builder_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_feedback_kilo_user_id": {
+ "name": "IDX_app_builder_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_feedback_project_id": {
+ "name": "IDX_app_builder_feedback_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "app_builder_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "app_builder_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "app_builder_feedback_project_id_app_builder_projects_id_fk": {
+ "name": "app_builder_feedback_project_id_app_builder_projects_id_fk",
+ "tableFrom": "app_builder_feedback",
+ "tableTo": "app_builder_projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_project_sessions": {
+ "name": "app_builder_project_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_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
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worker_version": {
+ "name": "worker_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'v2'"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_project_sessions_project_id": {
+ "name": "IDX_app_builder_project_sessions_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_project_sessions_project_id_app_builder_projects_id_fk": {
+ "name": "app_builder_project_sessions_project_id_app_builder_projects_id_fk",
+ "tableFrom": "app_builder_project_sessions",
+ "tableTo": "app_builder_projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_app_builder_project_sessions_cloud_agent_session_id": {
+ "name": "UQ_app_builder_project_sessions_cloud_agent_session_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "cloud_agent_session_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_projects": {
+ "name": "app_builder_projects",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "template": {
+ "name": "template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_at": {
+ "name": "last_message_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_repo_full_name": {
+ "name": "git_repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_platform_integration_id": {
+ "name": "git_platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "migrated_at": {
+ "name": "migrated_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_projects_created_by_user_id": {
+ "name": "IDX_app_builder_projects_created_by_user_id",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_owned_by_user_id": {
+ "name": "IDX_app_builder_projects_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_owned_by_organization_id": {
+ "name": "IDX_app_builder_projects_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_created_at": {
+ "name": "IDX_app_builder_projects_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_last_message_at": {
+ "name": "IDX_app_builder_projects_last_message_at",
+ "columns": [
+ {
+ "expression": "last_message_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_git_repo_integration": {
+ "name": "IDX_app_builder_projects_git_repo_integration",
+ "columns": [
+ {
+ "expression": "git_repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"app_builder_projects\".\"git_repo_full_name\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_projects_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "app_builder_projects_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_owned_by_organization_id_organizations_id_fk": {
+ "name": "app_builder_projects_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_deployment_id_deployments_id_fk": {
+ "name": "app_builder_projects_deployment_id_deployments_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk": {
+ "name": "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "git_platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "app_builder_projects_owner_check": {
+ "name": "app_builder_projects_owner_check",
+ "value": "(\n (\"app_builder_projects\".\"owned_by_user_id\" IS NOT NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NULL) OR\n (\"app_builder_projects\".\"owned_by_user_id\" IS NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_min_versions": {
+ "name": "app_min_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ios_min_version": {
+ "name": "ios_min_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'1.0.0'"
+ },
+ "android_min_version": {
+ "name": "android_min_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'1.0.0'"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_reported_messages": {
+ "name": "app_reported_messages",
+ "schema": "",
+ "columns": {
+ "report_id": {
+ "name": "report_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "signature": {
+ "name": "signature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "app_reported_messages_cli_session_id_cli_sessions_session_id_fk": {
+ "name": "app_reported_messages_cli_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "app_reported_messages",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "cli_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auto_fix_tickets": {
+ "name": "auto_fix_tickets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "triage_ticket_id": {
+ "name": "triage_ticket_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_url": {
+ "name": "issue_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_title": {
+ "name": "issue_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_body": {
+ "name": "issue_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "issue_author": {
+ "name": "issue_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_labels": {
+ "name": "issue_labels",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "trigger_source": {
+ "name": "trigger_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'label'"
+ },
+ "review_comment_id": {
+ "name": "review_comment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_comment_body": {
+ "name": "review_comment_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "line_number": {
+ "name": "line_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "diff_hunk": {
+ "name": "diff_hunk",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_ref": {
+ "name": "pr_head_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent_summary": {
+ "name": "intent_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_files": {
+ "name": "related_files",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_branch": {
+ "name": "pr_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_fix_tickets_repo_issue": {
+ "name": "UQ_auto_fix_tickets_repo_issue",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_fix_tickets\".\"trigger_source\" = 'label'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_auto_fix_tickets_repo_review_comment": {
+ "name": "UQ_auto_fix_tickets_repo_review_comment",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "review_comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_fix_tickets\".\"review_comment_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_owned_by_org": {
+ "name": "IDX_auto_fix_tickets_owned_by_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_owned_by_user": {
+ "name": "IDX_auto_fix_tickets_owned_by_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_status": {
+ "name": "IDX_auto_fix_tickets_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_created_at": {
+ "name": "IDX_auto_fix_tickets_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_triage_ticket_id": {
+ "name": "IDX_auto_fix_tickets_triage_ticket_id",
+ "columns": [
+ {
+ "expression": "triage_ticket_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_session_id": {
+ "name": "IDX_auto_fix_tickets_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_fix_tickets_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_fix_tickets_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk": {
+ "name": "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk": {
+ "name": "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "auto_triage_tickets",
+ "columnsFrom": [
+ "triage_ticket_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk": {
+ "name": "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "cli_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_fix_tickets_owner_check": {
+ "name": "auto_fix_tickets_owner_check",
+ "value": "(\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "auto_fix_tickets_status_check": {
+ "name": "auto_fix_tickets_status_check",
+ "value": "\"auto_fix_tickets\".\"status\" IN ('pending', 'running', 'completed', 'failed', 'cancelled')"
+ },
+ "auto_fix_tickets_classification_check": {
+ "name": "auto_fix_tickets_classification_check",
+ "value": "\"auto_fix_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'unclear')"
+ },
+ "auto_fix_tickets_confidence_check": {
+ "name": "auto_fix_tickets_confidence_check",
+ "value": "\"auto_fix_tickets\".\"confidence\" >= 0 AND \"auto_fix_tickets\".\"confidence\" <= 1"
+ },
+ "auto_fix_tickets_trigger_source_check": {
+ "name": "auto_fix_tickets_trigger_source_check",
+ "value": "\"auto_fix_tickets\".\"trigger_source\" IN ('label', 'review_comment')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.auto_model": {
+ "name": "auto_model",
+ "schema": "",
+ "columns": {
+ "auto_model_id": {
+ "name": "auto_model_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "auto_model": {
+ "name": "auto_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_auto_model": {
+ "name": "UQ_auto_model",
+ "columns": [
+ {
+ "expression": "auto_model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auto_top_up_configs": {
+ "name": "auto_top_up_configs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_method_id": {
+ "name": "stripe_payment_method_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_cents": {
+ "name": "amount_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 5000
+ },
+ "last_auto_top_up_at": {
+ "name": "last_auto_top_up_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_started_at": {
+ "name": "attempt_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disabled_reason": {
+ "name": "disabled_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_top_up_configs_owned_by_user_id": {
+ "name": "UQ_auto_top_up_configs_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_auto_top_up_configs_owned_by_organization_id": {
+ "name": "UQ_auto_top_up_configs_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_top_up_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "auto_top_up_configs_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_top_up_configs_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_top_up_configs",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_top_up_configs_exactly_one_owner": {
+ "name": "auto_top_up_configs_exactly_one_owner",
+ "value": "(\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NULL) OR (\"auto_top_up_configs\".\"owned_by_user_id\" IS NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.auto_triage_tickets": {
+ "name": "auto_triage_tickets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_url": {
+ "name": "issue_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_title": {
+ "name": "issue_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_body": {
+ "name": "issue_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "issue_author": {
+ "name": "issue_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type": {
+ "name": "issue_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_labels": {
+ "name": "issue_labels",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent_summary": {
+ "name": "intent_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_files": {
+ "name": "related_files",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_duplicate": {
+ "name": "is_duplicate",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "duplicate_of_ticket_id": {
+ "name": "duplicate_of_ticket_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "similarity_score": {
+ "name": "similarity_score",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "qdrant_point_id": {
+ "name": "qdrant_point_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "should_auto_fix": {
+ "name": "should_auto_fix",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "action_taken": {
+ "name": "action_taken",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_metadata": {
+ "name": "action_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_triage_tickets_repo_issue": {
+ "name": "UQ_auto_triage_tickets_repo_issue",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owned_by_org": {
+ "name": "IDX_auto_triage_tickets_owned_by_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owned_by_user": {
+ "name": "IDX_auto_triage_tickets_owned_by_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_status": {
+ "name": "IDX_auto_triage_tickets_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_created_at": {
+ "name": "IDX_auto_triage_tickets_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_qdrant_point_id": {
+ "name": "IDX_auto_triage_tickets_qdrant_point_id",
+ "columns": [
+ {
+ "expression": "qdrant_point_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owner_status_created": {
+ "name": "IDX_auto_triage_tickets_owner_status_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_user_status_created": {
+ "name": "IDX_auto_triage_tickets_user_status_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_repo_classification": {
+ "name": "IDX_auto_triage_tickets_repo_classification",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "classification",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_triage_tickets_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_triage_tickets_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk": {
+ "name": "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk": {
+ "name": "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "auto_triage_tickets",
+ "columnsFrom": [
+ "duplicate_of_ticket_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_triage_tickets_owner_check": {
+ "name": "auto_triage_tickets_owner_check",
+ "value": "(\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "auto_triage_tickets_issue_type_check": {
+ "name": "auto_triage_tickets_issue_type_check",
+ "value": "\"auto_triage_tickets\".\"issue_type\" IN ('issue', 'pull_request')"
+ },
+ "auto_triage_tickets_classification_check": {
+ "name": "auto_triage_tickets_classification_check",
+ "value": "\"auto_triage_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'duplicate', 'unclear')"
+ },
+ "auto_triage_tickets_confidence_check": {
+ "name": "auto_triage_tickets_confidence_check",
+ "value": "\"auto_triage_tickets\".\"confidence\" >= 0 AND \"auto_triage_tickets\".\"confidence\" <= 1"
+ },
+ "auto_triage_tickets_similarity_score_check": {
+ "name": "auto_triage_tickets_similarity_score_check",
+ "value": "\"auto_triage_tickets\".\"similarity_score\" >= 0 AND \"auto_triage_tickets\".\"similarity_score\" <= 1"
+ },
+ "auto_triage_tickets_status_check": {
+ "name": "auto_triage_tickets_status_check",
+ "value": "\"auto_triage_tickets\".\"status\" IN ('pending', 'analyzing', 'actioned', 'failed', 'skipped')"
+ },
+ "auto_triage_tickets_action_taken_check": {
+ "name": "auto_triage_tickets_action_taken_check",
+ "value": "\"auto_triage_tickets\".\"action_taken\" IN ('pr_created', 'comment_posted', 'closed_duplicate', 'needs_clarification')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.bot_request_cloud_agent_sessions": {
+ "name": "bot_request_cloud_agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "bot_request_id": {
+ "name": "bot_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "spawn_group_id": {
+ "name": "spawn_group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repo": {
+ "name": "github_repo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gitlab_project": {
+ "name": "gitlab_project",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "callback_step": {
+ "name": "callback_step",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message": {
+ "name": "final_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message_fetched_at": {
+ "name": "final_message_fetched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message_error": {
+ "name": "final_message_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "continuation_started_at": {
+ "name": "continuation_started_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_bot_request_cas_cloud_agent_session_id": {
+ "name": "UQ_bot_request_cas_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id": {
+ "name": "IDX_bot_request_cas_bot_request_id",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id_spawn_group_id": {
+ "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spawn_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id_spawn_group_id_status": {
+ "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id_status",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spawn_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk": {
+ "name": "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk",
+ "tableFrom": "bot_request_cloud_agent_sessions",
+ "tableTo": "bot_requests",
+ "columnsFrom": [
+ "bot_request_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bot_requests": {
+ "name": "bot_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_thread_id": {
+ "name": "platform_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_message_id": {
+ "name": "platform_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message": {
+ "name": "user_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_used": {
+ "name": "model_used",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "steps": {
+ "name": "steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_bot_requests_created_at": {
+ "name": "IDX_bot_requests_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_created_by": {
+ "name": "IDX_bot_requests_created_by",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_organization_id": {
+ "name": "IDX_bot_requests_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_platform_integration_id": {
+ "name": "IDX_bot_requests_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_status": {
+ "name": "IDX_bot_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "bot_requests_created_by_kilocode_users_id_fk": {
+ "name": "bot_requests_created_by_kilocode_users_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bot_requests_organization_id_organizations_id_fk": {
+ "name": "bot_requests_organization_id_organizations_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bot_requests_platform_integration_id_platform_integrations_id_fk": {
+ "name": "bot_requests_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.byok_api_keys": {
+ "name": "byok_api_keys",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "management_source": {
+ "name": "management_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'user'"
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "IDX_byok_api_keys_organization_id": {
+ "name": "IDX_byok_api_keys_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_byok_api_keys_kilo_user_id": {
+ "name": "IDX_byok_api_keys_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_byok_api_keys_provider_id": {
+ "name": "IDX_byok_api_keys_provider_id",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "byok_api_keys_organization_id_organizations_id_fk": {
+ "name": "byok_api_keys_organization_id_organizations_id_fk",
+ "tableFrom": "byok_api_keys",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "byok_api_keys_kilo_user_id_kilocode_users_id_fk": {
+ "name": "byok_api_keys_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "byok_api_keys",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_byok_api_keys_org_provider": {
+ "name": "UQ_byok_api_keys_org_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "provider_id"
+ ]
+ },
+ "UQ_byok_api_keys_user_provider": {
+ "name": "UQ_byok_api_keys_user_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_user_id",
+ "provider_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "byok_api_keys_management_source_check": {
+ "name": "byok_api_keys_management_source_check",
+ "value": "\"byok_api_keys\".\"management_source\" IN ('user', 'coding_plan')"
+ },
+ "byok_api_keys_owner_check": {
+ "name": "byok_api_keys_owner_check",
+ "value": "(\n (\"byok_api_keys\".\"kilo_user_id\" IS NOT NULL AND \"byok_api_keys\".\"organization_id\" IS NULL) OR\n (\"byok_api_keys\".\"kilo_user_id\" IS NULL AND \"byok_api_keys\".\"organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cli_sessions": {
+ "name": "cli_sessions",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_on_platform": {
+ "name": "created_on_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "api_conversation_history_blob_url": {
+ "name": "api_conversation_history_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_metadata_blob_url": {
+ "name": "task_metadata_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ui_messages_blob_url": {
+ "name": "ui_messages_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_state_blob_url": {
+ "name": "git_state_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "forked_from": {
+ "name": "forked_from",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_session_id": {
+ "name": "parent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_mode": {
+ "name": "last_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_model": {
+ "name": "last_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cli_sessions_kilo_user_id": {
+ "name": "IDX_cli_sessions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_created_at": {
+ "name": "IDX_cli_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_updated_at": {
+ "name": "IDX_cli_sessions_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_organization_id": {
+ "name": "IDX_cli_sessions_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_user_updated": {
+ "name": "IDX_cli_sessions_user_updated",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_sessions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cli_sessions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_forked_from_cli_sessions_session_id_fk": {
+ "name": "cli_sessions_forked_from_cli_sessions_session_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "forked_from"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_parent_session_id_cli_sessions_session_id_fk": {
+ "name": "cli_sessions_parent_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "parent_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_organization_id_organizations_id_fk": {
+ "name": "cli_sessions_organization_id_organizations_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "cli_sessions_cloud_agent_session_id_unique": {
+ "name": "cli_sessions_cloud_agent_session_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "cloud_agent_session_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_sessions_v2": {
+ "name": "cli_sessions_v2",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_session_id": {
+ "name": "parent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_on_platform": {
+ "name": "created_on_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_updated_at": {
+ "name": "status_updated_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cli_sessions_v2_parent_session_id_kilo_user_id": {
+ "name": "IDX_cli_sessions_v2_parent_session_id_kilo_user_id",
+ "columns": [
+ {
+ "expression": "parent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cli_sessions_v2_public_id": {
+ "name": "UQ_cli_sessions_v2_public_id",
+ "columns": [
+ {
+ "expression": "public_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cli_sessions_v2\".\"public_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cli_sessions_v2_cloud_agent_session_id": {
+ "name": "UQ_cli_sessions_v2_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cli_sessions_v2\".\"cloud_agent_session_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_organization_id": {
+ "name": "IDX_cli_sessions_v2_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_kilo_user_id": {
+ "name": "IDX_cli_sessions_v2_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_created_at": {
+ "name": "IDX_cli_sessions_v2_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_user_updated": {
+ "name": "IDX_cli_sessions_v2_user_updated",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_sessions_v2_git_url_branch_idx": {
+ "name": "cli_sessions_v2_git_url_branch_idx",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_v2_organization_id_organizations_id_fk": {
+ "name": "cli_sessions_v2_organization_id_organizations_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_v2_parent_session_id_kilo_user_id_fk": {
+ "name": "cli_sessions_v2_parent_session_id_kilo_user_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "cli_sessions_v2",
+ "columnsFrom": [
+ "parent_session_id",
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "session_id",
+ "kilo_user_id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "cli_sessions_v2_session_id_kilo_user_id_pk": {
+ "name": "cli_sessions_v2_session_id_kilo_user_id_pk",
+ "columns": [
+ "session_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_code_review_attempts": {
+ "name": "cloud_agent_code_review_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_review_id": {
+ "name": "code_review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_number": {
+ "name": "attempt_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "retry_of_attempt_id": {
+ "name": "retry_of_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "retry_reason": {
+ "name": "retry_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analytics_enabled_at_dispatch": {
+ "name": "analytics_enabled_at_dispatch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_reason": {
+ "name": "terminal_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_code_review_attempts_review_attempt_number": {
+ "name": "UQ_cloud_agent_code_review_attempts_review_attempt_number",
+ "columns": [
+ {
+ "expression": "code_review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "attempt_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_code_review_id": {
+ "name": "idx_cloud_agent_code_review_attempts_code_review_id",
+ "columns": [
+ {
+ "expression": "code_review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_session_id": {
+ "name": "idx_cloud_agent_code_review_attempts_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_cli_session_id": {
+ "name": "idx_cloud_agent_code_review_attempts_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_status": {
+ "name": "idx_cloud_agent_code_review_attempts_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_retry_reason": {
+ "name": "idx_cloud_agent_code_review_attempts_retry_reason",
+ "columns": [
+ {
+ "expression": "retry_reason",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk": {
+ "name": "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk",
+ "tableFrom": "cloud_agent_code_review_attempts",
+ "tableTo": "cloud_agent_code_reviews",
+ "columnsFrom": [
+ "code_review_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk": {
+ "name": "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk",
+ "tableFrom": "cloud_agent_code_review_attempts",
+ "tableTo": "cloud_agent_code_review_attempts",
+ "columnsFrom": [
+ "retry_of_attempt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_code_review_attempts_attempt_number_check": {
+ "name": "cloud_agent_code_review_attempts_attempt_number_check",
+ "value": "\"cloud_agent_code_review_attempts\".\"attempt_number\" >= 1"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_code_reviews": {
+ "name": "cloud_agent_code_reviews",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_title": {
+ "name": "pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_author": {
+ "name": "pr_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_author_github_id": {
+ "name": "pr_author_github_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_ref": {
+ "name": "base_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_ref": {
+ "name": "head_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "platform_project_id": {
+ "name": "platform_project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "dispatch_reservation_id": {
+ "name": "dispatch_reservation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_reason": {
+ "name": "terminal_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_version": {
+ "name": "agent_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'v1'"
+ },
+ "check_run_id": {
+ "name": "check_run_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_review_instructions_used": {
+ "name": "repository_review_instructions_used",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "repository_review_instructions_ref": {
+ "name": "repository_review_instructions_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_review_instructions_truncated": {
+ "name": "repository_review_instructions_truncated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "previous_summary_body": {
+ "name": "previous_summary_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_summary_head_sha": {
+ "name": "previous_summary_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens_in": {
+ "name": "total_tokens_in",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens_out": {
+ "name": "total_tokens_out",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost_musd": {
+ "name": "total_cost_musd",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_code_reviews_repo_pr_sha": {
+ "name": "UQ_cloud_agent_code_reviews_repo_pr_sha",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "pr_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_owned_by_org_id": {
+ "name": "idx_cloud_agent_code_reviews_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_owned_by_user_id": {
+ "name": "idx_cloud_agent_code_reviews_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_session_id": {
+ "name": "idx_cloud_agent_code_reviews_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_cli_session_id": {
+ "name": "idx_cloud_agent_code_reviews_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_status": {
+ "name": "idx_cloud_agent_code_reviews_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_repo": {
+ "name": "idx_cloud_agent_code_reviews_repo",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_pr_number": {
+ "name": "idx_cloud_agent_code_reviews_pr_number",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "pr_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_created_at": {
+ "name": "idx_cloud_agent_code_reviews_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_pr_author_github_id": {
+ "name": "idx_cloud_agent_code_reviews_pr_author_github_id",
+ "columns": [
+ {
+ "expression": "pr_author_github_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk": {
+ "name": "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_code_reviews_owner_check": {
+ "name": "cloud_agent_code_reviews_owner_check",
+ "value": "(\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NOT NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NULL) OR\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_feedback": {
+ "name": "cloud_agent_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_streaming": {
+ "name": "is_streaming",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_count": {
+ "name": "message_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recent_messages": {
+ "name": "recent_messages",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cloud_agent_feedback_created_at": {
+ "name": "IDX_cloud_agent_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_feedback_kilo_user_id": {
+ "name": "IDX_cloud_agent_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_feedback_cloud_agent_session_id": {
+ "name": "IDX_cloud_agent_feedback_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "cloud_agent_feedback_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_feedback_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_feedback",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_session_runs": {
+ "name": "cloud_agent_session_runs",
+ "schema": "",
+ "columns": {
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wrapper_run_id": {
+ "name": "wrapper_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dispatch_accepted_at": {
+ "name": "dispatch_accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_activity_observed_at": {
+ "name": "agent_activity_observed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message_redacted": {
+ "name": "error_message_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_expires_at": {
+ "name": "error_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_cloud_agent_session_runs_wrapper_run_id": {
+ "name": "IDX_cloud_agent_session_runs_wrapper_run_id",
+ "columns": [
+ {
+ "expression": "wrapper_run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_session_runs\".\"wrapper_run_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_session_queued": {
+ "name": "IDX_cloud_agent_session_runs_session_queued",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_queued_at": {
+ "name": "IDX_cloud_agent_session_runs_queued_at",
+ "columns": [
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_terminal_at": {
+ "name": "IDX_cloud_agent_session_runs_terminal_at",
+ "columns": [
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_status_terminal": {
+ "name": "IDX_cloud_agent_session_runs_status_terminal",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_failure_terminal": {
+ "name": "IDX_cloud_agent_session_runs_failure_terminal",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_error_expires_at": {
+ "name": "IDX_cloud_agent_session_runs_error_expires_at",
+ "columns": [
+ {
+ "expression": "error_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_session_runs\".\"error_expires_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk": {
+ "name": "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk",
+ "tableFrom": "cloud_agent_session_runs",
+ "tableTo": "cloud_agent_sessions",
+ "columnsFrom": [
+ "cloud_agent_session_id"
+ ],
+ "columnsTo": [
+ "cloud_agent_session_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk": {
+ "name": "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk",
+ "columns": [
+ "cloud_agent_session_id",
+ "message_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_session_runs_status_check": {
+ "name": "cloud_agent_session_runs_status_check",
+ "value": "\"cloud_agent_session_runs\".\"status\" IN ('queued', 'accepted', 'completed', 'failed', 'interrupted')"
+ },
+ "cloud_agent_session_runs_failure_classification_check": {
+ "name": "cloud_agent_session_runs_failure_classification_check",
+ "value": "(\"cloud_agent_session_runs\".\"failure_stage\" IS NULL AND \"cloud_agent_session_runs\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'pre_dispatch' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('sandbox_connect_failed', 'workspace_setup_failed', 'kilo_server_failed', 'wrapper_start_failed', 'invalid_delivery_request', 'session_metadata_missing', 'model_missing', 'delivery_failure_unknown')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'post_dispatch_no_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('wrapper_disconnected', 'wrapper_no_output', 'wrapper_ping_timeout', 'wrapper_error_before_activity', 'missing_assistant_reply')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'agent_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('assistant_error', 'wrapper_error_after_activity')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'interruption' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('user_interrupt', 'container_shutdown', 'system_interrupt')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'unknown' AND \"cloud_agent_session_runs\".\"failure_code\" = 'unclassified')"
+ },
+ "cloud_agent_session_runs_error_message_bounded_check": {
+ "name": "cloud_agent_session_runs_error_message_bounded_check",
+ "value": "\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_session_runs\".\"error_message_redacted\") <= 4096"
+ },
+ "cloud_agent_session_runs_error_expiry_check": {
+ "name": "cloud_agent_session_runs_error_expiry_check",
+ "value": "(\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_sessions": {
+ "name": "cloud_agent_sessions",
+ "schema": "",
+ "columns": {
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "initial_message_id": {
+ "name": "initial_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "failure_at": {
+ "name": "failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message_redacted": {
+ "name": "error_message_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_expires_at": {
+ "name": "error_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_sessions_kilo_session_id": {
+ "name": "UQ_cloud_agent_sessions_kilo_session_id",
+ "columns": [
+ {
+ "expression": "kilo_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cloud_agent_sessions_initial_message_id": {
+ "name": "UQ_cloud_agent_sessions_initial_message_id",
+ "columns": [
+ {
+ "expression": "initial_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_sandbox_id": {
+ "name": "IDX_cloud_agent_sessions_sandbox_id",
+ "columns": [
+ {
+ "expression": "sandbox_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"sandbox_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_created_at": {
+ "name": "IDX_cloud_agent_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_created": {
+ "name": "IDX_cloud_agent_sessions_failure_created",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_at": {
+ "name": "IDX_cloud_agent_sessions_failure_at",
+ "columns": [
+ {
+ "expression": "failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_classification_at": {
+ "name": "IDX_cloud_agent_sessions_failure_classification_at",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_error_expires_at": {
+ "name": "IDX_cloud_agent_sessions_error_expires_at",
+ "columns": [
+ {
+ "expression": "error_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"error_expires_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_sessions_failure_classification_check": {
+ "name": "cloud_agent_sessions_failure_classification_check",
+ "value": "(\"cloud_agent_sessions\".\"failure_at\" IS NULL AND \"cloud_agent_sessions\".\"failure_stage\" IS NULL AND \"cloud_agent_sessions\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'sandbox_identity' AND \"cloud_agent_sessions\".\"failure_code\" = 'sandbox_id_derivation_failed') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'registration' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_registration_rejected') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'initial_admission' AND \"cloud_agent_sessions\".\"failure_code\" IN ('initial_admission_rejected', 'initial_queue_full', 'invalid_initial_intent')) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'transport' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_rpc_outcome_unknown')"
+ },
+ "cloud_agent_sessions_error_message_bounded_check": {
+ "name": "cloud_agent_sessions_error_message_bounded_check",
+ "value": "\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_sessions\".\"error_message_redacted\") <= 4096"
+ },
+ "cloud_agent_sessions_error_expiry_check": {
+ "name": "cloud_agent_sessions_error_expiry_check",
+ "value": "(\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_sessions\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_webhook_triggers": {
+ "name": "cloud_agent_webhook_triggers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "trigger_id": {
+ "name": "trigger_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_type": {
+ "name": "target_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cloud_agent'"
+ },
+ "kiloclaw_instance_id": {
+ "name": "kiloclaw_instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "activation_mode": {
+ "name": "activation_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'webhook'"
+ },
+ "cron_expression": {
+ "name": "cron_expression",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cron_timezone": {
+ "name": "cron_timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'UTC'"
+ },
+ "github_repo": {
+ "name": "github_repo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_webhook_triggers_user_trigger": {
+ "name": "UQ_cloud_agent_webhook_triggers_user_trigger",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "trigger_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cloud_agent_webhook_triggers\".\"user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cloud_agent_webhook_triggers_org_trigger": {
+ "name": "UQ_cloud_agent_webhook_triggers_org_trigger",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "trigger_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cloud_agent_webhook_triggers\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_user": {
+ "name": "IDX_cloud_agent_webhook_triggers_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_org": {
+ "name": "IDX_cloud_agent_webhook_triggers_org",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_active": {
+ "name": "IDX_cloud_agent_webhook_triggers_active",
+ "columns": [
+ {
+ "expression": "is_active",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_profile": {
+ "name": "IDX_cloud_agent_webhook_triggers_profile",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_webhook_triggers_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk": {
+ "name": "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "kiloclaw_instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk": {
+ "name": "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_cloud_agent_webhook_triggers_owner": {
+ "name": "CHK_cloud_agent_webhook_triggers_owner",
+ "value": "(\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NULL) OR\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NOT NULL)\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_cloud_agent_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_cloud_agent_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'cloud_agent' OR\n (\"cloud_agent_webhook_triggers\".\"github_repo\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"profile_id\" IS NOT NULL)\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_kiloclaw_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_kiloclaw_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'kiloclaw_chat' OR\n \"cloud_agent_webhook_triggers\".\"kiloclaw_instance_id\" IS NOT NULL\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_scheduled_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_scheduled_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"activation_mode\" != 'scheduled' OR\n \"cloud_agent_webhook_triggers\".\"cron_expression\" IS NOT NULL\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_indexing_manifest": {
+ "name": "code_indexing_manifest",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_hash": {
+ "name": "file_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chunk_count": {
+ "name": "chunk_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_lines": {
+ "name": "total_lines",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_ai_lines": {
+ "name": "total_ai_lines",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_code_indexing_manifest_organization_id": {
+ "name": "IDX_code_indexing_manifest_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_kilo_user_id": {
+ "name": "IDX_code_indexing_manifest_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_project_id": {
+ "name": "IDX_code_indexing_manifest_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_git_branch": {
+ "name": "IDX_code_indexing_manifest_git_branch",
+ "columns": [
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_created_at": {
+ "name": "IDX_code_indexing_manifest_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk": {
+ "name": "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_indexing_manifest",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_indexing_manifest_org_user_project_hash_branch": {
+ "name": "UQ_code_indexing_manifest_org_user_project_hash_branch",
+ "nullsNotDistinct": true,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "project_id",
+ "file_path",
+ "git_branch"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.code_indexing_search": {
+ "name": "code_indexing_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "query": {
+ "name": "query",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_code_indexing_search_organization_id": {
+ "name": "IDX_code_indexing_search_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_kilo_user_id": {
+ "name": "IDX_code_indexing_search_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_project_id": {
+ "name": "IDX_code_indexing_search_project_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_created_at": {
+ "name": "IDX_code_indexing_search_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_indexing_search_kilo_user_id_kilocode_users_id_fk": {
+ "name": "code_indexing_search_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_indexing_search",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.code_review_analytics_findings": {
+ "name": "code_review_analytics_findings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "analytics_result_id": {
+ "name": "analytics_result_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordinal": {
+ "name": "ordinal",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "security_class": {
+ "name": "security_class",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk": {
+ "name": "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk",
+ "tableFrom": "code_review_analytics_findings",
+ "tableTo": "code_review_analytics_results",
+ "columnsFrom": [
+ "analytics_result_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_analytics_findings_result_ordinal": {
+ "name": "UQ_code_review_analytics_findings_result_ordinal",
+ "nullsNotDistinct": false,
+ "columns": [
+ "analytics_result_id",
+ "ordinal"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_analytics_findings_severity_check": {
+ "name": "code_review_analytics_findings_severity_check",
+ "value": "\"code_review_analytics_findings\".\"severity\" IN ('critical', 'warning', 'suggestion')"
+ },
+ "code_review_analytics_findings_category_check": {
+ "name": "code_review_analytics_findings_category_check",
+ "value": "\"code_review_analytics_findings\".\"category\" IN ('security', 'correctness', 'reliability', 'data_integrity', 'performance', 'compatibility', 'maintainability', 'test_quality', 'documentation', 'accessibility', 'other')"
+ },
+ "code_review_analytics_findings_security_class_check": {
+ "name": "code_review_analytics_findings_security_class_check",
+ "value": "\"code_review_analytics_findings\".\"security_class\" IN ('auth_access', 'injection', 'data_protection', 'request_resource_boundary', 'deserialization_object_integrity', 'dependency_supply_chain', 'memory_safety', 'availability', 'concurrency', 'security_configuration', 'other')"
+ },
+ "code_review_analytics_findings_ordinal_check": {
+ "name": "code_review_analytics_findings_ordinal_check",
+ "value": "\"code_review_analytics_findings\".\"ordinal\" >= 0"
+ },
+ "code_review_analytics_findings_security_class_presence_check": {
+ "name": "code_review_analytics_findings_security_class_presence_check",
+ "value": "(\n (\"code_review_analytics_findings\".\"category\" = 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NOT NULL) OR\n (\"code_review_analytics_findings\".\"category\" <> 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_analytics_results": {
+ "name": "code_review_analytics_results",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_review_id": {
+ "name": "code_review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_attempt_id": {
+ "name": "source_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capture_status": {
+ "name": "capture_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "schema_version": {
+ "name": "schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "taxonomy_version": {
+ "name": "taxonomy_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "change_type": {
+ "name": "change_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_level": {
+ "name": "impact_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "complexity_level": {
+ "name": "complexity_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "classification_confidence": {
+ "name": "classification_confidence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finalized_at": {
+ "name": "finalized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_analytics_results_source_attempt_id": {
+ "name": "idx_code_review_analytics_results_source_attempt_id",
+ "columns": [
+ {
+ "expression": "source_attempt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_analytics_results_finalized_at": {
+ "name": "idx_code_review_analytics_results_finalized_at",
+ "columns": [
+ {
+ "expression": "finalized_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk": {
+ "name": "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk",
+ "tableFrom": "code_review_analytics_results",
+ "tableTo": "cloud_agent_code_reviews",
+ "columnsFrom": [
+ "code_review_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk": {
+ "name": "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk",
+ "tableFrom": "code_review_analytics_results",
+ "tableTo": "cloud_agent_code_review_attempts",
+ "columnsFrom": [
+ "source_attempt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_analytics_results_code_review_id": {
+ "name": "UQ_code_review_analytics_results_code_review_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "code_review_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_analytics_results_capture_status_check": {
+ "name": "code_review_analytics_results_capture_status_check",
+ "value": "\"code_review_analytics_results\".\"capture_status\" IN ('captured', 'missing', 'invalid', 'omitted')"
+ },
+ "code_review_analytics_results_change_type_check": {
+ "name": "code_review_analytics_results_change_type_check",
+ "value": "\"code_review_analytics_results\".\"change_type\" IN ('bug_fix', 'feature', 'refactor', 'maintenance', 'dependency', 'test', 'documentation', 'mixed', 'other')"
+ },
+ "code_review_analytics_results_impact_level_check": {
+ "name": "code_review_analytics_results_impact_level_check",
+ "value": "\"code_review_analytics_results\".\"impact_level\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_complexity_level_check": {
+ "name": "code_review_analytics_results_complexity_level_check",
+ "value": "\"code_review_analytics_results\".\"complexity_level\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_classification_confidence_check": {
+ "name": "code_review_analytics_results_classification_confidence_check",
+ "value": "\"code_review_analytics_results\".\"classification_confidence\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_classification_presence_check": {
+ "name": "code_review_analytics_results_classification_presence_check",
+ "value": "(\n (\n \"code_review_analytics_results\".\"capture_status\" = 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NOT NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NOT NULL\n ) OR (\n \"code_review_analytics_results\".\"capture_status\" <> 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NULL\n )\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_feedback_events": {
+ "name": "code_review_feedback_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_comment_id": {
+ "name": "kilo_comment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reply_excerpt": {
+ "name": "reply_excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_comment_excerpt": {
+ "name": "kilo_comment_excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_hash": {
+ "name": "dedupe_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_feedback_events_owned_by_org_id": {
+ "name": "idx_code_review_feedback_events_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_owned_by_user_id": {
+ "name": "idx_code_review_feedback_events_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_platform_repo": {
+ "name": "idx_code_review_feedback_events_platform_repo",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_created_at": {
+ "name": "idx_code_review_feedback_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_feedback_events_owned_by_organization_id_organizations_id_fk": {
+ "name": "code_review_feedback_events_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "code_review_feedback_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_review_feedback_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_feedback_events_dedupe_hash": {
+ "name": "UQ_code_review_feedback_events_dedupe_hash",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_hash"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_feedback_events_owner_check": {
+ "name": "code_review_feedback_events_owner_check",
+ "value": "(\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_memory_proposals": {
+ "name": "code_review_memory_proposals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "proposed_markdown": {
+ "name": "proposed_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "positive_count": {
+ "name": "positive_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "negative_count": {
+ "name": "negative_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "neutral_count": {
+ "name": "neutral_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "change_request_url": {
+ "name": "change_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_memory_proposals_owned_by_org_id": {
+ "name": "idx_code_review_memory_proposals_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_owned_by_user_id": {
+ "name": "idx_code_review_memory_proposals_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_platform_repo_status": {
+ "name": "idx_code_review_memory_proposals_platform_repo_status",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_updated_at": {
+ "name": "idx_code_review_memory_proposals_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_code_review_memory_proposals_org_active_scope": {
+ "name": "UQ_code_review_memory_proposals_org_active_scope",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_code_review_memory_proposals_user_active_scope": {
+ "name": "UQ_code_review_memory_proposals_user_active_scope",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk": {
+ "name": "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "code_review_memory_proposals",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_review_memory_proposals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "code_review_memory_proposals_owner_check": {
+ "name": "code_review_memory_proposals_owner_check",
+ "value": "(\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_availability_intents": {
+ "name": "coding_plan_availability_intents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_availability_intents_user_plan": {
+ "name": "UQ_coding_plan_availability_intents_user_plan",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_availability_intents_plan": {
+ "name": "IDX_coding_plan_availability_intents_plan",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_availability_intents_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_availability_intents_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_availability_intents",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_key_inventory": {
+ "name": "coding_plan_key_inventory",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "upstream_plan_id": {
+ "name": "upstream_plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_fingerprint": {
+ "name": "credential_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'available'"
+ },
+ "assigned_to_user_id": {
+ "name": "assigned_to_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assigned_at": {
+ "name": "assigned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_requested_at": {
+ "name": "revocation_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_attempt_count": {
+ "name": "revocation_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_revocation_error": {
+ "name": "last_revocation_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_key_inv_fingerprint": {
+ "name": "UQ_coding_plan_key_inv_fingerprint",
+ "columns": [
+ {
+ "expression": "credential_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_key_inv_plan_status": {
+ "name": "IDX_coding_plan_key_inv_plan_status",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_key_inv_available": {
+ "name": "IDX_coding_plan_key_inv_available",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"coding_plan_key_inventory\".\"status\" = 'available'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_key_inventory",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "assigned_to_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_key_inventory_status_check": {
+ "name": "coding_plan_key_inventory_status_check",
+ "value": "\"coding_plan_key_inventory\".\"status\" IN ('available', 'assigned', 'revocation_pending', 'revoked', 'revocation_failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_subscriptions": {
+ "name": "coding_plan_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_inventory_id": {
+ "name": "key_inventory_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_byok_key_id": {
+ "name": "installed_byok_key_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_period_days": {
+ "name": "billing_period_days",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_period_start": {
+ "name": "current_period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_renewal_at": {
+ "name": "credit_renewal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "past_due_started_at": {
+ "name": "past_due_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payment_grace_expires_at": {
+ "name": "payment_grace_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_attempted_for_due": {
+ "name": "auto_top_up_attempted_for_due",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_reason": {
+ "name": "cancellation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_sub_live_user_plan": {
+ "name": "UQ_coding_plan_sub_live_user_plan",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_status": {
+ "name": "IDX_coding_plan_sub_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_renewal": {
+ "name": "IDX_coding_plan_sub_renewal",
+ "columns": [
+ {
+ "expression": "credit_renewal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_inventory": {
+ "name": "IDX_coding_plan_sub_inventory",
+ "columns": [
+ {
+ "expression": "key_inventory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_subscriptions_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_subscriptions_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk": {
+ "name": "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "coding_plan_key_inventory",
+ "columnsFrom": [
+ "key_inventory_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk": {
+ "name": "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "byok_api_keys",
+ "columnsFrom": [
+ "installed_byok_key_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_subscriptions_status_check": {
+ "name": "coding_plan_subscriptions_status_check",
+ "value": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due', 'canceled')"
+ },
+ "coding_plan_subscriptions_live_access_check": {
+ "name": "coding_plan_subscriptions_live_access_check",
+ "value": "\"coding_plan_subscriptions\".\"status\" = 'canceled' OR \"coding_plan_subscriptions\".\"key_inventory_id\" IS NOT NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_terms": {
+ "name": "coding_plan_terms",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_start": {
+ "name": "period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_end": {
+ "name": "period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_transaction_id": {
+ "name": "credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_terms_request": {
+ "name": "UQ_coding_plan_terms_request",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_terms_subscription": {
+ "name": "IDX_coding_plan_terms_subscription",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk": {
+ "name": "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "coding_plan_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_terms_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_terms_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_terms_kind_check": {
+ "name": "coding_plan_terms_kind_check",
+ "value": "\"coding_plan_terms\".\"kind\" IN ('activation', 'extension', 'renewal')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_contributors": {
+ "name": "contributor_champion_contributors",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_profile_url": {
+ "name": "github_profile_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_contribution_at": {
+ "name": "first_contribution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contribution_at": {
+ "name": "last_contribution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "all_time_contributions": {
+ "name": "all_time_contributions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "manual_email": {
+ "name": "manual_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_contributors_last_contribution_at": {
+ "name": "IDX_contributor_champion_contributors_last_contribution_at",
+ "columns": [
+ {
+ "expression": "last_contribution_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_contributors_manual_email": {
+ "name": "IDX_contributor_champion_contributors_manual_email",
+ "columns": [
+ {
+ "expression": "manual_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_contributors_github_login": {
+ "name": "UQ_contributor_champion_contributors_github_login",
+ "nullsNotDistinct": false,
+ "columns": [
+ "github_login"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_events": {
+ "name": "contributor_champion_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "contributor_id": {
+ "name": "contributor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_number": {
+ "name": "github_pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_url": {
+ "name": "github_pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_title": {
+ "name": "github_pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_author_login": {
+ "name": "github_author_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_author_email": {
+ "name": "github_author_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_events_contributor_id": {
+ "name": "IDX_contributor_champion_events_contributor_id",
+ "columns": [
+ {
+ "expression": "contributor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_events_merged_at": {
+ "name": "IDX_contributor_champion_events_merged_at",
+ "columns": [
+ {
+ "expression": "merged_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_events_author_email": {
+ "name": "IDX_contributor_champion_events_author_email",
+ "columns": [
+ {
+ "expression": "github_author_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk": {
+ "name": "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk",
+ "tableFrom": "contributor_champion_events",
+ "tableTo": "contributor_champion_contributors",
+ "columnsFrom": [
+ "contributor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_events_repo_pr": {
+ "name": "UQ_contributor_champion_events_repo_pr",
+ "nullsNotDistinct": false,
+ "columns": [
+ "repo_full_name",
+ "github_pr_number"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_memberships": {
+ "name": "contributor_champion_memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "contributor_id": {
+ "name": "contributor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "selected_tier": {
+ "name": "selected_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enrolled_tier": {
+ "name": "enrolled_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enrolled_at": {
+ "name": "enrolled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_amount_microdollars": {
+ "name": "credit_amount_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "credits_last_granted_at": {
+ "name": "credits_last_granted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linked_kilo_user_id": {
+ "name": "linked_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_memberships_credits_due": {
+ "name": "IDX_contributor_champion_memberships_credits_due",
+ "columns": [
+ {
+ "expression": "credits_last_granted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NOT NULL AND \"contributor_champion_memberships\".\"credit_amount_microdollars\" > 0",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_memberships_linked_kilo_user_id": {
+ "name": "IDX_contributor_champion_memberships_linked_kilo_user_id",
+ "columns": [
+ {
+ "expression": "linked_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk": {
+ "name": "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk",
+ "tableFrom": "contributor_champion_memberships",
+ "tableTo": "contributor_champion_contributors",
+ "columnsFrom": [
+ "contributor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk": {
+ "name": "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "contributor_champion_memberships",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "linked_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_memberships_contributor_id": {
+ "name": "UQ_contributor_champion_memberships_contributor_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "contributor_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "contributor_champion_memberships_selected_tier_check": {
+ "name": "contributor_champion_memberships_selected_tier_check",
+ "value": "\"contributor_champion_memberships\".\"selected_tier\" IS NULL OR \"contributor_champion_memberships\".\"selected_tier\" IN ('contributor', 'ambassador', 'champion')"
+ },
+ "contributor_champion_memberships_enrolled_tier_check": {
+ "name": "contributor_champion_memberships_enrolled_tier_check",
+ "value": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NULL OR \"contributor_champion_memberships\".\"enrolled_tier\" IN ('contributor', 'ambassador', 'champion')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_sync_state": {
+ "name": "contributor_champion_sync_state",
+ "schema": "",
+ "columns": {
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "last_merged_at": {
+ "name": "last_merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.credit_campaigns": {
+ "name": "credit_campaigns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_category": {
+ "name": "credit_category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_microdollars": {
+ "name": "amount_microdollars",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_expiry_hours": {
+ "name": "credit_expiry_hours",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "campaign_ends_at": {
+ "name": "campaign_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_redemptions_allowed": {
+ "name": "total_redemptions_allowed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_credit_campaigns_slug": {
+ "name": "UQ_credit_campaigns_slug",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_credit_campaigns_credit_category": {
+ "name": "UQ_credit_campaigns_credit_category",
+ "columns": [
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "credit_campaigns_slug_format_check": {
+ "name": "credit_campaigns_slug_format_check",
+ "value": "\"credit_campaigns\".\"slug\" ~ '^[a-z0-9-]{5,40}$'"
+ },
+ "credit_campaigns_amount_positive_check": {
+ "name": "credit_campaigns_amount_positive_check",
+ "value": "\"credit_campaigns\".\"amount_microdollars\" > 0"
+ },
+ "credit_campaigns_credit_expiry_hours_positive_check": {
+ "name": "credit_campaigns_credit_expiry_hours_positive_check",
+ "value": "\"credit_campaigns\".\"credit_expiry_hours\" IS NULL OR \"credit_campaigns\".\"credit_expiry_hours\" > 0"
+ },
+ "credit_campaigns_total_redemptions_allowed_positive_check": {
+ "name": "credit_campaigns_total_redemptions_allowed_positive_check",
+ "value": "\"credit_campaigns\".\"total_redemptions_allowed\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.credit_transactions": {
+ "name": "credit_transactions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_microdollars": {
+ "name": "amount_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expiration_baseline_microdollars_used": {
+ "name": "expiration_baseline_microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_baseline_microdollars_used": {
+ "name": "original_baseline_microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_transaction_id": {
+ "name": "original_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_id": {
+ "name": "stripe_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coinbase_credit_block_id": {
+ "name": "coinbase_credit_block_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_category": {
+ "name": "credit_category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expiry_date": {
+ "name": "expiry_date",
+ "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()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_category_uniqueness": {
+ "name": "check_category_uniqueness",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "IDX_credit_transactions_created_at": {
+ "name": "IDX_credit_transactions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_is_free": {
+ "name": "IDX_credit_transactions_is_free",
+ "columns": [
+ {
+ "expression": "is_free",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_kilo_user_id": {
+ "name": "IDX_credit_transactions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_credit_category": {
+ "name": "IDX_credit_transactions_credit_category",
+ "columns": [
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_stripe_payment_id": {
+ "name": "IDX_credit_transactions_stripe_payment_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_original_transaction_id": {
+ "name": "IDX_credit_transactions_original_transaction_id",
+ "columns": [
+ {
+ "expression": "original_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_coinbase_credit_block_id": {
+ "name": "IDX_credit_transactions_coinbase_credit_block_id",
+ "columns": [
+ {
+ "expression": "coinbase_credit_block_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_organization_id": {
+ "name": "IDX_credit_transactions_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_unique_category": {
+ "name": "IDX_credit_transactions_unique_category",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"credit_transactions\".\"check_category_uniqueness\" = TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "credit_transactions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_llm2": {
+ "name": "custom_llm2",
+ "schema": "",
+ "columns": {
+ "public_id": {
+ "name": "public_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "definition": {
+ "name": "definition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deleted_user_email_tombstones": {
+ "name": "deleted_user_email_tombstones",
+ "schema": "",
+ "columns": {
+ "normalized_email_hash": {
+ "name": "normalized_email_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_builds": {
+ "name": "deployment_builds",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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": {
+ "idx_deployment_builds_deployment_id": {
+ "name": "idx_deployment_builds_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_builds_status": {
+ "name": "idx_deployment_builds_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_builds_deployment_id_deployments_id_fk": {
+ "name": "deployment_builds_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_builds",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_env_vars": {
+ "name": "deployment_env_vars",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_secret": {
+ "name": "is_secret",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployment_env_vars_deployment_id": {
+ "name": "idx_deployment_env_vars_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_env_vars_deployment_id_deployments_id_fk": {
+ "name": "deployment_env_vars_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_env_vars",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployment_env_vars_deployment_key": {
+ "name": "UQ_deployment_env_vars_deployment_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_events": {
+ "name": "deployment_events",
+ "schema": "",
+ "columns": {
+ "build_id": {
+ "name": "build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'log'"
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_deployment_events_build_id": {
+ "name": "idx_deployment_events_build_id",
+ "columns": [
+ {
+ "expression": "build_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_events_timestamp": {
+ "name": "idx_deployment_events_timestamp",
+ "columns": [
+ {
+ "expression": "timestamp",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_events_type": {
+ "name": "idx_deployment_events_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_events_build_id_deployment_builds_id_fk": {
+ "name": "deployment_events_build_id_deployment_builds_id_fk",
+ "tableFrom": "deployment_events",
+ "tableTo": "deployment_builds",
+ "columnsFrom": [
+ "build_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "deployment_events_build_id_event_id_pk": {
+ "name": "deployment_events_build_id_event_id_pk",
+ "columns": [
+ "build_id",
+ "event_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_threat_detections": {
+ "name": "deployment_threat_detections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "build_id": {
+ "name": "build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "threat_type": {
+ "name": "threat_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployment_threat_detections_deployment_id": {
+ "name": "idx_deployment_threat_detections_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_threat_detections_created_at": {
+ "name": "idx_deployment_threat_detections_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_threat_detections_deployment_id_deployments_id_fk": {
+ "name": "deployment_threat_detections_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_threat_detections",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "deployment_threat_detections_build_id_deployment_builds_id_fk": {
+ "name": "deployment_threat_detections_build_id_deployment_builds_id_fk",
+ "tableFrom": "deployment_threat_detections",
+ "tableTo": "deployment_builds",
+ "columnsFrom": [
+ "build_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployments": {
+ "name": "deployments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deployment_slug": {
+ "name": "deployment_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_worker_name": {
+ "name": "internal_worker_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_source": {
+ "name": "repository_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch": {
+ "name": "branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deployment_url": {
+ "name": "deployment_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "git_auth_token": {
+ "name": "git_auth_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_deployed_at": {
+ "name": "last_deployed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_build_id": {
+ "name": "last_build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "threat_status": {
+ "name": "threat_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_from": {
+ "name": "created_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_deployments_owned_by_user_id": {
+ "name": "idx_deployments_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_owned_by_organization_id": {
+ "name": "idx_deployments_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_platform_integration_id": {
+ "name": "idx_deployments_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_repository_source_branch": {
+ "name": "idx_deployments_repository_source_branch",
+ "columns": [
+ {
+ "expression": "repository_source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_threat_status_pending": {
+ "name": "idx_deployments_threat_status_pending",
+ "columns": [
+ {
+ "expression": "threat_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"deployments\".\"threat_status\" = 'pending_scan'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployments_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "deployments_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deployments_owned_by_organization_id_organizations_id_fk": {
+ "name": "deployments_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployments_deployment_slug": {
+ "name": "UQ_deployments_deployment_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "deployments_owner_check": {
+ "name": "deployments_owner_check",
+ "value": "(\n (\"deployments\".\"owned_by_user_id\" IS NOT NULL AND \"deployments\".\"owned_by_organization_id\" IS NULL) OR\n (\"deployments\".\"owned_by_user_id\" IS NULL AND \"deployments\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "deployments_source_type_check": {
+ "name": "deployments_source_type_check",
+ "value": "\"deployments\".\"source_type\" IN ('github', 'git', 'app-builder')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.deployments_ephemeral": {
+ "name": "deployments_ephemeral",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_worker_name": {
+ "name": "internal_worker_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deployment_slug": {
+ "name": "deployment_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_cleanup_at": {
+ "name": "next_cleanup_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cleanup_claim_token": {
+ "name": "cleanup_claim_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cleanup_claimed_until": {
+ "name": "cleanup_claimed_until",
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployments_ephemeral_owned_by_user_id": {
+ "name": "idx_deployments_ephemeral_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_ephemeral_next_cleanup_at": {
+ "name": "idx_deployments_ephemeral_next_cleanup_at",
+ "columns": [
+ {
+ "expression": "next_cleanup_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "deployments_ephemeral",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployments_ephemeral_internal_worker_name": {
+ "name": "UQ_deployments_ephemeral_internal_worker_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "internal_worker_name"
+ ]
+ },
+ "UQ_deployments_ephemeral_deployment_slug": {
+ "name": "UQ_deployments_ephemeral_deployment_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "deployments_ephemeral_source_type_check": {
+ "name": "deployments_ephemeral_source_type_check",
+ "value": "\"deployments_ephemeral\".\"source_type\" IN ('html')"
+ },
+ "deployments_ephemeral_status_check": {
+ "name": "deployments_ephemeral_status_check",
+ "value": "\"deployments_ephemeral\".\"status\" IN ('pending', 'active', 'cleanup_retry')"
+ },
+ "deployments_ephemeral_claim_fields_check": {
+ "name": "deployments_ephemeral_claim_fields_check",
+ "value": "(\"deployments_ephemeral\".\"cleanup_claim_token\" IS NULL) = (\"deployments_ephemeral\".\"cleanup_claimed_until\" IS NULL)"
+ },
+ "deployments_ephemeral_active_fields_check": {
+ "name": "deployments_ephemeral_active_fields_check",
+ "value": "\"deployments_ephemeral\".\"status\" <> 'active' OR (\"deployments_ephemeral\".\"deployment_slug\" IS NOT NULL AND \"deployments_ephemeral\".\"expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.device_auth_requests": {
+ "name": "device_auth_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_device_auth_requests_code": {
+ "name": "UQ_device_auth_requests_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_status": {
+ "name": "IDX_device_auth_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_expires_at": {
+ "name": "IDX_device_auth_requests_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_kilo_user_id": {
+ "name": "IDX_device_auth_requests_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "device_auth_requests_kilo_user_id_kilocode_users_id_fk": {
+ "name": "device_auth_requests_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "device_auth_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.discord_gateway_listener": {
+ "name": "discord_gateway_listener",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "default": 1
+ },
+ "listener_id": {
+ "name": "listener_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_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": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.editor_name": {
+ "name": "editor_name",
+ "schema": "",
+ "columns": {
+ "editor_name_id": {
+ "name": "editor_name_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "editor_name": {
+ "name": "editor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_editor_name": {
+ "name": "UQ_editor_name",
+ "columns": [
+ {
+ "expression": "editor_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.enrichment_data": {
+ "name": "enrichment_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_enrichment_data": {
+ "name": "github_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linkedin_enrichment_data": {
+ "name": "linkedin_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clay_enrichment_data": {
+ "name": "clay_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_enrichment_data_user_id": {
+ "name": "IDX_enrichment_data_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "enrichment_data_user_id_kilocode_users_id_fk": {
+ "name": "enrichment_data_user_id_kilocode_users_id_fk",
+ "tableFrom": "enrichment_data",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_enrichment_data_user_id": {
+ "name": "UQ_enrichment_data_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.exa_monthly_usage": {
+ "name": "exa_monthly_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "month": {
+ "name": "month",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "total_charged_microdollars": {
+ "name": "total_charged_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "free_allowance_microdollars": {
+ "name": "free_allowance_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 10000000
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_exa_monthly_usage_personal": {
+ "name": "idx_exa_monthly_usage_personal",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"exa_monthly_usage\".\"organization_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_exa_monthly_usage_org": {
+ "name": "idx_exa_monthly_usage_org",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"exa_monthly_usage\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.exa_usage_log": {
+ "name": "exa_usage_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "charged_to_balance": {
+ "name": "charged_to_balance",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "feature_id": {
+ "name": "feature_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_exa_usage_log_user_created": {
+ "name": "idx_exa_usage_log_user_created",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "exa_usage_log_id_created_at_pk": {
+ "name": "exa_usage_log_id_created_at_pk",
+ "columns": [
+ "id",
+ "created_at"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature": {
+ "name": "feature",
+ "schema": "",
+ "columns": {
+ "feature_id": {
+ "name": "feature_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_feature": {
+ "name": "UQ_feature",
+ "columns": [
+ {
+ "expression": "feature",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.finish_reason": {
+ "name": "finish_reason",
+ "schema": "",
+ "columns": {
+ "finish_reason_id": {
+ "name": "finish_reason_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "finish_reason": {
+ "name": "finish_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_finish_reason": {
+ "name": "UQ_finish_reason",
+ "columns": [
+ {
+ "expression": "finish_reason",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.free_model_usage": {
+ "name": "free_model_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_free_model_usage_ip_created_at": {
+ "name": "idx_free_model_usage_ip_created_at",
+ "columns": [
+ {
+ "expression": "ip_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_free_model_usage_created_at": {
+ "name": "idx_free_model_usage_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_branch_pull_requests": {
+ "name": "github_branch_pull_requests",
+ "schema": "",
+ "columns": {
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_state": {
+ "name": "pr_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_title": {
+ "name": "pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_sha": {
+ "name": "pr_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_review_decision": {
+ "name": "pr_review_decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_decision_pending": {
+ "name": "review_decision_pending",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "review_decision_fetching_at": {
+ "name": "review_decision_fetching_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_last_synced_at": {
+ "name": "pr_last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_github_branch_prs_org": {
+ "name": "UQ_github_branch_prs_org",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"github_branch_pull_requests\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_github_branch_prs_user": {
+ "name": "UQ_github_branch_prs_user",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"github_branch_pull_requests\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk": {
+ "name": "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "github_branch_pull_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "github_branch_pull_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "github_branch_pull_requests_owner_check": {
+ "name": "github_branch_pull_requests_owner_check",
+ "value": "(\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NOT NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NULL) OR\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NOT NULL)\n )"
+ },
+ "github_branch_pull_requests_review_decision_check": {
+ "name": "github_branch_pull_requests_review_decision_check",
+ "value": "\"github_branch_pull_requests\".\"pr_review_decision\" IS NULL OR \"github_branch_pull_requests\".\"pr_review_decision\" IN ('approved', 'changes_requested', 'review_required')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.http_ip": {
+ "name": "http_ip",
+ "schema": "",
+ "columns": {
+ "http_ip_id": {
+ "name": "http_ip_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "http_ip": {
+ "name": "http_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_http_ip": {
+ "name": "UQ_http_ip",
+ "columns": [
+ {
+ "expression": "http_ip",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.http_user_agent": {
+ "name": "http_user_agent",
+ "schema": "",
+ "columns": {
+ "http_user_agent_id": {
+ "name": "http_user_agent_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_http_user_agent": {
+ "name": "UQ_http_user_agent",
+ "columns": [
+ {
+ "expression": "http_user_agent",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_participants": {
+ "name": "impact_advocate_participants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "advocate_id": {
+ "name": "advocate_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "advocate_account_id": {
+ "name": "advocate_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_referral_identifier": {
+ "name": "opaque_referral_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contact_email": {
+ "name": "contact_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_state": {
+ "name": "registration_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "registered_at": {
+ "name": "registered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_registration_attempt_at": {
+ "name": "last_registration_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_code": {
+ "name": "last_error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_message": {
+ "name": "last_error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_impact_advocate_participants_program_referral_identifier": {
+ "name": "UQ_impact_advocate_participants_program_referral_identifier",
+ "columns": [
+ {
+ "expression": "program_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "opaque_referral_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"impact_advocate_participants\".\"opaque_referral_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_participants_registration_state": {
+ "name": "IDX_impact_advocate_participants_registration_state",
+ "columns": [
+ {
+ "expression": "registration_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_participants_user_id_kilocode_users_id_fk": {
+ "name": "impact_advocate_participants_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_advocate_participants",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_participants_program_user": {
+ "name": "UQ_impact_advocate_participants_program_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "program_key",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_participants_program_key_check": {
+ "name": "impact_advocate_participants_program_key_check",
+ "value": "\"impact_advocate_participants\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_advocate_participants_registration_state_check": {
+ "name": "impact_advocate_participants_registration_state_check",
+ "value": "\"impact_advocate_participants\".\"registration_state\" IN ('pending', 'retrying', 'registered', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_registration_attempts": {
+ "name": "impact_advocate_registration_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "participant_id": {
+ "name": "participant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_cookie_value": {
+ "name": "opaque_cookie_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cookie_value_length": {
+ "name": "cookie_value_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delivery_state": {
+ "name": "delivery_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_payload": {
+ "name": "response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_advocate_registration_attempts_participant_id": {
+ "name": "IDX_impact_advocate_registration_attempts_participant_id",
+ "columns": [
+ {
+ "expression": "participant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_registration_attempts_delivery_state": {
+ "name": "IDX_impact_advocate_registration_attempts_delivery_state",
+ "columns": [
+ {
+ "expression": "delivery_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk": {
+ "name": "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk",
+ "tableFrom": "impact_advocate_registration_attempts",
+ "tableTo": "impact_advocate_participants",
+ "columnsFrom": [
+ "participant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_registration_attempts_dedupe_key": {
+ "name": "UQ_impact_advocate_registration_attempts_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_registration_attempts_program_key_check": {
+ "name": "impact_advocate_registration_attempts_program_key_check",
+ "value": "\"impact_advocate_registration_attempts\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_advocate_registration_attempts_delivery_state_check": {
+ "name": "impact_advocate_registration_attempts_delivery_state_check",
+ "value": "\"impact_advocate_registration_attempts\".\"delivery_state\" IN ('queued', 'sending', 'succeeded', 'failed')"
+ },
+ "impact_advocate_registration_attempts_cookie_value_length_non_negative_check": {
+ "name": "impact_advocate_registration_attempts_cookie_value_length_non_negative_check",
+ "value": "\"impact_advocate_registration_attempts\".\"cookie_value_length\" >= 0"
+ },
+ "impact_advocate_registration_attempts_attempt_count_non_negative_check": {
+ "name": "impact_advocate_registration_attempts_attempt_count_non_negative_check",
+ "value": "\"impact_advocate_registration_attempts\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_reward_redemptions": {
+ "name": "impact_advocate_reward_redemptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "reward_id": {
+ "name": "reward_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "impact_reward_id": {
+ "name": "impact_reward_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lookup_response_payload": {
+ "name": "lookup_response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redeem_response_payload": {
+ "name": "redeem_response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redeemed_at": {
+ "name": "redeemed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_advocate_reward_redemptions_beneficiary_user_id": {
+ "name": "IDX_impact_advocate_reward_redemptions_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_reward_redemptions_state": {
+ "name": "IDX_impact_advocate_reward_redemptions_state",
+ "columns": [
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk": {
+ "name": "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk",
+ "tableFrom": "impact_advocate_reward_redemptions",
+ "tableTo": "impact_referral_rewards",
+ "columnsFrom": [
+ "reward_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_advocate_reward_redemptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_reward_redemptions_reward_id": {
+ "name": "UQ_impact_advocate_reward_redemptions_reward_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "reward_id"
+ ]
+ },
+ "UQ_impact_advocate_reward_redemptions_dedupe_key": {
+ "name": "UQ_impact_advocate_reward_redemptions_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_reward_redemptions_state_check": {
+ "name": "impact_advocate_reward_redemptions_state_check",
+ "value": "\"impact_advocate_reward_redemptions\".\"state\" IN ('queued', 'retrying', 'redeemed', 'failed')"
+ },
+ "impact_advocate_reward_redemptions_attempt_count_non_negative_check": {
+ "name": "impact_advocate_reward_redemptions_attempt_count_non_negative_check",
+ "value": "\"impact_advocate_reward_redemptions\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_attribution_touches": {
+ "name": "impact_attribution_touches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'kiloclaw'"
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "anonymous_id": {
+ "name": "anonymous_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touch_type": {
+ "name": "touch_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_tracking_value": {
+ "name": "opaque_tracking_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tracking_value_length": {
+ "name": "tracking_value_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_tracking_value_accepted": {
+ "name": "is_tracking_value_accepted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "rs_code": {
+ "name": "rs_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rs_share_medium": {
+ "name": "rs_share_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rs_engagement_medium": {
+ "name": "rs_engagement_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "im_ref": {
+ "name": "im_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landing_path": {
+ "name": "landing_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_source": {
+ "name": "utm_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_medium": {
+ "name": "utm_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_campaign": {
+ "name": "utm_campaign",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_term": {
+ "name": "utm_term",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_content": {
+ "name": "utm_content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touched_at": {
+ "name": "touched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sale_attributed_at": {
+ "name": "sale_attributed_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": {
+ "IDX_impact_attribution_touches_product_user_id": {
+ "name": "IDX_impact_attribution_touches_product_user_id",
+ "columns": [
+ {
+ "expression": "product",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_user_id": {
+ "name": "IDX_impact_attribution_touches_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_anonymous_id": {
+ "name": "IDX_impact_attribution_touches_anonymous_id",
+ "columns": [
+ {
+ "expression": "anonymous_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_expires_at": {
+ "name": "IDX_impact_attribution_touches_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_sale_attributed_at": {
+ "name": "IDX_impact_attribution_touches_sale_attributed_at",
+ "columns": [
+ {
+ "expression": "sale_attributed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_attribution_touches_user_id_kilocode_users_id_fk": {
+ "name": "impact_attribution_touches_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_attribution_touches",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_attribution_touches_dedupe_key": {
+ "name": "UQ_impact_attribution_touches_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_attribution_touches_product_check": {
+ "name": "impact_attribution_touches_product_check",
+ "value": "\"impact_attribution_touches\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_attribution_touches_program_key_check": {
+ "name": "impact_attribution_touches_program_key_check",
+ "value": "\"impact_attribution_touches\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_attribution_touches_touch_type_check": {
+ "name": "impact_attribution_touches_touch_type_check",
+ "value": "\"impact_attribution_touches\".\"touch_type\" IN ('affiliate', 'referral')"
+ },
+ "impact_attribution_touches_provider_check": {
+ "name": "impact_attribution_touches_provider_check",
+ "value": "\"impact_attribution_touches\".\"provider\" IN ('impact_performance', 'impact_advocate')"
+ },
+ "impact_attribution_touches_tracking_value_length_non_negative_check": {
+ "name": "impact_attribution_touches_tracking_value_length_non_negative_check",
+ "value": "\"impact_attribution_touches\".\"tracking_value_length\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_conversion_reports": {
+ "name": "impact_conversion_reports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_tracker_id": {
+ "name": "action_tracker_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "order_id": {
+ "name": "order_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_payload": {
+ "name": "response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delivered_at": {
+ "name": "delivered_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_conversion_reports_conversion_id": {
+ "name": "IDX_impact_conversion_reports_conversion_id",
+ "columns": [
+ {
+ "expression": "conversion_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_conversion_reports_state": {
+ "name": "IDX_impact_conversion_reports_state",
+ "columns": [
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_conversion_reports",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_conversion_reports_dedupe_key": {
+ "name": "UQ_impact_conversion_reports_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_conversion_reports_state_check": {
+ "name": "impact_conversion_reports_state_check",
+ "value": "\"impact_conversion_reports\".\"state\" IN ('queued', 'retrying', 'delivered', 'failed')"
+ },
+ "impact_conversion_reports_attempt_count_non_negative_check": {
+ "name": "impact_conversion_reports_attempt_count_non_negative_check",
+ "value": "\"impact_conversion_reports\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_conversions": {
+ "name": "impact_referral_conversions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "referee_user_id": {
+ "name": "referee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer_user_id": {
+ "name": "referrer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_touch_id": {
+ "name": "source_touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "winning_touch_type": {
+ "name": "winning_touch_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'credits'"
+ },
+ "source_payment_id": {
+ "name": "source_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "qualified": {
+ "name": "qualified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "disqualification_reason": {
+ "name": "disqualification_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "converted_at": {
+ "name": "converted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_conversions_referee_user_id": {
+ "name": "IDX_impact_referral_conversions_referee_user_id",
+ "columns": [
+ {
+ "expression": "referee_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_conversions_referrer_user_id": {
+ "name": "IDX_impact_referral_conversions_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_conversions_referee_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_conversions_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk": {
+ "name": "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "impact_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_conversions_product_payment_source": {
+ "name": "UQ_impact_referral_conversions_product_payment_source",
+ "nullsNotDistinct": false,
+ "columns": [
+ "product",
+ "payment_provider",
+ "source_payment_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_conversions_product_check": {
+ "name": "impact_referral_conversions_product_check",
+ "value": "\"impact_referral_conversions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_conversions_winning_touch_type_check": {
+ "name": "impact_referral_conversions_winning_touch_type_check",
+ "value": "\"impact_referral_conversions\".\"winning_touch_type\" IN ('referral', 'affiliate', 'none')"
+ },
+ "impact_referral_conversions_payment_provider_check": {
+ "name": "impact_referral_conversions_payment_provider_check",
+ "value": "\"impact_referral_conversions\".\"payment_provider\" IN ('stripe', 'credits', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_reward_applications": {
+ "name": "impact_referral_reward_applications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "reward_id": {
+ "name": "reward_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_renewal_boundary": {
+ "name": "previous_renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "new_renewal_boundary": {
+ "name": "new_renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_operation_id": {
+ "name": "local_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_operation_id": {
+ "name": "stripe_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_idempotency_key": {
+ "name": "stripe_idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_reward_applications_reward_id": {
+ "name": "IDX_impact_referral_reward_applications_reward_id",
+ "columns": [
+ {
+ "expression": "reward_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_reward_applications_beneficiary_user_id": {
+ "name": "IDX_impact_referral_reward_applications_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk": {
+ "name": "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk",
+ "tableFrom": "impact_referral_reward_applications",
+ "tableTo": "impact_referral_rewards",
+ "columnsFrom": [
+ "reward_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_reward_applications",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_reward_applications_product_check": {
+ "name": "impact_referral_reward_applications_product_check",
+ "value": "\"impact_referral_reward_applications\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_reward_decisions": {
+ "name": "impact_referral_reward_decisions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_role": {
+ "name": "beneficiary_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_kind": {
+ "name": "reward_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw_free_month'"
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "reward_percent": {
+ "name": "reward_percent",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_tier": {
+ "name": "source_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_amount_usd": {
+ "name": "reward_amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_reward_decisions_beneficiary_user_id": {
+ "name": "IDX_impact_referral_reward_decisions_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_referral_reward_decisions",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_reward_decisions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_reward_decisions_conversion_role": {
+ "name": "UQ_impact_referral_reward_decisions_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_reward_decisions_product_check": {
+ "name": "impact_referral_reward_decisions_product_check",
+ "value": "\"impact_referral_reward_decisions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_reward_decisions_beneficiary_role_check": {
+ "name": "impact_referral_reward_decisions_beneficiary_role_check",
+ "value": "\"impact_referral_reward_decisions\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "impact_referral_reward_decisions_outcome_check": {
+ "name": "impact_referral_reward_decisions_outcome_check",
+ "value": "\"impact_referral_reward_decisions\".\"outcome\" IN ('granted', 'cap_limited', 'disqualified')"
+ },
+ "impact_referral_reward_decisions_reward_kind_check": {
+ "name": "impact_referral_reward_decisions_reward_kind_check",
+ "value": "\"impact_referral_reward_decisions\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
+ },
+ "impact_referral_reward_decisions_months_granted_non_negative_check": {
+ "name": "impact_referral_reward_decisions_months_granted_non_negative_check",
+ "value": "\"impact_referral_reward_decisions\".\"months_granted\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_rewards": {
+ "name": "impact_referral_rewards",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "decision_id": {
+ "name": "decision_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_role": {
+ "name": "beneficiary_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reward_kind": {
+ "name": "reward_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw_free_month'"
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "reward_percent": {
+ "name": "reward_percent",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_tier": {
+ "name": "source_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_amount_usd": {
+ "name": "reward_amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "applies_to_subscription_id": {
+ "name": "applies_to_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applies_to_kilo_pass_subscription_id": {
+ "name": "applies_to_kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consumed_kilo_pass_issuance_id": {
+ "name": "consumed_kilo_pass_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consumed_kilo_pass_issuance_item_id": {
+ "name": "consumed_kilo_pass_issuance_item_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "earned_at": {
+ "name": "earned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reversed_at": {
+ "name": "reversed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_reason": {
+ "name": "review_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_rewards_beneficiary_user_id": {
+ "name": "IDX_impact_referral_rewards_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_rewards_status": {
+ "name": "IDX_impact_referral_rewards_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk": {
+ "name": "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "impact_referral_reward_decisions",
+ "columnsFrom": [
+ "decision_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_subscription": {
+ "name": "FK_impact_referral_rewards_kilo_pass_subscription",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "applies_to_kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_issuance": {
+ "name": "FK_impact_referral_rewards_kilo_pass_issuance",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "consumed_kilo_pass_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_issuance_item": {
+ "name": "FK_impact_referral_rewards_kilo_pass_issuance_item",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_issuance_items",
+ "columnsFrom": [
+ "consumed_kilo_pass_issuance_item_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_rewards_conversion_role": {
+ "name": "UQ_impact_referral_rewards_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ },
+ "UQ_impact_referral_rewards_decision_id": {
+ "name": "UQ_impact_referral_rewards_decision_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "decision_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_rewards_product_check": {
+ "name": "impact_referral_rewards_product_check",
+ "value": "\"impact_referral_rewards\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_rewards_beneficiary_role_check": {
+ "name": "impact_referral_rewards_beneficiary_role_check",
+ "value": "\"impact_referral_rewards\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "impact_referral_rewards_reward_kind_check": {
+ "name": "impact_referral_rewards_reward_kind_check",
+ "value": "\"impact_referral_rewards\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
+ },
+ "impact_referral_rewards_status_check": {
+ "name": "impact_referral_rewards_status_check",
+ "value": "\"impact_referral_rewards\".\"status\" IN ('pending', 'earned', 'applied', 'reversed', 'expired', 'canceled', 'review_required')"
+ },
+ "impact_referral_rewards_months_granted_non_negative_check": {
+ "name": "impact_referral_rewards_months_granted_non_negative_check",
+ "value": "\"impact_referral_rewards\".\"months_granted\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referrals": {
+ "name": "impact_referrals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "referee_user_id": {
+ "name": "referee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer_user_id": {
+ "name": "referrer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_touch_id": {
+ "name": "source_touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_referral_id": {
+ "name": "impact_referral_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referrals_referrer_user_id": {
+ "name": "IDX_impact_referrals_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referrals_source_touch_id": {
+ "name": "IDX_impact_referrals_source_touch_id",
+ "columns": [
+ {
+ "expression": "source_touch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referrals_referee_user_id_kilocode_users_id_fk": {
+ "name": "impact_referrals_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referrals_referrer_user_id_kilocode_users_id_fk": {
+ "name": "impact_referrals_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "impact_referrals_source_touch_id_impact_attribution_touches_id_fk": {
+ "name": "impact_referrals_source_touch_id_impact_attribution_touches_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "impact_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referrals_product_referee_user_id": {
+ "name": "UQ_impact_referrals_product_referee_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "product",
+ "referee_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referrals_product_check": {
+ "name": "impact_referrals_product_check",
+ "value": "\"impact_referrals\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.ja4_digest": {
+ "name": "ja4_digest",
+ "schema": "",
+ "columns": {
+ "ja4_digest_id": {
+ "name": "ja4_digest_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ja4_digest": {
+ "name": "ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_ja4_digest": {
+ "name": "UQ_ja4_digest",
+ "columns": [
+ {
+ "expression": "ja4_digest",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_audit_log": {
+ "name": "kilo_pass_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_invoice_id": {
+ "name": "stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_credit_transaction_id": {
+ "name": "related_credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_monthly_issuance_id": {
+ "name": "related_monthly_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_audit_log_created_at": {
+ "name": "IDX_kilo_pass_audit_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_kilo_user_id": {
+ "name": "IDX_kilo_pass_audit_log_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_kilo_pass_subscription_id": {
+ "name": "IDX_kilo_pass_audit_log_kilo_pass_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_action": {
+ "name": "IDX_kilo_pass_audit_log_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_result": {
+ "name": "IDX_kilo_pass_audit_log_result",
+ "columns": [
+ {
+ "expression": "result",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_idempotency_key": {
+ "name": "IDX_kilo_pass_audit_log_idempotency_key",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_event_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_invoice_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_invoice_id",
+ "columns": [
+ {
+ "expression": "stripe_invoice_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_subscription_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_related_credit_transaction_id": {
+ "name": "IDX_kilo_pass_audit_log_related_credit_transaction_id",
+ "columns": [
+ {
+ "expression": "related_credit_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_related_monthly_issuance_id": {
+ "name": "IDX_kilo_pass_audit_log_related_monthly_issuance_id",
+ "columns": [
+ {
+ "expression": "related_monthly_issuance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "related_credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk": {
+ "name": "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "related_monthly_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_audit_log_action_check": {
+ "name": "kilo_pass_audit_log_action_check",
+ "value": "\"kilo_pass_audit_log\".\"action\" IN ('stripe_webhook_received', 'kilo_pass_invoice_paid_handled', 'store_purchase_completed', 'store_notification_received', 'store_subscription_renewed', 'store_subscription_canceled', 'store_subscription_expired', 'store_subscription_refunded', 'base_credits_issued', 'bonus_credits_issued', 'bonus_credits_skipped_idempotent', 'first_month_50pct_promo_issued', 'yearly_monthly_base_cron_started', 'yearly_monthly_base_cron_completed', 'issue_yearly_remaining_credits', 'duplicate_card_subscription_canceled', 'yearly_monthly_bonus_cron_started', 'yearly_monthly_bonus_cron_completed')"
+ },
+ "kilo_pass_audit_log_result_check": {
+ "name": "kilo_pass_audit_log_result_check",
+ "value": "\"kilo_pass_audit_log\".\"result\" IN ('success', 'skipped_idempotent', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_issuance_items": {
+ "name": "kilo_pass_issuance_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_issuance_id": {
+ "name": "kilo_pass_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_transaction_id": {
+ "name": "credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bonus_percent_applied": {
+ "name": "bonus_percent_applied",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_issuance_items_issuance_id": {
+ "name": "IDX_kilo_pass_issuance_items_issuance_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_issuance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuance_items_credit_transaction_id": {
+ "name": "IDX_kilo_pass_issuance_items_credit_transaction_id",
+ "columns": [
+ {
+ "expression": "credit_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk": {
+ "name": "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk",
+ "tableFrom": "kilo_pass_issuance_items",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "kilo_pass_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "kilo_pass_issuance_items",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilo_pass_issuance_items_credit_transaction_id_unique": {
+ "name": "kilo_pass_issuance_items_credit_transaction_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "credit_transaction_id"
+ ]
+ },
+ "UQ_kilo_pass_issuance_items_issuance_kind": {
+ "name": "UQ_kilo_pass_issuance_items_issuance_kind",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_pass_issuance_id",
+ "kind"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_issuance_items_bonus_percent_applied_range_check": {
+ "name": "kilo_pass_issuance_items_bonus_percent_applied_range_check",
+ "value": "\"kilo_pass_issuance_items\".\"bonus_percent_applied\" IS NULL OR (\"kilo_pass_issuance_items\".\"bonus_percent_applied\" >= 0 AND \"kilo_pass_issuance_items\".\"bonus_percent_applied\" <= 1)"
+ },
+ "kilo_pass_issuance_items_amount_usd_non_negative_check": {
+ "name": "kilo_pass_issuance_items_amount_usd_non_negative_check",
+ "value": "\"kilo_pass_issuance_items\".\"amount_usd\" >= 0"
+ },
+ "kilo_pass_issuance_items_kind_check": {
+ "name": "kilo_pass_issuance_items_kind_check",
+ "value": "\"kilo_pass_issuance_items\".\"kind\" IN ('base', 'bonus', 'promo_first_month_50pct', 'referral_bonus')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_issuances": {
+ "name": "kilo_pass_issuances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_month": {
+ "name": "issue_month",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_invoice_id": {
+ "name": "stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initial_welcome_promo_eligibility_reason": {
+ "name": "initial_welcome_promo_eligibility_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kilo_pass_issuances_stripe_invoice_id": {
+ "name": "UQ_kilo_pass_issuances_stripe_invoice_id",
+ "columns": [
+ {
+ "expression": "stripe_invoice_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_issuances\".\"stripe_invoice_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuances_subscription_id": {
+ "name": "IDX_kilo_pass_issuances_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuances_issue_month": {
+ "name": "IDX_kilo_pass_issuances_issue_month",
+ "columns": [
+ {
+ "expression": "issue_month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_issuances",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kilo_pass_issuances_subscription_issue_month": {
+ "name": "UQ_kilo_pass_issuances_subscription_issue_month",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_pass_subscription_id",
+ "issue_month"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_issuances_issue_month_day_one_check": {
+ "name": "kilo_pass_issuances_issue_month_day_one_check",
+ "value": "EXTRACT(DAY FROM \"kilo_pass_issuances\".\"issue_month\") = 1"
+ },
+ "kilo_pass_issuances_source_check": {
+ "name": "kilo_pass_issuances_source_check",
+ "value": "\"kilo_pass_issuances\".\"source\" IN ('stripe_invoice', 'app_store_transaction', 'google_play_transaction', 'cron')"
+ },
+ "kilo_pass_issuances_initial_welcome_promo_reason_check": {
+ "name": "kilo_pass_issuances_initial_welcome_promo_reason_check",
+ "value": "\"kilo_pass_issuances\".\"initial_welcome_promo_eligibility_reason\" IN ('first_payment_fingerprint_claim', 'fingerprint_previously_claimed', 'missing_fingerprint', 'no_supported_fingerprint', 'no_positive_settlement', 'settlement_unresolved')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_pause_events": {
+ "name": "kilo_pass_pause_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "paused_at": {
+ "name": "paused_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resumes_at": {
+ "name": "resumes_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resumed_at": {
+ "name": "resumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_pause_events_subscription_id": {
+ "name": "IDX_kilo_pass_pause_events_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_pause_events_one_open_per_sub": {
+ "name": "UQ_kilo_pass_pause_events_one_open_per_sub",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_pause_events",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_pause_events_resumed_at_after_paused_at_check": {
+ "name": "kilo_pass_pause_events_resumed_at_after_paused_at_check",
+ "value": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL OR \"kilo_pass_pause_events\".\"resumed_at\" >= \"kilo_pass_pause_events\".\"paused_at\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_scheduled_changes": {
+ "name": "kilo_pass_scheduled_changes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_tier": {
+ "name": "from_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_cadence": {
+ "name": "from_cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_tier": {
+ "name": "to_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_cadence": {
+ "name": "to_cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_schedule_id": {
+ "name": "stripe_schedule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_at": {
+ "name": "effective_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_scheduled_changes_kilo_user_id": {
+ "name": "IDX_kilo_pass_scheduled_changes_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_status": {
+ "name": "IDX_kilo_pass_scheduled_changes_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_stripe_subscription_id": {
+ "name": "IDX_kilo_pass_scheduled_changes_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id": {
+ "name": "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_scheduled_changes\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_effective_at": {
+ "name": "IDX_kilo_pass_scheduled_changes_effective_at",
+ "columns": [
+ {
+ "expression": "effective_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_deleted_at": {
+ "name": "IDX_kilo_pass_scheduled_changes_deleted_at",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_scheduled_changes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk": {
+ "name": "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk",
+ "tableFrom": "kilo_pass_scheduled_changes",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "stripe_subscription_id"
+ ],
+ "columnsTo": [
+ "stripe_subscription_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_scheduled_changes_from_tier_check": {
+ "name": "kilo_pass_scheduled_changes_from_tier_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"from_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_scheduled_changes_from_cadence_check": {
+ "name": "kilo_pass_scheduled_changes_from_cadence_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"from_cadence\" IN ('monthly', 'yearly')"
+ },
+ "kilo_pass_scheduled_changes_to_tier_check": {
+ "name": "kilo_pass_scheduled_changes_to_tier_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"to_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_scheduled_changes_to_cadence_check": {
+ "name": "kilo_pass_scheduled_changes_to_cadence_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"to_cadence\" IN ('monthly', 'yearly')"
+ },
+ "kilo_pass_scheduled_changes_status_check": {
+ "name": "kilo_pass_scheduled_changes_status_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"status\" IN ('not_started', 'active', 'completed', 'released', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_store_events": {
+ "name": "kilo_pass_store_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_transaction_id": {
+ "name": "provider_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_account_token": {
+ "name": "app_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment": {
+ "name": "environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "processing_started_at": {
+ "name": "processing_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processed_at": {
+ "name": "processed_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": {
+ "UQ_kilo_pass_store_events_provider_event": {
+ "name": "UQ_kilo_pass_store_events_provider_event",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_events_provider_subscription": {
+ "name": "IDX_kilo_pass_store_events_provider_subscription",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_events_app_account_token": {
+ "name": "IDX_kilo_pass_store_events_app_account_token",
+ "columns": [
+ {
+ "expression": "app_account_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_store_events_payment_provider_check": {
+ "name": "kilo_pass_store_events_payment_provider_check",
+ "value": "\"kilo_pass_store_events\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_store_purchases": {
+ "name": "kilo_pass_store_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_transaction_id": {
+ "name": "provider_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_original_transaction_id": {
+ "name": "provider_original_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_account_token": {
+ "name": "app_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "purchase_token": {
+ "name": "purchase_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environment": {
+ "name": "environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purchased_at": {
+ "name": "purchased_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_payload_json": {
+ "name": "raw_payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kilo_pass_store_purchases_provider_transaction": {
+ "name": "UQ_kilo_pass_store_purchases_provider_transaction",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_subscription_id": {
+ "name": "IDX_kilo_pass_store_purchases_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_user_id": {
+ "name": "IDX_kilo_pass_store_purchases_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_app_account_token": {
+ "name": "IDX_kilo_pass_store_purchases_app_account_token",
+ "columns": [
+ {
+ "expression": "app_account_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_latest_subscription_purchase": {
+ "name": "IDX_kilo_pass_store_purchases_latest_subscription_purchase",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "purchased_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "FK_kilo_pass_store_purchases_subscription_owner_provider": {
+ "name": "FK_kilo_pass_store_purchases_subscription_owner_provider",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id",
+ "kilo_user_id",
+ "payment_provider",
+ "provider_subscription_id"
+ ],
+ "columnsTo": [
+ "id",
+ "kilo_user_id",
+ "payment_provider",
+ "provider_subscription_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_store_purchases_store_provider_check": {
+ "name": "kilo_pass_store_purchases_store_provider_check",
+ "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('app_store', 'google_play')"
+ },
+ "kilo_pass_store_purchases_payment_provider_check": {
+ "name": "kilo_pass_store_purchases_payment_provider_check",
+ "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_subscriptions": {
+ "name": "kilo_pass_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'stripe'"
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tier": {
+ "name": "tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cadence": {
+ "name": "cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_streak_months": {
+ "name": "current_streak_months",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_yearly_issue_at": {
+ "name": "next_yearly_issue_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_subscriptions_kilo_user_id": {
+ "name": "IDX_kilo_pass_subscriptions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_payment_provider": {
+ "name": "IDX_kilo_pass_subscriptions_payment_provider",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_status": {
+ "name": "IDX_kilo_pass_subscriptions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_cadence": {
+ "name": "IDX_kilo_pass_subscriptions_cadence",
+ "columns": [
+ {
+ "expression": "cadence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_subscriptions_provider_subscription": {
+ "name": "UQ_kilo_pass_subscriptions_provider_subscription",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_subscriptions_store_purchase_reference": {
+ "name": "UQ_kilo_pass_subscriptions_store_purchase_reference",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilo_pass_subscriptions_stripe_subscription_id_unique": {
+ "name": "kilo_pass_subscriptions_stripe_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_subscriptions_current_streak_months_non_negative_check": {
+ "name": "kilo_pass_subscriptions_current_streak_months_non_negative_check",
+ "value": "\"kilo_pass_subscriptions\".\"current_streak_months\" >= 0"
+ },
+ "kilo_pass_subscriptions_provider_ids_check": {
+ "name": "kilo_pass_subscriptions_provider_ids_check",
+ "value": "(\n \"kilo_pass_subscriptions\".\"payment_provider\" = 'stripe'\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" = \"kilo_pass_subscriptions\".\"stripe_subscription_id\"\n ) OR (\n \"kilo_pass_subscriptions\".\"payment_provider\" IN ('app_store', 'google_play')\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NULL\n )"
+ },
+ "kilo_pass_subscriptions_payment_provider_check": {
+ "name": "kilo_pass_subscriptions_payment_provider_check",
+ "value": "\"kilo_pass_subscriptions\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ },
+ "kilo_pass_subscriptions_tier_check": {
+ "name": "kilo_pass_subscriptions_tier_check",
+ "value": "\"kilo_pass_subscriptions\".\"tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_subscriptions_cadence_check": {
+ "name": "kilo_pass_subscriptions_cadence_check",
+ "value": "\"kilo_pass_subscriptions\".\"cadence\" IN ('monthly', 'yearly')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_welcome_promo_payment_fingerprint_claims": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims",
+ "schema": "",
+ "columns": {
+ "stripe_payment_method_type": {
+ "name": "stripe_payment_method_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_fingerprint": {
+ "name": "stripe_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_stripe_invoice_id": {
+ "name": "source_stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk",
+ "columns": [
+ "stripe_payment_method_type",
+ "stripe_fingerprint"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id": {
+ "name": "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_stripe_invoice_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check",
+ "value": "\"kilo_pass_welcome_promo_payment_fingerprint_claims\".\"stripe_payment_method_type\" IN ('card', 'sepa_debit', 'us_bank_account', 'bacs_debit', 'au_becs_debit')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_access_codes": {
+ "name": "kiloclaw_access_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redeemed_at": {
+ "name": "redeemed_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": {
+ "UQ_kiloclaw_access_codes_code": {
+ "name": "UQ_kiloclaw_access_codes_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_access_codes_user_status": {
+ "name": "IDX_kiloclaw_access_codes_user_status",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_access_codes_one_active_per_user": {
+ "name": "UQ_kiloclaw_access_codes_one_active_per_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "status = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_access_codes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_admin_audit_logs": {
+ "name": "kiloclaw_admin_audit_logs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_admin_audit_logs_target_user_id": {
+ "name": "IDX_kiloclaw_admin_audit_logs_target_user_id",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_admin_audit_logs_action": {
+ "name": "IDX_kiloclaw_admin_audit_logs_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_admin_audit_logs_created_at": {
+ "name": "IDX_kiloclaw_admin_audit_logs_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_cli_runs": {
+ "name": "kiloclaw_cli_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiated_by_admin_id": {
+ "name": "initiated_by_admin_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "exit_code": {
+ "name": "exit_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_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": {
+ "IDX_kiloclaw_cli_runs_user_id": {
+ "name": "IDX_kiloclaw_cli_runs_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_cli_runs_started_at": {
+ "name": "IDX_kiloclaw_cli_runs_started_at",
+ "columns": [
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_cli_runs_instance_id": {
+ "name": "IDX_kiloclaw_cli_runs_instance_id",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_cli_runs_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_cli_runs_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "initiated_by_admin_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_earlybird_purchases": {
+ "name": "kiloclaw_earlybird_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manual_payment_id": {
+ "name": "manual_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_cents": {
+ "name": "amount_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_earlybird_purchases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_earlybird_purchases_user_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "kiloclaw_earlybird_purchases_stripe_charge_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_stripe_charge_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_charge_id"
+ ]
+ },
+ "kiloclaw_earlybird_purchases_manual_payment_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_manual_payment_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "manual_payment_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_email_log": {
+ "name": "kiloclaw_email_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_type": {
+ "name": "email_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_start": {
+ "name": "period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'epoch'"
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_email_log_user_type_global": {
+ "name": "UQ_kiloclaw_email_log_user_type_global",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_email_log_user_instance_type_period": {
+ "name": "UQ_kiloclaw_email_log_user_instance_type_period",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_start",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_email_log_type_sent_instance": {
+ "name": "IDX_kiloclaw_email_log_type_sent_instance",
+ "columns": [
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sent_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_email_log_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_email_log_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_email_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_email_log",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_google_oauth_connections": {
+ "name": "kiloclaw_google_oauth_connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'google'"
+ },
+ "account_email": {
+ "name": "account_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_subject": {
+ "name": "account_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_secret_encrypted": {
+ "name": "oauth_client_secret_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_profile": {
+ "name": "credential_profile",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kilo_owned'"
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "grants_by_source": {
+ "name": "grants_by_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "capabilities": {
+ "name": "capabilities",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_at": {
+ "name": "last_error_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_at": {
+ "name": "connected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_google_oauth_connections_instance": {
+ "name": "UQ_kiloclaw_google_oauth_connections_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_google_oauth_connections_status": {
+ "name": "IDX_kiloclaw_google_oauth_connections_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_google_oauth_connections_provider": {
+ "name": "IDX_kiloclaw_google_oauth_connections_provider",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_google_oauth_connections",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_google_oauth_connections_status_check": {
+ "name": "kiloclaw_google_oauth_connections_status_check",
+ "value": "\"kiloclaw_google_oauth_connections\".\"status\" IN ('active', 'action_required', 'disconnected')"
+ },
+ "kiloclaw_google_oauth_connections_credential_profile_check": {
+ "name": "kiloclaw_google_oauth_connections_credential_profile_check",
+ "value": "\"kiloclaw_google_oauth_connections\".\"credential_profile\" IN ('legacy', 'kilo_owned')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_image_catalog": {
+ "name": "kiloclaw_image_catalog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "openclaw_version": {
+ "name": "openclaw_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "variant": {
+ "name": "variant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "image_tag": {
+ "name": "image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image_digest": {
+ "name": "image_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'available'"
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "rollout_percent": {
+ "name": "rollout_percent",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "is_latest": {
+ "name": "is_latest",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_image_catalog_status": {
+ "name": "IDX_kiloclaw_image_catalog_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_image_catalog_variant": {
+ "name": "IDX_kiloclaw_image_catalog_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_image_catalog_one_latest_per_variant": {
+ "name": "UQ_kiloclaw_image_catalog_one_latest_per_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_image_catalog\".\"is_latest\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_image_catalog_one_candidate_per_variant": {
+ "name": "UQ_kiloclaw_image_catalog_one_candidate_per_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_image_catalog\".\"is_latest\" = false AND \"kiloclaw_image_catalog\".\"rollout_percent\" > 0 AND \"kiloclaw_image_catalog\".\"status\" = 'available'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_image_catalog_image_tag_unique": {
+ "name": "kiloclaw_image_catalog_image_tag_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "image_tag"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_inbound_email_aliases": {
+ "name": "kiloclaw_inbound_email_aliases",
+ "schema": "",
+ "columns": {
+ "alias": {
+ "name": "alias",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "retired_at": {
+ "name": "retired_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_inbound_email_aliases_instance_id": {
+ "name": "IDX_kiloclaw_inbound_email_aliases_instance_id",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_inbound_email_aliases_active_instance": {
+ "name": "UQ_kiloclaw_inbound_email_aliases_active_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_inbound_email_aliases\".\"retired_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_inbound_email_aliases",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_inbound_email_reserved_aliases": {
+ "name": "kiloclaw_inbound_email_reserved_aliases",
+ "schema": "",
+ "columns": {
+ "alias": {
+ "name": "alias",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_instances": {
+ "name": "kiloclaw_instances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'fly'"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inbound_email_enabled": {
+ "name": "inbound_email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "inactive_trial_stopped_at": {
+ "name": "inactive_trial_stopped_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()"
+ },
+ "destroyed_at": {
+ "name": "destroyed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tracked_image_tag": {
+ "name": "tracked_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_type": {
+ "name": "instance_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "admin_size_override": {
+ "name": "admin_size_override",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_instances_active": {
+ "name": "UQ_kiloclaw_instances_active",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sandbox_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_personal_by_user": {
+ "name": "IDX_kiloclaw_instances_active_personal_by_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_org_by_user_org": {
+ "name": "IDX_kiloclaw_instances_active_org_by_user_org",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_org_by_org_created": {
+ "name": "IDX_kiloclaw_instances_active_org_by_org_created",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_user_id_created_at": {
+ "name": "IDX_kiloclaw_instances_user_id_created_at",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_tracked_image_tag": {
+ "name": "IDX_kiloclaw_instances_tracked_image_tag",
+ "columns": [
+ {
+ "expression": "tracked_image_tag",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_instance_type": {
+ "name": "IDX_kiloclaw_instances_instance_type",
+ "columns": [
+ {
+ "expression": "instance_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_admin_size_override": {
+ "name": "IDX_kiloclaw_instances_admin_size_override",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"admin_size_override\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_instances_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_instances_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_instances",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_instances_organization_id_organizations_id_fk": {
+ "name": "kiloclaw_instances_organization_id_organizations_id_fk",
+ "tableFrom": "kiloclaw_instances",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_kiloclaw_instances_instance_type": {
+ "name": "CHK_kiloclaw_instances_instance_type",
+ "value": "\"kiloclaw_instances\".\"instance_type\" IS NULL OR \"kiloclaw_instances\".\"instance_type\" IN ('perf-1-3', 'perf-4-8', 'perf-4-16', 'shared-2-3', 'shared-2-4', 'custom')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_morning_briefing_configs": {
+ "name": "kiloclaw_morning_briefing_configs",
+ "schema": "",
+ "columns": {
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0 7 * * *'"
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "interest_topics": {
+ "name": "interest_topics",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_morning_briefing_configs_enabled": {
+ "name": "IDX_kiloclaw_morning_briefing_configs_enabled",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_morning_briefing_configs\".\"enabled\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_morning_briefing_configs",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_notifications": {
+ "name": "kiloclaw_scheduled_action_notifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'notice'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel": {
+ "name": "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_notifications_pending": {
+ "name": "IDX_kiloclaw_scheduled_action_notifications_pending",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_notifications\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk": {
+ "name": "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_notifications",
+ "tableTo": "kiloclaw_scheduled_action_targets",
+ "columnsFrom": [
+ "target_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_stages": {
+ "name": "kiloclaw_scheduled_action_stages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_index": {
+ "name": "stage_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_at": {
+ "name": "scheduled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "notice_sent_at": {
+ "name": "notice_sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applied_count": {
+ "name": "applied_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "skipped_count": {
+ "name": "skipped_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "failed_count": {
+ "name": "failed_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_stages_parent_index": {
+ "name": "UQ_kiloclaw_scheduled_action_stages_parent_index",
+ "columns": [
+ {
+ "expression": "scheduled_action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stage_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_stages_notice_due": {
+ "name": "IDX_kiloclaw_scheduled_action_stages_notice_due",
+ "columns": [
+ {
+ "expression": "scheduled_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_stages\".\"notice_sent_at\" IS NULL AND \"kiloclaw_scheduled_action_stages\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
+ "name": "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_stages",
+ "tableTo": "kiloclaw_scheduled_actions",
+ "columnsFrom": [
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_targets": {
+ "name": "kiloclaw_scheduled_action_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_image_tag": {
+ "name": "source_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_image_tag": {
+ "name": "target_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "skip_reason": {
+ "name": "skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_targets_parent_instance": {
+ "name": "UQ_kiloclaw_scheduled_action_targets_parent_instance",
+ "columns": [
+ {
+ "expression": "scheduled_action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_targets_stage": {
+ "name": "IDX_kiloclaw_scheduled_action_targets_stage",
+ "columns": [
+ {
+ "expression": "stage_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_targets_pending_by_instance": {
+ "name": "IDX_kiloclaw_scheduled_action_targets_pending_by_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_targets\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_scheduled_actions",
+ "columnsFrom": [
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_scheduled_action_stages",
+ "columnsFrom": [
+ "stage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_actions": {
+ "name": "kiloclaw_scheduled_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_image_tag": {
+ "name": "target_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "override_pins": {
+ "name": "override_pins",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "notice_lead_hours": {
+ "name": "notice_lead_hours",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 24
+ },
+ "notice_subject": {
+ "name": "notice_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "notice_body": {
+ "name": "notice_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'scheduled'"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled_at": {
+ "name": "cancelled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_count": {
+ "name": "total_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "applied_count": {
+ "name": "applied_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "skipped_count": {
+ "name": "skipped_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "failed_count": {
+ "name": "failed_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_scheduled_actions_status": {
+ "name": "IDX_kiloclaw_scheduled_actions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_actions_action_type": {
+ "name": "IDX_kiloclaw_scheduled_actions_action_type",
+ "columns": [
+ {
+ "expression": "action_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_actions_created_by": {
+ "name": "IDX_kiloclaw_scheduled_actions_created_by",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk": {
+ "name": "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk",
+ "tableFrom": "kiloclaw_scheduled_actions",
+ "tableTo": "kiloclaw_image_catalog",
+ "columnsFrom": [
+ "target_image_tag"
+ ],
+ "columnsTo": [
+ "image_tag"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk": {
+ "name": "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_scheduled_actions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_subscription_change_log": {
+ "name": "kiloclaw_subscription_change_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "before_state": {
+ "name": "before_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "after_state": {
+ "name": "after_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_subscription_change_log_subscription_created_at": {
+ "name": "IDX_kiloclaw_subscription_change_log_subscription_created_at",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscription_change_log_created_at": {
+ "name": "IDX_kiloclaw_subscription_change_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_subscription_change_log",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_subscription_change_log_actor_type_check": {
+ "name": "kiloclaw_subscription_change_log_actor_type_check",
+ "value": "\"kiloclaw_subscription_change_log\".\"actor_type\" IN ('user', 'system')"
+ },
+ "kiloclaw_subscription_change_log_action_check": {
+ "name": "kiloclaw_subscription_change_log_action_check",
+ "value": "\"kiloclaw_subscription_change_log\".\"action\" IN ('created', 'status_changed', 'plan_switched', 'period_advanced', 'canceled', 'reactivated', 'suspended', 'destruction_scheduled', 'reassigned', 'backfilled', 'payment_source_changed', 'schedule_changed', 'admin_override')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_subscriptions": {
+ "name": "kiloclaw_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_schedule_id": {
+ "name": "stripe_schedule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transferred_to_subscription_id": {
+ "name": "transferred_to_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_origin": {
+ "name": "access_origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payment_source": {
+ "name": "payment_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kiloclaw_price_version": {
+ "name": "kiloclaw_price_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_plan": {
+ "name": "scheduled_plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scheduled_by": {
+ "name": "scheduled_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "pending_conversion": {
+ "name": "pending_conversion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "trial_started_at": {
+ "name": "trial_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_start": {
+ "name": "current_period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_renewal_at": {
+ "name": "credit_renewal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "commit_ends_at": {
+ "name": "commit_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "past_due_since": {
+ "name": "past_due_since",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_at": {
+ "name": "suspended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "destruction_deadline": {
+ "name": "destruction_deadline",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_requested_at": {
+ "name": "auto_resume_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_retry_after": {
+ "name": "auto_resume_retry_after",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_attempt_count": {
+ "name": "auto_resume_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "auto_top_up_triggered_for_period": {
+ "name": "auto_top_up_triggered_for_period",
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_subscriptions_status": {
+ "name": "IDX_kiloclaw_subscriptions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_user_id": {
+ "name": "IDX_kiloclaw_subscriptions_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_user_status": {
+ "name": "IDX_kiloclaw_subscriptions_user_status",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_price_version": {
+ "name": "IDX_kiloclaw_subscriptions_price_version",
+ "columns": [
+ {
+ "expression": "kiloclaw_price_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_transferred_to": {
+ "name": "IDX_kiloclaw_subscriptions_transferred_to",
+ "columns": [
+ {
+ "expression": "transferred_to_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_stripe_schedule_id": {
+ "name": "IDX_kiloclaw_subscriptions_stripe_schedule_id",
+ "columns": [
+ {
+ "expression": "stripe_schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_auto_resume_retry_after": {
+ "name": "IDX_kiloclaw_subscriptions_auto_resume_retry_after",
+ "columns": [
+ {
+ "expression": "auto_resume_retry_after",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_subscriptions_instance": {
+ "name": "UQ_kiloclaw_subscriptions_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_subscriptions\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_subscriptions_transferred_to": {
+ "name": "UQ_kiloclaw_subscriptions_transferred_to",
+ "columns": [
+ {
+ "expression": "transferred_to_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_subscriptions\".\"transferred_to_subscription_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_earlybird_origin": {
+ "name": "IDX_kiloclaw_subscriptions_earlybird_origin",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "access_origin",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_subscriptions\".\"access_origin\" = 'earlybird'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_subscriptions_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_subscriptions_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "transferred_to_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_subscriptions_stripe_subscription_id_unique": {
+ "name": "kiloclaw_subscriptions_stripe_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_subscriptions_price_version_check": {
+ "name": "kiloclaw_subscriptions_price_version_check",
+ "value": "\"kiloclaw_subscriptions\".\"kiloclaw_price_version\" IN ('2026-03-19', '2026-05-10')"
+ },
+ "kiloclaw_subscriptions_plan_check": {
+ "name": "kiloclaw_subscriptions_plan_check",
+ "value": "\"kiloclaw_subscriptions\".\"plan\" IN ('trial', 'commit', 'standard')"
+ },
+ "kiloclaw_subscriptions_scheduled_plan_check": {
+ "name": "kiloclaw_subscriptions_scheduled_plan_check",
+ "value": "\"kiloclaw_subscriptions\".\"scheduled_plan\" IN ('commit', 'standard')"
+ },
+ "kiloclaw_subscriptions_scheduled_by_check": {
+ "name": "kiloclaw_subscriptions_scheduled_by_check",
+ "value": "\"kiloclaw_subscriptions\".\"scheduled_by\" IN ('auto', 'user')"
+ },
+ "kiloclaw_subscriptions_status_check": {
+ "name": "kiloclaw_subscriptions_status_check",
+ "value": "\"kiloclaw_subscriptions\".\"status\" IN ('trialing', 'active', 'past_due', 'canceled', 'unpaid')"
+ },
+ "kiloclaw_subscriptions_access_origin_check": {
+ "name": "kiloclaw_subscriptions_access_origin_check",
+ "value": "\"kiloclaw_subscriptions\".\"access_origin\" IN ('earlybird')"
+ },
+ "kiloclaw_subscriptions_payment_source_check": {
+ "name": "kiloclaw_subscriptions_payment_source_check",
+ "value": "\"kiloclaw_subscriptions\".\"payment_source\" IN ('stripe', 'credits')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_terminal_renewal_failures": {
+ "name": "kiloclaw_terminal_renewal_failures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "renewal_boundary": {
+ "name": "renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unresolved'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "first_failure_at": {
+ "name": "first_failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_at": {
+ "name": "last_failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_code": {
+ "name": "last_failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_message": {
+ "name": "last_failure_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_actor_type": {
+ "name": "resolution_actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_actor_id": {
+ "name": "resolution_actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_at": {
+ "name": "resolution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_reason": {
+ "name": "resolution_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary": {
+ "name": "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "renewal_boundary",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_terminal_renewal_failures_unresolved": {
+ "name": "IDX_kiloclaw_terminal_renewal_failures_unresolved",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "renewal_boundary",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_terminal_renewal_failures\".\"status\" = 'unresolved'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at": {
+ "name": "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "last_failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_terminal_renewal_failures",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_terminal_renewal_failures_status_check": {
+ "name": "kiloclaw_terminal_renewal_failures_status_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"status\" IN ('unresolved', 'resolved', 'waived', 'superseded')"
+ },
+ "kiloclaw_terminal_renewal_failures_last_failure_code_check": {
+ "name": "kiloclaw_terminal_renewal_failures_last_failure_code_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"last_failure_code\" IN ('credit_balance_read_failed', 'renewal_transaction_failed', 'auto_top_up_marker_write_failed', 'worker_timeout', 'poison_payload', 'queue_delivery_exhausted')"
+ },
+ "kiloclaw_terminal_renewal_failures_resolution_actor_type_check": {
+ "name": "kiloclaw_terminal_renewal_failures_resolution_actor_type_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"resolution_actor_type\" IN ('operator', 'system')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_version_pins": {
+ "name": "kiloclaw_version_pins",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image_tag": {
+ "name": "image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pinned_by": {
+ "name": "pinned_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk": {
+ "name": "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kiloclaw_image_catalog",
+ "columnsFrom": [
+ "image_tag"
+ ],
+ "columnsTo": [
+ "image_tag"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk": {
+ "name": "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "pinned_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_version_pins_instance_id_unique": {
+ "name": "kiloclaw_version_pins_instance_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "instance_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kilocode_users": {
+ "name": "kilocode_users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "google_user_email": {
+ "name": "google_user_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "google_user_name": {
+ "name": "google_user_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "google_user_image_url": {
+ "name": "google_user_image_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hosted_domain": {
+ "name": "hosted_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "microdollars_used": {
+ "name": "microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "kilo_pass_threshold": {
+ "name": "kilo_pass_threshold",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "app_store_account_token": {
+ "name": "app_store_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_manage_credits": {
+ "name": "can_manage_credits",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "total_microdollars_acquired": {
+ "name": "total_microdollars_acquired",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "next_credit_expiration_at": {
+ "name": "next_credit_expiration_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_validation_stytch": {
+ "name": "has_validation_stytch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_validation_novel_card_with_hold": {
+ "name": "has_validation_novel_card_with_hold",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_at": {
+ "name": "blocked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_by_kilo_user_id": {
+ "name": "blocked_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_token_pepper": {
+ "name": "api_token_pepper",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "web_session_pepper": {
+ "name": "web_session_pepper",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_enabled": {
+ "name": "auto_top_up_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_bot": {
+ "name": "is_bot",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "kiloclaw_early_access": {
+ "name": "kiloclaw_early_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_model": {
+ "name": "default_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cohorts": {
+ "name": "cohorts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "completed_welcome_form": {
+ "name": "completed_welcome_form",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "linkedin_url": {
+ "name": "linkedin_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_url": {
+ "name": "github_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discord_server_membership_verified_at": {
+ "name": "discord_server_membership_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_upstream_safety_identifier": {
+ "name": "openrouter_upstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_downstream_safety_identifier": {
+ "name": "openrouter_downstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_downstream_safety_identifier": {
+ "name": "vercel_downstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "customer_source": {
+ "name": "customer_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signup_ip": {
+ "name": "signup_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_deletion_requested_at": {
+ "name": "account_deletion_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "normalized_email": {
+ "name": "normalized_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_domain": {
+ "name": "email_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kilocode_users_signup_ip_created_at": {
+ "name": "IDX_kilocode_users_signup_ip_created_at",
+ "columns": [
+ {
+ "expression": "signup_ip",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_blocked_at": {
+ "name": "IDX_kilocode_users_blocked_at",
+ "columns": [
+ {
+ "expression": "blocked_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_blocked_by_kilo_user_id": {
+ "name": "IDX_kilocode_users_blocked_by_kilo_user_id",
+ "columns": [
+ {
+ "expression": "blocked_by_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_openrouter_upstream_safety_identifier": {
+ "name": "UQ_kilocode_users_openrouter_upstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "openrouter_upstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"openrouter_upstream_safety_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_openrouter_downstream_safety_identifier": {
+ "name": "UQ_kilocode_users_openrouter_downstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "openrouter_downstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"openrouter_downstream_safety_identifier\" IS NOT NULL",
+ "concurrently": true,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_vercel_downstream_safety_identifier": {
+ "name": "UQ_kilocode_users_vercel_downstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "vercel_downstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"vercel_downstream_safety_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_normalized_email": {
+ "name": "IDX_kilocode_users_normalized_email",
+ "columns": [
+ {
+ "expression": "normalized_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_email_domain": {
+ "name": "IDX_kilocode_users_email_domain",
+ "columns": [
+ {
+ "expression": "email_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilocode_users_app_store_account_token_unique": {
+ "name": "kilocode_users_app_store_account_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "app_store_account_token"
+ ]
+ },
+ "UQ_b1afacbcf43f2c7c4cb9f7e7faa": {
+ "name": "UQ_b1afacbcf43f2c7c4cb9f7e7faa",
+ "nullsNotDistinct": false,
+ "columns": [
+ "google_user_email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "blocked_reason_not_empty": {
+ "name": "blocked_reason_not_empty",
+ "value": "length(blocked_reason) > 0"
+ },
+ "kilocode_users_can_manage_credits_requires_admin_check": {
+ "name": "kilocode_users_can_manage_credits_requires_admin_check",
+ "value": "NOT \"kilocode_users\".\"can_manage_credits\" OR \"kilocode_users\".\"is_admin\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.magic_link_tokens": {
+ "name": "magic_link_tokens",
+ "schema": "",
+ "columns": {
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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": {
+ "idx_magic_link_tokens_email": {
+ "name": "idx_magic_link_tokens_email",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_magic_link_tokens_expires_at": {
+ "name": "idx_magic_link_tokens_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "check_expires_at_future": {
+ "name": "check_expires_at_future",
+ "value": "\"magic_link_tokens\".\"expires_at\" > \"magic_link_tokens\".\"created_at\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_assignments": {
+ "name": "mcp_gateway_assignments",
+ "schema": "",
+ "columns": {
+ "assignment_id": {
+ "name": "assignment_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "assigned_by_kilo_user_id": {
+ "name": "assigned_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "single_user_slot": {
+ "name": "single_user_slot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_assignments_active": {
+ "name": "UQ_mcp_gateway_assignments_active",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_assignments_single_user_slot": {
+ "name": "UQ_mcp_gateway_assignments_single_user_slot",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "single_user_slot",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null and \"mcp_gateway_assignments\".\"single_user_slot\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_assignments_config": {
+ "name": "IDX_mcp_gateway_assignments_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_assignments_user": {
+ "name": "IDX_mcp_gateway_assignments_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "assigned_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_audit_events": {
+ "name": "mcp_gateway_audit_events",
+ "schema": "",
+ "columns": {
+ "audit_event_id": {
+ "name": "audit_event_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "actor_kilo_user_id": {
+ "name": "actor_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connect_resource_id": {
+ "name": "connect_resource_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_metadata": {
+ "name": "correlation_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_mcp_gateway_audit_events_config": {
+ "name": "IDX_mcp_gateway_audit_events_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_audit_events_owner": {
+ "name": "IDX_mcp_gateway_audit_events_owner",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_audit_events_created_at": {
+ "name": "IDX_mcp_gateway_audit_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "actor_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk": {
+ "name": "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_connect_resources",
+ "columnsFrom": [
+ "connect_resource_id"
+ ],
+ "columnsTo": [
+ "connect_resource_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_audit_events_owner_scope": {
+ "name": "mcp_gateway_audit_events_owner_scope",
+ "value": "\"mcp_gateway_audit_events\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_audit_events_outcome": {
+ "name": "mcp_gateway_audit_events_outcome",
+ "value": "\"mcp_gateway_audit_events\".\"outcome\" IN ('success', 'failure', 'blocked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_authorization_codes": {
+ "name": "mcp_gateway_authorization_codes",
+ "schema": "",
+ "columns": {
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uri": {
+ "name": "redirect_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_challenge": {
+ "name": "code_challenge",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge_method": {
+ "name": "code_challenge_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'S256'"
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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": {
+ "UQ_mcp_gateway_authorization_codes_code_hash": {
+ "name": "UQ_mcp_gateway_authorization_codes_code_hash",
+ "columns": [
+ {
+ "expression": "code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_codes_expires_at": {
+ "name": "IDX_mcp_gateway_authorization_codes_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_codes_client": {
+ "name": "IDX_mcp_gateway_authorization_codes_client",
+ "columns": [
+ {
+ "expression": "oauth_client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
+ "name": "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_authorization_requests",
+ "columnsFrom": [
+ "authorization_request_id"
+ ],
+ "columnsTo": [
+ "authorization_request_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_authorization_codes_owner_scope": {
+ "name": "mcp_gateway_authorization_codes_owner_scope",
+ "value": "\"mcp_gateway_authorization_codes\".\"owner_scope\" IN ('personal', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_authorization_requests": {
+ "name": "mcp_gateway_authorization_requests",
+ "schema": "",
+ "columns": {
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "request_state_hash": {
+ "name": "request_state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uri": {
+ "name": "redirect_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_scopes": {
+ "name": "requested_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_state": {
+ "name": "oauth_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge": {
+ "name": "code_challenge",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge_method": {
+ "name": "code_challenge_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'S256'"
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_status": {
+ "name": "request_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_authorization_requests_state_hash": {
+ "name": "UQ_mcp_gateway_authorization_requests_state_hash",
+ "columns": [
+ {
+ "expression": "request_state_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_config": {
+ "name": "IDX_mcp_gateway_authorization_requests_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_user": {
+ "name": "IDX_mcp_gateway_authorization_requests_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_expires_at": {
+ "name": "IDX_mcp_gateway_authorization_requests_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_authorization_requests_owner_scope": {
+ "name": "mcp_gateway_authorization_requests_owner_scope",
+ "value": "\"mcp_gateway_authorization_requests\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_authorization_requests_status": {
+ "name": "mcp_gateway_authorization_requests_status",
+ "value": "\"mcp_gateway_authorization_requests\".\"request_status\" IN ('pending', 'completed', 'error')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_config_secrets": {
+ "name": "mcp_gateway_config_secrets",
+ "schema": "",
+ "columns": {
+ "config_secret_id": {
+ "name": "config_secret_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret_kind": {
+ "name": "secret_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_secret": {
+ "name": "encrypted_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret_version": {
+ "name": "secret_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_config_secrets_active_kind": {
+ "name": "UQ_mcp_gateway_config_secrets_active_kind",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "secret_kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_config_secrets\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_config_secrets_config": {
+ "name": "IDX_mcp_gateway_config_secrets_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_config_secrets",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_config_secrets_version_positive": {
+ "name": "mcp_gateway_config_secrets_version_positive",
+ "value": "\"mcp_gateway_config_secrets\".\"secret_version\" > 0"
+ },
+ "mcp_gateway_config_secrets_kind": {
+ "name": "mcp_gateway_config_secrets_kind",
+ "value": "\"mcp_gateway_config_secrets\".\"secret_kind\" IN ('static_provider_credentials', 'dynamic_registration', 'static_headers')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_configs": {
+ "name": "mcp_gateway_configs",
+ "schema": "",
+ "columns": {
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_url": {
+ "name": "remote_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_mode": {
+ "name": "auth_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sharing_mode": {
+ "name": "sharing_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_scopes": {
+ "name": "provider_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_scope_source": {
+ "name": "provider_scope_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'none'"
+ },
+ "provider_resource": {
+ "name": "provider_resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "path_passthrough": {
+ "name": "path_passthrough",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "config_version": {
+ "name": "config_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "discovered_provider_metadata": {
+ "name": "discovered_provider_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registry_metadata": {
+ "name": "registry_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "auxiliary_headers": {
+ "name": "auxiliary_headers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_mcp_gateway_configs_owner": {
+ "name": "IDX_mcp_gateway_configs_owner",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_configs_enabled": {
+ "name": "IDX_mcp_gateway_configs_enabled",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_configs_remote_url": {
+ "name": "IDX_mcp_gateway_configs_remote_url",
+ "columns": [
+ {
+ "expression": "remote_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_configs_name_not_empty": {
+ "name": "mcp_gateway_configs_name_not_empty",
+ "value": "length(trim(\"mcp_gateway_configs\".\"name\")) > 0"
+ },
+ "mcp_gateway_configs_config_version_positive": {
+ "name": "mcp_gateway_configs_config_version_positive",
+ "value": "\"mcp_gateway_configs\".\"config_version\" > 0"
+ },
+ "mcp_gateway_configs_personal_single_user": {
+ "name": "mcp_gateway_configs_personal_single_user",
+ "value": "\"mcp_gateway_configs\".\"owner_scope\" <> 'personal' OR \"mcp_gateway_configs\".\"sharing_mode\" = 'single_user'"
+ },
+ "mcp_gateway_configs_owner_scope": {
+ "name": "mcp_gateway_configs_owner_scope",
+ "value": "\"mcp_gateway_configs\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_configs_auth_mode": {
+ "name": "mcp_gateway_configs_auth_mode",
+ "value": "\"mcp_gateway_configs\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
+ },
+ "mcp_gateway_configs_sharing_mode": {
+ "name": "mcp_gateway_configs_sharing_mode",
+ "value": "\"mcp_gateway_configs\".\"sharing_mode\" IN ('single_user', 'multi_user')"
+ },
+ "mcp_gateway_configs_provider_scope_source": {
+ "name": "mcp_gateway_configs_provider_scope_source",
+ "value": "\"mcp_gateway_configs\".\"provider_scope_source\" IN ('none', 'discovered', 'override')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_connect_resources": {
+ "name": "mcp_gateway_connect_resources",
+ "schema": "",
+ "columns": {
+ "connect_resource_id": {
+ "name": "connect_resource_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_url": {
+ "name": "canonical_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_status": {
+ "name": "route_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "route_version": {
+ "name": "route_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "rotated_at": {
+ "name": "rotated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_connect_resources_route_key": {
+ "name": "UQ_mcp_gateway_connect_resources_route_key",
+ "columns": [
+ {
+ "expression": "route_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_connect_resources_active_config": {
+ "name": "UQ_mcp_gateway_connect_resources_active_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_connect_resources\".\"route_status\" = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connect_resources_config": {
+ "name": "IDX_mcp_gateway_connect_resources_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connect_resources_canonical_url": {
+ "name": "IDX_mcp_gateway_connect_resources_canonical_url",
+ "columns": [
+ {
+ "expression": "canonical_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_connect_resources",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_connect_resources_route_key_format": {
+ "name": "mcp_gateway_connect_resources_route_key_format",
+ "value": "\"mcp_gateway_connect_resources\".\"route_key\" ~ '^[A-Za-z0-9_-]{32,}$'"
+ },
+ "mcp_gateway_connect_resources_route_version_positive": {
+ "name": "mcp_gateway_connect_resources_route_version_positive",
+ "value": "\"mcp_gateway_connect_resources\".\"route_version\" > 0"
+ },
+ "mcp_gateway_connect_resources_owner_scope": {
+ "name": "mcp_gateway_connect_resources_owner_scope",
+ "value": "\"mcp_gateway_connect_resources\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_connect_resources_route_status": {
+ "name": "mcp_gateway_connect_resources_route_status",
+ "value": "\"mcp_gateway_connect_resources\".\"route_status\" IN ('active', 'rotated', 'revoked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_connection_instances": {
+ "name": "mcp_gateway_connection_instances",
+ "schema": "",
+ "columns": {
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_status": {
+ "name": "instance_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "instance_version": {
+ "name": "instance_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "removed_at": {
+ "name": "removed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_connection_instances_non_terminal": {
+ "name": "UQ_mcp_gateway_connection_instances_non_terminal",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connection_instances_config": {
+ "name": "IDX_mcp_gateway_connection_instances_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connection_instances_user": {
+ "name": "IDX_mcp_gateway_connection_instances_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_connection_instances",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_connection_instances",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_connection_instances_version_positive": {
+ "name": "mcp_gateway_connection_instances_version_positive",
+ "value": "\"mcp_gateway_connection_instances\".\"instance_version\" > 0"
+ },
+ "mcp_gateway_connection_instances_owner_scope": {
+ "name": "mcp_gateway_connection_instances_owner_scope",
+ "value": "\"mcp_gateway_connection_instances\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_connection_instances_status": {
+ "name": "mcp_gateway_connection_instances_status",
+ "value": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth', 'revoked', 'removed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_oauth_clients": {
+ "name": "mcp_gateway_oauth_clients",
+ "schema": "",
+ "columns": {
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_name": {
+ "name": "client_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_token_hash": {
+ "name": "registration_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret_hash": {
+ "name": "client_secret_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_types": {
+ "name": "grant_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "declared_scopes": {
+ "name": "declared_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "registration_access_token_expires_at": {
+ "name": "registration_access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_oauth_clients_client_id": {
+ "name": "UQ_mcp_gateway_oauth_clients_client_id",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_oauth_clients_registration_token_hash": {
+ "name": "UQ_mcp_gateway_oauth_clients_registration_token_hash",
+ "columns": [
+ {
+ "expression": "registration_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_oauth_clients_deleted_at": {
+ "name": "IDX_mcp_gateway_oauth_clients_deleted_at",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_oauth_clients_client_id_format": {
+ "name": "mcp_gateway_oauth_clients_client_id_format",
+ "value": "\"mcp_gateway_oauth_clients\".\"client_id\" ~ '^[A-Za-z0-9._-]+:[A-Za-z0-9._-]+$'"
+ },
+ "mcp_gateway_oauth_clients_auth_method": {
+ "name": "mcp_gateway_oauth_clients_auth_method",
+ "value": "\"mcp_gateway_oauth_clients\".\"token_endpoint_auth_method\" IN ('none', 'client_secret_post', 'client_secret_basic')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_pending_provider_authorizations": {
+ "name": "mcp_gateway_pending_provider_authorizations",
+ "schema": "",
+ "columns": {
+ "pending_provider_authorization_id": {
+ "name": "pending_provider_authorization_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "state_hash": {
+ "name": "state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_url": {
+ "name": "remote_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_mode": {
+ "name": "auth_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_authorization_endpoint": {
+ "name": "provider_authorization_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_token_endpoint": {
+ "name": "provider_token_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_state": {
+ "name": "encrypted_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_version": {
+ "name": "config_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pending_status": {
+ "name": "pending_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_pending_provider_authorizations_state_hash": {
+ "name": "UQ_mcp_gateway_pending_provider_authorizations_state_hash",
+ "columns": [
+ {
+ "expression": "state_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_pending_provider_authorizations_config": {
+ "name": "IDX_mcp_gateway_pending_provider_authorizations_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_pending_provider_authorizations_expires_at": {
+ "name": "IDX_mcp_gateway_pending_provider_authorizations_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_authorization_requests",
+ "columnsFrom": [
+ "authorization_request_id"
+ ],
+ "columnsTo": [
+ "authorization_request_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_pending_provider_authorizations_config_version_positive": {
+ "name": "mcp_gateway_pending_provider_authorizations_config_version_positive",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"config_version\" > 0"
+ },
+ "mcp_gateway_pending_provider_authorizations_owner_scope": {
+ "name": "mcp_gateway_pending_provider_authorizations_owner_scope",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_pending_provider_authorizations_auth_mode": {
+ "name": "mcp_gateway_pending_provider_authorizations_auth_mode",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
+ },
+ "mcp_gateway_pending_provider_authorizations_status": {
+ "name": "mcp_gateway_pending_provider_authorizations_status",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"pending_status\" IN ('pending', 'completed', 'error')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_provider_grants": {
+ "name": "mcp_gateway_provider_grants",
+ "schema": "",
+ "columns": {
+ "provider_grant_id": {
+ "name": "provider_grant_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_grant": {
+ "name": "encrypted_grant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject": {
+ "name": "provider_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_scope": {
+ "name": "grant_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_status": {
+ "name": "grant_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "grant_version": {
+ "name": "grant_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_provider_grants_active_instance": {
+ "name": "UQ_mcp_gateway_provider_grants_active_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_provider_grants\".\"grant_status\" = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_provider_grants_instance": {
+ "name": "IDX_mcp_gateway_provider_grants_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_provider_grants",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_provider_grants_version_positive": {
+ "name": "mcp_gateway_provider_grants_version_positive",
+ "value": "\"mcp_gateway_provider_grants\".\"grant_version\" > 0"
+ },
+ "mcp_gateway_provider_grants_status": {
+ "name": "mcp_gateway_provider_grants_status",
+ "value": "\"mcp_gateway_provider_grants\".\"grant_status\" IN ('active', 'revoked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_rate_limit_windows": {
+ "name": "mcp_gateway_rate_limit_windows",
+ "schema": "",
+ "columns": {
+ "rate_limit_window_id": {
+ "name": "rate_limit_window_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_started_at": {
+ "name": "window_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_count": {
+ "name": "attempt_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_rate_limit_windows_ip_window": {
+ "name": "UQ_mcp_gateway_rate_limit_windows_ip_window",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "window_started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_rate_limit_windows_window": {
+ "name": "IDX_mcp_gateway_rate_limit_windows_window",
+ "columns": [
+ {
+ "expression": "window_started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_rate_limit_windows_attempt_count_non_negative": {
+ "name": "mcp_gateway_rate_limit_windows_attempt_count_non_negative",
+ "value": "\"mcp_gateway_rate_limit_windows\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_refresh_tokens": {
+ "name": "mcp_gateway_refresh_tokens",
+ "schema": "",
+ "columns": {
+ "refresh_token_id": {
+ "name": "refresh_token_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rotated_from_refresh_token_id": {
+ "name": "rotated_from_refresh_token_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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": {
+ "UQ_mcp_gateway_refresh_tokens_token_hash": {
+ "name": "UQ_mcp_gateway_refresh_tokens_token_hash",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_user": {
+ "name": "IDX_mcp_gateway_refresh_tokens_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_config": {
+ "name": "IDX_mcp_gateway_refresh_tokens_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_consumed_at": {
+ "name": "IDX_mcp_gateway_refresh_tokens_consumed_at",
+ "columns": [
+ {
+ "expression": "consumed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_refresh_tokens_owner_scope": {
+ "name": "mcp_gateway_refresh_tokens_owner_scope",
+ "value": "\"mcp_gateway_refresh_tokens\".\"owner_scope\" IN ('personal', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage": {
+ "name": "microdollar_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_write_tokens": {
+ "name": "cache_write_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_hit_tokens": {
+ "name": "cache_hit_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_model": {
+ "name": "requested_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_discount": {
+ "name": "cache_discount",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_error": {
+ "name": "has_error",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "abuse_classification": {
+ "name": "abuse_classification",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_provider": {
+ "name": "inference_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_created_at": {
+ "name": "idx_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_abuse_classification": {
+ "name": "idx_abuse_classification",
+ "columns": [
+ {
+ "expression": "abuse_classification",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_kilo_user_id_created_at2": {
+ "name": "idx_kilo_user_id_created_at2",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_organization_id": {
+ "name": "idx_microdollar_usage_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"microdollar_usage\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage_daily": {
+ "name": "microdollar_usage_daily",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "usage_date": {
+ "name": "usage_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_microdollar_usage_daily_personal": {
+ "name": "idx_microdollar_usage_daily_personal",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"microdollar_usage_daily\".\"organization_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_daily_org": {
+ "name": "idx_microdollar_usage_daily_org",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"microdollar_usage_daily\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage_metadata": {
+ "name": "microdollar_usage_metadata",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "http_user_agent_id": {
+ "name": "http_user_agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_ip_id": {
+ "name": "http_ip_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_city_id": {
+ "name": "vercel_ip_city_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_country_id": {
+ "name": "vercel_ip_country_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_latitude": {
+ "name": "vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_longitude": {
+ "name": "vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ja4_digest_id": {
+ "name": "ja4_digest_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_prompt_prefix": {
+ "name": "user_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_prefix_id": {
+ "name": "system_prompt_prefix_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_length": {
+ "name": "system_prompt_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_tokens": {
+ "name": "max_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_middle_out_transform": {
+ "name": "has_middle_out_transform",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "upstream_id": {
+ "name": "upstream_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finish_reason_id": {
+ "name": "finish_reason_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency": {
+ "name": "latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderation_latency": {
+ "name": "moderation_latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_time": {
+ "name": "generation_time",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_byok": {
+ "name": "is_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_user_byok": {
+ "name": "is_user_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "streamed": {
+ "name": "streamed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled": {
+ "name": "cancelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_name_id": {
+ "name": "editor_name_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_kind_id": {
+ "name": "api_kind_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_tools": {
+ "name": "has_tools",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "machine_id": {
+ "name": "machine_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature_id": {
+ "name": "feature_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode_id": {
+ "name": "mode_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_model_id": {
+ "name": "auto_model_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_cost": {
+ "name": "market_cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_delay": {
+ "name": "abuse_delay",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_downgraded_from": {
+ "name": "abuse_downgraded_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_microdollar_usage_metadata_created_at": {
+ "name": "idx_microdollar_usage_metadata_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_metadata_session_id": {
+ "name": "idx_microdollar_usage_metadata_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"microdollar_usage_metadata\".\"session_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk": {
+ "name": "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "http_user_agent",
+ "columnsFrom": [
+ "http_user_agent_id"
+ ],
+ "columnsTo": [
+ "http_user_agent_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk": {
+ "name": "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "http_ip",
+ "columnsFrom": [
+ "http_ip_id"
+ ],
+ "columnsTo": [
+ "http_ip_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk": {
+ "name": "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "vercel_ip_city",
+ "columnsFrom": [
+ "vercel_ip_city_id"
+ ],
+ "columnsTo": [
+ "vercel_ip_city_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk": {
+ "name": "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "vercel_ip_country",
+ "columnsFrom": [
+ "vercel_ip_country_id"
+ ],
+ "columnsTo": [
+ "vercel_ip_country_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk": {
+ "name": "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "ja4_digest",
+ "columnsFrom": [
+ "ja4_digest_id"
+ ],
+ "columnsTo": [
+ "ja4_digest_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk": {
+ "name": "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "system_prompt_prefix",
+ "columnsFrom": [
+ "system_prompt_prefix_id"
+ ],
+ "columnsTo": [
+ "system_prompt_prefix_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mode": {
+ "name": "mode",
+ "schema": "",
+ "columns": {
+ "mode_id": {
+ "name": "mode_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_mode": {
+ "name": "UQ_mode",
+ "columns": [
+ {
+ "expression": "mode",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_stats": {
+ "name": "model_stats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "is_featured": {
+ "name": "is_featured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_stealth": {
+ "name": "is_stealth",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_recommended": {
+ "name": "is_recommended",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "openrouter_id": {
+ "name": "openrouter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aa_slug": {
+ "name": "aa_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_creator": {
+ "name": "model_creator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creator_slug": {
+ "name": "creator_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release_date": {
+ "name": "release_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_input": {
+ "name": "price_input",
+ "type": "numeric(10, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_output": {
+ "name": "price_output",
+ "type": "numeric(10, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coding_index": {
+ "name": "coding_index",
+ "type": "numeric(5, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "speed_tokens_per_sec": {
+ "name": "speed_tokens_per_sec",
+ "type": "numeric(8, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context_length": {
+ "name": "context_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_output_tokens": {
+ "name": "max_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_modalities": {
+ "name": "input_modalities",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_data": {
+ "name": "openrouter_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "benchmarks": {
+ "name": "benchmarks",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chart_data": {
+ "name": "chart_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_stats_openrouter_id": {
+ "name": "IDX_model_stats_openrouter_id",
+ "columns": [
+ {
+ "expression": "openrouter_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_slug": {
+ "name": "IDX_model_stats_slug",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_is_active": {
+ "name": "IDX_model_stats_is_active",
+ "columns": [
+ {
+ "expression": "is_active",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_creator_slug": {
+ "name": "IDX_model_stats_creator_slug",
+ "columns": [
+ {
+ "expression": "creator_slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_price_input": {
+ "name": "IDX_model_stats_price_input",
+ "columns": [
+ {
+ "expression": "price_input",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_coding_index": {
+ "name": "IDX_model_stats_coding_index",
+ "columns": [
+ {
+ "expression": "coding_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_context_length": {
+ "name": "IDX_model_stats_context_length",
+ "columns": [
+ {
+ "expression": "context_length",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_stats_openrouter_id_unique": {
+ "name": "model_stats_openrouter_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "openrouter_id"
+ ]
+ },
+ "model_stats_slug_unique": {
+ "name": "model_stats_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_eval_ingestions": {
+ "name": "model_eval_ingestions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "bench_eval_name": {
+ "name": "bench_eval_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bench_eval_url": {
+ "name": "bench_eval_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_stats_id": {
+ "name": "model_stats_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "variant": {
+ "name": "variant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_total_trials": {
+ "name": "n_total_trials",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_attempts": {
+ "name": "n_attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_score": {
+ "name": "total_score",
+ "type": "numeric(14, 6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overall_score": {
+ "name": "overall_score",
+ "type": "numeric(12, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_errored": {
+ "name": "n_errored",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "avg_cost_microdollars": {
+ "name": "avg_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_input_tokens": {
+ "name": "avg_input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_input_tokens": {
+ "name": "total_input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_output_tokens": {
+ "name": "avg_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_output_tokens": {
+ "name": "total_output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_cache_read_tokens": {
+ "name": "avg_cache_read_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cache_read_tokens": {
+ "name": "total_cache_read_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_execution_ms": {
+ "name": "avg_execution_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "promoted_at": {
+ "name": "promoted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "promoted_by_email": {
+ "name": "promoted_by_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "promotion_note": {
+ "name": "promotion_note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_eval_ingestions_lookup": {
+ "name": "IDX_model_eval_ingestions_lookup",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "task_source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "promoted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_eval_ingestions_model_stats": {
+ "name": "IDX_model_eval_ingestions_model_stats",
+ "columns": [
+ {
+ "expression": "model_stats_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_eval_ingestions_promoted_by_email_lower": {
+ "name": "IDX_model_eval_ingestions_promoted_by_email_lower",
+ "columns": [
+ {
+ "expression": "LOWER(\"promoted_by_email\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_eval_ingestions_model_stats_id_model_stats_id_fk": {
+ "name": "model_eval_ingestions_model_stats_id_model_stats_id_fk",
+ "tableFrom": "model_eval_ingestions",
+ "tableTo": "model_stats",
+ "columnsFrom": [
+ "model_stats_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_eval_ingestions_bench_eval_name_unique": {
+ "name": "model_eval_ingestions_bench_eval_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "bench_eval_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_experiment": {
+ "name": "model_experiment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "public_model_id": {
+ "name": "public_model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "is_archived": {
+ "name": "is_archived",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_model_experiment_public_model_id_routing": {
+ "name": "UQ_model_experiment_public_model_id_routing",
+ "columns": [
+ {
+ "expression": "public_model_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"model_experiment\".\"status\" IN ('active', 'paused')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_experiment_status": {
+ "name": "IDX_model_experiment_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_created_by_user_id_kilocode_users_id_fk": {
+ "name": "model_experiment_created_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "model_experiment",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_status_valid": {
+ "name": "model_experiment_status_valid",
+ "value": "\"model_experiment\".\"status\" IN ('draft', 'active', 'paused', 'completed')"
+ },
+ "model_experiment_active_not_archived": {
+ "name": "model_experiment_active_not_archived",
+ "value": "\"model_experiment\".\"status\" <> 'active' OR \"model_experiment\".\"is_archived\" = false"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_request": {
+ "name": "model_experiment_request",
+ "schema": "",
+ "columns": {
+ "usage_id": {
+ "name": "usage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "variant_version_id": {
+ "name": "variant_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allocation_subject": {
+ "name": "allocation_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_request_id": {
+ "name": "client_request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_kind": {
+ "name": "request_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_body_sha256": {
+ "name": "request_body_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "was_truncated": {
+ "name": "was_truncated",
+ "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": {
+ "IDX_model_experiment_request_variant_version_created_at": {
+ "name": "IDX_model_experiment_request_variant_version_created_at",
+ "columns": [
+ {
+ "expression": "variant_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_experiment_request_client_request_id": {
+ "name": "IDX_model_experiment_request_client_request_id",
+ "columns": [
+ {
+ "expression": "client_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"model_experiment_request\".\"client_request_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_request_usage_id_microdollar_usage_id_fk": {
+ "name": "model_experiment_request_usage_id_microdollar_usage_id_fk",
+ "tableFrom": "model_experiment_request",
+ "tableTo": "microdollar_usage",
+ "columnsFrom": [
+ "usage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk": {
+ "name": "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk",
+ "tableFrom": "model_experiment_request",
+ "tableTo": "model_experiment_variant_version",
+ "columnsFrom": [
+ "variant_version_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "model_experiment_request_usage_id_created_at_pk": {
+ "name": "model_experiment_request_usage_id_created_at_pk",
+ "columns": [
+ "usage_id",
+ "created_at"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_request_allocation_subject_valid": {
+ "name": "model_experiment_request_allocation_subject_valid",
+ "value": "\"model_experiment_request\".\"allocation_subject\" IN ('user', 'machine', 'ip')"
+ },
+ "model_experiment_request_request_kind_valid": {
+ "name": "model_experiment_request_request_kind_valid",
+ "value": "\"model_experiment_request\".\"request_kind\" IN ('chat_completions', 'messages', 'responses')"
+ },
+ "model_experiment_request_request_body_sha256_format": {
+ "name": "model_experiment_request_request_body_sha256_format",
+ "value": "\"model_experiment_request\".\"request_body_sha256\" ~ '^[0-9a-f]{64}$' OR \"model_experiment_request\".\"request_body_sha256\" IN ('__failed__', '__deleted__')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_variant": {
+ "name": "model_experiment_variant",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "experiment_id": {
+ "name": "experiment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "weight": {
+ "name": "weight",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_experiment_variant_experiment_id": {
+ "name": "IDX_model_experiment_variant_experiment_id",
+ "columns": [
+ {
+ "expression": "experiment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_variant_experiment_id_model_experiment_id_fk": {
+ "name": "model_experiment_variant_experiment_id_model_experiment_id_fk",
+ "tableFrom": "model_experiment_variant",
+ "tableTo": "model_experiment",
+ "columnsFrom": [
+ "experiment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_model_experiment_variant_experiment_label": {
+ "name": "UQ_model_experiment_variant_experiment_label",
+ "nullsNotDistinct": false,
+ "columns": [
+ "experiment_id",
+ "label"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_variant_weight_positive": {
+ "name": "model_experiment_variant_weight_positive",
+ "value": "\"model_experiment_variant\".\"weight\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_variant_version": {
+ "name": "model_experiment_variant_version",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "variant_id": {
+ "name": "variant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "upstream": {
+ "name": "upstream",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_at": {
+ "name": "effective_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_experiment_variant_version_variant_effective": {
+ "name": "IDX_model_experiment_variant_version_variant_effective",
+ "columns": [
+ {
+ "expression": "variant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "effective_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk": {
+ "name": "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk",
+ "tableFrom": "model_experiment_variant_version",
+ "tableTo": "model_experiment_variant",
+ "columnsFrom": [
+ "variant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "model_experiment_variant_version_created_by_kilocode_users_id_fk": {
+ "name": "model_experiment_variant_version_created_by_kilocode_users_id_fk",
+ "tableFrom": "model_experiment_variant_version",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.models_by_provider": {
+ "name": "models_by_provider",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "openrouter": {
+ "name": "openrouter",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel": {
+ "name": "vercel",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_audit_logs": {
+ "name": "organization_audit_logs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_audit_logs_organization_id": {
+ "name": "IDX_organization_audit_logs_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_action": {
+ "name": "IDX_organization_audit_logs_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_actor_id": {
+ "name": "IDX_organization_audit_logs_actor_id",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_created_at": {
+ "name": "IDX_organization_audit_logs_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_invitations": {
+ "name": "organization_invitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by": {
+ "name": "invited_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authentication_requirement": {
+ "name": "authentication_requirement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "sso_source_organization_id": {
+ "name": "sso_source_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_organization_invitations_token": {
+ "name": "UQ_organization_invitations_token",
+ "columns": [
+ {
+ "expression": "token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_org_id": {
+ "name": "IDX_organization_invitations_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_email": {
+ "name": "IDX_organization_invitations_email",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_expires_at": {
+ "name": "IDX_organization_invitations_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_invitations_sso_source_organization_id_organizations_id_fk": {
+ "name": "organization_invitations_sso_source_organization_id_organizations_id_fk",
+ "tableFrom": "organization_invitations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "sso_source_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_membership_removals": {
+ "name": "organization_membership_removals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "removed_at": {
+ "name": "removed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "removed_by": {
+ "name": "removed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_role": {
+ "name": "previous_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "IDX_org_membership_removals_org_id": {
+ "name": "IDX_org_membership_removals_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_org_membership_removals_user_id": {
+ "name": "IDX_org_membership_removals_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_org_membership_removals_org_user": {
+ "name": "UQ_org_membership_removals_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_memberships": {
+ "name": "organization_memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "invited_by": {
+ "name": "invited_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_memberships_org_id": {
+ "name": "IDX_organization_memberships_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_memberships_user_id": {
+ "name": "IDX_organization_memberships_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_memberships_org_user": {
+ "name": "UQ_organization_memberships_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_recommendation_dismissals": {
+ "name": "organization_recommendation_dismissals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_key": {
+ "name": "recommendation_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dismissed_by_user_id": {
+ "name": "dismissed_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dismissed_at": {
+ "name": "dismissed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk": {
+ "name": "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "organization_recommendation_dismissals",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk": {
+ "name": "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "organization_recommendation_dismissals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "dismissed_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_org_recommendation_dismissals_org_key": {
+ "name": "UQ_org_recommendation_dismissals_org_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_organization_id",
+ "recommendation_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_seats_purchases": {
+ "name": "organization_seats_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscription_stripe_id": {
+ "name": "subscription_stripe_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "seat_count": {
+ "name": "seat_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "numeric",
+ "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
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "subscription_status": {
+ "name": "subscription_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "starts_at": {
+ "name": "starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_cycle": {
+ "name": "billing_cycle",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'monthly'"
+ }
+ },
+ "indexes": {
+ "IDX_organization_seats_org_id": {
+ "name": "IDX_organization_seats_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_expires_at": {
+ "name": "IDX_organization_seats_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_created_at": {
+ "name": "IDX_organization_seats_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_updated_at": {
+ "name": "IDX_organization_seats_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_starts_at": {
+ "name": "IDX_organization_seats_starts_at",
+ "columns": [
+ {
+ "expression": "starts_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_seats_idempotency_key": {
+ "name": "UQ_organization_seats_idempotency_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "idempotency_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_user_limits": {
+ "name": "organization_user_limits",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "microdollar_limit": {
+ "name": "microdollar_limit",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_user_limits_org_id": {
+ "name": "IDX_organization_user_limits_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_user_limits_user_id": {
+ "name": "IDX_organization_user_limits_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_user_limits_org_user": {
+ "name": "UQ_organization_user_limits_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "limit_type"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_user_usage": {
+ "name": "organization_user_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "usage_date": {
+ "name": "usage_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "microdollar_usage": {
+ "name": "microdollar_usage",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_user_daily_usage_org_id": {
+ "name": "IDX_organization_user_daily_usage_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_user_daily_usage_user_id": {
+ "name": "IDX_organization_user_daily_usage_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_user_daily_usage_org_user_date": {
+ "name": "UQ_organization_user_daily_usage_org_user_date",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "limit_type",
+ "usage_date"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "microdollars_used": {
+ "name": "microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "microdollars_balance": {
+ "name": "microdollars_balance",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "total_microdollars_acquired": {
+ "name": "total_microdollars_acquired",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "next_credit_expiration_at": {
+ "name": "next_credit_expiration_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_enabled": {
+ "name": "auto_top_up_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "seat_count": {
+ "name": "seat_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "require_seats": {
+ "name": "require_seats",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sso_domain": {
+ "name": "sso_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_organization_id": {
+ "name": "parent_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'teams'"
+ },
+ "free_trial_end_at": {
+ "name": "free_trial_end_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_domain": {
+ "name": "company_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_slug": {
+ "name": "requested_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_organizations_sso_domain": {
+ "name": "IDX_organizations_sso_domain",
+ "columns": [
+ {
+ "expression": "sso_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organizations_parent_organization_id": {
+ "name": "IDX_organizations_parent_organization_id",
+ "columns": [
+ {
+ "expression": "parent_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organizations_parent_organization_id_organizations_id_fk": {
+ "name": "organizations_parent_organization_id_organizations_id_fk",
+ "tableFrom": "organizations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "parent_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organizations_slug_unique": {
+ "name": "organizations_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "organizations_name_not_empty_check": {
+ "name": "organizations_name_not_empty_check",
+ "value": "length(trim(\"organizations\".\"name\")) > 0"
+ },
+ "organizations_not_parented_by_self_check": {
+ "name": "organizations_not_parented_by_self_check",
+ "value": "\"organizations\".\"parent_organization_id\" IS NULL OR \"organizations\".\"parent_organization_id\" <> \"organizations\".\"id\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.organization_modes": {
+ "name": "organization_modes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ }
+ },
+ "indexes": {
+ "IDX_organization_modes_organization_id": {
+ "name": "IDX_organization_modes_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_modes_org_id_slug": {
+ "name": "UQ_organization_modes_org_id_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.payment_methods": {
+ "name": "payment_methods",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_fingerprint": {
+ "name": "stripe_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_id": {
+ "name": "stripe_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last4": {
+ "name": "last4",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "brand": {
+ "name": "brand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line1": {
+ "name": "address_line1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line2": {
+ "name": "address_line2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_city": {
+ "name": "address_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_state": {
+ "name": "address_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_zip": {
+ "name": "address_zip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_country": {
+ "name": "address_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "three_d_secure_supported": {
+ "name": "three_d_secure_supported",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "regulated_status": {
+ "name": "regulated_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line1_check_status": {
+ "name": "address_line1_check_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postal_code_check_status": {
+ "name": "postal_code_check_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eligible_for_free_credits": {
+ "name": "eligible_for_free_credits",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_data": {
+ "name": "stripe_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_d7d7fb15569674aaadcfbc0428": {
+ "name": "IDX_d7d7fb15569674aaadcfbc0428",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_e1feb919d0ab8a36381d5d5138": {
+ "name": "IDX_e1feb919d0ab8a36381d5d5138",
+ "columns": [
+ {
+ "expression": "stripe_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_payment_methods_organization_id": {
+ "name": "IDX_payment_methods_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_29df1b0403df5792c96bbbfdbe6": {
+ "name": "UQ_29df1b0403df5792c96bbbfdbe6",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "stripe_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pending_impact_sale_reversals": {
+ "name": "pending_impact_sale_reversals",
+ "schema": "",
+ "columns": {
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "dispute_id": {
+ "name": "dispute_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount": {
+ "name": "amount",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_date": {
+ "name": "event_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_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": {},
+ "policies": {},
+ "checkConstraints": {
+ "pending_impact_sale_reversals_attempt_count_non_negative_check": {
+ "name": "pending_impact_sale_reversals_attempt_count_non_negative_check",
+ "value": "\"pending_impact_sale_reversals\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.platform_access_token_credentials": {
+ "name": "platform_access_token_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_encrypted": {
+ "name": "token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_credential_type": {
+ "name": "provider_credential_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_scopes": {
+ "name": "provider_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_verified_at": {
+ "name": "provider_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_validated_at": {
+ "name": "last_validated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "FK_platform_access_token_credentials_parent": {
+ "name": "FK_platform_access_token_credentials_parent",
+ "tableFrom": "platform_access_token_credentials",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_platform_access_token_credentials_platform_integration_id": {
+ "name": "UQ_platform_access_token_credentials_platform_integration_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "platform_integration_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.platform_integrations": {
+ "name": "platform_integrations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_installation_id": {
+ "name": "platform_installation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_account_id": {
+ "name": "platform_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_account_login": {
+ "name": "platform_account_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_access": {
+ "name": "repository_access",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repositories": {
+ "name": "repositories",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repositories_synced_at": {
+ "name": "repositories_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_invalid_at": {
+ "name": "auth_invalid_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_invalid_reason": {
+ "name": "auth_invalid_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_requester_user_id": {
+ "name": "kilo_requester_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_requester_account_id": {
+ "name": "platform_requester_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "integration_status": {
+ "name": "integration_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_at": {
+ "name": "suspended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_by": {
+ "name": "suspended_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_app_type": {
+ "name": "github_app_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'standard'"
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_platform_integrations_owned_by_org_platform_inst": {
+ "name": "UQ_platform_integrations_owned_by_org_platform_inst",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_owned_by_user_platform_inst": {
+ "name": "UQ_platform_integrations_owned_by_user_platform_inst",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_slack_platform_inst": {
+ "name": "UQ_platform_integrations_slack_platform_inst",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'slack' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_linear_platform_inst": {
+ "name": "UQ_platform_integrations_linear_platform_inst",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'linear' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_user_bitbucket": {
+ "name": "UQ_platform_integrations_user_bitbucket",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_org_bitbucket": {
+ "name": "UQ_platform_integrations_org_bitbucket",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_org_id": {
+ "name": "IDX_platform_integrations_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_user_id": {
+ "name": "IDX_platform_integrations_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform_inst_id": {
+ "name": "IDX_platform_integrations_platform_inst_id",
+ "columns": [
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform": {
+ "name": "IDX_platform_integrations_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_org_platform": {
+ "name": "IDX_platform_integrations_owned_by_org_platform",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_user_platform": {
+ "name": "IDX_platform_integrations_owned_by_user_platform",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_integration_status": {
+ "name": "IDX_platform_integrations_integration_status",
+ "columns": [
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_kilo_requester": {
+ "name": "IDX_platform_integrations_kilo_requester",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_requester_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform_requester": {
+ "name": "IDX_platform_integrations_platform_requester",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_requester_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "platform_integrations_owned_by_organization_id_organizations_id_fk": {
+ "name": "platform_integrations_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "platform_integrations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "platform_integrations_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "platform_integrations_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "platform_integrations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "platform_integrations_owner_check": {
+ "name": "platform_integrations_owner_check",
+ "value": "(\n (\"platform_integrations\".\"owned_by_user_id\" IS NOT NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NULL) OR\n (\"platform_integrations\".\"owned_by_user_id\" IS NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.platform_oauth_credentials": {
+ "name": "platform_oauth_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorized_by_user_id": {
+ "name": "authorized_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject_id": {
+ "name": "provider_subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject_login": {
+ "name": "provider_subject_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_encrypted": {
+ "name": "access_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_reason": {
+ "name": "revocation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_platform_oauth_credentials_platform_integration_id": {
+ "name": "UQ_platform_oauth_credentials_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_oauth_credentials_authorized_by_user_id": {
+ "name": "IDX_platform_oauth_credentials_authorized_by_user_id",
+ "columns": [
+ {
+ "expression": "authorized_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk": {
+ "name": "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "platform_oauth_credentials",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk": {
+ "name": "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "platform_oauth_credentials",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "authorized_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.referral_code_usages": {
+ "name": "referral_code_usages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "referring_kilo_user_id": {
+ "name": "referring_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redeeming_kilo_user_id": {
+ "name": "redeeming_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "paid_at": {
+ "name": "paid_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_referral_code_usages_redeeming_kilo_user_id": {
+ "name": "IDX_referral_code_usages_redeeming_kilo_user_id",
+ "columns": [
+ {
+ "expression": "redeeming_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_referral_code_usages_redeeming_user_id_code": {
+ "name": "UQ_referral_code_usages_redeeming_user_id_code",
+ "nullsNotDistinct": false,
+ "columns": [
+ "redeeming_kilo_user_id",
+ "referring_kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.referral_codes": {
+ "name": "referral_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "max_redemptions": {
+ "name": "max_redemptions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 10
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_referral_codes_kilo_user_id": {
+ "name": "UQ_referral_codes_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_referral_codes_code": {
+ "name": "IDX_referral_codes_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_check_catalog": {
+ "name": "security_advisor_check_catalog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "check_id": {
+ "name": "check_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "explanation": {
+ "name": "explanation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "risk": {
+ "name": "risk",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_check_catalog_check_id_unique": {
+ "name": "security_advisor_check_catalog_check_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "check_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "security_advisor_check_catalog_severity_check": {
+ "name": "security_advisor_check_catalog_severity_check",
+ "value": "\"security_advisor_check_catalog\".\"severity\" in ('critical', 'warn', 'info')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_content": {
+ "name": "security_advisor_content",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_content_key_unique": {
+ "name": "security_advisor_content_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_kiloclaw_coverage": {
+ "name": "security_advisor_kiloclaw_coverage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "area": {
+ "name": "area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "detail": {
+ "name": "detail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "match_check_ids": {
+ "name": "match_check_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_kiloclaw_coverage_area_unique": {
+ "name": "security_advisor_kiloclaw_coverage_area_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "area"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_scans": {
+ "name": "security_advisor_scans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_platform": {
+ "name": "source_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_method": {
+ "name": "source_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plugin_version": {
+ "name": "plugin_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openclaw_version": {
+ "name": "openclaw_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_ip": {
+ "name": "public_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "findings_critical": {
+ "name": "findings_critical",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "findings_warn": {
+ "name": "findings_warn",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "findings_info": {
+ "name": "findings_info",
+ "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": {
+ "idx_security_advisor_scans_user_created_at": {
+ "name": "idx_security_advisor_scans_user_created_at",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_advisor_scans_created_at": {
+ "name": "idx_security_advisor_scans_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_advisor_scans_platform": {
+ "name": "idx_security_advisor_scans_platform",
+ "columns": [
+ {
+ "expression": "source_platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_agent_commands": {
+ "name": "security_agent_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "command_type": {
+ "name": "command_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'accepted'"
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_metadata": {
+ "name": "result_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_security_agent_commands_org_created": {
+ "name": "idx_security_agent_commands_org_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_user_created": {
+ "name": "idx_security_agent_commands_user_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_status_updated": {
+ "name": "idx_security_agent_commands_status_updated",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_finding_created": {
+ "name": "idx_security_agent_commands_finding_created",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_agent_commands_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_agent_commands_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_commands_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_agent_commands_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_commands_finding_id_security_findings_id_fk": {
+ "name": "security_agent_commands_finding_id_security_findings_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_agent_commands_owner_check": {
+ "name": "security_agent_commands_owner_check",
+ "value": "(\n (\"security_agent_commands\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_commands\".\"owned_by_user_id\" IS NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_agent_commands_type_check": {
+ "name": "security_agent_commands_type_check",
+ "value": "\"security_agent_commands\".\"command_type\" IN ('sync', 'dismiss_finding', 'start_analysis', 'apply_auto_remediation')"
+ },
+ "security_agent_commands_origin_check": {
+ "name": "security_agent_commands_origin_check",
+ "value": "\"security_agent_commands\".\"origin\" IN ('manual', 'dashboard_refresh', 'enable_initial_sync', 'settings_include_existing')"
+ },
+ "security_agent_commands_status_check": {
+ "name": "security_agent_commands_status_check",
+ "value": "\"security_agent_commands\".\"status\" IN ('accepted', 'running', 'succeeded', 'failed', 'no_op')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_agent_repository_sync_state": {
+ "name": "security_agent_repository_sync_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_attempted_at": {
+ "name": "last_attempted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_succeeded_at": {
+ "name": "last_succeeded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_failure_code": {
+ "name": "last_failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_agent_repository_sync_state_org_repo": {
+ "name": "UQ_security_agent_repository_sync_state_org_repo",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_agent_repository_sync_state\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_agent_repository_sync_state_user_repo": {
+ "name": "UQ_security_agent_repository_sync_state_user_repo",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_agent_repository_sync_state\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_agent_repository_sync_state",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_agent_repository_sync_state",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_agent_repository_sync_state_owner_check": {
+ "name": "security_agent_repository_sync_state_owner_check",
+ "value": "(\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_analysis_owner_state": {
+ "name": "security_analysis_owner_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_analysis_enabled_at": {
+ "name": "auto_analysis_enabled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_until": {
+ "name": "blocked_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reason": {
+ "name": "block_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consecutive_actor_resolution_failures": {
+ "name": "consecutive_actor_resolution_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_actor_resolution_failure_at": {
+ "name": "last_actor_resolution_failure_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_analysis_owner_state_org_owner": {
+ "name": "UQ_security_analysis_owner_state_org_owner",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_analysis_owner_state\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_analysis_owner_state_user_owner": {
+ "name": "UQ_security_analysis_owner_state_user_owner",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_analysis_owner_state\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_analysis_owner_state",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_analysis_owner_state",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_analysis_owner_state_owner_check": {
+ "name": "security_analysis_owner_state_owner_check",
+ "value": "(\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_analysis_owner_state_block_reason_check": {
+ "name": "security_analysis_owner_state_block_reason_check",
+ "value": "\"security_analysis_owner_state\".\"block_reason\" IS NULL OR \"security_analysis_owner_state\".\"block_reason\" IN ('INSUFFICIENT_CREDITS', 'ACTOR_RESOLUTION_FAILED', 'OPERATOR_PAUSE')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_analysis_queue": {
+ "name": "security_analysis_queue",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "queue_status": {
+ "name": "queue_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity_rank": {
+ "name": "severity_rank",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_by_job_id": {
+ "name": "claimed_by_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claim_token": {
+ "name": "claim_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "reopen_requeue_count": {
+ "name": "reopen_requeue_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_analysis_queue_finding_id": {
+ "name": "UQ_security_analysis_queue_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_claim_path_org": {
+ "name": "idx_security_analysis_queue_claim_path_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "severity_rank",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_claim_path_user": {
+ "name": "idx_security_analysis_queue_claim_path_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "severity_rank",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_in_flight_org": {
+ "name": "idx_security_analysis_queue_in_flight_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queue_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_in_flight_user": {
+ "name": "idx_security_analysis_queue_in_flight_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queue_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_lag_dashboards": {
+ "name": "idx_security_analysis_queue_lag_dashboards",
+ "columns": [
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_pending_reconciliation": {
+ "name": "idx_security_analysis_queue_pending_reconciliation",
+ "columns": [
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_running_reconciliation": {
+ "name": "idx_security_analysis_queue_running_reconciliation",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'running'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_failure_trend": {
+ "name": "idx_security_analysis_queue_failure_trend",
+ "columns": [
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"failure_code\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_analysis_queue_finding_id_security_findings_id_fk": {
+ "name": "security_analysis_queue_finding_id_security_findings_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_queue_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_analysis_queue_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_analysis_queue_owner_check": {
+ "name": "security_analysis_queue_owner_check",
+ "value": "(\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_analysis_queue_status_check": {
+ "name": "security_analysis_queue_status_check",
+ "value": "\"security_analysis_queue\".\"queue_status\" IN ('queued', 'pending', 'running', 'failed', 'completed')"
+ },
+ "security_analysis_queue_claim_token_required_check": {
+ "name": "security_analysis_queue_claim_token_required_check",
+ "value": "\"security_analysis_queue\".\"queue_status\" NOT IN ('pending', 'running') OR \"security_analysis_queue\".\"claim_token\" IS NOT NULL"
+ },
+ "security_analysis_queue_attempt_count_non_negative_check": {
+ "name": "security_analysis_queue_attempt_count_non_negative_check",
+ "value": "\"security_analysis_queue\".\"attempt_count\" >= 0"
+ },
+ "security_analysis_queue_reopen_requeue_count_non_negative_check": {
+ "name": "security_analysis_queue_reopen_requeue_count_non_negative_check",
+ "value": "\"security_analysis_queue\".\"reopen_requeue_count\" >= 0"
+ },
+ "security_analysis_queue_severity_rank_check": {
+ "name": "security_analysis_queue_severity_rank_check",
+ "value": "\"security_analysis_queue\".\"severity_rank\" IN (0, 1, 2, 3)"
+ },
+ "security_analysis_queue_failure_code_check": {
+ "name": "security_analysis_queue_failure_code_check",
+ "value": "\"security_analysis_queue\".\"failure_code\" IS NULL OR \"security_analysis_queue\".\"failure_code\" IN (\n 'NETWORK_TIMEOUT',\n 'UPSTREAM_5XX',\n 'TEMP_TOKEN_FAILURE',\n 'START_CALL_AMBIGUOUS',\n 'REQUEUE_TEMPORARY_PRECONDITION',\n 'ACTOR_RESOLUTION_FAILED',\n 'GITHUB_TOKEN_UNAVAILABLE',\n 'INVALID_CONFIG',\n 'MISSING_OWNERSHIP',\n 'PERMISSION_DENIED_PERMANENT',\n 'UNSUPPORTED_SEVERITY',\n 'INSUFFICIENT_CREDITS',\n 'STATE_GUARD_REJECTED',\n 'SKIPPED_ALREADY_IN_PROGRESS',\n 'SKIPPED_NO_LONGER_ELIGIBLE',\n 'REOPEN_LOOP_GUARD',\n 'RUN_LOST'\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_audit_log": {
+ "name": "security_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "before_state": {
+ "name": "before_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "after_state": {
+ "name": "after_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_occurred_at": {
+ "name": "source_occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_key": {
+ "name": "event_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_version": {
+ "name": "schema_version",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_snapshot": {
+ "name": "finding_snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_context": {
+ "name": "source_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_security_audit_log_org_created": {
+ "name": "IDX_security_audit_log_org_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_user_created": {
+ "name": "IDX_security_audit_log_user_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_resource": {
+ "name": "IDX_security_audit_log_resource",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_actor": {
+ "name": "IDX_security_audit_log_actor",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_action": {
+ "name": "IDX_security_audit_log_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_audit_log_org_event_key": {
+ "name": "UQ_security_audit_log_org_event_key",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_audit_log_user_event_key": {
+ "name": "UQ_security_audit_log_user_event_key",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_org_occurred": {
+ "name": "IDX_security_audit_log_org_occurred",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_user_occurred": {
+ "name": "IDX_security_audit_log_user_occurred",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_audit_log_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_audit_log_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_audit_log",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_audit_log_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_audit_log_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_audit_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_audit_log_owner_check": {
+ "name": "security_audit_log_owner_check",
+ "value": "(\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NULL) OR (\"security_audit_log\".\"owned_by_user_id\" IS NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL)"
+ },
+ "security_audit_log_action_check": {
+ "name": "security_audit_log_action_check",
+ "value": "\"security_audit_log\".\"action\" IN ('security.finding.created', 'security.finding.severity_changed', 'security.finding.status_change', 'security.finding.dismissed', 'security.finding.auto_dismissed', 'security.finding.superseded', 'security.finding.analysis_started', 'security.finding.analysis_completed', 'security.finding.analysis_failed', 'security.remediation.queued', 'security.remediation.started', 'security.remediation.pr_opened', 'security.remediation.failed', 'security.remediation.blocked', 'security.remediation.no_changes_needed', 'security.remediation.cancelled', 'security.remediation.retried', 'security.finding.deleted', 'security.config.enabled', 'security.config.disabled', 'security.config.updated', 'security.sync.triggered', 'security.sync.completed', 'security.audit_log.exported', 'security.audit_report.generated')"
+ },
+ "security_audit_log_actor_type_check": {
+ "name": "security_audit_log_actor_type_check",
+ "value": "\"security_audit_log\".\"actor_type\" IN ('customer_user', 'kilo_admin', 'system')"
+ },
+ "security_audit_log_source_context_check": {
+ "name": "security_audit_log_source_context_check",
+ "value": "\"security_audit_log\".\"source_context\" IN ('security_sync', 'web', 'analysis_worker', 'remediation_callback', 'rollout_baseline')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_finding_notifications": {
+ "name": "security_finding_notifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient_user_id": {
+ "name": "recipient_user_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": "'staged'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_security_finding_notifications_finding_recipient_kind": {
+ "name": "uq_security_finding_notifications_finding_recipient_kind",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recipient_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_pending": {
+ "name": "idx_security_finding_notifications_pending",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_finding_notifications\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_staged": {
+ "name": "idx_security_finding_notifications_staged",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_finding_notifications\".\"status\" = 'staged'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_finding_id": {
+ "name": "idx_security_finding_notifications_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_recipient_user_id": {
+ "name": "idx_security_finding_notifications_recipient_user_id",
+ "columns": [
+ {
+ "expression": "recipient_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_finding_notifications_finding_fk": {
+ "name": "security_finding_notifications_finding_fk",
+ "tableFrom": "security_finding_notifications",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_finding_notifications_recipient_fk": {
+ "name": "security_finding_notifications_recipient_fk",
+ "tableFrom": "security_finding_notifications",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "recipient_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_finding_notifications_kind_check": {
+ "name": "security_finding_notifications_kind_check",
+ "value": "\"security_finding_notifications\".\"kind\" IN ('new_finding', 'sla_warning', 'sla_breach')"
+ },
+ "security_finding_notifications_status_check": {
+ "name": "security_finding_notifications_status_check",
+ "value": "\"security_finding_notifications\".\"status\" IN ('staged', 'pending', 'sending', 'sent', 'failed', 'cancelled')"
+ },
+ "security_finding_notifications_attempt_count_check": {
+ "name": "security_finding_notifications_attempt_count_check",
+ "value": "\"security_finding_notifications\".\"attempt_count\" >= 0"
+ },
+ "security_finding_notifications_claimed_at_check": {
+ "name": "security_finding_notifications_claimed_at_check",
+ "value": "(\n (\"security_finding_notifications\".\"status\" = 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NULL)\n )"
+ },
+ "security_finding_notifications_sent_at_check": {
+ "name": "security_finding_notifications_sent_at_check",
+ "value": "(\n (\"security_finding_notifications\".\"status\" = 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NULL)\n )"
+ },
+ "security_finding_notifications_error_message_length_check": {
+ "name": "security_finding_notifications_error_message_length_check",
+ "value": "\"security_finding_notifications\".\"error_message\" IS NULL OR length(\"security_finding_notifications\".\"error_message\") <= 500"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_findings": {
+ "name": "security_findings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ghsa_id": {
+ "name": "ghsa_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cve_id": {
+ "name": "cve_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "package_name": {
+ "name": "package_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "package_ecosystem": {
+ "name": "package_ecosystem",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "vulnerable_version_range": {
+ "name": "vulnerable_version_range",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patched_version": {
+ "name": "patched_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manifest_path": {
+ "name": "manifest_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "ignored_reason": {
+ "name": "ignored_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ignored_by": {
+ "name": "ignored_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_at": {
+ "name": "fixed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sla_due_at": {
+ "name": "sla_due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dependabot_html_url": {
+ "name": "dependabot_html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cwe_ids": {
+ "name": "cwe_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cvss_score": {
+ "name": "cvss_score",
+ "type": "numeric(3, 1)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dependency_scope": {
+ "name": "dependency_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_status": {
+ "name": "analysis_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_started_at": {
+ "name": "analysis_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_completed_at": {
+ "name": "analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_error": {
+ "name": "analysis_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis": {
+ "name": "analysis",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_data": {
+ "name": "raw_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_detected_at": {
+ "name": "first_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_security_findings_user_source": {
+ "name": "uq_security_findings_user_source",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_findings\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "uq_security_findings_org_source": {
+ "name": "uq_security_findings_org_source",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_findings\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_org_id": {
+ "name": "idx_security_findings_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_user_id": {
+ "name": "idx_security_findings_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_repo": {
+ "name": "idx_security_findings_repo",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_severity": {
+ "name": "idx_security_findings_severity",
+ "columns": [
+ {
+ "expression": "severity",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_status": {
+ "name": "idx_security_findings_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_package": {
+ "name": "idx_security_findings_package",
+ "columns": [
+ {
+ "expression": "package_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_sla_due_at": {
+ "name": "idx_security_findings_sla_due_at",
+ "columns": [
+ {
+ "expression": "sla_due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_session_id": {
+ "name": "idx_security_findings_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_cli_session_id": {
+ "name": "idx_security_findings_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_analysis_status": {
+ "name": "idx_security_findings_analysis_status",
+ "columns": [
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_org_analysis_in_flight": {
+ "name": "idx_security_findings_org_analysis_in_flight",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_user_analysis_in_flight": {
+ "name": "idx_security_findings_user_analysis_in_flight",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_findings_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_findings_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_findings_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_findings_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_findings_platform_integration_id_platform_integrations_id_fk": {
+ "name": "security_findings_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_findings_owner_check": {
+ "name": "security_findings_owner_check",
+ "value": "(\n (\"security_findings\".\"owned_by_user_id\" IS NOT NULL AND \"security_findings\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_findings\".\"owned_by_user_id\" IS NULL AND \"security_findings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_remediation_attempts": {
+ "name": "security_remediation_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "remediation_id": {
+ "name": "remediation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_number": {
+ "name": "attempt_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "retry_of_attempt_id": {
+ "name": "retry_of_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_by_user_id": {
+ "name": "requested_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_fingerprint": {
+ "name": "analysis_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "analysis_completed_at": {
+ "name": "analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remediation_model_slug": {
+ "name": "remediation_model_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 50
+ },
+ "claim_token": {
+ "name": "claim_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_by_job_id": {
+ "name": "claimed_by_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "launch_attempt_count": {
+ "name": "launch_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "callback_attempt_token_hash": {
+ "name": "callback_attempt_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "structured_result": {
+ "name": "structured_result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_assistant_message": {
+ "name": "final_assistant_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "validation_evidence": {
+ "name": "validation_evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "risk_notes": {
+ "name": "risk_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draft_reason": {
+ "name": "draft_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_draft": {
+ "name": "pr_draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_branch": {
+ "name": "pr_head_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_base_branch": {
+ "name": "pr_base_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_requested_at": {
+ "name": "cancellation_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_requested_by_user_id": {
+ "name": "cancellation_requested_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "launched_at": {
+ "name": "launched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_remediation_attempts_number": {
+ "name": "UQ_security_remediation_attempts_number",
+ "columns": [
+ {
+ "expression": "remediation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "attempt_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_active_finding": {
+ "name": "UQ_security_remediation_attempts_active_finding",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_active_remediation": {
+ "name": "UQ_security_remediation_attempts_active_remediation",
+ "columns": [
+ {
+ "expression": "remediation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_finding_fingerprint_terminal": {
+ "name": "UQ_security_remediation_attempts_finding_fingerprint_terminal",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_org_claim": {
+ "name": "idx_security_remediation_attempts_org_claim",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_user_claim": {
+ "name": "idx_security_remediation_attempts_user_claim",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_repo_claim": {
+ "name": "idx_security_remediation_attempts_repo_claim",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_org_inflight": {
+ "name": "idx_security_remediation_attempts_org_inflight",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_user_inflight": {
+ "name": "idx_security_remediation_attempts_user_inflight",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_repo_inflight": {
+ "name": "idx_security_remediation_attempts_repo_inflight",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_cloud_agent_session": {
+ "name": "idx_security_remediation_attempts_cloud_agent_session",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_finding_fingerprint": {
+ "name": "idx_security_remediation_attempts_finding_fingerprint",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_remediation_attempts_remediation_id_security_remediations_id_fk": {
+ "name": "security_remediation_attempts_remediation_id_security_remediations_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "security_remediations",
+ "columnsFrom": [
+ "remediation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_finding_id_security_findings_id_fk": {
+ "name": "security_remediation_attempts_finding_id_security_findings_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_remediation_attempts_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "requested_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "cancellation_requested_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_remediation_attempts_owner_check": {
+ "name": "security_remediation_attempts_owner_check",
+ "value": "(\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_remediation_attempts_status_check": {
+ "name": "security_remediation_attempts_status_check",
+ "value": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
+ },
+ "security_remediation_attempts_origin_check": {
+ "name": "security_remediation_attempts_origin_check",
+ "value": "\"security_remediation_attempts\".\"origin\" IN ('auto_policy', 'bulk_existing', 'manual')"
+ },
+ "security_remediation_attempts_attempt_number_check": {
+ "name": "security_remediation_attempts_attempt_number_check",
+ "value": "\"security_remediation_attempts\".\"attempt_number\" >= 1"
+ },
+ "security_remediation_attempts_launch_attempt_count_check": {
+ "name": "security_remediation_attempts_launch_attempt_count_check",
+ "value": "\"security_remediation_attempts\".\"launch_attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_remediations": {
+ "name": "security_remediations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "latest_attempt_id": {
+ "name": "latest_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latest_analysis_fingerprint": {
+ "name": "latest_analysis_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latest_analysis_completed_at": {
+ "name": "latest_analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_draft": {
+ "name": "pr_draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_branch": {
+ "name": "pr_head_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_base_branch": {
+ "name": "pr_base_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_summary": {
+ "name": "outcome_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_remediations_finding_id": {
+ "name": "UQ_security_remediations_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_org_status": {
+ "name": "idx_security_remediations_org_status",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_user_status": {
+ "name": "idx_security_remediations_user_status",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_repo_status": {
+ "name": "idx_security_remediations_repo_status",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_latest_attempt": {
+ "name": "idx_security_remediations_latest_attempt",
+ "columns": [
+ {
+ "expression": "latest_attempt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_remediations_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_remediations_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediations_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediations_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediations_finding_id_security_findings_id_fk": {
+ "name": "security_remediations_finding_id_security_findings_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_remediations_owner_check": {
+ "name": "security_remediations_owner_check",
+ "value": "(\n (\"security_remediations\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediations\".\"owned_by_user_id\" IS NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_remediations_status_check": {
+ "name": "security_remediations_status_check",
+ "value": "\"security_remediations\".\"status\" IN ('queued', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.shared_cli_sessions": {
+ "name": "shared_cli_sessions",
+ "schema": "",
+ "columns": {
+ "share_id": {
+ "name": "share_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "shared_state": {
+ "name": "shared_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "api_conversation_history_blob_url": {
+ "name": "api_conversation_history_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_metadata_blob_url": {
+ "name": "task_metadata_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ui_messages_blob_url": {
+ "name": "ui_messages_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_state_blob_url": {
+ "name": "git_state_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_shared_cli_sessions_session_id": {
+ "name": "IDX_shared_cli_sessions_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_shared_cli_sessions_created_at": {
+ "name": "IDX_shared_cli_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_cli_sessions_session_id_cli_sessions_session_id_fk": {
+ "name": "shared_cli_sessions_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "shared_cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "shared_cli_sessions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "shared_cli_sessions_shared_state_check": {
+ "name": "shared_cli_sessions_shared_state_check",
+ "value": "\"shared_cli_sessions\".\"shared_state\" IN ('public', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.slack_bot_requests": {
+ "name": "slack_bot_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slack_team_id": {
+ "name": "slack_team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_team_name": {
+ "name": "slack_team_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slack_channel_id": {
+ "name": "slack_channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_user_id": {
+ "name": "slack_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_thread_ts": {
+ "name": "slack_thread_ts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message": {
+ "name": "user_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message_truncated": {
+ "name": "user_message_truncated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_used": {
+ "name": "model_used",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_calls_made": {
+ "name": "tool_calls_made",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_slack_bot_requests_created_at": {
+ "name": "idx_slack_bot_requests_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_slack_team_id": {
+ "name": "idx_slack_bot_requests_slack_team_id",
+ "columns": [
+ {
+ "expression": "slack_team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_owned_by_org_id": {
+ "name": "idx_slack_bot_requests_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_owned_by_user_id": {
+ "name": "idx_slack_bot_requests_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_status": {
+ "name": "idx_slack_bot_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_event_type": {
+ "name": "idx_slack_bot_requests_event_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_team_created": {
+ "name": "idx_slack_bot_requests_team_created",
+ "columns": [
+ {
+ "expression": "slack_team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "slack_bot_requests_owned_by_organization_id_organizations_id_fk": {
+ "name": "slack_bot_requests_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "slack_bot_requests_platform_integration_id_platform_integrations_id_fk": {
+ "name": "slack_bot_requests_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "slack_bot_requests_owner_check": {
+ "name": "slack_bot_requests_owner_check",
+ "value": "(\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NOT NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NOT NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.source_embeddings": {
+ "name": "source_embeddings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "embedding": {
+ "name": "embedding",
+ "type": "vector(1536)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_hash": {
+ "name": "file_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_line": {
+ "name": "start_line",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_line": {
+ "name": "end_line",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "is_base_branch": {
+ "name": "is_base_branch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_source_embeddings_organization_id": {
+ "name": "IDX_source_embeddings_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_kilo_user_id": {
+ "name": "IDX_source_embeddings_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_project_id": {
+ "name": "IDX_source_embeddings_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_created_at": {
+ "name": "IDX_source_embeddings_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_updated_at": {
+ "name": "IDX_source_embeddings_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_file_path_lower": {
+ "name": "IDX_source_embeddings_file_path_lower",
+ "columns": [
+ {
+ "expression": "LOWER(\"file_path\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_git_branch": {
+ "name": "IDX_source_embeddings_git_branch",
+ "columns": [
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_org_project_branch": {
+ "name": "IDX_source_embeddings_org_project_branch",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "source_embeddings_organization_id_organizations_id_fk": {
+ "name": "source_embeddings_organization_id_organizations_id_fk",
+ "tableFrom": "source_embeddings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "source_embeddings_kilo_user_id_kilocode_users_id_fk": {
+ "name": "source_embeddings_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "source_embeddings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_source_embeddings_org_project_branch_file_lines": {
+ "name": "UQ_source_embeddings_org_project_branch_file_lines",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "project_id",
+ "git_branch",
+ "file_path",
+ "start_line",
+ "end_line"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.stripe_dispute_actions": {
+ "name": "stripe_dispute_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "case_id": {
+ "name": "case_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_key": {
+ "name": "target_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_reference_id": {
+ "name": "result_reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_dispute_actions_case_id": {
+ "name": "IDX_stripe_dispute_actions_case_id",
+ "columns": [
+ {
+ "expression": "case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_actions_claim_path": {
+ "name": "IDX_stripe_dispute_actions_claim_path",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk": {
+ "name": "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk",
+ "tableFrom": "stripe_dispute_actions",
+ "tableTo": "stripe_dispute_cases",
+ "columnsFrom": [
+ "case_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_dispute_actions_case_type_target": {
+ "name": "UQ_stripe_dispute_actions_case_type_target",
+ "nullsNotDistinct": false,
+ "columns": [
+ "case_id",
+ "action_type",
+ "target_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_dispute_actions_action_type_check": {
+ "name": "stripe_dispute_actions_action_type_check",
+ "value": "\"stripe_dispute_actions\".\"action_type\" IN ('stripe_acceptance', 'user_block', 'auto_top_up_disable', 'credit_balance_reset', 'subscription_cancellation', 'access_termination', 'kiloclaw_suspension')"
+ },
+ "stripe_dispute_actions_status_check": {
+ "name": "stripe_dispute_actions_status_check",
+ "value": "\"stripe_dispute_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'skipped')"
+ },
+ "stripe_dispute_actions_attempt_count_non_negative_check": {
+ "name": "stripe_dispute_actions_attempt_count_non_negative_check",
+ "value": "\"stripe_dispute_actions\".\"attempt_count\" >= 0"
+ },
+ "stripe_dispute_actions_target_key_not_empty_check": {
+ "name": "stripe_dispute_actions_target_key_not_empty_check",
+ "value": "length(\"stripe_dispute_actions\".\"target_key\") > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_dispute_cases": {
+ "name": "stripe_dispute_cases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_dispute_id": {
+ "name": "stripe_dispute_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_event_created_at": {
+ "name": "stripe_event_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_intent_id": {
+ "name": "stripe_payment_intent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_minor_units": {
+ "name": "amount_minor_units",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dispute_reason": {
+ "name": "dispute_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_status": {
+ "name": "stripe_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_classification": {
+ "name": "owner_classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'needs_action'"
+ },
+ "status_reason": {
+ "name": "status_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_created_at": {
+ "name": "stripe_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence_due_by": {
+ "name": "evidence_due_by",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by_kilo_user_id": {
+ "name": "accepted_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "acceptance_started_at": {
+ "name": "acceptance_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enforcement_completed_at": {
+ "name": "enforcement_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_required_at": {
+ "name": "review_required_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_dispute_cases_event_id": {
+ "name": "IDX_stripe_dispute_cases_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_charge_id": {
+ "name": "IDX_stripe_dispute_cases_charge_id",
+ "columns": [
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_payment_intent_id": {
+ "name": "IDX_stripe_dispute_cases_payment_intent_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_intent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_customer_id": {
+ "name": "IDX_stripe_dispute_cases_customer_id",
+ "columns": [
+ {
+ "expression": "stripe_customer_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_kilo_user_id": {
+ "name": "IDX_stripe_dispute_cases_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_organization_id": {
+ "name": "IDX_stripe_dispute_cases_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_status_due_by": {
+ "name": "IDX_stripe_dispute_cases_status_due_by",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "evidence_due_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stripe_created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_dispute_cases_organization_id_organizations_id_fk": {
+ "name": "stripe_dispute_cases_organization_id_organizations_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "accepted_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_dispute_cases_dispute_id": {
+ "name": "UQ_stripe_dispute_cases_dispute_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_dispute_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_dispute_cases_owner_classification_check": {
+ "name": "stripe_dispute_cases_owner_classification_check",
+ "value": "\"stripe_dispute_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
+ },
+ "stripe_dispute_cases_status_check": {
+ "name": "stripe_dispute_cases_status_check",
+ "value": "\"stripe_dispute_cases\".\"status\" IN ('needs_action', 'processing', 'accepted', 'acceptance_failed', 'enforcement_failed', 'review_required', 'closed')"
+ },
+ "stripe_dispute_cases_amount_minor_units_non_negative_check": {
+ "name": "stripe_dispute_cases_amount_minor_units_non_negative_check",
+ "value": "\"stripe_dispute_cases\".\"amount_minor_units\" IS NULL OR \"stripe_dispute_cases\".\"amount_minor_units\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_early_fraud_warning_actions": {
+ "name": "stripe_early_fraud_warning_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "case_id": {
+ "name": "case_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_key": {
+ "name": "target_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_reference_id": {
+ "name": "result_reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_early_fraud_warning_actions_case_id": {
+ "name": "IDX_stripe_early_fraud_warning_actions_case_id",
+ "columns": [
+ {
+ "expression": "case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_actions_claim_path": {
+ "name": "IDX_stripe_early_fraud_warning_actions_claim_path",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk": {
+ "name": "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_actions",
+ "tableTo": "stripe_early_fraud_warning_cases",
+ "columnsFrom": [
+ "case_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_early_fraud_warning_actions_case_type_target": {
+ "name": "UQ_stripe_early_fraud_warning_actions_case_type_target",
+ "nullsNotDistinct": false,
+ "columns": [
+ "case_id",
+ "action_type",
+ "target_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_early_fraud_warning_actions_action_type_check": {
+ "name": "stripe_early_fraud_warning_actions_action_type_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"action_type\" IN ('containment', 'refund', 'payment_value_clawback', 'subscription_termination', 'access_termination', 'kiloclaw_suspension', 'affiliate_payout_reversal', 'referral_reward_reversal', 'user_notice')"
+ },
+ "stripe_early_fraud_warning_actions_status_check": {
+ "name": "stripe_early_fraud_warning_actions_status_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'review_required', 'dismissed')"
+ },
+ "stripe_early_fraud_warning_actions_attempt_count_non_negative_check": {
+ "name": "stripe_early_fraud_warning_actions_attempt_count_non_negative_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"attempt_count\" >= 0"
+ },
+ "stripe_early_fraud_warning_actions_target_key_not_empty_check": {
+ "name": "stripe_early_fraud_warning_actions_target_key_not_empty_check",
+ "value": "length(\"stripe_early_fraud_warning_actions\".\"target_key\") > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_early_fraud_warning_cases": {
+ "name": "stripe_early_fraud_warning_cases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_early_fraud_warning_id": {
+ "name": "stripe_early_fraud_warning_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_intent_id": {
+ "name": "stripe_payment_intent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_minor_units": {
+ "name": "amount_minor_units",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_classification": {
+ "name": "owner_classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warning_created_at": {
+ "name": "warning_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contained_at": {
+ "name": "contained_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processing_started_at": {
+ "name": "processing_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_required_at": {
+ "name": "review_required_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remediated_at": {
+ "name": "remediated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dismissed_at": {
+ "name": "dismissed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_early_fraud_warning_cases_event_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_charge_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_charge_id",
+ "columns": [
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_payment_intent_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_payment_intent_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_intent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_customer_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_customer_id",
+ "columns": [
+ {
+ "expression": "stripe_customer_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_kilo_user_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_organization_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_status_created_at": {
+ "name": "IDX_stripe_early_fraud_warning_cases_status_created_at",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk": {
+ "name": "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_cases",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_early_fraud_warning_cases_warning_id": {
+ "name": "UQ_stripe_early_fraud_warning_cases_warning_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_early_fraud_warning_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_early_fraud_warning_cases_owner_classification_check": {
+ "name": "stripe_early_fraud_warning_cases_owner_classification_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
+ },
+ "stripe_early_fraud_warning_cases_status_check": {
+ "name": "stripe_early_fraud_warning_cases_status_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"status\" IN ('queued', 'contained', 'processing', 'completed', 'review_required', 'failed', 'remediated', 'dismissed')"
+ },
+ "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check": {
+ "name": "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"amount_minor_units\" IS NULL OR \"stripe_early_fraud_warning_cases\".\"amount_minor_units\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stytch_fingerprints": {
+ "name": "stytch_fingerprints",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visitor_fingerprint": {
+ "name": "visitor_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "browser_fingerprint": {
+ "name": "browser_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "browser_id": {
+ "name": "browser_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hardware_fingerprint": {
+ "name": "hardware_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "network_fingerprint": {
+ "name": "network_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visitor_id": {
+ "name": "visitor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verdict_action": {
+ "name": "verdict_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "detected_device_type": {
+ "name": "detected_device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_authentic_device": {
+ "name": "is_authentic_device",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reasons": {
+ "name": "reasons",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{\"\"}'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fingerprint_data": {
+ "name": "fingerprint_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_free_tier_allowed": {
+ "name": "kilo_free_tier_allowed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_hardware_fingerprint": {
+ "name": "idx_hardware_fingerprint",
+ "columns": [
+ {
+ "expression": "hardware_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_kilo_user_id": {
+ "name": "idx_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_stytch_fingerprints_reasons_gin": {
+ "name": "idx_stytch_fingerprints_reasons_gin",
+ "columns": [
+ {
+ "expression": "reasons",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ },
+ "idx_verdict_action": {
+ "name": "idx_verdict_action",
+ "columns": [
+ {
+ "expression": "verdict_action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_visitor_fingerprint": {
+ "name": "idx_visitor_fingerprint",
+ "columns": [
+ {
+ "expression": "visitor_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "schema": "",
+ "columns": {
+ "system_prompt_prefix_id": {
+ "name": "system_prompt_prefix_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_system_prompt_prefix": {
+ "name": "UQ_system_prompt_prefix",
+ "columns": [
+ {
+ "expression": "system_prompt_prefix",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.transactional_email_log": {
+ "name": "transactional_email_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_type": {
+ "name": "email_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_transactional_email_log_type_idempotency_key": {
+ "name": "UQ_transactional_email_log_type_idempotency_key",
+ "columns": [
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_transactional_email_log_user_id": {
+ "name": "IDX_transactional_email_log_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_transactional_email_log_organization_id": {
+ "name": "IDX_transactional_email_log_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "transactional_email_log_user_id_kilocode_users_id_fk": {
+ "name": "transactional_email_log_user_id_kilocode_users_id_fk",
+ "tableFrom": "transactional_email_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "transactional_email_log_organization_id_organizations_id_fk": {
+ "name": "transactional_email_log_organization_id_organizations_id_fk",
+ "tableFrom": "transactional_email_log",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_transactional_email_log_owner": {
+ "name": "CHK_transactional_email_log_owner",
+ "value": "\"transactional_email_log\".\"user_id\" IS NOT NULL OR \"transactional_email_log\".\"organization_id\" IS NOT NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_admin_notes": {
+ "name": "user_admin_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note_content": {
+ "name": "note_content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "admin_kilo_user_id": {
+ "name": "admin_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_34517df0b385234babc38fe81b": {
+ "name": "IDX_34517df0b385234babc38fe81b",
+ "columns": [
+ {
+ "expression": "admin_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_ccbde98c4c14046daa5682ec4f": {
+ "name": "IDX_ccbde98c4c14046daa5682ec4f",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_d0270eb24ef6442d65a0b7853c": {
+ "name": "IDX_d0270eb24ef6442d65a0b7853c",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_affiliate_attributions": {
+ "name": "user_affiliate_attributions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tracking_id": {
+ "name": "tracking_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_affiliate_attributions_user_id": {
+ "name": "IDX_user_affiliate_attributions_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_affiliate_attributions_user_id_kilocode_users_id_fk": {
+ "name": "user_affiliate_attributions_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_affiliate_attributions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_user_affiliate_attributions_user_provider": {
+ "name": "UQ_user_affiliate_attributions_user_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "provider"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "user_affiliate_attributions_provider_check": {
+ "name": "user_affiliate_attributions_provider_check",
+ "value": "\"user_affiliate_attributions\".\"provider\" IN ('impact')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_affiliate_events": {
+ "name": "user_affiliate_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_event_id": {
+ "name": "parent_event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delivery_state": {
+ "name": "delivery_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_action_id": {
+ "name": "impact_action_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_submission_uri": {
+ "name": "impact_submission_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_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": {
+ "IDX_user_affiliate_events_claim_path": {
+ "name": "IDX_user_affiliate_events_claim_path",
+ "columns": [
+ {
+ "expression": "delivery_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_affiliate_events_parent_event_id": {
+ "name": "IDX_user_affiliate_events_parent_event_id",
+ "columns": [
+ {
+ "expression": "parent_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_affiliate_events_provider_event_type_charge": {
+ "name": "IDX_user_affiliate_events_provider_event_type_charge",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_affiliate_events_user_id_kilocode_users_id_fk": {
+ "name": "user_affiliate_events_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_affiliate_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_affiliate_events_parent_event_id_fk": {
+ "name": "user_affiliate_events_parent_event_id_fk",
+ "tableFrom": "user_affiliate_events",
+ "tableTo": "user_affiliate_events",
+ "columnsFrom": [
+ "parent_event_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_user_affiliate_events_dedupe_key": {
+ "name": "UQ_user_affiliate_events_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "user_affiliate_events_provider_check": {
+ "name": "user_affiliate_events_provider_check",
+ "value": "\"user_affiliate_events\".\"provider\" IN ('impact')"
+ },
+ "user_affiliate_events_event_type_check": {
+ "name": "user_affiliate_events_event_type_check",
+ "value": "\"user_affiliate_events\".\"event_type\" IN ('signup', 'trial_start', 'trial_end', 'sale', 'sale_reversal')"
+ },
+ "user_affiliate_events_delivery_state_check": {
+ "name": "user_affiliate_events_delivery_state_check",
+ "value": "\"user_affiliate_events\".\"delivery_state\" IN ('queued', 'blocked', 'sending', 'delivered', 'failed')"
+ },
+ "user_affiliate_events_attempt_count_non_negative_check": {
+ "name": "user_affiliate_events_attempt_count_non_negative_check",
+ "value": "\"user_affiliate_events\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_auth_provider": {
+ "name": "user_auth_provider",
+ "schema": "",
+ "columns": {
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_account_id": {
+ "name": "provider_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hosted_domain": {
+ "name": "hosted_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_auth_provider_kilo_user_id": {
+ "name": "IDX_user_auth_provider_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_auth_provider_hosted_domain": {
+ "name": "IDX_user_auth_provider_hosted_domain",
+ "columns": [
+ {
+ "expression": "hosted_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "user_auth_provider_provider_provider_account_id_pk": {
+ "name": "user_auth_provider_provider_provider_account_id_pk",
+ "columns": [
+ "provider",
+ "provider_account_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feedback": {
+ "name": "user_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feedback_for": {
+ "name": "feedback_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "feedback_batch": {
+ "name": "feedback_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "context_json": {
+ "name": "context_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_feedback_created_at": {
+ "name": "IDX_user_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_kilo_user_id": {
+ "name": "IDX_user_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_feedback_for": {
+ "name": "IDX_user_feedback_feedback_for",
+ "columns": [
+ {
+ "expression": "feedback_for",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_feedback_batch": {
+ "name": "IDX_user_feedback_feedback_batch",
+ "columns": [
+ {
+ "expression": "feedback_batch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_source": {
+ "name": "IDX_user_feedback_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_github_app_tokens": {
+ "name": "user_github_app_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_app_type": {
+ "name": "github_app_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'standard'"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_encrypted": {
+ "name": "access_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_reason": {
+ "name": "revocation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_user_github_app_tokens_user_app": {
+ "name": "UQ_user_github_app_tokens_user_app",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "github_app_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_github_app_tokens_github_user_app": {
+ "name": "UQ_user_github_app_tokens_github_user_app",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "github_app_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_github_app_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_github_app_tokens_app_type_check": {
+ "name": "user_github_app_tokens_app_type_check",
+ "value": "\"user_github_app_tokens\".\"github_app_type\" IN ('standard', 'lite')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_period_cache": {
+ "name": "user_period_cache",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_type": {
+ "name": "cache_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_type": {
+ "name": "period_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_key": {
+ "name": "period_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "computed_at": {
+ "name": "computed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "shared_url_token": {
+ "name": "shared_url_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "shared_at": {
+ "name": "shared_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_user_period_cache_kilo_user_id": {
+ "name": "IDX_user_period_cache_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_period_cache": {
+ "name": "UQ_user_period_cache",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "cache_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_period_cache_lookup": {
+ "name": "IDX_user_period_cache_lookup",
+ "columns": [
+ {
+ "expression": "cache_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_period_cache_share_token": {
+ "name": "UQ_user_period_cache_share_token",
+ "columns": [
+ {
+ "expression": "shared_url_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_period_cache\".\"shared_url_token\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_period_cache_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_period_cache_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_period_cache",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_period_cache_period_type_check": {
+ "name": "user_period_cache_period_type_check",
+ "value": "\"user_period_cache\".\"period_type\" IN ('year', 'quarter', 'month', 'week', 'custom')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_push_tokens": {
+ "name": "user_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_user_push_tokens_token": {
+ "name": "UQ_user_push_tokens_token",
+ "columns": [
+ {
+ "expression": "token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_push_tokens_user_id": {
+ "name": "IDX_user_push_tokens_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_push_tokens_user_id_kilocode_users_id_fk": {
+ "name": "user_push_tokens_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_push_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.vercel_ip_city": {
+ "name": "vercel_ip_city",
+ "schema": "",
+ "columns": {
+ "vercel_ip_city_id": {
+ "name": "vercel_ip_city_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "vercel_ip_city": {
+ "name": "vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_vercel_ip_city": {
+ "name": "UQ_vercel_ip_city",
+ "columns": [
+ {
+ "expression": "vercel_ip_city",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.vercel_ip_country": {
+ "name": "vercel_ip_country",
+ "schema": "",
+ "columns": {
+ "vercel_ip_country_id": {
+ "name": "vercel_ip_country_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "vercel_ip_country": {
+ "name": "vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_vercel_ip_country": {
+ "name": "UQ_vercel_ip_country",
+ "columns": [
+ {
+ "expression": "vercel_ip_country",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook_events": {
+ "name": "webhook_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_action": {
+ "name": "event_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "headers": {
+ "name": "headers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "processed": {
+ "name": "processed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "handlers_triggered": {
+ "name": "handlers_triggered",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "errors": {
+ "name": "errors",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_signature": {
+ "name": "event_signature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_webhook_events_owned_by_org_id": {
+ "name": "IDX_webhook_events_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_owned_by_user_id": {
+ "name": "IDX_webhook_events_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_platform": {
+ "name": "IDX_webhook_events_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_event_type": {
+ "name": "IDX_webhook_events_event_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_created_at": {
+ "name": "IDX_webhook_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_events_owned_by_organization_id_organizations_id_fk": {
+ "name": "webhook_events_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "webhook_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "webhook_events_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "webhook_events_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "webhook_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_webhook_events_signature": {
+ "name": "UQ_webhook_events_signature",
+ "nullsNotDistinct": false,
+ "columns": [
+ "event_signature"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "webhook_events_owner_check": {
+ "name": "webhook_events_owner_check",
+ "value": "(\n (\"webhook_events\".\"owned_by_user_id\" IS NOT NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"webhook_events\".\"owned_by_user_id\" IS NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {
+ "public.microdollar_usage_view": {
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_write_tokens": {
+ "name": "cache_write_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_hit_tokens": {
+ "name": "cache_hit_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_model": {
+ "name": "requested_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_prompt_prefix": {
+ "name": "user_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_length": {
+ "name": "system_prompt_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_discount": {
+ "name": "cache_discount",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_tokens": {
+ "name": "max_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_middle_out_transform": {
+ "name": "has_middle_out_transform",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_error": {
+ "name": "has_error",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "abuse_classification": {
+ "name": "abuse_classification",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_provider": {
+ "name": "inference_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "upstream_id": {
+ "name": "upstream_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finish_reason": {
+ "name": "finish_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency": {
+ "name": "latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderation_latency": {
+ "name": "moderation_latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_time": {
+ "name": "generation_time",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_byok": {
+ "name": "is_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_user_byok": {
+ "name": "is_user_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "streamed": {
+ "name": "streamed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled": {
+ "name": "cancelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_name": {
+ "name": "editor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_kind": {
+ "name": "api_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_tools": {
+ "name": "has_tools",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "machine_id": {
+ "name": "machine_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_model": {
+ "name": "auto_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_cost": {
+ "name": "market_cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_delay": {
+ "name": "abuse_delay",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_downgraded_from": {
+ "name": "abuse_downgraded_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "definition": "\n SELECT\n mu.id,\n mu.kilo_user_id,\n meta.message_id,\n mu.cost,\n mu.input_tokens,\n mu.output_tokens,\n mu.cache_write_tokens,\n mu.cache_hit_tokens,\n mu.created_at,\n ip.http_ip AS http_x_forwarded_for,\n city.vercel_ip_city AS http_x_vercel_ip_city,\n country.vercel_ip_country AS http_x_vercel_ip_country,\n meta.vercel_ip_latitude AS http_x_vercel_ip_latitude,\n meta.vercel_ip_longitude AS http_x_vercel_ip_longitude,\n ja4.ja4_digest AS http_x_vercel_ja4_digest,\n mu.provider,\n mu.model,\n mu.requested_model,\n meta.user_prompt_prefix,\n spp.system_prompt_prefix,\n meta.system_prompt_length,\n ua.http_user_agent,\n mu.cache_discount,\n meta.max_tokens,\n meta.has_middle_out_transform,\n mu.has_error,\n mu.abuse_classification,\n mu.organization_id,\n mu.inference_provider,\n mu.project_id,\n meta.status_code,\n meta.upstream_id,\n frfr.finish_reason,\n meta.latency,\n meta.moderation_latency,\n meta.generation_time,\n meta.is_byok,\n meta.is_user_byok,\n meta.streamed,\n meta.cancelled,\n edit.editor_name,\n ak.api_kind,\n meta.has_tools,\n meta.machine_id,\n feat.feature,\n meta.session_id,\n md.mode,\n am.auto_model,\n meta.market_cost,\n meta.is_free,\n meta.abuse_delay,\n meta.abuse_downgraded_from\n FROM \"microdollar_usage\" mu\n LEFT JOIN \"microdollar_usage_metadata\" meta ON mu.id = meta.id\n LEFT JOIN \"http_ip\" ip ON meta.http_ip_id = ip.http_ip_id\n LEFT JOIN \"vercel_ip_city\" city ON meta.vercel_ip_city_id = city.vercel_ip_city_id\n LEFT JOIN \"vercel_ip_country\" country ON meta.vercel_ip_country_id = country.vercel_ip_country_id\n LEFT JOIN \"ja4_digest\" ja4 ON meta.ja4_digest_id = ja4.ja4_digest_id\n LEFT JOIN \"system_prompt_prefix\" spp ON meta.system_prompt_prefix_id = spp.system_prompt_prefix_id\n LEFT JOIN \"http_user_agent\" ua ON meta.http_user_agent_id = ua.http_user_agent_id\n LEFT JOIN \"finish_reason\" frfr ON meta.finish_reason_id = frfr.finish_reason_id\n LEFT JOIN \"editor_name\" edit ON meta.editor_name_id = edit.editor_name_id\n LEFT JOIN \"api_kind\" ak ON meta.api_kind_id = ak.api_kind_id\n LEFT JOIN \"feature\" feat ON meta.feature_id = feat.feature_id\n LEFT JOIN \"mode\" md ON meta.mode_id = md.mode_id\n LEFT JOIN \"auto_model\" am ON meta.auto_model_id = am.auto_model_id\n",
+ "name": "microdollar_usage_view",
+ "schema": "public",
+ "isExisting": false,
+ "materialized": false
+ }
+ },
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.json
index 819761c75c..ca0632c955 100644
--- a/packages/db/src/migrations/meta/_journal.json
+++ b/packages/db/src/migrations/meta/_journal.json
@@ -1219,6 +1219,13 @@
"when": 1782381719017,
"tag": "0173_lowly_venom",
"breakpoints": true
+ },
+ {
+ "idx": 174,
+ "version": "7",
+ "when": 1782402944684,
+ "tag": "0174_omniscient_tenebrous",
+ "breakpoints": true
}
]
}
\ No newline at end of file
From 1144d7c38804f74c3bbdffc14f5cddcdd1d5cebe Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 11:09:51 -0500
Subject: [PATCH 04/33] Reorder organization-types col ordering to match schema
& make migration idempotent
---
apps/web/src/lib/organizations/organization-types.ts | 4 ++--
packages/db/src/migrations/0174_omniscient_tenebrous.sql | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/apps/web/src/lib/organizations/organization-types.ts b/apps/web/src/lib/organizations/organization-types.ts
index 1d56bc1579..22ee89e27f 100644
--- a/apps/web/src/lib/organizations/organization-types.ts
+++ b/apps/web/src/lib/organizations/organization-types.ts
@@ -56,8 +56,6 @@ export const OrganizationCreateRequestSchema = z.object({
export const OrganizationSchema = z.object({
id: z.string(),
name: z.string(),
- slug: z.string().nullable(),
- requested_slug: z.string().nullable(),
created_at: z.string(),
updated_at: z.string(),
microdollars_used: z.number(),
@@ -75,6 +73,8 @@ export const OrganizationSchema = z.object({
plan: z.enum(['teams', 'enterprise']),
free_trial_end_at: z.string().nullable(),
company_domain: z.string().nullable(),
+ slug: z.string().nullable(),
+ requested_slug: z.string().nullable(),
});
export type UserOrganizationWithSeats = {
diff --git a/packages/db/src/migrations/0174_omniscient_tenebrous.sql b/packages/db/src/migrations/0174_omniscient_tenebrous.sql
index 8c99291408..d898be05f0 100644
--- a/packages/db/src/migrations/0174_omniscient_tenebrous.sql
+++ b/packages/db/src/migrations/0174_omniscient_tenebrous.sql
@@ -1,3 +1,3 @@
-ALTER TABLE "organizations" ADD COLUMN "slug" text;--> statement-breakpoint
-ALTER TABLE "organizations" ADD COLUMN "requested_slug" text;--> statement-breakpoint
-ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_unique" UNIQUE("slug");
\ No newline at end of file
+ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "slug" text;--> statement-breakpoint
+ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "requested_slug" text;--> statement-breakpoint
+ALTER TABLE "organizations" ADD CONSTRAINT IF NOT EXISTS "organizations_slug_unique" UNIQUE("slug");
From 4a6781ca937da6653a9e297fd31ef89792727488 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 11:44:00 -0500
Subject: [PATCH 05/33] feat(organizations): manage requested slugs
---
apps/web/src/app/api/organizations/hooks.ts | 80 +++++
.../organizations/OrganizationInfoCard.tsx | 279 +++++++++++++++++-
.../auto-model-change-log.test.ts | 2 +
.../organization-admin-router.ts | 2 +
.../organizations/organization-router.ts | 123 +++++++-
5 files changed, 483 insertions(+), 3 deletions(-)
diff --git a/apps/web/src/app/api/organizations/hooks.ts b/apps/web/src/app/api/organizations/hooks.ts
index ae28e1c4eb..b28706d90f 100644
--- a/apps/web/src/app/api/organizations/hooks.ts
+++ b/apps/web/src/app/api/organizations/hooks.ts
@@ -105,6 +105,34 @@ export function useOrganizationUsageStats(organizationId: string) {
return useQuery(trpc.organizations.usageStats.queryOptions({ organizationId }));
}
+export function useRequestedSlugAvailability(
+ organizationId: string,
+ requestedSlug: string | null,
+ options?: { enabled?: boolean }
+) {
+ const trpc = useTRPC();
+ return useQuery(
+ trpc.organizations.requestedSlugAvailability.queryOptions(
+ { organizationId, requested_slug: requestedSlug },
+ options
+ )
+ );
+}
+
+export function useSlugAvailability(
+ organizationId: string,
+ slug: string | null,
+ options?: { enabled?: boolean }
+) {
+ const trpc = useTRPC();
+ return useQuery(
+ trpc.organizations.requestedSlugAvailability.queryOptions(
+ { organizationId, requested_slug: slug },
+ options
+ )
+ );
+}
+
export function useOrganizationAutocompleteMetrics(
organizationId: string,
period: TimePeriod = 'month'
@@ -189,6 +217,58 @@ export function useUpdateOrganizationName() {
);
}
+export function useUpdateOrganizationRequestedSlug() {
+ const trpc = useTRPC();
+ const onSuccess = useInvalidateOrganizationAndMembers();
+ return useMutation(
+ trpc.organizations.updateRequestedSlug.mutationOptions({
+ onSuccess,
+ })
+ );
+}
+
+export function useAdminUpdateOrganizationSlug() {
+ const trpc = useTRPC();
+ const invalidate = useInvalidateAllOrganizationData();
+ const queryClient = useQueryClient();
+ return useMutation(
+ trpc.organizations.updateSlug.mutationOptions({
+ onSuccess: () => {
+ void queryClient.invalidateQueries({ queryKey: ['admin-organizations'] });
+ void invalidate();
+ },
+ })
+ );
+}
+
+export function useAdminAcceptRequestedSlug() {
+ const trpc = useTRPC();
+ const invalidate = useInvalidateAllOrganizationData();
+ const queryClient = useQueryClient();
+ return useMutation(
+ trpc.organizations.acceptRequestedSlug.mutationOptions({
+ onSuccess: () => {
+ void queryClient.invalidateQueries({ queryKey: ['admin-organizations'] });
+ void invalidate();
+ },
+ })
+ );
+}
+
+export function useAdminDeclineRequestedSlug() {
+ const trpc = useTRPC();
+ const invalidate = useInvalidateAllOrganizationData();
+ const queryClient = useQueryClient();
+ return useMutation(
+ trpc.organizations.declineRequestedSlug.mutationOptions({
+ onSuccess: () => {
+ void queryClient.invalidateQueries({ queryKey: ['admin-organizations'] });
+ void invalidate();
+ },
+ })
+ );
+}
+
export function useUpdateCompanyDomain() {
const trpc = useTRPC();
const onSuccess = useInvalidateOrganizationAndMembers();
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index 79356ad1f8..83f0fa8388 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -5,6 +5,12 @@ import { Button } from '@/components/ui/button';
import { BooleanBadge } from '@/components/ui/boolean-badge';
import {
useUpdateOrganizationName,
+ useUpdateOrganizationRequestedSlug,
+ useRequestedSlugAvailability,
+ useSlugAvailability,
+ useAdminUpdateOrganizationSlug,
+ useAdminAcceptRequestedSlug,
+ useAdminDeclineRequestedSlug,
useUpdateCompanyDomain,
useOrganizationWithMembers,
useAdminToggleCodeIndexing,
@@ -15,7 +21,7 @@ import { normalizeCompanyDomain, isValidDomain } from '@/lib/organizations/compa
import { ErrorCard } from '@/components/ErrorCard';
import { LoadingCard } from '@/components/LoadingCard';
import { AnimatedDollars } from './AnimatedDollars';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import {
Edit,
Check,
@@ -163,6 +169,12 @@ function Inner(props: InnerProps) {
const [isEditing, setIsEditing] = useState(false);
const [editedName, setEditedName] = useState(name);
+ const [isEditingRequestedSlug, setIsEditingRequestedSlug] = useState(false);
+ const [editedRequestedSlug, setEditedRequestedSlug] = useState(info.requested_slug ?? '');
+ const [requestedSlugError, setRequestedSlugError] = useState(null);
+ const [isEditingSlug, setIsEditingSlug] = useState(false);
+ const [editedSlug, setEditedSlug] = useState(info.slug ?? '');
+ const [slugError, setSlugError] = useState(null);
const [isEditingDomain, setIsEditingDomain] = useState(false);
const [editedDomain, setEditedDomain] = useState(info.company_domain ?? '');
const [domainError, setDomainError] = useState(null);
@@ -173,11 +185,39 @@ function Inner(props: InnerProps) {
const [isSpendingAlertsModalOpen, setIsSpendingAlertsModalOpen] = useState(false);
const [ossSponsorshipDialogOpen, setOssSponsorshipDialogOpen] = useState(false);
const updateOrganizationName = useUpdateOrganizationName();
+ const updateOrganizationRequestedSlug = useUpdateOrganizationRequestedSlug();
+ const adminUpdateOrganizationSlug = useAdminUpdateOrganizationSlug();
+ const adminAcceptRequestedSlug = useAdminAcceptRequestedSlug();
+ const adminDeclineRequestedSlug = useAdminDeclineRequestedSlug();
const updateCompanyDomain = useUpdateCompanyDomain();
const adminToggleCodeIndexing = useAdminToggleCodeIndexing();
const updateSuppressTrialMessaging = useUpdateSuppressTrialMessaging();
const { expiringBlocks, expiring_mUsd, earliestExpiry } = useExpiringCredits(id);
+ const requestedSlugAvailability = useRequestedSlugAvailability(id, info.requested_slug, {
+ enabled: Boolean(info.requested_slug),
+ });
+ const editedSlugAvailability = useSlugAvailability(id, editedSlug.trim() || null, {
+ enabled: isEditingSlug && Boolean(editedSlug.trim()) && editedSlug.trim() !== info.slug,
+ });
+ const isRequestedSlugAvailable = requestedSlugAvailability.data?.available ?? true;
+ const isEditedSlugAvailable = editedSlugAvailability.data?.available ?? true;
+ const requestedSlugMutationPending =
+ updateOrganizationRequestedSlug.isPending ||
+ adminAcceptRequestedSlug.isPending ||
+ adminDeclineRequestedSlug.isPending;
+
+ useEffect(() => {
+ if (!isEditingRequestedSlug) {
+ setEditedRequestedSlug(info.requested_slug ?? '');
+ }
+ }, [info.requested_slug, isEditingRequestedSlug]);
+
+ useEffect(() => {
+ if (!isEditingSlug) {
+ setEditedSlug(info.slug ?? '');
+ }
+ }, [info.slug, isEditingSlug]);
const handleSave = async () => {
if (editedName.trim() === name) {
@@ -211,6 +251,83 @@ function Inner(props: InnerProps) {
}
};
+ const handleRequestedSlugSave = async () => {
+ setRequestedSlugError(null);
+ const nextRequestedSlug = editedRequestedSlug.trim() || null;
+ if (nextRequestedSlug === info.requested_slug) {
+ setEditedRequestedSlug(info.requested_slug ?? '');
+ setIsEditingRequestedSlug(false);
+ return;
+ }
+
+ try {
+ await updateOrganizationRequestedSlug.mutateAsync({
+ organizationId: id,
+ requested_slug: nextRequestedSlug,
+ });
+ setIsEditingRequestedSlug(false);
+ } catch (error) {
+ console.error('Failed to update requested organization slug:', error);
+ setRequestedSlugError(
+ error instanceof Error ? error.message : 'Requested slug is not available'
+ );
+ }
+ };
+
+ const handleRequestedSlugCancel = () => {
+ setEditedRequestedSlug(info.requested_slug ?? '');
+ setRequestedSlugError(null);
+ setIsEditingRequestedSlug(false);
+ };
+
+ const handleRequestedSlugKeyDown = (e: React.KeyboardEvent) => {
+ if (e.key === 'Enter') {
+ void handleRequestedSlugSave();
+ } else if (e.key === 'Escape') {
+ handleRequestedSlugCancel();
+ }
+ };
+
+ const handleSlugSave = async () => {
+ setSlugError(null);
+ const nextSlug = editedSlug.trim() || null;
+ if (nextSlug === info.slug) {
+ setEditedSlug(info.slug ?? '');
+ setIsEditingSlug(false);
+ return;
+ }
+
+ if (!isEditedSlugAvailable) {
+ setSlugError('Not Available');
+ return;
+ }
+
+ try {
+ await adminUpdateOrganizationSlug.mutateAsync({
+ organizationId: id,
+ slug: nextSlug,
+ });
+ setIsEditingSlug(false);
+ } catch (error) {
+ console.error('Failed to update organization slug:', error);
+ setSlugError(error instanceof Error ? error.message : 'Slug is not available');
+ }
+ };
+
+ const handleSlugCancel = () => {
+ setEditedSlug(info.slug ?? '');
+ setSlugError(null);
+ setIsEditingSlug(false);
+ };
+
+ const handleSlugKeyDown = (e: React.KeyboardEvent) => {
+ if (e.key === 'Enter') {
+ void handleSlugSave();
+ } else if (e.key === 'Escape') {
+ handleSlugCancel();
+ }
+ };
+
const handleDomainSave = async () => {
setDomainError(null);
const normalized = normalizeCompanyDomain(editedDomain);
@@ -354,7 +471,165 @@ function Inner(props: InnerProps) {
Slug
-
{info.slug}
+ {isEditingSlug ? (
+
+
+ {
+ setEditedSlug(e.target.value);
+ setSlugError(null);
+ }}
+ onKeyDown={handleSlugKeyDown}
+ className={`font-mono text-sm ${slugError ? 'border-red-400' : ''}`}
+ autoFocus
+ disabled={adminUpdateOrganizationSlug.isPending}
+ />
+ {editedSlug.trim() && !isEditedSlugAvailable ? (
+
+ Not Available
+
+ ) : null}
+
+
+
+
+
+
+
+ {slugError ?
{slugError}
: null}
+
+ ) : (
+
+
+ {info.slug || Not set }
+
+ {isKiloAdmin && (
+
setIsEditingSlug(true)}
+ className="hover:bg-muted inline-flex cursor-pointer items-center gap-1 rounded p-1 transition-all duration-200 focus:outline-none"
+ title="Edit organization slug"
+ >
+
+
+ )}
+
+ )}
+
+
+
Requested Slug
+ {isEditingRequestedSlug ? (
+
+
+ {
+ setEditedRequestedSlug(e.target.value);
+ setRequestedSlugError(null);
+ }}
+ onKeyDown={handleRequestedSlugKeyDown}
+ className={`font-mono text-sm ${requestedSlugError ? 'border-red-400' : ''}`}
+ autoFocus
+ disabled={updateOrganizationRequestedSlug.isPending}
+ />
+
+
+
+
+
+
+
+ {requestedSlugError ? (
+
{requestedSlugError}
+ ) : null}
+
+ ) : (
+
+
+ {info.requested_slug || Not set }
+
+ {info.requested_slug && !isRequestedSlugAvailable ? (
+
+ Not Available
+
+ ) : null}
+ {isOrgOwner && (
+
setIsEditingRequestedSlug(true)}
+ className="hover:bg-muted inline-flex cursor-pointer items-center gap-1 rounded p-1 transition-all duration-200 focus:outline-none"
+ title="Edit requested organization slug"
+ >
+
+
+ )}
+ {isKiloAdmin && info.requested_slug ? (
+ <>
+
+ adminAcceptRequestedSlug.mutate({
+ organizationId: id,
+ })
+ }
+ disabled={requestedSlugMutationPending || !isRequestedSlugAvailable}
+ className="h-8 w-8 p-0"
+ aria-label="Accept requested organization slug"
+ title={
+ isRequestedSlugAvailable
+ ? 'Accept requested organization slug'
+ : 'Requested slug is not available'
+ }
+ >
+
+
+
+ adminDeclineRequestedSlug.mutate({
+ organizationId: id,
+ })
+ }
+ disabled={requestedSlugMutationPending}
+ className="h-8 w-8 p-0"
+ aria-label="Decline requested organization slug"
+ title="Decline requested organization slug"
+ >
+
+
+ >
+ ) : null}
+
+ )}
Company Domain
diff --git a/apps/web/src/lib/organizations/auto-model-change-log.test.ts b/apps/web/src/lib/organizations/auto-model-change-log.test.ts
index c93f25b39e..f782fedc56 100644
--- a/apps/web/src/lib/organizations/auto-model-change-log.test.ts
+++ b/apps/web/src/lib/organizations/auto-model-change-log.test.ts
@@ -67,6 +67,8 @@ function buildEnterpriseOrg(overrides: Partial = {}): Organization
plan: 'enterprise',
free_trial_end_at: null,
company_domain: null,
+ slug: null,
+ requested_slug: null,
...overrides,
} satisfies Organization;
}
diff --git a/apps/web/src/routers/organizations/organization-admin-router.ts b/apps/web/src/routers/organizations/organization-admin-router.ts
index 08a0b7bb4a..ade3a5ae2e 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.ts
@@ -1011,6 +1011,8 @@ export const organizationAdminRouter = createTRPCRouter({
plan: organizations.plan,
free_trial_end_at: organizations.free_trial_end_at,
company_domain: organizations.company_domain,
+ slug: organizations.slug,
+ requested_slug: organizations.requested_slug,
// Null out subscription_amount_usd for non-billable statuses so the
// "Subscription" column doesn't display the dollar amount of a churned
// plan as if it were current MRR. Reading "latest_stripe_status" tells
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index 253d2295d8..b8246fb4c5 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -39,7 +39,7 @@ import { organizationsSubscriptionRouter } from '@/routers/organizations/organiz
import { organizationsSettingsRouter } from '@/routers/organizations/organization-settings-router';
import { organizationsUsageDetailsRouter } from '@/routers/organizations/organization-usage-details-router';
import { TRPCError } from '@trpc/server';
-import { and, asc, count, desc, eq, inArray, isNull, sql } from 'drizzle-orm';
+import { and, asc, count, desc, eq, inArray, isNull, ne, sql } from 'drizzle-orm';
import * as z from 'zod';
import { getCreditTransactionsForOrganization } from '@/lib/creditTransactions';
import { getCreditBlocks } from '@/lib/getCreditBlocks';
@@ -69,6 +69,24 @@ const OrganizationUpdateSchema = OrganizationIdInputSchema.extend({
name: OrganizationNameSchema,
});
+const OrganizationSlugSchema = z
+ .string()
+ .trim()
+ .min(1, 'Organization slug is required')
+ .max(100, 'Organization slug must be less than 100 characters')
+ .regex(
+ /^[a-z0-9][a-z0-9-]*$/,
+ 'Organization slug must use lowercase letters, numbers, and hyphens'
+ );
+
+const OrganizationRequestedSlugUpdateSchema = OrganizationIdInputSchema.extend({
+ requested_slug: OrganizationSlugSchema.nullable(),
+});
+
+const OrganizationSlugUpdateSchema = OrganizationIdInputSchema.extend({
+ slug: OrganizationSlugSchema.nullable(),
+});
+
const OrganizationSeatsUpdateSchema = OrganizationIdInputSchema.extend({
seatsRequired: z.boolean(),
});
@@ -82,6 +100,26 @@ function daysAgo(days: number): Date {
return new Date(now.getTime() - days * 24 * 60 * 60 * 1000);
}
+async function getOrganizationByActiveSlug(slug: string, organizationId: string) {
+ const [existingOrganization] = await db
+ .select({ id: organizations.id })
+ .from(organizations)
+ .where(and(eq(organizations.slug, slug), ne(organizations.id, organizationId)))
+ .limit(1);
+
+ return existingOrganization ?? null;
+}
+
+async function assertActiveSlugAvailable(slug: string, organizationId: string) {
+ const existingOrganization = await getOrganizationByActiveSlug(slug, organizationId);
+ if (existingOrganization) {
+ throw new TRPCError({
+ code: 'CONFLICT',
+ message: 'Requested slug is not available',
+ });
+ }
+}
+
const MAX_ORGANIZATIONS_PER_USER = 5;
function getDateThreshold(period: string): Date | null {
@@ -192,6 +230,31 @@ export const organizationsRouter = createTRPCRouter({
return successResult();
}),
+ updateRequestedSlug: organizationBillingMutationProcedure
+ .input(OrganizationRequestedSlugUpdateSchema)
+ .mutation(async opts => {
+ await db
+ .update(organizations)
+ .set({ requested_slug: opts.input.requested_slug })
+ .where(eq(organizations.id, opts.input.organizationId));
+ return successResult();
+ }),
+
+ requestedSlugAvailability: organizationMemberProcedure
+ .input(OrganizationRequestedSlugUpdateSchema)
+ .query(async opts => {
+ if (!opts.input.requested_slug) {
+ return { available: true };
+ }
+
+ const existingOrganization = await getOrganizationByActiveSlug(
+ opts.input.requested_slug,
+ opts.input.organizationId
+ );
+
+ return { available: !existingOrganization };
+ }),
+
withMembers: organizationMemberProcedure.query(async opts => {
const organizationId = opts.input.organizationId;
@@ -369,6 +432,64 @@ export const organizationsRouter = createTRPCRouter({
};
}),
+ updateSlug: adminProcedure.input(OrganizationSlugUpdateSchema).mutation(async opts => {
+ await ensureOrganizationAccess(opts.ctx, opts.input.organizationId, ['owner']);
+ if (opts.input.slug) {
+ await assertActiveSlugAvailable(opts.input.slug, opts.input.organizationId);
+ }
+
+ await db
+ .update(organizations)
+ .set({ slug: opts.input.slug })
+ .where(eq(organizations.id, opts.input.organizationId));
+
+ return {
+ organization: {
+ id: opts.input.organizationId,
+ slug: opts.input.slug,
+ },
+ };
+ }),
+
+ acceptRequestedSlug: adminProcedure.input(OrganizationIdInputSchema).mutation(async opts => {
+ await ensureOrganizationAccess(opts.ctx, opts.input.organizationId, ['owner']);
+ const organization = await getOrganizationById(opts.input.organizationId);
+ if (!organization) {
+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Organization not found' });
+ }
+
+ const requestedSlug = OrganizationSlugSchema.parse(organization.requested_slug);
+ await assertActiveSlugAvailable(requestedSlug, opts.input.organizationId);
+
+ await db
+ .update(organizations)
+ .set({ slug: requestedSlug, requested_slug: null })
+ .where(eq(organizations.id, opts.input.organizationId));
+
+ return {
+ organization: {
+ id: opts.input.organizationId,
+ slug: requestedSlug,
+ requested_slug: null,
+ },
+ };
+ }),
+
+ declineRequestedSlug: adminProcedure.input(OrganizationIdInputSchema).mutation(async opts => {
+ await ensureOrganizationAccess(opts.ctx, opts.input.organizationId, ['owner']);
+ await db
+ .update(organizations)
+ .set({ requested_slug: null })
+ .where(eq(organizations.id, opts.input.organizationId));
+
+ return {
+ organization: {
+ id: opts.input.organizationId,
+ requested_slug: null,
+ },
+ };
+ }),
+
usageStats: organizationMemberProcedure.output(UsageStatsSchema).query(async opts => {
// Fetch and return usage stats for the organization (last 30 days)
// Get usage statistics
From cfff64efe2ba92067fcb0c0b2d925a3f2a1eb4c9 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 12:01:14 -0500
Subject: [PATCH 06/33] Only display slug request to the relevant users
---
.../organizations/OrganizationInfoCard.tsx | 177 +++++++++---------
1 file changed, 90 insertions(+), 87 deletions(-)
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index 83f0fa8388..aa94fb9998 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -374,6 +374,7 @@ function Inner(props: InnerProps) {
const isAutoTopUpEnabled = useIsAutoTopUpEnabled();
const isInAdminDashboard = isKiloAdmin && showAdminControls;
const isOrgOwner = useCanManagePaymentInfo();
+ const canManageRequestedSlug = isOrgOwner || isKiloAdmin;
const hierarchyQuery = useAdminOrganizationHierarchy(id, isInAdminDashboard);
const handleSeatsRequirementEdit = () => {
@@ -530,107 +531,109 @@ function Inner(props: InnerProps) {
)}
-
-
Requested Slug
- {isEditingRequestedSlug ? (
-
-
- {
- setEditedRequestedSlug(e.target.value);
- setRequestedSlugError(null);
- }}
- onKeyDown={handleRequestedSlugKeyDown}
- className={`font-mono text-sm ${requestedSlugError ? 'border-red-400' : ''}`}
- autoFocus
- disabled={updateOrganizationRequestedSlug.isPending}
- />
-
-
-
-
-
-
-
- {requestedSlugError ? (
-
{requestedSlugError}
- ) : null}
-
- ) : (
-
-
- {info.requested_slug || Not set }
-
- {info.requested_slug && !isRequestedSlugAvailable ? (
-
- Not Available
-
- ) : null}
- {isOrgOwner && (
-
setIsEditingRequestedSlug(true)}
- className="hover:bg-muted inline-flex cursor-pointer items-center gap-1 rounded p-1 transition-all duration-200 focus:outline-none"
- title="Edit requested organization slug"
- >
-
-
- )}
- {isKiloAdmin && info.requested_slug ? (
- <>
+ {canManageRequestedSlug ? (
+
+
Requested Slug
+ {isEditingRequestedSlug ? (
+
+
+ {
+ setEditedRequestedSlug(e.target.value);
+ setRequestedSlugError(null);
+ }}
+ onKeyDown={handleRequestedSlugKeyDown}
+ className={`font-mono text-sm ${requestedSlugError ? 'border-red-400' : ''}`}
+ autoFocus
+ disabled={updateOrganizationRequestedSlug.isPending}
+ />
- adminAcceptRequestedSlug.mutate({
- organizationId: id,
- })
- }
- disabled={requestedSlugMutationPending || !isRequestedSlugAvailable}
+ onClick={handleRequestedSlugSave}
+ disabled={updateOrganizationRequestedSlug.isPending}
className="h-8 w-8 p-0"
- aria-label="Accept requested organization slug"
- title={
- isRequestedSlugAvailable
- ? 'Accept requested organization slug'
- : 'Requested slug is not available'
- }
+ aria-label="Save requested organization slug"
>
- adminDeclineRequestedSlug.mutate({
- organizationId: id,
- })
- }
- disabled={requestedSlugMutationPending}
+ onClick={handleRequestedSlugCancel}
+ disabled={updateOrganizationRequestedSlug.isPending}
className="h-8 w-8 p-0"
- aria-label="Decline requested organization slug"
- title="Decline requested organization slug"
+ aria-label="Cancel requested organization slug edit"
>
- >
- ) : null}
-
- )}
-
+
+ {requestedSlugError ? (
+
{requestedSlugError}
+ ) : null}
+
+ ) : (
+
+
+ {info.requested_slug || Not set }
+
+ {info.requested_slug && !isRequestedSlugAvailable ? (
+
+ Not Available
+
+ ) : null}
+ {isOrgOwner && (
+
setIsEditingRequestedSlug(true)}
+ className="hover:bg-muted inline-flex cursor-pointer items-center gap-1 rounded p-1 transition-all duration-200 focus:outline-none"
+ title="Edit requested organization slug"
+ >
+
+
+ )}
+ {isKiloAdmin && info.requested_slug ? (
+ <>
+
+ adminAcceptRequestedSlug.mutate({
+ organizationId: id,
+ })
+ }
+ disabled={requestedSlugMutationPending || !isRequestedSlugAvailable}
+ className="h-8 w-8 p-0"
+ aria-label="Accept requested organization slug"
+ title={
+ isRequestedSlugAvailable
+ ? 'Accept requested organization slug'
+ : 'Requested slug is not available'
+ }
+ >
+
+
+
+ adminDeclineRequestedSlug.mutate({
+ organizationId: id,
+ })
+ }
+ disabled={requestedSlugMutationPending}
+ className="h-8 w-8 p-0"
+ aria-label="Decline requested organization slug"
+ title="Decline requested organization slug"
+ >
+
+
+ >
+ ) : null}
+
+ )}
+
+ ) : null}
Company Domain
{isEditingDomain ? (
From ea9b6f3e7c970b1ea280ef9b7b195e1c60112ad1 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 12:08:17 -0500
Subject: [PATCH 07/33] Enforce max length 32 for org slugs (UUIDs are 38)
---
.../migrations/0175_aspiring_omega_flight.sql | 1 +
.../db/src/migrations/meta/0175_snapshot.json | 32122 ++++++++++++++++
packages/db/src/migrations/meta/_journal.json | 7 +
packages/db/src/schema.ts | 4 +
4 files changed, 32134 insertions(+)
create mode 100644 packages/db/src/migrations/0175_aspiring_omega_flight.sql
create mode 100644 packages/db/src/migrations/meta/0175_snapshot.json
diff --git a/packages/db/src/migrations/0175_aspiring_omega_flight.sql b/packages/db/src/migrations/0175_aspiring_omega_flight.sql
new file mode 100644
index 0000000000..747cedddfd
--- /dev/null
+++ b/packages/db/src/migrations/0175_aspiring_omega_flight.sql
@@ -0,0 +1 @@
+ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_max_length_check" CHECK ("organizations"."slug" IS NULL OR length("organizations"."slug") <= 32);
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/0175_snapshot.json b/packages/db/src/migrations/meta/0175_snapshot.json
new file mode 100644
index 0000000000..0056df97c6
--- /dev/null
+++ b/packages/db/src/migrations/meta/0175_snapshot.json
@@ -0,0 +1,32122 @@
+{
+ "id": "a61286a8-e035-4479-8dba-3b034b3ba1b6",
+ "prevId": "ae36098e-33f9-4138-895b-c0e0098b822a",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.agent_configs": {
+ "name": "agent_configs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_type": {
+ "name": "agent_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_configs_org_id": {
+ "name": "IDX_agent_configs_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_owned_by_user_id": {
+ "name": "IDX_agent_configs_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_agent_type": {
+ "name": "IDX_agent_configs_agent_type",
+ "columns": [
+ {
+ "expression": "agent_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_configs_platform": {
+ "name": "IDX_agent_configs_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_configs_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_configs_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_configs",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_configs_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_configs_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_configs_org_agent_platform": {
+ "name": "UQ_agent_configs_org_agent_platform",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_organization_id",
+ "agent_type",
+ "platform"
+ ]
+ },
+ "UQ_agent_configs_user_agent_platform": {
+ "name": "UQ_agent_configs_user_agent_platform",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_user_id",
+ "agent_type",
+ "platform"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_configs_owner_check": {
+ "name": "agent_configs_owner_check",
+ "value": "(\n (\"agent_configs\".\"owned_by_user_id\" IS NOT NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_configs\".\"owned_by_user_id\" IS NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "agent_configs_agent_type_check": {
+ "name": "agent_configs_agent_type_check",
+ "value": "\"agent_configs\".\"agent_type\" IN ('code_review', 'auto_triage', 'auto_fix', 'security_scan')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_agents": {
+ "name": "agent_environment_profile_agents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_agents_profile_id": {
+ "name": "IDX_agent_env_profile_agents_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_agents",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_agents_profile_slug": {
+ "name": "UQ_agent_env_profile_agents_profile_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_commands": {
+ "name": "agent_environment_profile_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "command": {
+ "name": "command",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_commands_profile_id": {
+ "name": "IDX_agent_env_profile_commands_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_commands",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_commands_profile_sequence": {
+ "name": "UQ_agent_env_profile_commands_profile_sequence",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "sequence"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_kilo_commands": {
+ "name": "agent_environment_profile_kilo_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "template": {
+ "name": "template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent": {
+ "name": "agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subtask": {
+ "name": "subtask",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_kilo_cmds_profile_id": {
+ "name": "IDX_agent_env_profile_kilo_cmds_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_kilo_commands",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_kilo_cmds_profile_name": {
+ "name": "UQ_agent_env_profile_kilo_cmds_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_mcp_servers": {
+ "name": "agent_environment_profile_mcp_servers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "timeout": {
+ "name": "timeout",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_mcp_servers_profile_id": {
+ "name": "IDX_agent_env_profile_mcp_servers_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_mcp_servers",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_mcp_servers_profile_name": {
+ "name": "UQ_agent_env_profile_mcp_servers_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_repo_bindings": {
+ "name": "agent_environment_profile_repo_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_agent_env_profile_repo_bindings_user": {
+ "name": "UQ_agent_env_profile_repo_bindings_user",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profile_repo_bindings_org": {
+ "name": "UQ_agent_env_profile_repo_bindings_org",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_environment_profile_repo_bindings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_env_profile_repo_bindings_owner_check": {
+ "name": "agent_env_profile_repo_bindings_owner_check",
+ "value": "(\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_skills": {
+ "name": "agent_environment_profile_skills",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_markdown": {
+ "name": "raw_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "files": {
+ "name": "files",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_skills_profile_id": {
+ "name": "IDX_agent_env_profile_skills_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_skills",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_skills_profile_name": {
+ "name": "UQ_agent_env_profile_skills_profile_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profile_vars": {
+ "name": "agent_environment_profile_vars",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_secret": {
+ "name": "is_secret",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_agent_env_profile_vars_profile_id": {
+ "name": "IDX_agent_env_profile_vars_profile_id",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk": {
+ "name": "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "agent_environment_profile_vars",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_agent_env_profile_vars_profile_key": {
+ "name": "UQ_agent_env_profile_vars_profile_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "profile_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_environment_profiles": {
+ "name": "agent_environment_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_agent_env_profiles_org_name": {
+ "name": "UQ_agent_env_profiles_org_name",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_user_name": {
+ "name": "UQ_agent_env_profiles_user_name",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_org_default": {
+ "name": "UQ_agent_env_profiles_org_default",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_agent_env_profiles_user_default": {
+ "name": "UQ_agent_env_profiles_user_default",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_org_id": {
+ "name": "IDX_agent_env_profiles_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_user_id": {
+ "name": "IDX_agent_env_profiles_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_agent_env_profiles_created_by_user_id": {
+ "name": "IDX_agent_env_profiles_created_by_user_id",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_environment_profiles_owned_by_organization_id_organizations_id_fk": {
+ "name": "agent_environment_profiles_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "agent_environment_profiles",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "agent_environment_profiles",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_env_profiles_owner_check": {
+ "name": "agent_env_profiles_owner_check",
+ "value": "(\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.api_kind": {
+ "name": "api_kind",
+ "schema": "",
+ "columns": {
+ "api_kind_id": {
+ "name": "api_kind_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "api_kind": {
+ "name": "api_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_api_kind": {
+ "name": "UQ_api_kind",
+ "columns": [
+ {
+ "expression": "api_kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.api_request_compress_log": {
+ "name": "api_request_compress_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request": {
+ "name": "request",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_api_request_compress_log_created_at": {
+ "name": "idx_api_request_compress_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.api_request_log": {
+ "name": "api_request_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request": {
+ "name": "request",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response": {
+ "name": "response",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_api_request_log_created_at": {
+ "name": "idx_api_request_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_feedback": {
+ "name": "app_builder_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "preview_status": {
+ "name": "preview_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_streaming": {
+ "name": "is_streaming",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_count": {
+ "name": "message_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recent_messages": {
+ "name": "recent_messages",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_feedback_created_at": {
+ "name": "IDX_app_builder_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_feedback_kilo_user_id": {
+ "name": "IDX_app_builder_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_feedback_project_id": {
+ "name": "IDX_app_builder_feedback_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "app_builder_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "app_builder_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "app_builder_feedback_project_id_app_builder_projects_id_fk": {
+ "name": "app_builder_feedback_project_id_app_builder_projects_id_fk",
+ "tableFrom": "app_builder_feedback",
+ "tableTo": "app_builder_projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_project_sessions": {
+ "name": "app_builder_project_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_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
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worker_version": {
+ "name": "worker_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'v2'"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_project_sessions_project_id": {
+ "name": "IDX_app_builder_project_sessions_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_project_sessions_project_id_app_builder_projects_id_fk": {
+ "name": "app_builder_project_sessions_project_id_app_builder_projects_id_fk",
+ "tableFrom": "app_builder_project_sessions",
+ "tableTo": "app_builder_projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_app_builder_project_sessions_cloud_agent_session_id": {
+ "name": "UQ_app_builder_project_sessions_cloud_agent_session_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "cloud_agent_session_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_builder_projects": {
+ "name": "app_builder_projects",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "template": {
+ "name": "template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_at": {
+ "name": "last_message_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_repo_full_name": {
+ "name": "git_repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_platform_integration_id": {
+ "name": "git_platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "migrated_at": {
+ "name": "migrated_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_app_builder_projects_created_by_user_id": {
+ "name": "IDX_app_builder_projects_created_by_user_id",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_owned_by_user_id": {
+ "name": "IDX_app_builder_projects_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_owned_by_organization_id": {
+ "name": "IDX_app_builder_projects_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_created_at": {
+ "name": "IDX_app_builder_projects_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_last_message_at": {
+ "name": "IDX_app_builder_projects_last_message_at",
+ "columns": [
+ {
+ "expression": "last_message_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_app_builder_projects_git_repo_integration": {
+ "name": "IDX_app_builder_projects_git_repo_integration",
+ "columns": [
+ {
+ "expression": "git_repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"app_builder_projects\".\"git_repo_full_name\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "app_builder_projects_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "app_builder_projects_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_owned_by_organization_id_organizations_id_fk": {
+ "name": "app_builder_projects_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_deployment_id_deployments_id_fk": {
+ "name": "app_builder_projects_deployment_id_deployments_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk": {
+ "name": "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "app_builder_projects",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "git_platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "app_builder_projects_owner_check": {
+ "name": "app_builder_projects_owner_check",
+ "value": "(\n (\"app_builder_projects\".\"owned_by_user_id\" IS NOT NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NULL) OR\n (\"app_builder_projects\".\"owned_by_user_id\" IS NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_min_versions": {
+ "name": "app_min_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ios_min_version": {
+ "name": "ios_min_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'1.0.0'"
+ },
+ "android_min_version": {
+ "name": "android_min_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'1.0.0'"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_reported_messages": {
+ "name": "app_reported_messages",
+ "schema": "",
+ "columns": {
+ "report_id": {
+ "name": "report_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "signature": {
+ "name": "signature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "app_reported_messages_cli_session_id_cli_sessions_session_id_fk": {
+ "name": "app_reported_messages_cli_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "app_reported_messages",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "cli_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auto_fix_tickets": {
+ "name": "auto_fix_tickets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "triage_ticket_id": {
+ "name": "triage_ticket_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_url": {
+ "name": "issue_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_title": {
+ "name": "issue_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_body": {
+ "name": "issue_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "issue_author": {
+ "name": "issue_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_labels": {
+ "name": "issue_labels",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "trigger_source": {
+ "name": "trigger_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'label'"
+ },
+ "review_comment_id": {
+ "name": "review_comment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_comment_body": {
+ "name": "review_comment_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "line_number": {
+ "name": "line_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "diff_hunk": {
+ "name": "diff_hunk",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_ref": {
+ "name": "pr_head_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent_summary": {
+ "name": "intent_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_files": {
+ "name": "related_files",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_branch": {
+ "name": "pr_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_fix_tickets_repo_issue": {
+ "name": "UQ_auto_fix_tickets_repo_issue",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_fix_tickets\".\"trigger_source\" = 'label'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_auto_fix_tickets_repo_review_comment": {
+ "name": "UQ_auto_fix_tickets_repo_review_comment",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "review_comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_fix_tickets\".\"review_comment_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_owned_by_org": {
+ "name": "IDX_auto_fix_tickets_owned_by_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_owned_by_user": {
+ "name": "IDX_auto_fix_tickets_owned_by_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_status": {
+ "name": "IDX_auto_fix_tickets_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_created_at": {
+ "name": "IDX_auto_fix_tickets_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_triage_ticket_id": {
+ "name": "IDX_auto_fix_tickets_triage_ticket_id",
+ "columns": [
+ {
+ "expression": "triage_ticket_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_fix_tickets_session_id": {
+ "name": "IDX_auto_fix_tickets_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_fix_tickets_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_fix_tickets_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk": {
+ "name": "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk": {
+ "name": "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "auto_triage_tickets",
+ "columnsFrom": [
+ "triage_ticket_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk": {
+ "name": "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "auto_fix_tickets",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "cli_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_fix_tickets_owner_check": {
+ "name": "auto_fix_tickets_owner_check",
+ "value": "(\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "auto_fix_tickets_status_check": {
+ "name": "auto_fix_tickets_status_check",
+ "value": "\"auto_fix_tickets\".\"status\" IN ('pending', 'running', 'completed', 'failed', 'cancelled')"
+ },
+ "auto_fix_tickets_classification_check": {
+ "name": "auto_fix_tickets_classification_check",
+ "value": "\"auto_fix_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'unclear')"
+ },
+ "auto_fix_tickets_confidence_check": {
+ "name": "auto_fix_tickets_confidence_check",
+ "value": "\"auto_fix_tickets\".\"confidence\" >= 0 AND \"auto_fix_tickets\".\"confidence\" <= 1"
+ },
+ "auto_fix_tickets_trigger_source_check": {
+ "name": "auto_fix_tickets_trigger_source_check",
+ "value": "\"auto_fix_tickets\".\"trigger_source\" IN ('label', 'review_comment')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.auto_model": {
+ "name": "auto_model",
+ "schema": "",
+ "columns": {
+ "auto_model_id": {
+ "name": "auto_model_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "auto_model": {
+ "name": "auto_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_auto_model": {
+ "name": "UQ_auto_model",
+ "columns": [
+ {
+ "expression": "auto_model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auto_top_up_configs": {
+ "name": "auto_top_up_configs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_method_id": {
+ "name": "stripe_payment_method_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_cents": {
+ "name": "amount_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 5000
+ },
+ "last_auto_top_up_at": {
+ "name": "last_auto_top_up_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_started_at": {
+ "name": "attempt_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disabled_reason": {
+ "name": "disabled_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_top_up_configs_owned_by_user_id": {
+ "name": "UQ_auto_top_up_configs_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_auto_top_up_configs_owned_by_organization_id": {
+ "name": "UQ_auto_top_up_configs_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_top_up_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "auto_top_up_configs_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_top_up_configs_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_top_up_configs",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_top_up_configs_exactly_one_owner": {
+ "name": "auto_top_up_configs_exactly_one_owner",
+ "value": "(\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NULL) OR (\"auto_top_up_configs\".\"owned_by_user_id\" IS NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.auto_triage_tickets": {
+ "name": "auto_triage_tickets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_url": {
+ "name": "issue_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_title": {
+ "name": "issue_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_body": {
+ "name": "issue_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "issue_author": {
+ "name": "issue_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type": {
+ "name": "issue_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_labels": {
+ "name": "issue_labels",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent_summary": {
+ "name": "intent_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_files": {
+ "name": "related_files",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_duplicate": {
+ "name": "is_duplicate",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "duplicate_of_ticket_id": {
+ "name": "duplicate_of_ticket_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "similarity_score": {
+ "name": "similarity_score",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "qdrant_point_id": {
+ "name": "qdrant_point_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "should_auto_fix": {
+ "name": "should_auto_fix",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "action_taken": {
+ "name": "action_taken",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_metadata": {
+ "name": "action_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_auto_triage_tickets_repo_issue": {
+ "name": "UQ_auto_triage_tickets_repo_issue",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owned_by_org": {
+ "name": "IDX_auto_triage_tickets_owned_by_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owned_by_user": {
+ "name": "IDX_auto_triage_tickets_owned_by_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_status": {
+ "name": "IDX_auto_triage_tickets_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_created_at": {
+ "name": "IDX_auto_triage_tickets_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_qdrant_point_id": {
+ "name": "IDX_auto_triage_tickets_qdrant_point_id",
+ "columns": [
+ {
+ "expression": "qdrant_point_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_owner_status_created": {
+ "name": "IDX_auto_triage_tickets_owner_status_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_user_status_created": {
+ "name": "IDX_auto_triage_tickets_user_status_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_auto_triage_tickets_repo_classification": {
+ "name": "IDX_auto_triage_tickets_repo_classification",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "classification",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auto_triage_tickets_owned_by_organization_id_organizations_id_fk": {
+ "name": "auto_triage_tickets_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk": {
+ "name": "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk": {
+ "name": "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk",
+ "tableFrom": "auto_triage_tickets",
+ "tableTo": "auto_triage_tickets",
+ "columnsFrom": [
+ "duplicate_of_ticket_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "auto_triage_tickets_owner_check": {
+ "name": "auto_triage_tickets_owner_check",
+ "value": "(\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "auto_triage_tickets_issue_type_check": {
+ "name": "auto_triage_tickets_issue_type_check",
+ "value": "\"auto_triage_tickets\".\"issue_type\" IN ('issue', 'pull_request')"
+ },
+ "auto_triage_tickets_classification_check": {
+ "name": "auto_triage_tickets_classification_check",
+ "value": "\"auto_triage_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'duplicate', 'unclear')"
+ },
+ "auto_triage_tickets_confidence_check": {
+ "name": "auto_triage_tickets_confidence_check",
+ "value": "\"auto_triage_tickets\".\"confidence\" >= 0 AND \"auto_triage_tickets\".\"confidence\" <= 1"
+ },
+ "auto_triage_tickets_similarity_score_check": {
+ "name": "auto_triage_tickets_similarity_score_check",
+ "value": "\"auto_triage_tickets\".\"similarity_score\" >= 0 AND \"auto_triage_tickets\".\"similarity_score\" <= 1"
+ },
+ "auto_triage_tickets_status_check": {
+ "name": "auto_triage_tickets_status_check",
+ "value": "\"auto_triage_tickets\".\"status\" IN ('pending', 'analyzing', 'actioned', 'failed', 'skipped')"
+ },
+ "auto_triage_tickets_action_taken_check": {
+ "name": "auto_triage_tickets_action_taken_check",
+ "value": "\"auto_triage_tickets\".\"action_taken\" IN ('pr_created', 'comment_posted', 'closed_duplicate', 'needs_clarification')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.bot_request_cloud_agent_sessions": {
+ "name": "bot_request_cloud_agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "bot_request_id": {
+ "name": "bot_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "spawn_group_id": {
+ "name": "spawn_group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repo": {
+ "name": "github_repo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gitlab_project": {
+ "name": "gitlab_project",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "callback_step": {
+ "name": "callback_step",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message": {
+ "name": "final_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message_fetched_at": {
+ "name": "final_message_fetched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_message_error": {
+ "name": "final_message_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "continuation_started_at": {
+ "name": "continuation_started_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_bot_request_cas_cloud_agent_session_id": {
+ "name": "UQ_bot_request_cas_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id": {
+ "name": "IDX_bot_request_cas_bot_request_id",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id_spawn_group_id": {
+ "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spawn_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_request_cas_bot_request_id_spawn_group_id_status": {
+ "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id_status",
+ "columns": [
+ {
+ "expression": "bot_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spawn_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk": {
+ "name": "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk",
+ "tableFrom": "bot_request_cloud_agent_sessions",
+ "tableTo": "bot_requests",
+ "columnsFrom": [
+ "bot_request_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bot_requests": {
+ "name": "bot_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_thread_id": {
+ "name": "platform_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_message_id": {
+ "name": "platform_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message": {
+ "name": "user_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_used": {
+ "name": "model_used",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "steps": {
+ "name": "steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_bot_requests_created_at": {
+ "name": "IDX_bot_requests_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_created_by": {
+ "name": "IDX_bot_requests_created_by",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_organization_id": {
+ "name": "IDX_bot_requests_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_platform_integration_id": {
+ "name": "IDX_bot_requests_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_bot_requests_status": {
+ "name": "IDX_bot_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "bot_requests_created_by_kilocode_users_id_fk": {
+ "name": "bot_requests_created_by_kilocode_users_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bot_requests_organization_id_organizations_id_fk": {
+ "name": "bot_requests_organization_id_organizations_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bot_requests_platform_integration_id_platform_integrations_id_fk": {
+ "name": "bot_requests_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "bot_requests",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.byok_api_keys": {
+ "name": "byok_api_keys",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "management_source": {
+ "name": "management_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'user'"
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "IDX_byok_api_keys_organization_id": {
+ "name": "IDX_byok_api_keys_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_byok_api_keys_kilo_user_id": {
+ "name": "IDX_byok_api_keys_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_byok_api_keys_provider_id": {
+ "name": "IDX_byok_api_keys_provider_id",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "byok_api_keys_organization_id_organizations_id_fk": {
+ "name": "byok_api_keys_organization_id_organizations_id_fk",
+ "tableFrom": "byok_api_keys",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "byok_api_keys_kilo_user_id_kilocode_users_id_fk": {
+ "name": "byok_api_keys_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "byok_api_keys",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_byok_api_keys_org_provider": {
+ "name": "UQ_byok_api_keys_org_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "provider_id"
+ ]
+ },
+ "UQ_byok_api_keys_user_provider": {
+ "name": "UQ_byok_api_keys_user_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_user_id",
+ "provider_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "byok_api_keys_management_source_check": {
+ "name": "byok_api_keys_management_source_check",
+ "value": "\"byok_api_keys\".\"management_source\" IN ('user', 'coding_plan')"
+ },
+ "byok_api_keys_owner_check": {
+ "name": "byok_api_keys_owner_check",
+ "value": "(\n (\"byok_api_keys\".\"kilo_user_id\" IS NOT NULL AND \"byok_api_keys\".\"organization_id\" IS NULL) OR\n (\"byok_api_keys\".\"kilo_user_id\" IS NULL AND \"byok_api_keys\".\"organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cli_sessions": {
+ "name": "cli_sessions",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_on_platform": {
+ "name": "created_on_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "api_conversation_history_blob_url": {
+ "name": "api_conversation_history_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_metadata_blob_url": {
+ "name": "task_metadata_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ui_messages_blob_url": {
+ "name": "ui_messages_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_state_blob_url": {
+ "name": "git_state_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "forked_from": {
+ "name": "forked_from",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_session_id": {
+ "name": "parent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_mode": {
+ "name": "last_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_model": {
+ "name": "last_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cli_sessions_kilo_user_id": {
+ "name": "IDX_cli_sessions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_created_at": {
+ "name": "IDX_cli_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_updated_at": {
+ "name": "IDX_cli_sessions_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_organization_id": {
+ "name": "IDX_cli_sessions_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_user_updated": {
+ "name": "IDX_cli_sessions_user_updated",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_sessions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cli_sessions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_forked_from_cli_sessions_session_id_fk": {
+ "name": "cli_sessions_forked_from_cli_sessions_session_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "forked_from"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_parent_session_id_cli_sessions_session_id_fk": {
+ "name": "cli_sessions_parent_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "parent_session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_organization_id_organizations_id_fk": {
+ "name": "cli_sessions_organization_id_organizations_id_fk",
+ "tableFrom": "cli_sessions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "cli_sessions_cloud_agent_session_id_unique": {
+ "name": "cli_sessions_cloud_agent_session_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "cloud_agent_session_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_sessions_v2": {
+ "name": "cli_sessions_v2",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_session_id": {
+ "name": "parent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_on_platform": {
+ "name": "created_on_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_updated_at": {
+ "name": "status_updated_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cli_sessions_v2_parent_session_id_kilo_user_id": {
+ "name": "IDX_cli_sessions_v2_parent_session_id_kilo_user_id",
+ "columns": [
+ {
+ "expression": "parent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cli_sessions_v2_public_id": {
+ "name": "UQ_cli_sessions_v2_public_id",
+ "columns": [
+ {
+ "expression": "public_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cli_sessions_v2\".\"public_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cli_sessions_v2_cloud_agent_session_id": {
+ "name": "UQ_cli_sessions_v2_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cli_sessions_v2\".\"cloud_agent_session_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_organization_id": {
+ "name": "IDX_cli_sessions_v2_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_kilo_user_id": {
+ "name": "IDX_cli_sessions_v2_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_created_at": {
+ "name": "IDX_cli_sessions_v2_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cli_sessions_v2_user_updated": {
+ "name": "IDX_cli_sessions_v2_user_updated",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_sessions_v2_git_url_branch_idx": {
+ "name": "cli_sessions_v2_git_url_branch_idx",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_v2_organization_id_organizations_id_fk": {
+ "name": "cli_sessions_v2_organization_id_organizations_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "cli_sessions_v2_parent_session_id_kilo_user_id_fk": {
+ "name": "cli_sessions_v2_parent_session_id_kilo_user_id_fk",
+ "tableFrom": "cli_sessions_v2",
+ "tableTo": "cli_sessions_v2",
+ "columnsFrom": [
+ "parent_session_id",
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "session_id",
+ "kilo_user_id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "cli_sessions_v2_session_id_kilo_user_id_pk": {
+ "name": "cli_sessions_v2_session_id_kilo_user_id_pk",
+ "columns": [
+ "session_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_code_review_attempts": {
+ "name": "cloud_agent_code_review_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_review_id": {
+ "name": "code_review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_number": {
+ "name": "attempt_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "retry_of_attempt_id": {
+ "name": "retry_of_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "retry_reason": {
+ "name": "retry_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analytics_enabled_at_dispatch": {
+ "name": "analytics_enabled_at_dispatch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_reason": {
+ "name": "terminal_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_code_review_attempts_review_attempt_number": {
+ "name": "UQ_cloud_agent_code_review_attempts_review_attempt_number",
+ "columns": [
+ {
+ "expression": "code_review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "attempt_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_code_review_id": {
+ "name": "idx_cloud_agent_code_review_attempts_code_review_id",
+ "columns": [
+ {
+ "expression": "code_review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_session_id": {
+ "name": "idx_cloud_agent_code_review_attempts_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_cli_session_id": {
+ "name": "idx_cloud_agent_code_review_attempts_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_status": {
+ "name": "idx_cloud_agent_code_review_attempts_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_review_attempts_retry_reason": {
+ "name": "idx_cloud_agent_code_review_attempts_retry_reason",
+ "columns": [
+ {
+ "expression": "retry_reason",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk": {
+ "name": "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk",
+ "tableFrom": "cloud_agent_code_review_attempts",
+ "tableTo": "cloud_agent_code_reviews",
+ "columnsFrom": [
+ "code_review_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk": {
+ "name": "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk",
+ "tableFrom": "cloud_agent_code_review_attempts",
+ "tableTo": "cloud_agent_code_review_attempts",
+ "columnsFrom": [
+ "retry_of_attempt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_code_review_attempts_attempt_number_check": {
+ "name": "cloud_agent_code_review_attempts_attempt_number_check",
+ "value": "\"cloud_agent_code_review_attempts\".\"attempt_number\" >= 1"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_code_reviews": {
+ "name": "cloud_agent_code_reviews",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_title": {
+ "name": "pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_author": {
+ "name": "pr_author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_author_github_id": {
+ "name": "pr_author_github_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_ref": {
+ "name": "base_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_ref": {
+ "name": "head_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "platform_project_id": {
+ "name": "platform_project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "dispatch_reservation_id": {
+ "name": "dispatch_reservation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_reason": {
+ "name": "terminal_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_version": {
+ "name": "agent_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'v1'"
+ },
+ "check_run_id": {
+ "name": "check_run_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_review_instructions_used": {
+ "name": "repository_review_instructions_used",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "repository_review_instructions_ref": {
+ "name": "repository_review_instructions_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_review_instructions_truncated": {
+ "name": "repository_review_instructions_truncated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "previous_summary_body": {
+ "name": "previous_summary_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_summary_head_sha": {
+ "name": "previous_summary_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens_in": {
+ "name": "total_tokens_in",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens_out": {
+ "name": "total_tokens_out",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost_musd": {
+ "name": "total_cost_musd",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_code_reviews_repo_pr_sha": {
+ "name": "UQ_cloud_agent_code_reviews_repo_pr_sha",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "pr_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_owned_by_org_id": {
+ "name": "idx_cloud_agent_code_reviews_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_owned_by_user_id": {
+ "name": "idx_cloud_agent_code_reviews_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_session_id": {
+ "name": "idx_cloud_agent_code_reviews_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_cli_session_id": {
+ "name": "idx_cloud_agent_code_reviews_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_status": {
+ "name": "idx_cloud_agent_code_reviews_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_repo": {
+ "name": "idx_cloud_agent_code_reviews_repo",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_pr_number": {
+ "name": "idx_cloud_agent_code_reviews_pr_number",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "pr_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_created_at": {
+ "name": "idx_cloud_agent_code_reviews_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_cloud_agent_code_reviews_pr_author_github_id": {
+ "name": "idx_cloud_agent_code_reviews_pr_author_github_id",
+ "columns": [
+ {
+ "expression": "pr_author_github_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk": {
+ "name": "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "cloud_agent_code_reviews",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_code_reviews_owner_check": {
+ "name": "cloud_agent_code_reviews_owner_check",
+ "value": "(\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NOT NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NULL) OR\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_feedback": {
+ "name": "cloud_agent_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_streaming": {
+ "name": "is_streaming",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_count": {
+ "name": "message_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recent_messages": {
+ "name": "recent_messages",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_cloud_agent_feedback_created_at": {
+ "name": "IDX_cloud_agent_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_feedback_kilo_user_id": {
+ "name": "IDX_cloud_agent_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_feedback_cloud_agent_session_id": {
+ "name": "IDX_cloud_agent_feedback_cloud_agent_session_id",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "cloud_agent_feedback_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_feedback_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_feedback",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_session_runs": {
+ "name": "cloud_agent_session_runs",
+ "schema": "",
+ "columns": {
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wrapper_run_id": {
+ "name": "wrapper_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dispatch_accepted_at": {
+ "name": "dispatch_accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_activity_observed_at": {
+ "name": "agent_activity_observed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message_redacted": {
+ "name": "error_message_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_expires_at": {
+ "name": "error_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_cloud_agent_session_runs_wrapper_run_id": {
+ "name": "IDX_cloud_agent_session_runs_wrapper_run_id",
+ "columns": [
+ {
+ "expression": "wrapper_run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_session_runs\".\"wrapper_run_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_session_queued": {
+ "name": "IDX_cloud_agent_session_runs_session_queued",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_queued_at": {
+ "name": "IDX_cloud_agent_session_runs_queued_at",
+ "columns": [
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_terminal_at": {
+ "name": "IDX_cloud_agent_session_runs_terminal_at",
+ "columns": [
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_status_terminal": {
+ "name": "IDX_cloud_agent_session_runs_status_terminal",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_failure_terminal": {
+ "name": "IDX_cloud_agent_session_runs_failure_terminal",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "terminal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_session_runs_error_expires_at": {
+ "name": "IDX_cloud_agent_session_runs_error_expires_at",
+ "columns": [
+ {
+ "expression": "error_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_session_runs\".\"error_expires_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk": {
+ "name": "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk",
+ "tableFrom": "cloud_agent_session_runs",
+ "tableTo": "cloud_agent_sessions",
+ "columnsFrom": [
+ "cloud_agent_session_id"
+ ],
+ "columnsTo": [
+ "cloud_agent_session_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk": {
+ "name": "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk",
+ "columns": [
+ "cloud_agent_session_id",
+ "message_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_session_runs_status_check": {
+ "name": "cloud_agent_session_runs_status_check",
+ "value": "\"cloud_agent_session_runs\".\"status\" IN ('queued', 'accepted', 'completed', 'failed', 'interrupted')"
+ },
+ "cloud_agent_session_runs_failure_classification_check": {
+ "name": "cloud_agent_session_runs_failure_classification_check",
+ "value": "(\"cloud_agent_session_runs\".\"failure_stage\" IS NULL AND \"cloud_agent_session_runs\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'pre_dispatch' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('sandbox_connect_failed', 'workspace_setup_failed', 'kilo_server_failed', 'wrapper_start_failed', 'invalid_delivery_request', 'session_metadata_missing', 'model_missing', 'delivery_failure_unknown')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'post_dispatch_no_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('wrapper_disconnected', 'wrapper_no_output', 'wrapper_ping_timeout', 'wrapper_error_before_activity', 'missing_assistant_reply')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'agent_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('assistant_error', 'wrapper_error_after_activity')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'interruption' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('user_interrupt', 'container_shutdown', 'system_interrupt')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'unknown' AND \"cloud_agent_session_runs\".\"failure_code\" = 'unclassified')"
+ },
+ "cloud_agent_session_runs_error_message_bounded_check": {
+ "name": "cloud_agent_session_runs_error_message_bounded_check",
+ "value": "\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_session_runs\".\"error_message_redacted\") <= 4096"
+ },
+ "cloud_agent_session_runs_error_expiry_check": {
+ "name": "cloud_agent_session_runs_error_expiry_check",
+ "value": "(\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_sessions": {
+ "name": "cloud_agent_sessions",
+ "schema": "",
+ "columns": {
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "initial_message_id": {
+ "name": "initial_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "failure_at": {
+ "name": "failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message_redacted": {
+ "name": "error_message_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_expires_at": {
+ "name": "error_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_sessions_kilo_session_id": {
+ "name": "UQ_cloud_agent_sessions_kilo_session_id",
+ "columns": [
+ {
+ "expression": "kilo_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cloud_agent_sessions_initial_message_id": {
+ "name": "UQ_cloud_agent_sessions_initial_message_id",
+ "columns": [
+ {
+ "expression": "initial_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_sandbox_id": {
+ "name": "IDX_cloud_agent_sessions_sandbox_id",
+ "columns": [
+ {
+ "expression": "sandbox_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"sandbox_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_created_at": {
+ "name": "IDX_cloud_agent_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_created": {
+ "name": "IDX_cloud_agent_sessions_failure_created",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_at": {
+ "name": "IDX_cloud_agent_sessions_failure_at",
+ "columns": [
+ {
+ "expression": "failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_failure_classification_at": {
+ "name": "IDX_cloud_agent_sessions_failure_classification_at",
+ "columns": [
+ {
+ "expression": "failure_stage",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_sessions_error_expires_at": {
+ "name": "IDX_cloud_agent_sessions_error_expires_at",
+ "columns": [
+ {
+ "expression": "error_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"cloud_agent_sessions\".\"error_expires_at\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cloud_agent_sessions_failure_classification_check": {
+ "name": "cloud_agent_sessions_failure_classification_check",
+ "value": "(\"cloud_agent_sessions\".\"failure_at\" IS NULL AND \"cloud_agent_sessions\".\"failure_stage\" IS NULL AND \"cloud_agent_sessions\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'sandbox_identity' AND \"cloud_agent_sessions\".\"failure_code\" = 'sandbox_id_derivation_failed') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'registration' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_registration_rejected') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'initial_admission' AND \"cloud_agent_sessions\".\"failure_code\" IN ('initial_admission_rejected', 'initial_queue_full', 'invalid_initial_intent')) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'transport' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_rpc_outcome_unknown')"
+ },
+ "cloud_agent_sessions_error_message_bounded_check": {
+ "name": "cloud_agent_sessions_error_message_bounded_check",
+ "value": "\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_sessions\".\"error_message_redacted\") <= 4096"
+ },
+ "cloud_agent_sessions_error_expiry_check": {
+ "name": "cloud_agent_sessions_error_expiry_check",
+ "value": "(\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_sessions\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.cloud_agent_webhook_triggers": {
+ "name": "cloud_agent_webhook_triggers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "trigger_id": {
+ "name": "trigger_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_type": {
+ "name": "target_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cloud_agent'"
+ },
+ "kiloclaw_instance_id": {
+ "name": "kiloclaw_instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "activation_mode": {
+ "name": "activation_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'webhook'"
+ },
+ "cron_expression": {
+ "name": "cron_expression",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cron_timezone": {
+ "name": "cron_timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'UTC'"
+ },
+ "github_repo": {
+ "name": "github_repo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "profile_id": {
+ "name": "profile_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_cloud_agent_webhook_triggers_user_trigger": {
+ "name": "UQ_cloud_agent_webhook_triggers_user_trigger",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "trigger_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cloud_agent_webhook_triggers\".\"user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_cloud_agent_webhook_triggers_org_trigger": {
+ "name": "UQ_cloud_agent_webhook_triggers_org_trigger",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "trigger_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"cloud_agent_webhook_triggers\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_user": {
+ "name": "IDX_cloud_agent_webhook_triggers_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_org": {
+ "name": "IDX_cloud_agent_webhook_triggers_org",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_active": {
+ "name": "IDX_cloud_agent_webhook_triggers_active",
+ "columns": [
+ {
+ "expression": "is_active",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_cloud_agent_webhook_triggers_profile": {
+ "name": "IDX_cloud_agent_webhook_triggers_profile",
+ "columns": [
+ {
+ "expression": "profile_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk": {
+ "name": "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_organization_id_organizations_id_fk": {
+ "name": "cloud_agent_webhook_triggers_organization_id_organizations_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk": {
+ "name": "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "kiloclaw_instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk": {
+ "name": "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk",
+ "tableFrom": "cloud_agent_webhook_triggers",
+ "tableTo": "agent_environment_profiles",
+ "columnsFrom": [
+ "profile_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_cloud_agent_webhook_triggers_owner": {
+ "name": "CHK_cloud_agent_webhook_triggers_owner",
+ "value": "(\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NULL) OR\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NOT NULL)\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_cloud_agent_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_cloud_agent_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'cloud_agent' OR\n (\"cloud_agent_webhook_triggers\".\"github_repo\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"profile_id\" IS NOT NULL)\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_kiloclaw_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_kiloclaw_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'kiloclaw_chat' OR\n \"cloud_agent_webhook_triggers\".\"kiloclaw_instance_id\" IS NOT NULL\n )"
+ },
+ "CHK_cloud_agent_webhook_triggers_scheduled_fields": {
+ "name": "CHK_cloud_agent_webhook_triggers_scheduled_fields",
+ "value": "(\n \"cloud_agent_webhook_triggers\".\"activation_mode\" != 'scheduled' OR\n \"cloud_agent_webhook_triggers\".\"cron_expression\" IS NOT NULL\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_indexing_manifest": {
+ "name": "code_indexing_manifest",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_hash": {
+ "name": "file_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chunk_count": {
+ "name": "chunk_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_lines": {
+ "name": "total_lines",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_ai_lines": {
+ "name": "total_ai_lines",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_code_indexing_manifest_organization_id": {
+ "name": "IDX_code_indexing_manifest_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_kilo_user_id": {
+ "name": "IDX_code_indexing_manifest_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_project_id": {
+ "name": "IDX_code_indexing_manifest_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_git_branch": {
+ "name": "IDX_code_indexing_manifest_git_branch",
+ "columns": [
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_manifest_created_at": {
+ "name": "IDX_code_indexing_manifest_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk": {
+ "name": "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_indexing_manifest",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_indexing_manifest_org_user_project_hash_branch": {
+ "name": "UQ_code_indexing_manifest_org_user_project_hash_branch",
+ "nullsNotDistinct": true,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "project_id",
+ "file_path",
+ "git_branch"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.code_indexing_search": {
+ "name": "code_indexing_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "query": {
+ "name": "query",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_code_indexing_search_organization_id": {
+ "name": "IDX_code_indexing_search_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_kilo_user_id": {
+ "name": "IDX_code_indexing_search_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_project_id": {
+ "name": "IDX_code_indexing_search_project_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_code_indexing_search_created_at": {
+ "name": "IDX_code_indexing_search_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_indexing_search_kilo_user_id_kilocode_users_id_fk": {
+ "name": "code_indexing_search_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_indexing_search",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.code_review_analytics_findings": {
+ "name": "code_review_analytics_findings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "analytics_result_id": {
+ "name": "analytics_result_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordinal": {
+ "name": "ordinal",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "security_class": {
+ "name": "security_class",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk": {
+ "name": "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk",
+ "tableFrom": "code_review_analytics_findings",
+ "tableTo": "code_review_analytics_results",
+ "columnsFrom": [
+ "analytics_result_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_analytics_findings_result_ordinal": {
+ "name": "UQ_code_review_analytics_findings_result_ordinal",
+ "nullsNotDistinct": false,
+ "columns": [
+ "analytics_result_id",
+ "ordinal"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_analytics_findings_severity_check": {
+ "name": "code_review_analytics_findings_severity_check",
+ "value": "\"code_review_analytics_findings\".\"severity\" IN ('critical', 'warning', 'suggestion')"
+ },
+ "code_review_analytics_findings_category_check": {
+ "name": "code_review_analytics_findings_category_check",
+ "value": "\"code_review_analytics_findings\".\"category\" IN ('security', 'correctness', 'reliability', 'data_integrity', 'performance', 'compatibility', 'maintainability', 'test_quality', 'documentation', 'accessibility', 'other')"
+ },
+ "code_review_analytics_findings_security_class_check": {
+ "name": "code_review_analytics_findings_security_class_check",
+ "value": "\"code_review_analytics_findings\".\"security_class\" IN ('auth_access', 'injection', 'data_protection', 'request_resource_boundary', 'deserialization_object_integrity', 'dependency_supply_chain', 'memory_safety', 'availability', 'concurrency', 'security_configuration', 'other')"
+ },
+ "code_review_analytics_findings_ordinal_check": {
+ "name": "code_review_analytics_findings_ordinal_check",
+ "value": "\"code_review_analytics_findings\".\"ordinal\" >= 0"
+ },
+ "code_review_analytics_findings_security_class_presence_check": {
+ "name": "code_review_analytics_findings_security_class_presence_check",
+ "value": "(\n (\"code_review_analytics_findings\".\"category\" = 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NOT NULL) OR\n (\"code_review_analytics_findings\".\"category\" <> 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_analytics_results": {
+ "name": "code_review_analytics_results",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_review_id": {
+ "name": "code_review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_attempt_id": {
+ "name": "source_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capture_status": {
+ "name": "capture_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "schema_version": {
+ "name": "schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "taxonomy_version": {
+ "name": "taxonomy_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "change_type": {
+ "name": "change_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_level": {
+ "name": "impact_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "complexity_level": {
+ "name": "complexity_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "classification_confidence": {
+ "name": "classification_confidence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finalized_at": {
+ "name": "finalized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_analytics_results_source_attempt_id": {
+ "name": "idx_code_review_analytics_results_source_attempt_id",
+ "columns": [
+ {
+ "expression": "source_attempt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_analytics_results_finalized_at": {
+ "name": "idx_code_review_analytics_results_finalized_at",
+ "columns": [
+ {
+ "expression": "finalized_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk": {
+ "name": "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk",
+ "tableFrom": "code_review_analytics_results",
+ "tableTo": "cloud_agent_code_reviews",
+ "columnsFrom": [
+ "code_review_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk": {
+ "name": "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk",
+ "tableFrom": "code_review_analytics_results",
+ "tableTo": "cloud_agent_code_review_attempts",
+ "columnsFrom": [
+ "source_attempt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_analytics_results_code_review_id": {
+ "name": "UQ_code_review_analytics_results_code_review_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "code_review_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_analytics_results_capture_status_check": {
+ "name": "code_review_analytics_results_capture_status_check",
+ "value": "\"code_review_analytics_results\".\"capture_status\" IN ('captured', 'missing', 'invalid', 'omitted')"
+ },
+ "code_review_analytics_results_change_type_check": {
+ "name": "code_review_analytics_results_change_type_check",
+ "value": "\"code_review_analytics_results\".\"change_type\" IN ('bug_fix', 'feature', 'refactor', 'maintenance', 'dependency', 'test', 'documentation', 'mixed', 'other')"
+ },
+ "code_review_analytics_results_impact_level_check": {
+ "name": "code_review_analytics_results_impact_level_check",
+ "value": "\"code_review_analytics_results\".\"impact_level\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_complexity_level_check": {
+ "name": "code_review_analytics_results_complexity_level_check",
+ "value": "\"code_review_analytics_results\".\"complexity_level\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_classification_confidence_check": {
+ "name": "code_review_analytics_results_classification_confidence_check",
+ "value": "\"code_review_analytics_results\".\"classification_confidence\" IN ('low', 'medium', 'high')"
+ },
+ "code_review_analytics_results_classification_presence_check": {
+ "name": "code_review_analytics_results_classification_presence_check",
+ "value": "(\n (\n \"code_review_analytics_results\".\"capture_status\" = 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NOT NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NOT NULL\n ) OR (\n \"code_review_analytics_results\".\"capture_status\" <> 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NULL\n )\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_feedback_events": {
+ "name": "code_review_feedback_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_comment_id": {
+ "name": "kilo_comment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reply_excerpt": {
+ "name": "reply_excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_comment_excerpt": {
+ "name": "kilo_comment_excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_hash": {
+ "name": "dedupe_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_feedback_events_owned_by_org_id": {
+ "name": "idx_code_review_feedback_events_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_owned_by_user_id": {
+ "name": "idx_code_review_feedback_events_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_platform_repo": {
+ "name": "idx_code_review_feedback_events_platform_repo",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_feedback_events_created_at": {
+ "name": "idx_code_review_feedback_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_feedback_events_owned_by_organization_id_organizations_id_fk": {
+ "name": "code_review_feedback_events_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "code_review_feedback_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_review_feedback_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_code_review_feedback_events_dedupe_hash": {
+ "name": "UQ_code_review_feedback_events_dedupe_hash",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_hash"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "code_review_feedback_events_owner_check": {
+ "name": "code_review_feedback_events_owner_check",
+ "value": "(\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.code_review_memory_proposals": {
+ "name": "code_review_memory_proposals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "proposed_markdown": {
+ "name": "proposed_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "positive_count": {
+ "name": "positive_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "negative_count": {
+ "name": "negative_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "neutral_count": {
+ "name": "neutral_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "change_request_url": {
+ "name": "change_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_code_review_memory_proposals_owned_by_org_id": {
+ "name": "idx_code_review_memory_proposals_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_owned_by_user_id": {
+ "name": "idx_code_review_memory_proposals_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_platform_repo_status": {
+ "name": "idx_code_review_memory_proposals_platform_repo_status",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_code_review_memory_proposals_updated_at": {
+ "name": "idx_code_review_memory_proposals_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_code_review_memory_proposals_org_active_scope": {
+ "name": "UQ_code_review_memory_proposals_org_active_scope",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_code_review_memory_proposals_user_active_scope": {
+ "name": "UQ_code_review_memory_proposals_user_active_scope",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk": {
+ "name": "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "code_review_memory_proposals",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "code_review_memory_proposals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "code_review_memory_proposals_owner_check": {
+ "name": "code_review_memory_proposals_owner_check",
+ "value": "(\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_availability_intents": {
+ "name": "coding_plan_availability_intents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_availability_intents_user_plan": {
+ "name": "UQ_coding_plan_availability_intents_user_plan",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_availability_intents_plan": {
+ "name": "IDX_coding_plan_availability_intents_plan",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_availability_intents_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_availability_intents_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_availability_intents",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_key_inventory": {
+ "name": "coding_plan_key_inventory",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "upstream_plan_id": {
+ "name": "upstream_plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_fingerprint": {
+ "name": "credential_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'available'"
+ },
+ "assigned_to_user_id": {
+ "name": "assigned_to_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assigned_at": {
+ "name": "assigned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_requested_at": {
+ "name": "revocation_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_attempt_count": {
+ "name": "revocation_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_revocation_error": {
+ "name": "last_revocation_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_key_inv_fingerprint": {
+ "name": "UQ_coding_plan_key_inv_fingerprint",
+ "columns": [
+ {
+ "expression": "credential_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_key_inv_plan_status": {
+ "name": "IDX_coding_plan_key_inv_plan_status",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_key_inv_available": {
+ "name": "IDX_coding_plan_key_inv_available",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"coding_plan_key_inventory\".\"status\" = 'available'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_key_inventory",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "assigned_to_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_key_inventory_status_check": {
+ "name": "coding_plan_key_inventory_status_check",
+ "value": "\"coding_plan_key_inventory\".\"status\" IN ('available', 'assigned', 'revocation_pending', 'revoked', 'revocation_failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_subscriptions": {
+ "name": "coding_plan_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_inventory_id": {
+ "name": "key_inventory_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_byok_key_id": {
+ "name": "installed_byok_key_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_period_days": {
+ "name": "billing_period_days",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_period_start": {
+ "name": "current_period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_renewal_at": {
+ "name": "credit_renewal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "past_due_started_at": {
+ "name": "past_due_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payment_grace_expires_at": {
+ "name": "payment_grace_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_attempted_for_due": {
+ "name": "auto_top_up_attempted_for_due",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_reason": {
+ "name": "cancellation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_sub_live_user_plan": {
+ "name": "UQ_coding_plan_sub_live_user_plan",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_status": {
+ "name": "IDX_coding_plan_sub_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_renewal": {
+ "name": "IDX_coding_plan_sub_renewal",
+ "columns": [
+ {
+ "expression": "credit_renewal_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_sub_inventory": {
+ "name": "IDX_coding_plan_sub_inventory",
+ "columns": [
+ {
+ "expression": "key_inventory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_subscriptions_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_subscriptions_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk": {
+ "name": "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "coding_plan_key_inventory",
+ "columnsFrom": [
+ "key_inventory_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk": {
+ "name": "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk",
+ "tableFrom": "coding_plan_subscriptions",
+ "tableTo": "byok_api_keys",
+ "columnsFrom": [
+ "installed_byok_key_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_subscriptions_status_check": {
+ "name": "coding_plan_subscriptions_status_check",
+ "value": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due', 'canceled')"
+ },
+ "coding_plan_subscriptions_live_access_check": {
+ "name": "coding_plan_subscriptions_live_access_check",
+ "value": "\"coding_plan_subscriptions\".\"status\" = 'canceled' OR \"coding_plan_subscriptions\".\"key_inventory_id\" IS NOT NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.coding_plan_terms": {
+ "name": "coding_plan_terms",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_start": {
+ "name": "period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_end": {
+ "name": "period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_transaction_id": {
+ "name": "credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_coding_plan_terms_request": {
+ "name": "UQ_coding_plan_terms_request",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_coding_plan_terms_subscription": {
+ "name": "IDX_coding_plan_terms_subscription",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk": {
+ "name": "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "coding_plan_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_terms_user_id_kilocode_users_id_fk": {
+ "name": "coding_plan_terms_user_id_kilocode_users_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "coding_plan_terms",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "coding_plan_terms_kind_check": {
+ "name": "coding_plan_terms_kind_check",
+ "value": "\"coding_plan_terms\".\"kind\" IN ('activation', 'extension', 'renewal')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_contributors": {
+ "name": "contributor_champion_contributors",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_profile_url": {
+ "name": "github_profile_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_contribution_at": {
+ "name": "first_contribution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contribution_at": {
+ "name": "last_contribution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "all_time_contributions": {
+ "name": "all_time_contributions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "manual_email": {
+ "name": "manual_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_contributors_last_contribution_at": {
+ "name": "IDX_contributor_champion_contributors_last_contribution_at",
+ "columns": [
+ {
+ "expression": "last_contribution_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_contributors_manual_email": {
+ "name": "IDX_contributor_champion_contributors_manual_email",
+ "columns": [
+ {
+ "expression": "manual_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_contributors_github_login": {
+ "name": "UQ_contributor_champion_contributors_github_login",
+ "nullsNotDistinct": false,
+ "columns": [
+ "github_login"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_events": {
+ "name": "contributor_champion_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "contributor_id": {
+ "name": "contributor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_number": {
+ "name": "github_pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_url": {
+ "name": "github_pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_pr_title": {
+ "name": "github_pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_author_login": {
+ "name": "github_author_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_author_email": {
+ "name": "github_author_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_events_contributor_id": {
+ "name": "IDX_contributor_champion_events_contributor_id",
+ "columns": [
+ {
+ "expression": "contributor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_events_merged_at": {
+ "name": "IDX_contributor_champion_events_merged_at",
+ "columns": [
+ {
+ "expression": "merged_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_events_author_email": {
+ "name": "IDX_contributor_champion_events_author_email",
+ "columns": [
+ {
+ "expression": "github_author_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk": {
+ "name": "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk",
+ "tableFrom": "contributor_champion_events",
+ "tableTo": "contributor_champion_contributors",
+ "columnsFrom": [
+ "contributor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_events_repo_pr": {
+ "name": "UQ_contributor_champion_events_repo_pr",
+ "nullsNotDistinct": false,
+ "columns": [
+ "repo_full_name",
+ "github_pr_number"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_memberships": {
+ "name": "contributor_champion_memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "contributor_id": {
+ "name": "contributor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "selected_tier": {
+ "name": "selected_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enrolled_tier": {
+ "name": "enrolled_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enrolled_at": {
+ "name": "enrolled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_amount_microdollars": {
+ "name": "credit_amount_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "credits_last_granted_at": {
+ "name": "credits_last_granted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linked_kilo_user_id": {
+ "name": "linked_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_contributor_champion_memberships_credits_due": {
+ "name": "IDX_contributor_champion_memberships_credits_due",
+ "columns": [
+ {
+ "expression": "credits_last_granted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NOT NULL AND \"contributor_champion_memberships\".\"credit_amount_microdollars\" > 0",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_contributor_champion_memberships_linked_kilo_user_id": {
+ "name": "IDX_contributor_champion_memberships_linked_kilo_user_id",
+ "columns": [
+ {
+ "expression": "linked_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk": {
+ "name": "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk",
+ "tableFrom": "contributor_champion_memberships",
+ "tableTo": "contributor_champion_contributors",
+ "columnsFrom": [
+ "contributor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk": {
+ "name": "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "contributor_champion_memberships",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "linked_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_contributor_champion_memberships_contributor_id": {
+ "name": "UQ_contributor_champion_memberships_contributor_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "contributor_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "contributor_champion_memberships_selected_tier_check": {
+ "name": "contributor_champion_memberships_selected_tier_check",
+ "value": "\"contributor_champion_memberships\".\"selected_tier\" IS NULL OR \"contributor_champion_memberships\".\"selected_tier\" IN ('contributor', 'ambassador', 'champion')"
+ },
+ "contributor_champion_memberships_enrolled_tier_check": {
+ "name": "contributor_champion_memberships_enrolled_tier_check",
+ "value": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NULL OR \"contributor_champion_memberships\".\"enrolled_tier\" IN ('contributor', 'ambassador', 'champion')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.contributor_champion_sync_state": {
+ "name": "contributor_champion_sync_state",
+ "schema": "",
+ "columns": {
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "last_merged_at": {
+ "name": "last_merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.credit_campaigns": {
+ "name": "credit_campaigns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_category": {
+ "name": "credit_category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_microdollars": {
+ "name": "amount_microdollars",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_expiry_hours": {
+ "name": "credit_expiry_hours",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "campaign_ends_at": {
+ "name": "campaign_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_redemptions_allowed": {
+ "name": "total_redemptions_allowed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_credit_campaigns_slug": {
+ "name": "UQ_credit_campaigns_slug",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_credit_campaigns_credit_category": {
+ "name": "UQ_credit_campaigns_credit_category",
+ "columns": [
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "credit_campaigns_slug_format_check": {
+ "name": "credit_campaigns_slug_format_check",
+ "value": "\"credit_campaigns\".\"slug\" ~ '^[a-z0-9-]{5,40}$'"
+ },
+ "credit_campaigns_amount_positive_check": {
+ "name": "credit_campaigns_amount_positive_check",
+ "value": "\"credit_campaigns\".\"amount_microdollars\" > 0"
+ },
+ "credit_campaigns_credit_expiry_hours_positive_check": {
+ "name": "credit_campaigns_credit_expiry_hours_positive_check",
+ "value": "\"credit_campaigns\".\"credit_expiry_hours\" IS NULL OR \"credit_campaigns\".\"credit_expiry_hours\" > 0"
+ },
+ "credit_campaigns_total_redemptions_allowed_positive_check": {
+ "name": "credit_campaigns_total_redemptions_allowed_positive_check",
+ "value": "\"credit_campaigns\".\"total_redemptions_allowed\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.credit_transactions": {
+ "name": "credit_transactions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_microdollars": {
+ "name": "amount_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expiration_baseline_microdollars_used": {
+ "name": "expiration_baseline_microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_baseline_microdollars_used": {
+ "name": "original_baseline_microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_transaction_id": {
+ "name": "original_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_id": {
+ "name": "stripe_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coinbase_credit_block_id": {
+ "name": "coinbase_credit_block_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_category": {
+ "name": "credit_category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expiry_date": {
+ "name": "expiry_date",
+ "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()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_category_uniqueness": {
+ "name": "check_category_uniqueness",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "IDX_credit_transactions_created_at": {
+ "name": "IDX_credit_transactions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_is_free": {
+ "name": "IDX_credit_transactions_is_free",
+ "columns": [
+ {
+ "expression": "is_free",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_kilo_user_id": {
+ "name": "IDX_credit_transactions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_credit_category": {
+ "name": "IDX_credit_transactions_credit_category",
+ "columns": [
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_stripe_payment_id": {
+ "name": "IDX_credit_transactions_stripe_payment_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_original_transaction_id": {
+ "name": "IDX_credit_transactions_original_transaction_id",
+ "columns": [
+ {
+ "expression": "original_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_coinbase_credit_block_id": {
+ "name": "IDX_credit_transactions_coinbase_credit_block_id",
+ "columns": [
+ {
+ "expression": "coinbase_credit_block_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_organization_id": {
+ "name": "IDX_credit_transactions_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_credit_transactions_unique_category": {
+ "name": "IDX_credit_transactions_unique_category",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credit_category",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"credit_transactions\".\"check_category_uniqueness\" = TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "credit_transactions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_llm2": {
+ "name": "custom_llm2",
+ "schema": "",
+ "columns": {
+ "public_id": {
+ "name": "public_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "definition": {
+ "name": "definition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deleted_user_email_tombstones": {
+ "name": "deleted_user_email_tombstones",
+ "schema": "",
+ "columns": {
+ "normalized_email_hash": {
+ "name": "normalized_email_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_builds": {
+ "name": "deployment_builds",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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": {
+ "idx_deployment_builds_deployment_id": {
+ "name": "idx_deployment_builds_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_builds_status": {
+ "name": "idx_deployment_builds_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_builds_deployment_id_deployments_id_fk": {
+ "name": "deployment_builds_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_builds",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_env_vars": {
+ "name": "deployment_env_vars",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_secret": {
+ "name": "is_secret",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployment_env_vars_deployment_id": {
+ "name": "idx_deployment_env_vars_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_env_vars_deployment_id_deployments_id_fk": {
+ "name": "deployment_env_vars_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_env_vars",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployment_env_vars_deployment_key": {
+ "name": "UQ_deployment_env_vars_deployment_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_events": {
+ "name": "deployment_events",
+ "schema": "",
+ "columns": {
+ "build_id": {
+ "name": "build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'log'"
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_deployment_events_build_id": {
+ "name": "idx_deployment_events_build_id",
+ "columns": [
+ {
+ "expression": "build_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_events_timestamp": {
+ "name": "idx_deployment_events_timestamp",
+ "columns": [
+ {
+ "expression": "timestamp",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_events_type": {
+ "name": "idx_deployment_events_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_events_build_id_deployment_builds_id_fk": {
+ "name": "deployment_events_build_id_deployment_builds_id_fk",
+ "tableFrom": "deployment_events",
+ "tableTo": "deployment_builds",
+ "columnsFrom": [
+ "build_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "deployment_events_build_id_event_id_pk": {
+ "name": "deployment_events_build_id_event_id_pk",
+ "columns": [
+ "build_id",
+ "event_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_threat_detections": {
+ "name": "deployment_threat_detections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "build_id": {
+ "name": "build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "threat_type": {
+ "name": "threat_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployment_threat_detections_deployment_id": {
+ "name": "idx_deployment_threat_detections_deployment_id",
+ "columns": [
+ {
+ "expression": "deployment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployment_threat_detections_created_at": {
+ "name": "idx_deployment_threat_detections_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployment_threat_detections_deployment_id_deployments_id_fk": {
+ "name": "deployment_threat_detections_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_threat_detections",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "deployment_threat_detections_build_id_deployment_builds_id_fk": {
+ "name": "deployment_threat_detections_build_id_deployment_builds_id_fk",
+ "tableFrom": "deployment_threat_detections",
+ "tableTo": "deployment_builds",
+ "columnsFrom": [
+ "build_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployments": {
+ "name": "deployments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deployment_slug": {
+ "name": "deployment_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_worker_name": {
+ "name": "internal_worker_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_source": {
+ "name": "repository_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch": {
+ "name": "branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deployment_url": {
+ "name": "deployment_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'github'"
+ },
+ "git_auth_token": {
+ "name": "git_auth_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_deployed_at": {
+ "name": "last_deployed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_build_id": {
+ "name": "last_build_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "threat_status": {
+ "name": "threat_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_from": {
+ "name": "created_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_deployments_owned_by_user_id": {
+ "name": "idx_deployments_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_owned_by_organization_id": {
+ "name": "idx_deployments_owned_by_organization_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_platform_integration_id": {
+ "name": "idx_deployments_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_repository_source_branch": {
+ "name": "idx_deployments_repository_source_branch",
+ "columns": [
+ {
+ "expression": "repository_source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_threat_status_pending": {
+ "name": "idx_deployments_threat_status_pending",
+ "columns": [
+ {
+ "expression": "threat_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"deployments\".\"threat_status\" = 'pending_scan'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployments_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "deployments_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deployments_owned_by_organization_id_organizations_id_fk": {
+ "name": "deployments_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployments_deployment_slug": {
+ "name": "UQ_deployments_deployment_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "deployments_owner_check": {
+ "name": "deployments_owner_check",
+ "value": "(\n (\"deployments\".\"owned_by_user_id\" IS NOT NULL AND \"deployments\".\"owned_by_organization_id\" IS NULL) OR\n (\"deployments\".\"owned_by_user_id\" IS NULL AND \"deployments\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "deployments_source_type_check": {
+ "name": "deployments_source_type_check",
+ "value": "\"deployments\".\"source_type\" IN ('github', 'git', 'app-builder')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.deployments_ephemeral": {
+ "name": "deployments_ephemeral",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_worker_name": {
+ "name": "internal_worker_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deployment_slug": {
+ "name": "deployment_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_cleanup_at": {
+ "name": "next_cleanup_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cleanup_claim_token": {
+ "name": "cleanup_claim_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cleanup_claimed_until": {
+ "name": "cleanup_claimed_until",
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deployments_ephemeral_owned_by_user_id": {
+ "name": "idx_deployments_ephemeral_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deployments_ephemeral_next_cleanup_at": {
+ "name": "idx_deployments_ephemeral_next_cleanup_at",
+ "columns": [
+ {
+ "expression": "next_cleanup_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "deployments_ephemeral",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_deployments_ephemeral_internal_worker_name": {
+ "name": "UQ_deployments_ephemeral_internal_worker_name",
+ "nullsNotDistinct": false,
+ "columns": [
+ "internal_worker_name"
+ ]
+ },
+ "UQ_deployments_ephemeral_deployment_slug": {
+ "name": "UQ_deployments_ephemeral_deployment_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "deployment_slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "deployments_ephemeral_source_type_check": {
+ "name": "deployments_ephemeral_source_type_check",
+ "value": "\"deployments_ephemeral\".\"source_type\" IN ('html')"
+ },
+ "deployments_ephemeral_status_check": {
+ "name": "deployments_ephemeral_status_check",
+ "value": "\"deployments_ephemeral\".\"status\" IN ('pending', 'active', 'cleanup_retry')"
+ },
+ "deployments_ephemeral_claim_fields_check": {
+ "name": "deployments_ephemeral_claim_fields_check",
+ "value": "(\"deployments_ephemeral\".\"cleanup_claim_token\" IS NULL) = (\"deployments_ephemeral\".\"cleanup_claimed_until\" IS NULL)"
+ },
+ "deployments_ephemeral_active_fields_check": {
+ "name": "deployments_ephemeral_active_fields_check",
+ "value": "\"deployments_ephemeral\".\"status\" <> 'active' OR (\"deployments_ephemeral\".\"deployment_slug\" IS NOT NULL AND \"deployments_ephemeral\".\"expires_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.device_auth_requests": {
+ "name": "device_auth_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_device_auth_requests_code": {
+ "name": "UQ_device_auth_requests_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_status": {
+ "name": "IDX_device_auth_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_expires_at": {
+ "name": "IDX_device_auth_requests_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_device_auth_requests_kilo_user_id": {
+ "name": "IDX_device_auth_requests_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "device_auth_requests_kilo_user_id_kilocode_users_id_fk": {
+ "name": "device_auth_requests_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "device_auth_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.discord_gateway_listener": {
+ "name": "discord_gateway_listener",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "default": 1
+ },
+ "listener_id": {
+ "name": "listener_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_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": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.editor_name": {
+ "name": "editor_name",
+ "schema": "",
+ "columns": {
+ "editor_name_id": {
+ "name": "editor_name_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "editor_name": {
+ "name": "editor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_editor_name": {
+ "name": "UQ_editor_name",
+ "columns": [
+ {
+ "expression": "editor_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.enrichment_data": {
+ "name": "enrichment_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_enrichment_data": {
+ "name": "github_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linkedin_enrichment_data": {
+ "name": "linkedin_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clay_enrichment_data": {
+ "name": "clay_enrichment_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_enrichment_data_user_id": {
+ "name": "IDX_enrichment_data_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "enrichment_data_user_id_kilocode_users_id_fk": {
+ "name": "enrichment_data_user_id_kilocode_users_id_fk",
+ "tableFrom": "enrichment_data",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_enrichment_data_user_id": {
+ "name": "UQ_enrichment_data_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.exa_monthly_usage": {
+ "name": "exa_monthly_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "month": {
+ "name": "month",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "total_charged_microdollars": {
+ "name": "total_charged_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "free_allowance_microdollars": {
+ "name": "free_allowance_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 10000000
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_exa_monthly_usage_personal": {
+ "name": "idx_exa_monthly_usage_personal",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"exa_monthly_usage\".\"organization_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_exa_monthly_usage_org": {
+ "name": "idx_exa_monthly_usage_org",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"exa_monthly_usage\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.exa_usage_log": {
+ "name": "exa_usage_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost_microdollars": {
+ "name": "cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "charged_to_balance": {
+ "name": "charged_to_balance",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "feature_id": {
+ "name": "feature_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_exa_usage_log_user_created": {
+ "name": "idx_exa_usage_log_user_created",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "exa_usage_log_id_created_at_pk": {
+ "name": "exa_usage_log_id_created_at_pk",
+ "columns": [
+ "id",
+ "created_at"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature": {
+ "name": "feature",
+ "schema": "",
+ "columns": {
+ "feature_id": {
+ "name": "feature_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_feature": {
+ "name": "UQ_feature",
+ "columns": [
+ {
+ "expression": "feature",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.finish_reason": {
+ "name": "finish_reason",
+ "schema": "",
+ "columns": {
+ "finish_reason_id": {
+ "name": "finish_reason_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "finish_reason": {
+ "name": "finish_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_finish_reason": {
+ "name": "UQ_finish_reason",
+ "columns": [
+ {
+ "expression": "finish_reason",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.free_model_usage": {
+ "name": "free_model_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_free_model_usage_ip_created_at": {
+ "name": "idx_free_model_usage_ip_created_at",
+ "columns": [
+ {
+ "expression": "ip_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_free_model_usage_created_at": {
+ "name": "idx_free_model_usage_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_branch_pull_requests": {
+ "name": "github_branch_pull_requests",
+ "schema": "",
+ "columns": {
+ "git_url": {
+ "name": "git_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_state": {
+ "name": "pr_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_title": {
+ "name": "pr_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_sha": {
+ "name": "pr_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_review_decision": {
+ "name": "pr_review_decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_decision_pending": {
+ "name": "review_decision_pending",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "review_decision_fetching_at": {
+ "name": "review_decision_fetching_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_last_synced_at": {
+ "name": "pr_last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_github_branch_prs_org": {
+ "name": "UQ_github_branch_prs_org",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"github_branch_pull_requests\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_github_branch_prs_user": {
+ "name": "UQ_github_branch_prs_user",
+ "columns": [
+ {
+ "expression": "git_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"github_branch_pull_requests\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk": {
+ "name": "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "github_branch_pull_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "github_branch_pull_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "github_branch_pull_requests_owner_check": {
+ "name": "github_branch_pull_requests_owner_check",
+ "value": "(\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NOT NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NULL) OR\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NOT NULL)\n )"
+ },
+ "github_branch_pull_requests_review_decision_check": {
+ "name": "github_branch_pull_requests_review_decision_check",
+ "value": "\"github_branch_pull_requests\".\"pr_review_decision\" IS NULL OR \"github_branch_pull_requests\".\"pr_review_decision\" IN ('approved', 'changes_requested', 'review_required')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.http_ip": {
+ "name": "http_ip",
+ "schema": "",
+ "columns": {
+ "http_ip_id": {
+ "name": "http_ip_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "http_ip": {
+ "name": "http_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_http_ip": {
+ "name": "UQ_http_ip",
+ "columns": [
+ {
+ "expression": "http_ip",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.http_user_agent": {
+ "name": "http_user_agent",
+ "schema": "",
+ "columns": {
+ "http_user_agent_id": {
+ "name": "http_user_agent_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_http_user_agent": {
+ "name": "UQ_http_user_agent",
+ "columns": [
+ {
+ "expression": "http_user_agent",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_participants": {
+ "name": "impact_advocate_participants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "advocate_id": {
+ "name": "advocate_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "advocate_account_id": {
+ "name": "advocate_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_referral_identifier": {
+ "name": "opaque_referral_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contact_email": {
+ "name": "contact_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_state": {
+ "name": "registration_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "registered_at": {
+ "name": "registered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_registration_attempt_at": {
+ "name": "last_registration_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_code": {
+ "name": "last_error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_message": {
+ "name": "last_error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_impact_advocate_participants_program_referral_identifier": {
+ "name": "UQ_impact_advocate_participants_program_referral_identifier",
+ "columns": [
+ {
+ "expression": "program_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "opaque_referral_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"impact_advocate_participants\".\"opaque_referral_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_participants_registration_state": {
+ "name": "IDX_impact_advocate_participants_registration_state",
+ "columns": [
+ {
+ "expression": "registration_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_participants_user_id_kilocode_users_id_fk": {
+ "name": "impact_advocate_participants_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_advocate_participants",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_participants_program_user": {
+ "name": "UQ_impact_advocate_participants_program_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "program_key",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_participants_program_key_check": {
+ "name": "impact_advocate_participants_program_key_check",
+ "value": "\"impact_advocate_participants\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_advocate_participants_registration_state_check": {
+ "name": "impact_advocate_participants_registration_state_check",
+ "value": "\"impact_advocate_participants\".\"registration_state\" IN ('pending', 'retrying', 'registered', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_registration_attempts": {
+ "name": "impact_advocate_registration_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "participant_id": {
+ "name": "participant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_cookie_value": {
+ "name": "opaque_cookie_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cookie_value_length": {
+ "name": "cookie_value_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delivery_state": {
+ "name": "delivery_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_payload": {
+ "name": "response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_advocate_registration_attempts_participant_id": {
+ "name": "IDX_impact_advocate_registration_attempts_participant_id",
+ "columns": [
+ {
+ "expression": "participant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_registration_attempts_delivery_state": {
+ "name": "IDX_impact_advocate_registration_attempts_delivery_state",
+ "columns": [
+ {
+ "expression": "delivery_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk": {
+ "name": "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk",
+ "tableFrom": "impact_advocate_registration_attempts",
+ "tableTo": "impact_advocate_participants",
+ "columnsFrom": [
+ "participant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_registration_attempts_dedupe_key": {
+ "name": "UQ_impact_advocate_registration_attempts_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_registration_attempts_program_key_check": {
+ "name": "impact_advocate_registration_attempts_program_key_check",
+ "value": "\"impact_advocate_registration_attempts\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_advocate_registration_attempts_delivery_state_check": {
+ "name": "impact_advocate_registration_attempts_delivery_state_check",
+ "value": "\"impact_advocate_registration_attempts\".\"delivery_state\" IN ('queued', 'sending', 'succeeded', 'failed')"
+ },
+ "impact_advocate_registration_attempts_cookie_value_length_non_negative_check": {
+ "name": "impact_advocate_registration_attempts_cookie_value_length_non_negative_check",
+ "value": "\"impact_advocate_registration_attempts\".\"cookie_value_length\" >= 0"
+ },
+ "impact_advocate_registration_attempts_attempt_count_non_negative_check": {
+ "name": "impact_advocate_registration_attempts_attempt_count_non_negative_check",
+ "value": "\"impact_advocate_registration_attempts\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_advocate_reward_redemptions": {
+ "name": "impact_advocate_reward_redemptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "reward_id": {
+ "name": "reward_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "impact_reward_id": {
+ "name": "impact_reward_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lookup_response_payload": {
+ "name": "lookup_response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redeem_response_payload": {
+ "name": "redeem_response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redeemed_at": {
+ "name": "redeemed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_advocate_reward_redemptions_beneficiary_user_id": {
+ "name": "IDX_impact_advocate_reward_redemptions_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_advocate_reward_redemptions_state": {
+ "name": "IDX_impact_advocate_reward_redemptions_state",
+ "columns": [
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk": {
+ "name": "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk",
+ "tableFrom": "impact_advocate_reward_redemptions",
+ "tableTo": "impact_referral_rewards",
+ "columnsFrom": [
+ "reward_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_advocate_reward_redemptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_advocate_reward_redemptions_reward_id": {
+ "name": "UQ_impact_advocate_reward_redemptions_reward_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "reward_id"
+ ]
+ },
+ "UQ_impact_advocate_reward_redemptions_dedupe_key": {
+ "name": "UQ_impact_advocate_reward_redemptions_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_advocate_reward_redemptions_state_check": {
+ "name": "impact_advocate_reward_redemptions_state_check",
+ "value": "\"impact_advocate_reward_redemptions\".\"state\" IN ('queued', 'retrying', 'redeemed', 'failed')"
+ },
+ "impact_advocate_reward_redemptions_attempt_count_non_negative_check": {
+ "name": "impact_advocate_reward_redemptions_attempt_count_non_negative_check",
+ "value": "\"impact_advocate_reward_redemptions\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_attribution_touches": {
+ "name": "impact_attribution_touches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "program_key": {
+ "name": "program_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'kiloclaw'"
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "anonymous_id": {
+ "name": "anonymous_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touch_type": {
+ "name": "touch_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opaque_tracking_value": {
+ "name": "opaque_tracking_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tracking_value_length": {
+ "name": "tracking_value_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_tracking_value_accepted": {
+ "name": "is_tracking_value_accepted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "rs_code": {
+ "name": "rs_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rs_share_medium": {
+ "name": "rs_share_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rs_engagement_medium": {
+ "name": "rs_engagement_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "im_ref": {
+ "name": "im_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landing_path": {
+ "name": "landing_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_source": {
+ "name": "utm_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_medium": {
+ "name": "utm_medium",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_campaign": {
+ "name": "utm_campaign",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_term": {
+ "name": "utm_term",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utm_content": {
+ "name": "utm_content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touched_at": {
+ "name": "touched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sale_attributed_at": {
+ "name": "sale_attributed_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": {
+ "IDX_impact_attribution_touches_product_user_id": {
+ "name": "IDX_impact_attribution_touches_product_user_id",
+ "columns": [
+ {
+ "expression": "product",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_user_id": {
+ "name": "IDX_impact_attribution_touches_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_anonymous_id": {
+ "name": "IDX_impact_attribution_touches_anonymous_id",
+ "columns": [
+ {
+ "expression": "anonymous_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_expires_at": {
+ "name": "IDX_impact_attribution_touches_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_attribution_touches_sale_attributed_at": {
+ "name": "IDX_impact_attribution_touches_sale_attributed_at",
+ "columns": [
+ {
+ "expression": "sale_attributed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_attribution_touches_user_id_kilocode_users_id_fk": {
+ "name": "impact_attribution_touches_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_attribution_touches",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_attribution_touches_dedupe_key": {
+ "name": "UQ_impact_attribution_touches_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_attribution_touches_product_check": {
+ "name": "impact_attribution_touches_product_check",
+ "value": "\"impact_attribution_touches\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_attribution_touches_program_key_check": {
+ "name": "impact_attribution_touches_program_key_check",
+ "value": "\"impact_attribution_touches\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_attribution_touches_touch_type_check": {
+ "name": "impact_attribution_touches_touch_type_check",
+ "value": "\"impact_attribution_touches\".\"touch_type\" IN ('affiliate', 'referral')"
+ },
+ "impact_attribution_touches_provider_check": {
+ "name": "impact_attribution_touches_provider_check",
+ "value": "\"impact_attribution_touches\".\"provider\" IN ('impact_performance', 'impact_advocate')"
+ },
+ "impact_attribution_touches_tracking_value_length_non_negative_check": {
+ "name": "impact_attribution_touches_tracking_value_length_non_negative_check",
+ "value": "\"impact_attribution_touches\".\"tracking_value_length\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_conversion_reports": {
+ "name": "impact_conversion_reports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_tracker_id": {
+ "name": "action_tracker_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "order_id": {
+ "name": "order_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_payload": {
+ "name": "response_payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status_code": {
+ "name": "response_status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delivered_at": {
+ "name": "delivered_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_conversion_reports_conversion_id": {
+ "name": "IDX_impact_conversion_reports_conversion_id",
+ "columns": [
+ {
+ "expression": "conversion_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_conversion_reports_state": {
+ "name": "IDX_impact_conversion_reports_state",
+ "columns": [
+ {
+ "expression": "state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_conversion_reports",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_conversion_reports_dedupe_key": {
+ "name": "UQ_impact_conversion_reports_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_conversion_reports_state_check": {
+ "name": "impact_conversion_reports_state_check",
+ "value": "\"impact_conversion_reports\".\"state\" IN ('queued', 'retrying', 'delivered', 'failed')"
+ },
+ "impact_conversion_reports_attempt_count_non_negative_check": {
+ "name": "impact_conversion_reports_attempt_count_non_negative_check",
+ "value": "\"impact_conversion_reports\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_conversions": {
+ "name": "impact_referral_conversions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "referee_user_id": {
+ "name": "referee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer_user_id": {
+ "name": "referrer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_touch_id": {
+ "name": "source_touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "winning_touch_type": {
+ "name": "winning_touch_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'credits'"
+ },
+ "source_payment_id": {
+ "name": "source_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "qualified": {
+ "name": "qualified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "disqualification_reason": {
+ "name": "disqualification_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "converted_at": {
+ "name": "converted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_conversions_referee_user_id": {
+ "name": "IDX_impact_referral_conversions_referee_user_id",
+ "columns": [
+ {
+ "expression": "referee_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_conversions_referrer_user_id": {
+ "name": "IDX_impact_referral_conversions_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_conversions_referee_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_conversions_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk": {
+ "name": "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk",
+ "tableFrom": "impact_referral_conversions",
+ "tableTo": "impact_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_conversions_product_payment_source": {
+ "name": "UQ_impact_referral_conversions_product_payment_source",
+ "nullsNotDistinct": false,
+ "columns": [
+ "product",
+ "payment_provider",
+ "source_payment_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_conversions_product_check": {
+ "name": "impact_referral_conversions_product_check",
+ "value": "\"impact_referral_conversions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_conversions_winning_touch_type_check": {
+ "name": "impact_referral_conversions_winning_touch_type_check",
+ "value": "\"impact_referral_conversions\".\"winning_touch_type\" IN ('referral', 'affiliate', 'none')"
+ },
+ "impact_referral_conversions_payment_provider_check": {
+ "name": "impact_referral_conversions_payment_provider_check",
+ "value": "\"impact_referral_conversions\".\"payment_provider\" IN ('stripe', 'credits', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_reward_applications": {
+ "name": "impact_referral_reward_applications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "reward_id": {
+ "name": "reward_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_renewal_boundary": {
+ "name": "previous_renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "new_renewal_boundary": {
+ "name": "new_renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_operation_id": {
+ "name": "local_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_operation_id": {
+ "name": "stripe_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_idempotency_key": {
+ "name": "stripe_idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_reward_applications_reward_id": {
+ "name": "IDX_impact_referral_reward_applications_reward_id",
+ "columns": [
+ {
+ "expression": "reward_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_reward_applications_beneficiary_user_id": {
+ "name": "IDX_impact_referral_reward_applications_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk": {
+ "name": "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk",
+ "tableFrom": "impact_referral_reward_applications",
+ "tableTo": "impact_referral_rewards",
+ "columnsFrom": [
+ "reward_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_reward_applications",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_reward_applications_product_check": {
+ "name": "impact_referral_reward_applications_product_check",
+ "value": "\"impact_referral_reward_applications\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_reward_decisions": {
+ "name": "impact_referral_reward_decisions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_role": {
+ "name": "beneficiary_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_kind": {
+ "name": "reward_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw_free_month'"
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "reward_percent": {
+ "name": "reward_percent",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_tier": {
+ "name": "source_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_amount_usd": {
+ "name": "reward_amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_reward_decisions_beneficiary_user_id": {
+ "name": "IDX_impact_referral_reward_decisions_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_referral_reward_decisions",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_reward_decisions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_reward_decisions_conversion_role": {
+ "name": "UQ_impact_referral_reward_decisions_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_reward_decisions_product_check": {
+ "name": "impact_referral_reward_decisions_product_check",
+ "value": "\"impact_referral_reward_decisions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_reward_decisions_beneficiary_role_check": {
+ "name": "impact_referral_reward_decisions_beneficiary_role_check",
+ "value": "\"impact_referral_reward_decisions\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "impact_referral_reward_decisions_outcome_check": {
+ "name": "impact_referral_reward_decisions_outcome_check",
+ "value": "\"impact_referral_reward_decisions\".\"outcome\" IN ('granted', 'cap_limited', 'disqualified')"
+ },
+ "impact_referral_reward_decisions_reward_kind_check": {
+ "name": "impact_referral_reward_decisions_reward_kind_check",
+ "value": "\"impact_referral_reward_decisions\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
+ },
+ "impact_referral_reward_decisions_months_granted_non_negative_check": {
+ "name": "impact_referral_reward_decisions_months_granted_non_negative_check",
+ "value": "\"impact_referral_reward_decisions\".\"months_granted\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referral_rewards": {
+ "name": "impact_referral_rewards",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "conversion_id": {
+ "name": "conversion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "decision_id": {
+ "name": "decision_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_user_id": {
+ "name": "beneficiary_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "beneficiary_role": {
+ "name": "beneficiary_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reward_kind": {
+ "name": "reward_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw_free_month'"
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "reward_percent": {
+ "name": "reward_percent",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_tier": {
+ "name": "source_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_amount_usd": {
+ "name": "reward_amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "applies_to_subscription_id": {
+ "name": "applies_to_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applies_to_kilo_pass_subscription_id": {
+ "name": "applies_to_kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consumed_kilo_pass_issuance_id": {
+ "name": "consumed_kilo_pass_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consumed_kilo_pass_issuance_item_id": {
+ "name": "consumed_kilo_pass_issuance_item_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "earned_at": {
+ "name": "earned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reversed_at": {
+ "name": "reversed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_reason": {
+ "name": "review_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referral_rewards_beneficiary_user_id": {
+ "name": "IDX_impact_referral_rewards_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referral_rewards_status": {
+ "name": "IDX_impact_referral_rewards_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk": {
+ "name": "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "impact_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk": {
+ "name": "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "impact_referral_reward_decisions",
+ "columnsFrom": [
+ "decision_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_subscription": {
+ "name": "FK_impact_referral_rewards_kilo_pass_subscription",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "applies_to_kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_issuance": {
+ "name": "FK_impact_referral_rewards_kilo_pass_issuance",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "consumed_kilo_pass_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "FK_impact_referral_rewards_kilo_pass_issuance_item": {
+ "name": "FK_impact_referral_rewards_kilo_pass_issuance_item",
+ "tableFrom": "impact_referral_rewards",
+ "tableTo": "kilo_pass_issuance_items",
+ "columnsFrom": [
+ "consumed_kilo_pass_issuance_item_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referral_rewards_conversion_role": {
+ "name": "UQ_impact_referral_rewards_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ },
+ "UQ_impact_referral_rewards_decision_id": {
+ "name": "UQ_impact_referral_rewards_decision_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "decision_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referral_rewards_product_check": {
+ "name": "impact_referral_rewards_product_check",
+ "value": "\"impact_referral_rewards\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ },
+ "impact_referral_rewards_beneficiary_role_check": {
+ "name": "impact_referral_rewards_beneficiary_role_check",
+ "value": "\"impact_referral_rewards\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "impact_referral_rewards_reward_kind_check": {
+ "name": "impact_referral_rewards_reward_kind_check",
+ "value": "\"impact_referral_rewards\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
+ },
+ "impact_referral_rewards_status_check": {
+ "name": "impact_referral_rewards_status_check",
+ "value": "\"impact_referral_rewards\".\"status\" IN ('pending', 'earned', 'applied', 'reversed', 'expired', 'canceled', 'review_required')"
+ },
+ "impact_referral_rewards_months_granted_non_negative_check": {
+ "name": "impact_referral_rewards_months_granted_non_negative_check",
+ "value": "\"impact_referral_rewards\".\"months_granted\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.impact_referrals": {
+ "name": "impact_referrals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "product": {
+ "name": "product",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kiloclaw'"
+ },
+ "referee_user_id": {
+ "name": "referee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer_user_id": {
+ "name": "referrer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_touch_id": {
+ "name": "source_touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_referral_id": {
+ "name": "impact_referral_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_impact_referrals_referrer_user_id": {
+ "name": "IDX_impact_referrals_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_impact_referrals_source_touch_id": {
+ "name": "IDX_impact_referrals_source_touch_id",
+ "columns": [
+ {
+ "expression": "source_touch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "impact_referrals_referee_user_id_kilocode_users_id_fk": {
+ "name": "impact_referrals_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "impact_referrals_referrer_user_id_kilocode_users_id_fk": {
+ "name": "impact_referrals_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "impact_referrals_source_touch_id_impact_attribution_touches_id_fk": {
+ "name": "impact_referrals_source_touch_id_impact_attribution_touches_id_fk",
+ "tableFrom": "impact_referrals",
+ "tableTo": "impact_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_impact_referrals_product_referee_user_id": {
+ "name": "UQ_impact_referrals_product_referee_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "product",
+ "referee_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "impact_referrals_product_check": {
+ "name": "impact_referrals_product_check",
+ "value": "\"impact_referrals\".\"product\" IN ('kiloclaw', 'kilo_pass')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.ja4_digest": {
+ "name": "ja4_digest",
+ "schema": "",
+ "columns": {
+ "ja4_digest_id": {
+ "name": "ja4_digest_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ja4_digest": {
+ "name": "ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_ja4_digest": {
+ "name": "UQ_ja4_digest",
+ "columns": [
+ {
+ "expression": "ja4_digest",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_audit_log": {
+ "name": "kilo_pass_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_invoice_id": {
+ "name": "stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_credit_transaction_id": {
+ "name": "related_credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "related_monthly_issuance_id": {
+ "name": "related_monthly_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_audit_log_created_at": {
+ "name": "IDX_kilo_pass_audit_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_kilo_user_id": {
+ "name": "IDX_kilo_pass_audit_log_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_kilo_pass_subscription_id": {
+ "name": "IDX_kilo_pass_audit_log_kilo_pass_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_action": {
+ "name": "IDX_kilo_pass_audit_log_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_result": {
+ "name": "IDX_kilo_pass_audit_log_result",
+ "columns": [
+ {
+ "expression": "result",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_idempotency_key": {
+ "name": "IDX_kilo_pass_audit_log_idempotency_key",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_event_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_invoice_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_invoice_id",
+ "columns": [
+ {
+ "expression": "stripe_invoice_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_stripe_subscription_id": {
+ "name": "IDX_kilo_pass_audit_log_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_related_credit_transaction_id": {
+ "name": "IDX_kilo_pass_audit_log_related_credit_transaction_id",
+ "columns": [
+ {
+ "expression": "related_credit_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_audit_log_related_monthly_issuance_id": {
+ "name": "IDX_kilo_pass_audit_log_related_monthly_issuance_id",
+ "columns": [
+ {
+ "expression": "related_monthly_issuance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "related_credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk": {
+ "name": "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk",
+ "tableFrom": "kilo_pass_audit_log",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "related_monthly_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_audit_log_action_check": {
+ "name": "kilo_pass_audit_log_action_check",
+ "value": "\"kilo_pass_audit_log\".\"action\" IN ('stripe_webhook_received', 'kilo_pass_invoice_paid_handled', 'store_purchase_completed', 'store_notification_received', 'store_subscription_renewed', 'store_subscription_canceled', 'store_subscription_expired', 'store_subscription_refunded', 'base_credits_issued', 'bonus_credits_issued', 'bonus_credits_skipped_idempotent', 'first_month_50pct_promo_issued', 'yearly_monthly_base_cron_started', 'yearly_monthly_base_cron_completed', 'issue_yearly_remaining_credits', 'duplicate_card_subscription_canceled', 'yearly_monthly_bonus_cron_started', 'yearly_monthly_bonus_cron_completed')"
+ },
+ "kilo_pass_audit_log_result_check": {
+ "name": "kilo_pass_audit_log_result_check",
+ "value": "\"kilo_pass_audit_log\".\"result\" IN ('success', 'skipped_idempotent', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_issuance_items": {
+ "name": "kilo_pass_issuance_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_issuance_id": {
+ "name": "kilo_pass_issuance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credit_transaction_id": {
+ "name": "credit_transaction_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "numeric(12, 2)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bonus_percent_applied": {
+ "name": "bonus_percent_applied",
+ "type": "numeric(6, 4)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_issuance_items_issuance_id": {
+ "name": "IDX_kilo_pass_issuance_items_issuance_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_issuance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuance_items_credit_transaction_id": {
+ "name": "IDX_kilo_pass_issuance_items_credit_transaction_id",
+ "columns": [
+ {
+ "expression": "credit_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk": {
+ "name": "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk",
+ "tableFrom": "kilo_pass_issuance_items",
+ "tableTo": "kilo_pass_issuances",
+ "columnsFrom": [
+ "kilo_pass_issuance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk": {
+ "name": "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk",
+ "tableFrom": "kilo_pass_issuance_items",
+ "tableTo": "credit_transactions",
+ "columnsFrom": [
+ "credit_transaction_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilo_pass_issuance_items_credit_transaction_id_unique": {
+ "name": "kilo_pass_issuance_items_credit_transaction_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "credit_transaction_id"
+ ]
+ },
+ "UQ_kilo_pass_issuance_items_issuance_kind": {
+ "name": "UQ_kilo_pass_issuance_items_issuance_kind",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_pass_issuance_id",
+ "kind"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_issuance_items_bonus_percent_applied_range_check": {
+ "name": "kilo_pass_issuance_items_bonus_percent_applied_range_check",
+ "value": "\"kilo_pass_issuance_items\".\"bonus_percent_applied\" IS NULL OR (\"kilo_pass_issuance_items\".\"bonus_percent_applied\" >= 0 AND \"kilo_pass_issuance_items\".\"bonus_percent_applied\" <= 1)"
+ },
+ "kilo_pass_issuance_items_amount_usd_non_negative_check": {
+ "name": "kilo_pass_issuance_items_amount_usd_non_negative_check",
+ "value": "\"kilo_pass_issuance_items\".\"amount_usd\" >= 0"
+ },
+ "kilo_pass_issuance_items_kind_check": {
+ "name": "kilo_pass_issuance_items_kind_check",
+ "value": "\"kilo_pass_issuance_items\".\"kind\" IN ('base', 'bonus', 'promo_first_month_50pct', 'referral_bonus')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_issuances": {
+ "name": "kilo_pass_issuances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_month": {
+ "name": "issue_month",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_invoice_id": {
+ "name": "stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initial_welcome_promo_eligibility_reason": {
+ "name": "initial_welcome_promo_eligibility_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kilo_pass_issuances_stripe_invoice_id": {
+ "name": "UQ_kilo_pass_issuances_stripe_invoice_id",
+ "columns": [
+ {
+ "expression": "stripe_invoice_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_issuances\".\"stripe_invoice_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuances_subscription_id": {
+ "name": "IDX_kilo_pass_issuances_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_issuances_issue_month": {
+ "name": "IDX_kilo_pass_issuances_issue_month",
+ "columns": [
+ {
+ "expression": "issue_month",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_issuances",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kilo_pass_issuances_subscription_issue_month": {
+ "name": "UQ_kilo_pass_issuances_subscription_issue_month",
+ "nullsNotDistinct": false,
+ "columns": [
+ "kilo_pass_subscription_id",
+ "issue_month"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_issuances_issue_month_day_one_check": {
+ "name": "kilo_pass_issuances_issue_month_day_one_check",
+ "value": "EXTRACT(DAY FROM \"kilo_pass_issuances\".\"issue_month\") = 1"
+ },
+ "kilo_pass_issuances_source_check": {
+ "name": "kilo_pass_issuances_source_check",
+ "value": "\"kilo_pass_issuances\".\"source\" IN ('stripe_invoice', 'app_store_transaction', 'google_play_transaction', 'cron')"
+ },
+ "kilo_pass_issuances_initial_welcome_promo_reason_check": {
+ "name": "kilo_pass_issuances_initial_welcome_promo_reason_check",
+ "value": "\"kilo_pass_issuances\".\"initial_welcome_promo_eligibility_reason\" IN ('first_payment_fingerprint_claim', 'fingerprint_previously_claimed', 'missing_fingerprint', 'no_supported_fingerprint', 'no_positive_settlement', 'settlement_unresolved')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_pause_events": {
+ "name": "kilo_pass_pause_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "paused_at": {
+ "name": "paused_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resumes_at": {
+ "name": "resumes_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resumed_at": {
+ "name": "resumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_pause_events_subscription_id": {
+ "name": "IDX_kilo_pass_pause_events_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_pause_events_one_open_per_sub": {
+ "name": "UQ_kilo_pass_pause_events_one_open_per_sub",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_pause_events",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_pause_events_resumed_at_after_paused_at_check": {
+ "name": "kilo_pass_pause_events_resumed_at_after_paused_at_check",
+ "value": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL OR \"kilo_pass_pause_events\".\"resumed_at\" >= \"kilo_pass_pause_events\".\"paused_at\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_scheduled_changes": {
+ "name": "kilo_pass_scheduled_changes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_tier": {
+ "name": "from_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_cadence": {
+ "name": "from_cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_tier": {
+ "name": "to_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_cadence": {
+ "name": "to_cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_schedule_id": {
+ "name": "stripe_schedule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_at": {
+ "name": "effective_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_scheduled_changes_kilo_user_id": {
+ "name": "IDX_kilo_pass_scheduled_changes_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_status": {
+ "name": "IDX_kilo_pass_scheduled_changes_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_stripe_subscription_id": {
+ "name": "IDX_kilo_pass_scheduled_changes_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id": {
+ "name": "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id",
+ "columns": [
+ {
+ "expression": "stripe_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_scheduled_changes\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_effective_at": {
+ "name": "IDX_kilo_pass_scheduled_changes_effective_at",
+ "columns": [
+ {
+ "expression": "effective_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_scheduled_changes_deleted_at": {
+ "name": "IDX_kilo_pass_scheduled_changes_deleted_at",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_scheduled_changes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk": {
+ "name": "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk",
+ "tableFrom": "kilo_pass_scheduled_changes",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "stripe_subscription_id"
+ ],
+ "columnsTo": [
+ "stripe_subscription_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_scheduled_changes_from_tier_check": {
+ "name": "kilo_pass_scheduled_changes_from_tier_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"from_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_scheduled_changes_from_cadence_check": {
+ "name": "kilo_pass_scheduled_changes_from_cadence_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"from_cadence\" IN ('monthly', 'yearly')"
+ },
+ "kilo_pass_scheduled_changes_to_tier_check": {
+ "name": "kilo_pass_scheduled_changes_to_tier_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"to_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_scheduled_changes_to_cadence_check": {
+ "name": "kilo_pass_scheduled_changes_to_cadence_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"to_cadence\" IN ('monthly', 'yearly')"
+ },
+ "kilo_pass_scheduled_changes_status_check": {
+ "name": "kilo_pass_scheduled_changes_status_check",
+ "value": "\"kilo_pass_scheduled_changes\".\"status\" IN ('not_started', 'active', 'completed', 'released', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_store_events": {
+ "name": "kilo_pass_store_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_transaction_id": {
+ "name": "provider_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_account_token": {
+ "name": "app_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment": {
+ "name": "environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "processing_started_at": {
+ "name": "processing_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processed_at": {
+ "name": "processed_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": {
+ "UQ_kilo_pass_store_events_provider_event": {
+ "name": "UQ_kilo_pass_store_events_provider_event",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_events_provider_subscription": {
+ "name": "IDX_kilo_pass_store_events_provider_subscription",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_events_app_account_token": {
+ "name": "IDX_kilo_pass_store_events_app_account_token",
+ "columns": [
+ {
+ "expression": "app_account_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_store_events_payment_provider_check": {
+ "name": "kilo_pass_store_events_payment_provider_check",
+ "value": "\"kilo_pass_store_events\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_store_purchases": {
+ "name": "kilo_pass_store_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_pass_subscription_id": {
+ "name": "kilo_pass_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_transaction_id": {
+ "name": "provider_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_original_transaction_id": {
+ "name": "provider_original_transaction_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_account_token": {
+ "name": "app_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "purchase_token": {
+ "name": "purchase_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environment": {
+ "name": "environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purchased_at": {
+ "name": "purchased_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_payload_json": {
+ "name": "raw_payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kilo_pass_store_purchases_provider_transaction": {
+ "name": "UQ_kilo_pass_store_purchases_provider_transaction",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_transaction_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_subscription_id": {
+ "name": "IDX_kilo_pass_store_purchases_subscription_id",
+ "columns": [
+ {
+ "expression": "kilo_pass_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_user_id": {
+ "name": "IDX_kilo_pass_store_purchases_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_app_account_token": {
+ "name": "IDX_kilo_pass_store_purchases_app_account_token",
+ "columns": [
+ {
+ "expression": "app_account_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_store_purchases_latest_subscription_purchase": {
+ "name": "IDX_kilo_pass_store_purchases_latest_subscription_purchase",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "purchased_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
+ "name": "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "FK_kilo_pass_store_purchases_subscription_owner_provider": {
+ "name": "FK_kilo_pass_store_purchases_subscription_owner_provider",
+ "tableFrom": "kilo_pass_store_purchases",
+ "tableTo": "kilo_pass_subscriptions",
+ "columnsFrom": [
+ "kilo_pass_subscription_id",
+ "kilo_user_id",
+ "payment_provider",
+ "provider_subscription_id"
+ ],
+ "columnsTo": [
+ "id",
+ "kilo_user_id",
+ "payment_provider",
+ "provider_subscription_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_store_purchases_store_provider_check": {
+ "name": "kilo_pass_store_purchases_store_provider_check",
+ "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('app_store', 'google_play')"
+ },
+ "kilo_pass_store_purchases_payment_provider_check": {
+ "name": "kilo_pass_store_purchases_payment_provider_check",
+ "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_subscriptions": {
+ "name": "kilo_pass_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payment_provider": {
+ "name": "payment_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'stripe'"
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tier": {
+ "name": "tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cadence": {
+ "name": "cadence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_streak_months": {
+ "name": "current_streak_months",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_yearly_issue_at": {
+ "name": "next_yearly_issue_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kilo_pass_subscriptions_kilo_user_id": {
+ "name": "IDX_kilo_pass_subscriptions_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_payment_provider": {
+ "name": "IDX_kilo_pass_subscriptions_payment_provider",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_status": {
+ "name": "IDX_kilo_pass_subscriptions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilo_pass_subscriptions_cadence": {
+ "name": "IDX_kilo_pass_subscriptions_cadence",
+ "columns": [
+ {
+ "expression": "cadence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_subscriptions_provider_subscription": {
+ "name": "UQ_kilo_pass_subscriptions_provider_subscription",
+ "columns": [
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilo_pass_subscriptions_store_purchase_reference": {
+ "name": "UQ_kilo_pass_subscriptions_store_purchase_reference",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "payment_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kilo_pass_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilo_pass_subscriptions_stripe_subscription_id_unique": {
+ "name": "kilo_pass_subscriptions_stripe_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_subscriptions_current_streak_months_non_negative_check": {
+ "name": "kilo_pass_subscriptions_current_streak_months_non_negative_check",
+ "value": "\"kilo_pass_subscriptions\".\"current_streak_months\" >= 0"
+ },
+ "kilo_pass_subscriptions_provider_ids_check": {
+ "name": "kilo_pass_subscriptions_provider_ids_check",
+ "value": "(\n \"kilo_pass_subscriptions\".\"payment_provider\" = 'stripe'\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" = \"kilo_pass_subscriptions\".\"stripe_subscription_id\"\n ) OR (\n \"kilo_pass_subscriptions\".\"payment_provider\" IN ('app_store', 'google_play')\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NULL\n )"
+ },
+ "kilo_pass_subscriptions_payment_provider_check": {
+ "name": "kilo_pass_subscriptions_payment_provider_check",
+ "value": "\"kilo_pass_subscriptions\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
+ },
+ "kilo_pass_subscriptions_tier_check": {
+ "name": "kilo_pass_subscriptions_tier_check",
+ "value": "\"kilo_pass_subscriptions\".\"tier\" IN ('tier_19', 'tier_49', 'tier_199')"
+ },
+ "kilo_pass_subscriptions_cadence_check": {
+ "name": "kilo_pass_subscriptions_cadence_check",
+ "value": "\"kilo_pass_subscriptions\".\"cadence\" IN ('monthly', 'yearly')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kilo_pass_welcome_promo_payment_fingerprint_claims": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims",
+ "schema": "",
+ "columns": {
+ "stripe_payment_method_type": {
+ "name": "stripe_payment_method_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_fingerprint": {
+ "name": "stripe_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_stripe_invoice_id": {
+ "name": "source_stripe_invoice_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk",
+ "columns": [
+ "stripe_payment_method_type",
+ "stripe_fingerprint"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id": {
+ "name": "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_stripe_invoice_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check": {
+ "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check",
+ "value": "\"kilo_pass_welcome_promo_payment_fingerprint_claims\".\"stripe_payment_method_type\" IN ('card', 'sepa_debit', 'us_bank_account', 'bacs_debit', 'au_becs_debit')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_access_codes": {
+ "name": "kiloclaw_access_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redeemed_at": {
+ "name": "redeemed_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": {
+ "UQ_kiloclaw_access_codes_code": {
+ "name": "UQ_kiloclaw_access_codes_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_access_codes_user_status": {
+ "name": "IDX_kiloclaw_access_codes_user_status",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_access_codes_one_active_per_user": {
+ "name": "UQ_kiloclaw_access_codes_one_active_per_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "status = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_access_codes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_admin_audit_logs": {
+ "name": "kiloclaw_admin_audit_logs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_admin_audit_logs_target_user_id": {
+ "name": "IDX_kiloclaw_admin_audit_logs_target_user_id",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_admin_audit_logs_action": {
+ "name": "IDX_kiloclaw_admin_audit_logs_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_admin_audit_logs_created_at": {
+ "name": "IDX_kiloclaw_admin_audit_logs_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_cli_runs": {
+ "name": "kiloclaw_cli_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiated_by_admin_id": {
+ "name": "initiated_by_admin_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "exit_code": {
+ "name": "exit_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_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": {
+ "IDX_kiloclaw_cli_runs_user_id": {
+ "name": "IDX_kiloclaw_cli_runs_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_cli_runs_started_at": {
+ "name": "IDX_kiloclaw_cli_runs_started_at",
+ "columns": [
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_cli_runs_instance_id": {
+ "name": "IDX_kiloclaw_cli_runs_instance_id",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_cli_runs_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_cli_runs_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_cli_runs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "initiated_by_admin_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_earlybird_purchases": {
+ "name": "kiloclaw_earlybird_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manual_payment_id": {
+ "name": "manual_payment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_cents": {
+ "name": "amount_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_earlybird_purchases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_earlybird_purchases_user_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "kiloclaw_earlybird_purchases_stripe_charge_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_stripe_charge_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_charge_id"
+ ]
+ },
+ "kiloclaw_earlybird_purchases_manual_payment_id_unique": {
+ "name": "kiloclaw_earlybird_purchases_manual_payment_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "manual_payment_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_email_log": {
+ "name": "kiloclaw_email_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_type": {
+ "name": "email_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_start": {
+ "name": "period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'epoch'"
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_email_log_user_type_global": {
+ "name": "UQ_kiloclaw_email_log_user_type_global",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_email_log_user_instance_type_period": {
+ "name": "UQ_kiloclaw_email_log_user_instance_type_period",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_start",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_email_log_type_sent_instance": {
+ "name": "IDX_kiloclaw_email_log_type_sent_instance",
+ "columns": [
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sent_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_email_log_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_email_log_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_email_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_email_log",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_google_oauth_connections": {
+ "name": "kiloclaw_google_oauth_connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'google'"
+ },
+ "account_email": {
+ "name": "account_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_subject": {
+ "name": "account_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_secret_encrypted": {
+ "name": "oauth_client_secret_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_profile": {
+ "name": "credential_profile",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'kilo_owned'"
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "grants_by_source": {
+ "name": "grants_by_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "capabilities": {
+ "name": "capabilities",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_at": {
+ "name": "last_error_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_at": {
+ "name": "connected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_google_oauth_connections_instance": {
+ "name": "UQ_kiloclaw_google_oauth_connections_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_google_oauth_connections_status": {
+ "name": "IDX_kiloclaw_google_oauth_connections_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_google_oauth_connections_provider": {
+ "name": "IDX_kiloclaw_google_oauth_connections_provider",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_google_oauth_connections",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_google_oauth_connections_status_check": {
+ "name": "kiloclaw_google_oauth_connections_status_check",
+ "value": "\"kiloclaw_google_oauth_connections\".\"status\" IN ('active', 'action_required', 'disconnected')"
+ },
+ "kiloclaw_google_oauth_connections_credential_profile_check": {
+ "name": "kiloclaw_google_oauth_connections_credential_profile_check",
+ "value": "\"kiloclaw_google_oauth_connections\".\"credential_profile\" IN ('legacy', 'kilo_owned')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_image_catalog": {
+ "name": "kiloclaw_image_catalog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "openclaw_version": {
+ "name": "openclaw_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "variant": {
+ "name": "variant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "image_tag": {
+ "name": "image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image_digest": {
+ "name": "image_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'available'"
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "rollout_percent": {
+ "name": "rollout_percent",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "is_latest": {
+ "name": "is_latest",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_image_catalog_status": {
+ "name": "IDX_kiloclaw_image_catalog_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_image_catalog_variant": {
+ "name": "IDX_kiloclaw_image_catalog_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_image_catalog_one_latest_per_variant": {
+ "name": "UQ_kiloclaw_image_catalog_one_latest_per_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_image_catalog\".\"is_latest\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_image_catalog_one_candidate_per_variant": {
+ "name": "UQ_kiloclaw_image_catalog_one_candidate_per_variant",
+ "columns": [
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_image_catalog\".\"is_latest\" = false AND \"kiloclaw_image_catalog\".\"rollout_percent\" > 0 AND \"kiloclaw_image_catalog\".\"status\" = 'available'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_image_catalog_image_tag_unique": {
+ "name": "kiloclaw_image_catalog_image_tag_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "image_tag"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_inbound_email_aliases": {
+ "name": "kiloclaw_inbound_email_aliases",
+ "schema": "",
+ "columns": {
+ "alias": {
+ "name": "alias",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "retired_at": {
+ "name": "retired_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_inbound_email_aliases_instance_id": {
+ "name": "IDX_kiloclaw_inbound_email_aliases_instance_id",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_inbound_email_aliases_active_instance": {
+ "name": "UQ_kiloclaw_inbound_email_aliases_active_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_inbound_email_aliases\".\"retired_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_inbound_email_aliases",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_inbound_email_reserved_aliases": {
+ "name": "kiloclaw_inbound_email_reserved_aliases",
+ "schema": "",
+ "columns": {
+ "alias": {
+ "name": "alias",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_instances": {
+ "name": "kiloclaw_instances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'fly'"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inbound_email_enabled": {
+ "name": "inbound_email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "inactive_trial_stopped_at": {
+ "name": "inactive_trial_stopped_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()"
+ },
+ "destroyed_at": {
+ "name": "destroyed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tracked_image_tag": {
+ "name": "tracked_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_type": {
+ "name": "instance_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "admin_size_override": {
+ "name": "admin_size_override",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_instances_active": {
+ "name": "UQ_kiloclaw_instances_active",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sandbox_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_personal_by_user": {
+ "name": "IDX_kiloclaw_instances_active_personal_by_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_org_by_user_org": {
+ "name": "IDX_kiloclaw_instances_active_org_by_user_org",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_active_org_by_org_created": {
+ "name": "IDX_kiloclaw_instances_active_org_by_org_created",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_user_id_created_at": {
+ "name": "IDX_kiloclaw_instances_user_id_created_at",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_tracked_image_tag": {
+ "name": "IDX_kiloclaw_instances_tracked_image_tag",
+ "columns": [
+ {
+ "expression": "tracked_image_tag",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_instance_type": {
+ "name": "IDX_kiloclaw_instances_instance_type",
+ "columns": [
+ {
+ "expression": "instance_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_instances_admin_size_override": {
+ "name": "IDX_kiloclaw_instances_admin_size_override",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_instances\".\"admin_size_override\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_instances_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_instances_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_instances",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_instances_organization_id_organizations_id_fk": {
+ "name": "kiloclaw_instances_organization_id_organizations_id_fk",
+ "tableFrom": "kiloclaw_instances",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_kiloclaw_instances_instance_type": {
+ "name": "CHK_kiloclaw_instances_instance_type",
+ "value": "\"kiloclaw_instances\".\"instance_type\" IS NULL OR \"kiloclaw_instances\".\"instance_type\" IN ('perf-1-3', 'perf-4-8', 'perf-4-16', 'shared-2-3', 'shared-2-4', 'custom')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_morning_briefing_configs": {
+ "name": "kiloclaw_morning_briefing_configs",
+ "schema": "",
+ "columns": {
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0 7 * * *'"
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "interest_topics": {
+ "name": "interest_topics",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_morning_briefing_configs_enabled": {
+ "name": "IDX_kiloclaw_morning_briefing_configs_enabled",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_morning_briefing_configs\".\"enabled\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_morning_briefing_configs",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_notifications": {
+ "name": "kiloclaw_scheduled_action_notifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'notice'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel": {
+ "name": "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_notifications_pending": {
+ "name": "IDX_kiloclaw_scheduled_action_notifications_pending",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_notifications\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk": {
+ "name": "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_notifications",
+ "tableTo": "kiloclaw_scheduled_action_targets",
+ "columnsFrom": [
+ "target_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_stages": {
+ "name": "kiloclaw_scheduled_action_stages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_index": {
+ "name": "stage_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_at": {
+ "name": "scheduled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "notice_sent_at": {
+ "name": "notice_sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "applied_count": {
+ "name": "applied_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "skipped_count": {
+ "name": "skipped_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "failed_count": {
+ "name": "failed_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_stages_parent_index": {
+ "name": "UQ_kiloclaw_scheduled_action_stages_parent_index",
+ "columns": [
+ {
+ "expression": "scheduled_action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stage_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_stages_notice_due": {
+ "name": "IDX_kiloclaw_scheduled_action_stages_notice_due",
+ "columns": [
+ {
+ "expression": "scheduled_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_stages\".\"notice_sent_at\" IS NULL AND \"kiloclaw_scheduled_action_stages\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
+ "name": "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_stages",
+ "tableTo": "kiloclaw_scheduled_actions",
+ "columnsFrom": [
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_action_targets": {
+ "name": "kiloclaw_scheduled_action_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_image_tag": {
+ "name": "source_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_image_tag": {
+ "name": "target_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "applied_at": {
+ "name": "applied_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "skip_reason": {
+ "name": "skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_scheduled_action_targets_parent_instance": {
+ "name": "UQ_kiloclaw_scheduled_action_targets_parent_instance",
+ "columns": [
+ {
+ "expression": "scheduled_action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_targets_stage": {
+ "name": "IDX_kiloclaw_scheduled_action_targets_stage",
+ "columns": [
+ {
+ "expression": "stage_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_action_targets_pending_by_instance": {
+ "name": "IDX_kiloclaw_scheduled_action_targets_pending_by_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_scheduled_action_targets\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_scheduled_actions",
+ "columnsFrom": [
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_scheduled_action_stages",
+ "columnsFrom": [
+ "stage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_scheduled_action_targets",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_scheduled_actions": {
+ "name": "kiloclaw_scheduled_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_image_tag": {
+ "name": "target_image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "override_pins": {
+ "name": "override_pins",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "notice_lead_hours": {
+ "name": "notice_lead_hours",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 24
+ },
+ "notice_subject": {
+ "name": "notice_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "notice_body": {
+ "name": "notice_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'scheduled'"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled_at": {
+ "name": "cancelled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_count": {
+ "name": "total_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "applied_count": {
+ "name": "applied_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "skipped_count": {
+ "name": "skipped_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "failed_count": {
+ "name": "failed_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_scheduled_actions_status": {
+ "name": "IDX_kiloclaw_scheduled_actions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_actions_action_type": {
+ "name": "IDX_kiloclaw_scheduled_actions_action_type",
+ "columns": [
+ {
+ "expression": "action_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_scheduled_actions_created_by": {
+ "name": "IDX_kiloclaw_scheduled_actions_created_by",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk": {
+ "name": "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk",
+ "tableFrom": "kiloclaw_scheduled_actions",
+ "tableTo": "kiloclaw_image_catalog",
+ "columnsFrom": [
+ "target_image_tag"
+ ],
+ "columnsTo": [
+ "image_tag"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk": {
+ "name": "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_scheduled_actions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_subscription_change_log": {
+ "name": "kiloclaw_subscription_change_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "before_state": {
+ "name": "before_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "after_state": {
+ "name": "after_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_subscription_change_log_subscription_created_at": {
+ "name": "IDX_kiloclaw_subscription_change_log_subscription_created_at",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscription_change_log_created_at": {
+ "name": "IDX_kiloclaw_subscription_change_log_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_subscription_change_log",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_subscription_change_log_actor_type_check": {
+ "name": "kiloclaw_subscription_change_log_actor_type_check",
+ "value": "\"kiloclaw_subscription_change_log\".\"actor_type\" IN ('user', 'system')"
+ },
+ "kiloclaw_subscription_change_log_action_check": {
+ "name": "kiloclaw_subscription_change_log_action_check",
+ "value": "\"kiloclaw_subscription_change_log\".\"action\" IN ('created', 'status_changed', 'plan_switched', 'period_advanced', 'canceled', 'reactivated', 'suspended', 'destruction_scheduled', 'reassigned', 'backfilled', 'payment_source_changed', 'schedule_changed', 'admin_override')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_subscriptions": {
+ "name": "kiloclaw_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_subscription_id": {
+ "name": "stripe_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_schedule_id": {
+ "name": "stripe_schedule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transferred_to_subscription_id": {
+ "name": "transferred_to_subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_origin": {
+ "name": "access_origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payment_source": {
+ "name": "payment_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kiloclaw_price_version": {
+ "name": "kiloclaw_price_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_plan": {
+ "name": "scheduled_plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scheduled_by": {
+ "name": "scheduled_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "pending_conversion": {
+ "name": "pending_conversion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "trial_started_at": {
+ "name": "trial_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_start": {
+ "name": "current_period_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credit_renewal_at": {
+ "name": "credit_renewal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "commit_ends_at": {
+ "name": "commit_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "past_due_since": {
+ "name": "past_due_since",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_at": {
+ "name": "suspended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "destruction_deadline": {
+ "name": "destruction_deadline",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_requested_at": {
+ "name": "auto_resume_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_retry_after": {
+ "name": "auto_resume_retry_after",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_resume_attempt_count": {
+ "name": "auto_resume_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "auto_top_up_triggered_for_period": {
+ "name": "auto_top_up_triggered_for_period",
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_kiloclaw_subscriptions_status": {
+ "name": "IDX_kiloclaw_subscriptions_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_user_id": {
+ "name": "IDX_kiloclaw_subscriptions_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_user_status": {
+ "name": "IDX_kiloclaw_subscriptions_user_status",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_price_version": {
+ "name": "IDX_kiloclaw_subscriptions_price_version",
+ "columns": [
+ {
+ "expression": "kiloclaw_price_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_transferred_to": {
+ "name": "IDX_kiloclaw_subscriptions_transferred_to",
+ "columns": [
+ {
+ "expression": "transferred_to_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_stripe_schedule_id": {
+ "name": "IDX_kiloclaw_subscriptions_stripe_schedule_id",
+ "columns": [
+ {
+ "expression": "stripe_schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_auto_resume_retry_after": {
+ "name": "IDX_kiloclaw_subscriptions_auto_resume_retry_after",
+ "columns": [
+ {
+ "expression": "auto_resume_retry_after",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_subscriptions_instance": {
+ "name": "UQ_kiloclaw_subscriptions_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_subscriptions\".\"instance_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kiloclaw_subscriptions_transferred_to": {
+ "name": "UQ_kiloclaw_subscriptions_transferred_to",
+ "columns": [
+ {
+ "expression": "transferred_to_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kiloclaw_subscriptions\".\"transferred_to_subscription_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_subscriptions_earlybird_origin": {
+ "name": "IDX_kiloclaw_subscriptions_earlybird_origin",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "access_origin",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_subscriptions\".\"access_origin\" = 'earlybird'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_subscriptions_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_subscriptions_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "transferred_to_subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_subscriptions",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_subscriptions_stripe_subscription_id_unique": {
+ "name": "kiloclaw_subscriptions_stripe_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_subscriptions_price_version_check": {
+ "name": "kiloclaw_subscriptions_price_version_check",
+ "value": "\"kiloclaw_subscriptions\".\"kiloclaw_price_version\" IN ('2026-03-19', '2026-05-10')"
+ },
+ "kiloclaw_subscriptions_plan_check": {
+ "name": "kiloclaw_subscriptions_plan_check",
+ "value": "\"kiloclaw_subscriptions\".\"plan\" IN ('trial', 'commit', 'standard')"
+ },
+ "kiloclaw_subscriptions_scheduled_plan_check": {
+ "name": "kiloclaw_subscriptions_scheduled_plan_check",
+ "value": "\"kiloclaw_subscriptions\".\"scheduled_plan\" IN ('commit', 'standard')"
+ },
+ "kiloclaw_subscriptions_scheduled_by_check": {
+ "name": "kiloclaw_subscriptions_scheduled_by_check",
+ "value": "\"kiloclaw_subscriptions\".\"scheduled_by\" IN ('auto', 'user')"
+ },
+ "kiloclaw_subscriptions_status_check": {
+ "name": "kiloclaw_subscriptions_status_check",
+ "value": "\"kiloclaw_subscriptions\".\"status\" IN ('trialing', 'active', 'past_due', 'canceled', 'unpaid')"
+ },
+ "kiloclaw_subscriptions_access_origin_check": {
+ "name": "kiloclaw_subscriptions_access_origin_check",
+ "value": "\"kiloclaw_subscriptions\".\"access_origin\" IN ('earlybird')"
+ },
+ "kiloclaw_subscriptions_payment_source_check": {
+ "name": "kiloclaw_subscriptions_payment_source_check",
+ "value": "\"kiloclaw_subscriptions\".\"payment_source\" IN ('stripe', 'credits')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_terminal_renewal_failures": {
+ "name": "kiloclaw_terminal_renewal_failures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "renewal_boundary": {
+ "name": "renewal_boundary",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unresolved'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "first_failure_at": {
+ "name": "first_failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_at": {
+ "name": "last_failure_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_code": {
+ "name": "last_failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_failure_message": {
+ "name": "last_failure_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_actor_type": {
+ "name": "resolution_actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_actor_id": {
+ "name": "resolution_actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_at": {
+ "name": "resolution_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution_reason": {
+ "name": "resolution_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary": {
+ "name": "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "renewal_boundary",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_terminal_renewal_failures_unresolved": {
+ "name": "IDX_kiloclaw_terminal_renewal_failures_unresolved",
+ "columns": [
+ {
+ "expression": "subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "renewal_boundary",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"kiloclaw_terminal_renewal_failures\".\"status\" = 'unresolved'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at": {
+ "name": "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "last_failure_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk": {
+ "name": "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk",
+ "tableFrom": "kiloclaw_terminal_renewal_failures",
+ "tableTo": "kiloclaw_subscriptions",
+ "columnsFrom": [
+ "subscription_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_terminal_renewal_failures_status_check": {
+ "name": "kiloclaw_terminal_renewal_failures_status_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"status\" IN ('unresolved', 'resolved', 'waived', 'superseded')"
+ },
+ "kiloclaw_terminal_renewal_failures_last_failure_code_check": {
+ "name": "kiloclaw_terminal_renewal_failures_last_failure_code_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"last_failure_code\" IN ('credit_balance_read_failed', 'renewal_transaction_failed', 'auto_top_up_marker_write_failed', 'worker_timeout', 'poison_payload', 'queue_delivery_exhausted')"
+ },
+ "kiloclaw_terminal_renewal_failures_resolution_actor_type_check": {
+ "name": "kiloclaw_terminal_renewal_failures_resolution_actor_type_check",
+ "value": "\"kiloclaw_terminal_renewal_failures\".\"resolution_actor_type\" IN ('operator', 'system')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_version_pins": {
+ "name": "kiloclaw_version_pins",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image_tag": {
+ "name": "image_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pinned_by": {
+ "name": "pinned_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk": {
+ "name": "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kiloclaw_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk": {
+ "name": "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kiloclaw_image_catalog",
+ "columnsFrom": [
+ "image_tag"
+ ],
+ "columnsTo": [
+ "image_tag"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk": {
+ "name": "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_version_pins",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "pinned_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kiloclaw_version_pins_instance_id_unique": {
+ "name": "kiloclaw_version_pins_instance_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "instance_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kilocode_users": {
+ "name": "kilocode_users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "google_user_email": {
+ "name": "google_user_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "google_user_name": {
+ "name": "google_user_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "google_user_image_url": {
+ "name": "google_user_image_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hosted_domain": {
+ "name": "hosted_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "microdollars_used": {
+ "name": "microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "kilo_pass_threshold": {
+ "name": "kilo_pass_threshold",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "app_store_account_token": {
+ "name": "app_store_account_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_manage_credits": {
+ "name": "can_manage_credits",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "total_microdollars_acquired": {
+ "name": "total_microdollars_acquired",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "next_credit_expiration_at": {
+ "name": "next_credit_expiration_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_validation_stytch": {
+ "name": "has_validation_stytch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_validation_novel_card_with_hold": {
+ "name": "has_validation_novel_card_with_hold",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_at": {
+ "name": "blocked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_by_kilo_user_id": {
+ "name": "blocked_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_token_pepper": {
+ "name": "api_token_pepper",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "web_session_pepper": {
+ "name": "web_session_pepper",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_enabled": {
+ "name": "auto_top_up_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_bot": {
+ "name": "is_bot",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "kiloclaw_early_access": {
+ "name": "kiloclaw_early_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_model": {
+ "name": "default_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cohorts": {
+ "name": "cohorts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "completed_welcome_form": {
+ "name": "completed_welcome_form",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "linkedin_url": {
+ "name": "linkedin_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_url": {
+ "name": "github_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discord_server_membership_verified_at": {
+ "name": "discord_server_membership_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_upstream_safety_identifier": {
+ "name": "openrouter_upstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_downstream_safety_identifier": {
+ "name": "openrouter_downstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_downstream_safety_identifier": {
+ "name": "vercel_downstream_safety_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "customer_source": {
+ "name": "customer_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signup_ip": {
+ "name": "signup_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_deletion_requested_at": {
+ "name": "account_deletion_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "normalized_email": {
+ "name": "normalized_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_domain": {
+ "name": "email_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_kilocode_users_signup_ip_created_at": {
+ "name": "IDX_kilocode_users_signup_ip_created_at",
+ "columns": [
+ {
+ "expression": "signup_ip",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_blocked_at": {
+ "name": "IDX_kilocode_users_blocked_at",
+ "columns": [
+ {
+ "expression": "blocked_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_blocked_by_kilo_user_id": {
+ "name": "IDX_kilocode_users_blocked_by_kilo_user_id",
+ "columns": [
+ {
+ "expression": "blocked_by_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_openrouter_upstream_safety_identifier": {
+ "name": "UQ_kilocode_users_openrouter_upstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "openrouter_upstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"openrouter_upstream_safety_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_openrouter_downstream_safety_identifier": {
+ "name": "UQ_kilocode_users_openrouter_downstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "openrouter_downstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"openrouter_downstream_safety_identifier\" IS NOT NULL",
+ "concurrently": true,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_kilocode_users_vercel_downstream_safety_identifier": {
+ "name": "UQ_kilocode_users_vercel_downstream_safety_identifier",
+ "columns": [
+ {
+ "expression": "vercel_downstream_safety_identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"kilocode_users\".\"vercel_downstream_safety_identifier\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_normalized_email": {
+ "name": "IDX_kilocode_users_normalized_email",
+ "columns": [
+ {
+ "expression": "normalized_email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kilocode_users_email_domain": {
+ "name": "IDX_kilocode_users_email_domain",
+ "columns": [
+ {
+ "expression": "email_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "kilocode_users_app_store_account_token_unique": {
+ "name": "kilocode_users_app_store_account_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "app_store_account_token"
+ ]
+ },
+ "UQ_b1afacbcf43f2c7c4cb9f7e7faa": {
+ "name": "UQ_b1afacbcf43f2c7c4cb9f7e7faa",
+ "nullsNotDistinct": false,
+ "columns": [
+ "google_user_email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "blocked_reason_not_empty": {
+ "name": "blocked_reason_not_empty",
+ "value": "length(blocked_reason) > 0"
+ },
+ "kilocode_users_can_manage_credits_requires_admin_check": {
+ "name": "kilocode_users_can_manage_credits_requires_admin_check",
+ "value": "NOT \"kilocode_users\".\"can_manage_credits\" OR \"kilocode_users\".\"is_admin\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.magic_link_tokens": {
+ "name": "magic_link_tokens",
+ "schema": "",
+ "columns": {
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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": {
+ "idx_magic_link_tokens_email": {
+ "name": "idx_magic_link_tokens_email",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_magic_link_tokens_expires_at": {
+ "name": "idx_magic_link_tokens_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "check_expires_at_future": {
+ "name": "check_expires_at_future",
+ "value": "\"magic_link_tokens\".\"expires_at\" > \"magic_link_tokens\".\"created_at\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_assignments": {
+ "name": "mcp_gateway_assignments",
+ "schema": "",
+ "columns": {
+ "assignment_id": {
+ "name": "assignment_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "assigned_by_kilo_user_id": {
+ "name": "assigned_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "single_user_slot": {
+ "name": "single_user_slot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_assignments_active": {
+ "name": "UQ_mcp_gateway_assignments_active",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_assignments_single_user_slot": {
+ "name": "UQ_mcp_gateway_assignments_single_user_slot",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "single_user_slot",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null and \"mcp_gateway_assignments\".\"single_user_slot\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_assignments_config": {
+ "name": "IDX_mcp_gateway_assignments_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_assignments_user": {
+ "name": "IDX_mcp_gateway_assignments_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_assignments",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "assigned_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_audit_events": {
+ "name": "mcp_gateway_audit_events",
+ "schema": "",
+ "columns": {
+ "audit_event_id": {
+ "name": "audit_event_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "actor_kilo_user_id": {
+ "name": "actor_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connect_resource_id": {
+ "name": "connect_resource_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_metadata": {
+ "name": "correlation_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_mcp_gateway_audit_events_config": {
+ "name": "IDX_mcp_gateway_audit_events_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_audit_events_owner": {
+ "name": "IDX_mcp_gateway_audit_events_owner",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_audit_events_created_at": {
+ "name": "IDX_mcp_gateway_audit_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "actor_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk": {
+ "name": "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_connect_resources",
+ "columnsFrom": [
+ "connect_resource_id"
+ ],
+ "columnsTo": [
+ "connect_resource_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_audit_events",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_audit_events_owner_scope": {
+ "name": "mcp_gateway_audit_events_owner_scope",
+ "value": "\"mcp_gateway_audit_events\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_audit_events_outcome": {
+ "name": "mcp_gateway_audit_events_outcome",
+ "value": "\"mcp_gateway_audit_events\".\"outcome\" IN ('success', 'failure', 'blocked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_authorization_codes": {
+ "name": "mcp_gateway_authorization_codes",
+ "schema": "",
+ "columns": {
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uri": {
+ "name": "redirect_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_challenge": {
+ "name": "code_challenge",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge_method": {
+ "name": "code_challenge_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'S256'"
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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": {
+ "UQ_mcp_gateway_authorization_codes_code_hash": {
+ "name": "UQ_mcp_gateway_authorization_codes_code_hash",
+ "columns": [
+ {
+ "expression": "code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_codes_expires_at": {
+ "name": "IDX_mcp_gateway_authorization_codes_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_codes_client": {
+ "name": "IDX_mcp_gateway_authorization_codes_client",
+ "columns": [
+ {
+ "expression": "oauth_client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
+ "name": "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_authorization_requests",
+ "columnsFrom": [
+ "authorization_request_id"
+ ],
+ "columnsTo": [
+ "authorization_request_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_authorization_codes",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_authorization_codes_owner_scope": {
+ "name": "mcp_gateway_authorization_codes_owner_scope",
+ "value": "\"mcp_gateway_authorization_codes\".\"owner_scope\" IN ('personal', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_authorization_requests": {
+ "name": "mcp_gateway_authorization_requests",
+ "schema": "",
+ "columns": {
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "request_state_hash": {
+ "name": "request_state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uri": {
+ "name": "redirect_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_scopes": {
+ "name": "requested_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oauth_state": {
+ "name": "oauth_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge": {
+ "name": "code_challenge",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code_challenge_method": {
+ "name": "code_challenge_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'S256'"
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_status": {
+ "name": "request_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_authorization_requests_state_hash": {
+ "name": "UQ_mcp_gateway_authorization_requests_state_hash",
+ "columns": [
+ {
+ "expression": "request_state_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_config": {
+ "name": "IDX_mcp_gateway_authorization_requests_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_user": {
+ "name": "IDX_mcp_gateway_authorization_requests_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_authorization_requests_expires_at": {
+ "name": "IDX_mcp_gateway_authorization_requests_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_authorization_requests",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_authorization_requests_owner_scope": {
+ "name": "mcp_gateway_authorization_requests_owner_scope",
+ "value": "\"mcp_gateway_authorization_requests\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_authorization_requests_status": {
+ "name": "mcp_gateway_authorization_requests_status",
+ "value": "\"mcp_gateway_authorization_requests\".\"request_status\" IN ('pending', 'completed', 'error')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_config_secrets": {
+ "name": "mcp_gateway_config_secrets",
+ "schema": "",
+ "columns": {
+ "config_secret_id": {
+ "name": "config_secret_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret_kind": {
+ "name": "secret_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_secret": {
+ "name": "encrypted_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret_version": {
+ "name": "secret_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_config_secrets_active_kind": {
+ "name": "UQ_mcp_gateway_config_secrets_active_kind",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "secret_kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_config_secrets\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_config_secrets_config": {
+ "name": "IDX_mcp_gateway_config_secrets_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_config_secrets",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_config_secrets_version_positive": {
+ "name": "mcp_gateway_config_secrets_version_positive",
+ "value": "\"mcp_gateway_config_secrets\".\"secret_version\" > 0"
+ },
+ "mcp_gateway_config_secrets_kind": {
+ "name": "mcp_gateway_config_secrets_kind",
+ "value": "\"mcp_gateway_config_secrets\".\"secret_kind\" IN ('static_provider_credentials', 'dynamic_registration', 'static_headers')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_configs": {
+ "name": "mcp_gateway_configs",
+ "schema": "",
+ "columns": {
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_url": {
+ "name": "remote_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_mode": {
+ "name": "auth_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sharing_mode": {
+ "name": "sharing_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_scopes": {
+ "name": "provider_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_scope_source": {
+ "name": "provider_scope_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'none'"
+ },
+ "provider_resource": {
+ "name": "provider_resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "path_passthrough": {
+ "name": "path_passthrough",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "config_version": {
+ "name": "config_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "discovered_provider_metadata": {
+ "name": "discovered_provider_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registry_metadata": {
+ "name": "registry_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "auxiliary_headers": {
+ "name": "auxiliary_headers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_mcp_gateway_configs_owner": {
+ "name": "IDX_mcp_gateway_configs_owner",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_configs_enabled": {
+ "name": "IDX_mcp_gateway_configs_enabled",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_configs_remote_url": {
+ "name": "IDX_mcp_gateway_configs_remote_url",
+ "columns": [
+ {
+ "expression": "remote_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_configs",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_configs_name_not_empty": {
+ "name": "mcp_gateway_configs_name_not_empty",
+ "value": "length(trim(\"mcp_gateway_configs\".\"name\")) > 0"
+ },
+ "mcp_gateway_configs_config_version_positive": {
+ "name": "mcp_gateway_configs_config_version_positive",
+ "value": "\"mcp_gateway_configs\".\"config_version\" > 0"
+ },
+ "mcp_gateway_configs_personal_single_user": {
+ "name": "mcp_gateway_configs_personal_single_user",
+ "value": "\"mcp_gateway_configs\".\"owner_scope\" <> 'personal' OR \"mcp_gateway_configs\".\"sharing_mode\" = 'single_user'"
+ },
+ "mcp_gateway_configs_owner_scope": {
+ "name": "mcp_gateway_configs_owner_scope",
+ "value": "\"mcp_gateway_configs\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_configs_auth_mode": {
+ "name": "mcp_gateway_configs_auth_mode",
+ "value": "\"mcp_gateway_configs\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
+ },
+ "mcp_gateway_configs_sharing_mode": {
+ "name": "mcp_gateway_configs_sharing_mode",
+ "value": "\"mcp_gateway_configs\".\"sharing_mode\" IN ('single_user', 'multi_user')"
+ },
+ "mcp_gateway_configs_provider_scope_source": {
+ "name": "mcp_gateway_configs_provider_scope_source",
+ "value": "\"mcp_gateway_configs\".\"provider_scope_source\" IN ('none', 'discovered', 'override')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_connect_resources": {
+ "name": "mcp_gateway_connect_resources",
+ "schema": "",
+ "columns": {
+ "connect_resource_id": {
+ "name": "connect_resource_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_url": {
+ "name": "canonical_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_status": {
+ "name": "route_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "route_version": {
+ "name": "route_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "rotated_at": {
+ "name": "rotated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_connect_resources_route_key": {
+ "name": "UQ_mcp_gateway_connect_resources_route_key",
+ "columns": [
+ {
+ "expression": "route_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_connect_resources_active_config": {
+ "name": "UQ_mcp_gateway_connect_resources_active_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_connect_resources\".\"route_status\" = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connect_resources_config": {
+ "name": "IDX_mcp_gateway_connect_resources_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connect_resources_canonical_url": {
+ "name": "IDX_mcp_gateway_connect_resources_canonical_url",
+ "columns": [
+ {
+ "expression": "canonical_url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_connect_resources",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_connect_resources_route_key_format": {
+ "name": "mcp_gateway_connect_resources_route_key_format",
+ "value": "\"mcp_gateway_connect_resources\".\"route_key\" ~ '^[A-Za-z0-9_-]{32,}$'"
+ },
+ "mcp_gateway_connect_resources_route_version_positive": {
+ "name": "mcp_gateway_connect_resources_route_version_positive",
+ "value": "\"mcp_gateway_connect_resources\".\"route_version\" > 0"
+ },
+ "mcp_gateway_connect_resources_owner_scope": {
+ "name": "mcp_gateway_connect_resources_owner_scope",
+ "value": "\"mcp_gateway_connect_resources\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_connect_resources_route_status": {
+ "name": "mcp_gateway_connect_resources_route_status",
+ "value": "\"mcp_gateway_connect_resources\".\"route_status\" IN ('active', 'rotated', 'revoked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_connection_instances": {
+ "name": "mcp_gateway_connection_instances",
+ "schema": "",
+ "columns": {
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_status": {
+ "name": "instance_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "instance_version": {
+ "name": "instance_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "removed_at": {
+ "name": "removed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_connection_instances_non_terminal": {
+ "name": "UQ_mcp_gateway_connection_instances_non_terminal",
+ "columns": [
+ {
+ "expression": "owner_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connection_instances_config": {
+ "name": "IDX_mcp_gateway_connection_instances_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_connection_instances_user": {
+ "name": "IDX_mcp_gateway_connection_instances_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_connection_instances",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_connection_instances",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_connection_instances_version_positive": {
+ "name": "mcp_gateway_connection_instances_version_positive",
+ "value": "\"mcp_gateway_connection_instances\".\"instance_version\" > 0"
+ },
+ "mcp_gateway_connection_instances_owner_scope": {
+ "name": "mcp_gateway_connection_instances_owner_scope",
+ "value": "\"mcp_gateway_connection_instances\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_connection_instances_status": {
+ "name": "mcp_gateway_connection_instances_status",
+ "value": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth', 'revoked', 'removed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_oauth_clients": {
+ "name": "mcp_gateway_oauth_clients",
+ "schema": "",
+ "columns": {
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_name": {
+ "name": "client_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_token_hash": {
+ "name": "registration_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret_hash": {
+ "name": "client_secret_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_types": {
+ "name": "grant_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "declared_scopes": {
+ "name": "declared_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "registration_access_token_expires_at": {
+ "name": "registration_access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_oauth_clients_client_id": {
+ "name": "UQ_mcp_gateway_oauth_clients_client_id",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_mcp_gateway_oauth_clients_registration_token_hash": {
+ "name": "UQ_mcp_gateway_oauth_clients_registration_token_hash",
+ "columns": [
+ {
+ "expression": "registration_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_oauth_clients_deleted_at": {
+ "name": "IDX_mcp_gateway_oauth_clients_deleted_at",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_oauth_clients_client_id_format": {
+ "name": "mcp_gateway_oauth_clients_client_id_format",
+ "value": "\"mcp_gateway_oauth_clients\".\"client_id\" ~ '^[A-Za-z0-9._-]+:[A-Za-z0-9._-]+$'"
+ },
+ "mcp_gateway_oauth_clients_auth_method": {
+ "name": "mcp_gateway_oauth_clients_auth_method",
+ "value": "\"mcp_gateway_oauth_clients\".\"token_endpoint_auth_method\" IN ('none', 'client_secret_post', 'client_secret_basic')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_pending_provider_authorizations": {
+ "name": "mcp_gateway_pending_provider_authorizations",
+ "schema": "",
+ "columns": {
+ "pending_provider_authorization_id": {
+ "name": "pending_provider_authorization_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "state_hash": {
+ "name": "state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorization_request_id": {
+ "name": "authorization_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_url": {
+ "name": "remote_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_mode": {
+ "name": "auth_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_authorization_endpoint": {
+ "name": "provider_authorization_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_token_endpoint": {
+ "name": "provider_token_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_state": {
+ "name": "encrypted_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_version": {
+ "name": "config_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pending_status": {
+ "name": "pending_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_pending_provider_authorizations_state_hash": {
+ "name": "UQ_mcp_gateway_pending_provider_authorizations_state_hash",
+ "columns": [
+ {
+ "expression": "state_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_pending_provider_authorizations_config": {
+ "name": "IDX_mcp_gateway_pending_provider_authorizations_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_pending_provider_authorizations_expires_at": {
+ "name": "IDX_mcp_gateway_pending_provider_authorizations_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_authorization_requests",
+ "columnsFrom": [
+ "authorization_request_id"
+ ],
+ "columnsTo": [
+ "authorization_request_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_pending_provider_authorizations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_pending_provider_authorizations_config_version_positive": {
+ "name": "mcp_gateway_pending_provider_authorizations_config_version_positive",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"config_version\" > 0"
+ },
+ "mcp_gateway_pending_provider_authorizations_owner_scope": {
+ "name": "mcp_gateway_pending_provider_authorizations_owner_scope",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"owner_scope\" IN ('personal', 'organization')"
+ },
+ "mcp_gateway_pending_provider_authorizations_auth_mode": {
+ "name": "mcp_gateway_pending_provider_authorizations_auth_mode",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
+ },
+ "mcp_gateway_pending_provider_authorizations_status": {
+ "name": "mcp_gateway_pending_provider_authorizations_status",
+ "value": "\"mcp_gateway_pending_provider_authorizations\".\"pending_status\" IN ('pending', 'completed', 'error')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_provider_grants": {
+ "name": "mcp_gateway_provider_grants",
+ "schema": "",
+ "columns": {
+ "provider_grant_id": {
+ "name": "provider_grant_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_grant": {
+ "name": "encrypted_grant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject": {
+ "name": "provider_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_scope": {
+ "name": "grant_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_status": {
+ "name": "grant_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "grant_version": {
+ "name": "grant_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_provider_grants_active_instance": {
+ "name": "UQ_mcp_gateway_provider_grants_active_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"mcp_gateway_provider_grants\".\"grant_status\" = 'active'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_provider_grants_instance": {
+ "name": "IDX_mcp_gateway_provider_grants_instance",
+ "columns": [
+ {
+ "expression": "instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_provider_grants",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_provider_grants_version_positive": {
+ "name": "mcp_gateway_provider_grants_version_positive",
+ "value": "\"mcp_gateway_provider_grants\".\"grant_version\" > 0"
+ },
+ "mcp_gateway_provider_grants_status": {
+ "name": "mcp_gateway_provider_grants_status",
+ "value": "\"mcp_gateway_provider_grants\".\"grant_status\" IN ('active', 'revoked')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_rate_limit_windows": {
+ "name": "mcp_gateway_rate_limit_windows",
+ "schema": "",
+ "columns": {
+ "rate_limit_window_id": {
+ "name": "rate_limit_window_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_started_at": {
+ "name": "window_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_count": {
+ "name": "attempt_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_mcp_gateway_rate_limit_windows_ip_window": {
+ "name": "UQ_mcp_gateway_rate_limit_windows_ip_window",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "window_started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_rate_limit_windows_window": {
+ "name": "IDX_mcp_gateway_rate_limit_windows_window",
+ "columns": [
+ {
+ "expression": "window_started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_rate_limit_windows_attempt_count_non_negative": {
+ "name": "mcp_gateway_rate_limit_windows_attempt_count_non_negative",
+ "value": "\"mcp_gateway_rate_limit_windows\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_gateway_refresh_tokens": {
+ "name": "mcp_gateway_refresh_tokens",
+ "schema": "",
+ "columns": {
+ "refresh_token_id": {
+ "name": "refresh_token_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rotated_from_refresh_token_id": {
+ "name": "rotated_from_refresh_token_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_client_id": {
+ "name": "oauth_client_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_scope": {
+ "name": "owner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canonical_resource_url": {
+ "name": "canonical_resource_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_scopes": {
+ "name": "granted_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "execution_context": {
+ "name": "execution_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_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": {
+ "UQ_mcp_gateway_refresh_tokens_token_hash": {
+ "name": "UQ_mcp_gateway_refresh_tokens_token_hash",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_user": {
+ "name": "IDX_mcp_gateway_refresh_tokens_user",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_config": {
+ "name": "IDX_mcp_gateway_refresh_tokens_config",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_mcp_gateway_refresh_tokens_consumed_at": {
+ "name": "IDX_mcp_gateway_refresh_tokens_consumed_at",
+ "columns": [
+ {
+ "expression": "consumed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_oauth_clients",
+ "columnsFrom": [
+ "oauth_client_id"
+ ],
+ "columnsTo": [
+ "oauth_client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "config_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
+ "name": "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk",
+ "tableFrom": "mcp_gateway_refresh_tokens",
+ "tableTo": "mcp_gateway_connection_instances",
+ "columnsFrom": [
+ "instance_id"
+ ],
+ "columnsTo": [
+ "instance_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_gateway_refresh_tokens_owner_scope": {
+ "name": "mcp_gateway_refresh_tokens_owner_scope",
+ "value": "\"mcp_gateway_refresh_tokens\".\"owner_scope\" IN ('personal', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage": {
+ "name": "microdollar_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_write_tokens": {
+ "name": "cache_write_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_hit_tokens": {
+ "name": "cache_hit_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_model": {
+ "name": "requested_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_discount": {
+ "name": "cache_discount",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_error": {
+ "name": "has_error",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "abuse_classification": {
+ "name": "abuse_classification",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_provider": {
+ "name": "inference_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_created_at": {
+ "name": "idx_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_abuse_classification": {
+ "name": "idx_abuse_classification",
+ "columns": [
+ {
+ "expression": "abuse_classification",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_kilo_user_id_created_at2": {
+ "name": "idx_kilo_user_id_created_at2",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_organization_id": {
+ "name": "idx_microdollar_usage_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"microdollar_usage\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage_daily": {
+ "name": "microdollar_usage_daily",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "usage_date": {
+ "name": "usage_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_microdollar_usage_daily_personal": {
+ "name": "idx_microdollar_usage_daily_personal",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"microdollar_usage_daily\".\"organization_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_daily_org": {
+ "name": "idx_microdollar_usage_daily_org",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"microdollar_usage_daily\".\"organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.microdollar_usage_metadata": {
+ "name": "microdollar_usage_metadata",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "http_user_agent_id": {
+ "name": "http_user_agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_ip_id": {
+ "name": "http_ip_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_city_id": {
+ "name": "vercel_ip_city_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_country_id": {
+ "name": "vercel_ip_country_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_latitude": {
+ "name": "vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel_ip_longitude": {
+ "name": "vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ja4_digest_id": {
+ "name": "ja4_digest_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_prompt_prefix": {
+ "name": "user_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_prefix_id": {
+ "name": "system_prompt_prefix_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_length": {
+ "name": "system_prompt_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_tokens": {
+ "name": "max_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_middle_out_transform": {
+ "name": "has_middle_out_transform",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "upstream_id": {
+ "name": "upstream_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finish_reason_id": {
+ "name": "finish_reason_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency": {
+ "name": "latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderation_latency": {
+ "name": "moderation_latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_time": {
+ "name": "generation_time",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_byok": {
+ "name": "is_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_user_byok": {
+ "name": "is_user_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "streamed": {
+ "name": "streamed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled": {
+ "name": "cancelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_name_id": {
+ "name": "editor_name_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_kind_id": {
+ "name": "api_kind_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_tools": {
+ "name": "has_tools",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "machine_id": {
+ "name": "machine_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature_id": {
+ "name": "feature_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode_id": {
+ "name": "mode_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_model_id": {
+ "name": "auto_model_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_cost": {
+ "name": "market_cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_delay": {
+ "name": "abuse_delay",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_downgraded_from": {
+ "name": "abuse_downgraded_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_microdollar_usage_metadata_created_at": {
+ "name": "idx_microdollar_usage_metadata_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_microdollar_usage_metadata_session_id": {
+ "name": "idx_microdollar_usage_metadata_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"microdollar_usage_metadata\".\"session_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk": {
+ "name": "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "http_user_agent",
+ "columnsFrom": [
+ "http_user_agent_id"
+ ],
+ "columnsTo": [
+ "http_user_agent_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk": {
+ "name": "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "http_ip",
+ "columnsFrom": [
+ "http_ip_id"
+ ],
+ "columnsTo": [
+ "http_ip_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk": {
+ "name": "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "vercel_ip_city",
+ "columnsFrom": [
+ "vercel_ip_city_id"
+ ],
+ "columnsTo": [
+ "vercel_ip_city_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk": {
+ "name": "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "vercel_ip_country",
+ "columnsFrom": [
+ "vercel_ip_country_id"
+ ],
+ "columnsTo": [
+ "vercel_ip_country_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk": {
+ "name": "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "ja4_digest",
+ "columnsFrom": [
+ "ja4_digest_id"
+ ],
+ "columnsTo": [
+ "ja4_digest_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk": {
+ "name": "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk",
+ "tableFrom": "microdollar_usage_metadata",
+ "tableTo": "system_prompt_prefix",
+ "columnsFrom": [
+ "system_prompt_prefix_id"
+ ],
+ "columnsTo": [
+ "system_prompt_prefix_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mode": {
+ "name": "mode",
+ "schema": "",
+ "columns": {
+ "mode_id": {
+ "name": "mode_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_mode": {
+ "name": "UQ_mode",
+ "columns": [
+ {
+ "expression": "mode",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_stats": {
+ "name": "model_stats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "is_featured": {
+ "name": "is_featured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_stealth": {
+ "name": "is_stealth",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_recommended": {
+ "name": "is_recommended",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "openrouter_id": {
+ "name": "openrouter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aa_slug": {
+ "name": "aa_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_creator": {
+ "name": "model_creator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creator_slug": {
+ "name": "creator_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release_date": {
+ "name": "release_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_input": {
+ "name": "price_input",
+ "type": "numeric(10, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_output": {
+ "name": "price_output",
+ "type": "numeric(10, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coding_index": {
+ "name": "coding_index",
+ "type": "numeric(5, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "speed_tokens_per_sec": {
+ "name": "speed_tokens_per_sec",
+ "type": "numeric(8, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context_length": {
+ "name": "context_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_output_tokens": {
+ "name": "max_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_modalities": {
+ "name": "input_modalities",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openrouter_data": {
+ "name": "openrouter_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "benchmarks": {
+ "name": "benchmarks",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chart_data": {
+ "name": "chart_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_stats_openrouter_id": {
+ "name": "IDX_model_stats_openrouter_id",
+ "columns": [
+ {
+ "expression": "openrouter_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_slug": {
+ "name": "IDX_model_stats_slug",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_is_active": {
+ "name": "IDX_model_stats_is_active",
+ "columns": [
+ {
+ "expression": "is_active",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_creator_slug": {
+ "name": "IDX_model_stats_creator_slug",
+ "columns": [
+ {
+ "expression": "creator_slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_price_input": {
+ "name": "IDX_model_stats_price_input",
+ "columns": [
+ {
+ "expression": "price_input",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_coding_index": {
+ "name": "IDX_model_stats_coding_index",
+ "columns": [
+ {
+ "expression": "coding_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_stats_context_length": {
+ "name": "IDX_model_stats_context_length",
+ "columns": [
+ {
+ "expression": "context_length",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_stats_openrouter_id_unique": {
+ "name": "model_stats_openrouter_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "openrouter_id"
+ ]
+ },
+ "model_stats_slug_unique": {
+ "name": "model_stats_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_eval_ingestions": {
+ "name": "model_eval_ingestions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "bench_eval_name": {
+ "name": "bench_eval_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bench_eval_url": {
+ "name": "bench_eval_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_stats_id": {
+ "name": "model_stats_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "variant": {
+ "name": "variant",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_total_trials": {
+ "name": "n_total_trials",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_attempts": {
+ "name": "n_attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_score": {
+ "name": "total_score",
+ "type": "numeric(14, 6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overall_score": {
+ "name": "overall_score",
+ "type": "numeric(12, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "n_errored": {
+ "name": "n_errored",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "avg_cost_microdollars": {
+ "name": "avg_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost_microdollars": {
+ "name": "total_cost_microdollars",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_input_tokens": {
+ "name": "avg_input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_input_tokens": {
+ "name": "total_input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_output_tokens": {
+ "name": "avg_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_output_tokens": {
+ "name": "total_output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_cache_read_tokens": {
+ "name": "avg_cache_read_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cache_read_tokens": {
+ "name": "total_cache_read_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_execution_ms": {
+ "name": "avg_execution_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "promoted_at": {
+ "name": "promoted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "promoted_by_email": {
+ "name": "promoted_by_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "promotion_note": {
+ "name": "promotion_note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_eval_ingestions_lookup": {
+ "name": "IDX_model_eval_ingestions_lookup",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "variant",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "task_source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "promoted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_eval_ingestions_model_stats": {
+ "name": "IDX_model_eval_ingestions_model_stats",
+ "columns": [
+ {
+ "expression": "model_stats_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_eval_ingestions_promoted_by_email_lower": {
+ "name": "IDX_model_eval_ingestions_promoted_by_email_lower",
+ "columns": [
+ {
+ "expression": "LOWER(\"promoted_by_email\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_eval_ingestions_model_stats_id_model_stats_id_fk": {
+ "name": "model_eval_ingestions_model_stats_id_model_stats_id_fk",
+ "tableFrom": "model_eval_ingestions",
+ "tableTo": "model_stats",
+ "columnsFrom": [
+ "model_stats_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_eval_ingestions_bench_eval_name_unique": {
+ "name": "model_eval_ingestions_bench_eval_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "bench_eval_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_experiment": {
+ "name": "model_experiment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "public_model_id": {
+ "name": "public_model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "is_archived": {
+ "name": "is_archived",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "UQ_model_experiment_public_model_id_routing": {
+ "name": "UQ_model_experiment_public_model_id_routing",
+ "columns": [
+ {
+ "expression": "public_model_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"model_experiment\".\"status\" IN ('active', 'paused')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_experiment_status": {
+ "name": "IDX_model_experiment_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_created_by_user_id_kilocode_users_id_fk": {
+ "name": "model_experiment_created_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "model_experiment",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_status_valid": {
+ "name": "model_experiment_status_valid",
+ "value": "\"model_experiment\".\"status\" IN ('draft', 'active', 'paused', 'completed')"
+ },
+ "model_experiment_active_not_archived": {
+ "name": "model_experiment_active_not_archived",
+ "value": "\"model_experiment\".\"status\" <> 'active' OR \"model_experiment\".\"is_archived\" = false"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_request": {
+ "name": "model_experiment_request",
+ "schema": "",
+ "columns": {
+ "usage_id": {
+ "name": "usage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "variant_version_id": {
+ "name": "variant_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allocation_subject": {
+ "name": "allocation_subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_request_id": {
+ "name": "client_request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_kind": {
+ "name": "request_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_body_sha256": {
+ "name": "request_body_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "was_truncated": {
+ "name": "was_truncated",
+ "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": {
+ "IDX_model_experiment_request_variant_version_created_at": {
+ "name": "IDX_model_experiment_request_variant_version_created_at",
+ "columns": [
+ {
+ "expression": "variant_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_model_experiment_request_client_request_id": {
+ "name": "IDX_model_experiment_request_client_request_id",
+ "columns": [
+ {
+ "expression": "client_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"model_experiment_request\".\"client_request_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_request_usage_id_microdollar_usage_id_fk": {
+ "name": "model_experiment_request_usage_id_microdollar_usage_id_fk",
+ "tableFrom": "model_experiment_request",
+ "tableTo": "microdollar_usage",
+ "columnsFrom": [
+ "usage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk": {
+ "name": "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk",
+ "tableFrom": "model_experiment_request",
+ "tableTo": "model_experiment_variant_version",
+ "columnsFrom": [
+ "variant_version_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "model_experiment_request_usage_id_created_at_pk": {
+ "name": "model_experiment_request_usage_id_created_at_pk",
+ "columns": [
+ "usage_id",
+ "created_at"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_request_allocation_subject_valid": {
+ "name": "model_experiment_request_allocation_subject_valid",
+ "value": "\"model_experiment_request\".\"allocation_subject\" IN ('user', 'machine', 'ip')"
+ },
+ "model_experiment_request_request_kind_valid": {
+ "name": "model_experiment_request_request_kind_valid",
+ "value": "\"model_experiment_request\".\"request_kind\" IN ('chat_completions', 'messages', 'responses')"
+ },
+ "model_experiment_request_request_body_sha256_format": {
+ "name": "model_experiment_request_request_body_sha256_format",
+ "value": "\"model_experiment_request\".\"request_body_sha256\" ~ '^[0-9a-f]{64}$' OR \"model_experiment_request\".\"request_body_sha256\" IN ('__failed__', '__deleted__')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_variant": {
+ "name": "model_experiment_variant",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "experiment_id": {
+ "name": "experiment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "weight": {
+ "name": "weight",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_experiment_variant_experiment_id": {
+ "name": "IDX_model_experiment_variant_experiment_id",
+ "columns": [
+ {
+ "expression": "experiment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_variant_experiment_id_model_experiment_id_fk": {
+ "name": "model_experiment_variant_experiment_id_model_experiment_id_fk",
+ "tableFrom": "model_experiment_variant",
+ "tableTo": "model_experiment",
+ "columnsFrom": [
+ "experiment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_model_experiment_variant_experiment_label": {
+ "name": "UQ_model_experiment_variant_experiment_label",
+ "nullsNotDistinct": false,
+ "columns": [
+ "experiment_id",
+ "label"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "model_experiment_variant_weight_positive": {
+ "name": "model_experiment_variant_weight_positive",
+ "value": "\"model_experiment_variant\".\"weight\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.model_experiment_variant_version": {
+ "name": "model_experiment_variant_version",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "variant_id": {
+ "name": "variant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "upstream": {
+ "name": "upstream",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_at": {
+ "name": "effective_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_model_experiment_variant_version_variant_effective": {
+ "name": "IDX_model_experiment_variant_version_variant_effective",
+ "columns": [
+ {
+ "expression": "variant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "effective_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk": {
+ "name": "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk",
+ "tableFrom": "model_experiment_variant_version",
+ "tableTo": "model_experiment_variant",
+ "columnsFrom": [
+ "variant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "model_experiment_variant_version_created_by_kilocode_users_id_fk": {
+ "name": "model_experiment_variant_version_created_by_kilocode_users_id_fk",
+ "tableFrom": "model_experiment_variant_version",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.models_by_provider": {
+ "name": "models_by_provider",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "openrouter": {
+ "name": "openrouter",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vercel": {
+ "name": "vercel",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_audit_logs": {
+ "name": "organization_audit_logs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_audit_logs_organization_id": {
+ "name": "IDX_organization_audit_logs_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_action": {
+ "name": "IDX_organization_audit_logs_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_actor_id": {
+ "name": "IDX_organization_audit_logs_actor_id",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_audit_logs_created_at": {
+ "name": "IDX_organization_audit_logs_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_invitations": {
+ "name": "organization_invitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by": {
+ "name": "invited_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authentication_requirement": {
+ "name": "authentication_requirement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "sso_source_organization_id": {
+ "name": "sso_source_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_organization_invitations_token": {
+ "name": "UQ_organization_invitations_token",
+ "columns": [
+ {
+ "expression": "token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_org_id": {
+ "name": "IDX_organization_invitations_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_email": {
+ "name": "IDX_organization_invitations_email",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_invitations_expires_at": {
+ "name": "IDX_organization_invitations_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_invitations_sso_source_organization_id_organizations_id_fk": {
+ "name": "organization_invitations_sso_source_organization_id_organizations_id_fk",
+ "tableFrom": "organization_invitations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "sso_source_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_membership_removals": {
+ "name": "organization_membership_removals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "removed_at": {
+ "name": "removed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "removed_by": {
+ "name": "removed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_role": {
+ "name": "previous_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "IDX_org_membership_removals_org_id": {
+ "name": "IDX_org_membership_removals_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_org_membership_removals_user_id": {
+ "name": "IDX_org_membership_removals_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_org_membership_removals_org_user": {
+ "name": "UQ_org_membership_removals_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_memberships": {
+ "name": "organization_memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "invited_by": {
+ "name": "invited_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_memberships_org_id": {
+ "name": "IDX_organization_memberships_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_memberships_user_id": {
+ "name": "IDX_organization_memberships_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_memberships_org_user": {
+ "name": "UQ_organization_memberships_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_recommendation_dismissals": {
+ "name": "organization_recommendation_dismissals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_key": {
+ "name": "recommendation_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dismissed_by_user_id": {
+ "name": "dismissed_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dismissed_at": {
+ "name": "dismissed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk": {
+ "name": "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "organization_recommendation_dismissals",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk": {
+ "name": "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "organization_recommendation_dismissals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "dismissed_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_org_recommendation_dismissals_org_key": {
+ "name": "UQ_org_recommendation_dismissals_org_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "owned_by_organization_id",
+ "recommendation_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_seats_purchases": {
+ "name": "organization_seats_purchases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscription_stripe_id": {
+ "name": "subscription_stripe_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "seat_count": {
+ "name": "seat_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "numeric",
+ "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
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "subscription_status": {
+ "name": "subscription_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "starts_at": {
+ "name": "starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_cycle": {
+ "name": "billing_cycle",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'monthly'"
+ }
+ },
+ "indexes": {
+ "IDX_organization_seats_org_id": {
+ "name": "IDX_organization_seats_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_expires_at": {
+ "name": "IDX_organization_seats_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_created_at": {
+ "name": "IDX_organization_seats_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_updated_at": {
+ "name": "IDX_organization_seats_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_seats_starts_at": {
+ "name": "IDX_organization_seats_starts_at",
+ "columns": [
+ {
+ "expression": "starts_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_seats_idempotency_key": {
+ "name": "UQ_organization_seats_idempotency_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "idempotency_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_user_limits": {
+ "name": "organization_user_limits",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "microdollar_limit": {
+ "name": "microdollar_limit",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_user_limits_org_id": {
+ "name": "IDX_organization_user_limits_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_user_limits_user_id": {
+ "name": "IDX_organization_user_limits_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_user_limits_org_user": {
+ "name": "UQ_organization_user_limits_org_user",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "limit_type"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_user_usage": {
+ "name": "organization_user_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "usage_date": {
+ "name": "usage_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "microdollar_usage": {
+ "name": "microdollar_usage",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_organization_user_daily_usage_org_id": {
+ "name": "IDX_organization_user_daily_usage_org_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organization_user_daily_usage_user_id": {
+ "name": "IDX_organization_user_daily_usage_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_user_daily_usage_org_user_date": {
+ "name": "UQ_organization_user_daily_usage_org_user_date",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "kilo_user_id",
+ "limit_type",
+ "usage_date"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "microdollars_used": {
+ "name": "microdollars_used",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "microdollars_balance": {
+ "name": "microdollars_balance",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "total_microdollars_acquired": {
+ "name": "total_microdollars_acquired",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0'"
+ },
+ "next_credit_expiration_at": {
+ "name": "next_credit_expiration_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_top_up_enabled": {
+ "name": "auto_top_up_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "seat_count": {
+ "name": "seat_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "require_seats": {
+ "name": "require_seats",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by_kilo_user_id": {
+ "name": "created_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sso_domain": {
+ "name": "sso_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_organization_id": {
+ "name": "parent_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'teams'"
+ },
+ "free_trial_end_at": {
+ "name": "free_trial_end_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_domain": {
+ "name": "company_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_slug": {
+ "name": "requested_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_organizations_sso_domain": {
+ "name": "IDX_organizations_sso_domain",
+ "columns": [
+ {
+ "expression": "sso_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_organizations_parent_organization_id": {
+ "name": "IDX_organizations_parent_organization_id",
+ "columns": [
+ {
+ "expression": "parent_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organizations_parent_organization_id_organizations_id_fk": {
+ "name": "organizations_parent_organization_id_organizations_id_fk",
+ "tableFrom": "organizations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "parent_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organizations_slug_unique": {
+ "name": "organizations_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "organizations_name_not_empty_check": {
+ "name": "organizations_name_not_empty_check",
+ "value": "length(trim(\"organizations\".\"name\")) > 0"
+ },
+ "organizations_slug_max_length_check": {
+ "name": "organizations_slug_max_length_check",
+ "value": "\"organizations\".\"slug\" IS NULL OR length(\"organizations\".\"slug\") <= 32"
+ },
+ "organizations_not_parented_by_self_check": {
+ "name": "organizations_not_parented_by_self_check",
+ "value": "\"organizations\".\"parent_organization_id\" IS NULL OR \"organizations\".\"parent_organization_id\" <> \"organizations\".\"id\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.organization_modes": {
+ "name": "organization_modes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ }
+ },
+ "indexes": {
+ "IDX_organization_modes_organization_id": {
+ "name": "IDX_organization_modes_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_organization_modes_org_id_slug": {
+ "name": "UQ_organization_modes_org_id_slug",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.payment_methods": {
+ "name": "payment_methods",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_fingerprint": {
+ "name": "stripe_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_id": {
+ "name": "stripe_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last4": {
+ "name": "last4",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "brand": {
+ "name": "brand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line1": {
+ "name": "address_line1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line2": {
+ "name": "address_line2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_city": {
+ "name": "address_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_state": {
+ "name": "address_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_zip": {
+ "name": "address_zip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_country": {
+ "name": "address_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "three_d_secure_supported": {
+ "name": "three_d_secure_supported",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "regulated_status": {
+ "name": "regulated_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line1_check_status": {
+ "name": "address_line1_check_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postal_code_check_status": {
+ "name": "postal_code_check_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eligible_for_free_credits": {
+ "name": "eligible_for_free_credits",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_data": {
+ "name": "stripe_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_d7d7fb15569674aaadcfbc0428": {
+ "name": "IDX_d7d7fb15569674aaadcfbc0428",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_e1feb919d0ab8a36381d5d5138": {
+ "name": "IDX_e1feb919d0ab8a36381d5d5138",
+ "columns": [
+ {
+ "expression": "stripe_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_payment_methods_organization_id": {
+ "name": "IDX_payment_methods_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_29df1b0403df5792c96bbbfdbe6": {
+ "name": "UQ_29df1b0403df5792c96bbbfdbe6",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "stripe_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pending_impact_sale_reversals": {
+ "name": "pending_impact_sale_reversals",
+ "schema": "",
+ "columns": {
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "dispute_id": {
+ "name": "dispute_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount": {
+ "name": "amount",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_date": {
+ "name": "event_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_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": {},
+ "policies": {},
+ "checkConstraints": {
+ "pending_impact_sale_reversals_attempt_count_non_negative_check": {
+ "name": "pending_impact_sale_reversals_attempt_count_non_negative_check",
+ "value": "\"pending_impact_sale_reversals\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.platform_access_token_credentials": {
+ "name": "platform_access_token_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_encrypted": {
+ "name": "token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_credential_type": {
+ "name": "provider_credential_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_scopes": {
+ "name": "provider_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_verified_at": {
+ "name": "provider_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_validated_at": {
+ "name": "last_validated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "FK_platform_access_token_credentials_parent": {
+ "name": "FK_platform_access_token_credentials_parent",
+ "tableFrom": "platform_access_token_credentials",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_platform_access_token_credentials_platform_integration_id": {
+ "name": "UQ_platform_access_token_credentials_platform_integration_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "platform_integration_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.platform_integrations": {
+ "name": "platform_integrations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_installation_id": {
+ "name": "platform_installation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_account_id": {
+ "name": "platform_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_account_login": {
+ "name": "platform_account_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_access": {
+ "name": "repository_access",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repositories": {
+ "name": "repositories",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repositories_synced_at": {
+ "name": "repositories_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_invalid_at": {
+ "name": "auth_invalid_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_invalid_reason": {
+ "name": "auth_invalid_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_requester_user_id": {
+ "name": "kilo_requester_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_requester_account_id": {
+ "name": "platform_requester_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "integration_status": {
+ "name": "integration_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_at": {
+ "name": "suspended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_by": {
+ "name": "suspended_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_app_type": {
+ "name": "github_app_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'standard'"
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_platform_integrations_owned_by_org_platform_inst": {
+ "name": "UQ_platform_integrations_owned_by_org_platform_inst",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_owned_by_user_platform_inst": {
+ "name": "UQ_platform_integrations_owned_by_user_platform_inst",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_slack_platform_inst": {
+ "name": "UQ_platform_integrations_slack_platform_inst",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'slack' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_linear_platform_inst": {
+ "name": "UQ_platform_integrations_linear_platform_inst",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'linear' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_user_bitbucket": {
+ "name": "UQ_platform_integrations_user_bitbucket",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_platform_integrations_org_bitbucket": {
+ "name": "UQ_platform_integrations_org_bitbucket",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_org_id": {
+ "name": "IDX_platform_integrations_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_user_id": {
+ "name": "IDX_platform_integrations_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform_inst_id": {
+ "name": "IDX_platform_integrations_platform_inst_id",
+ "columns": [
+ {
+ "expression": "platform_installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform": {
+ "name": "IDX_platform_integrations_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_org_platform": {
+ "name": "IDX_platform_integrations_owned_by_org_platform",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_owned_by_user_platform": {
+ "name": "IDX_platform_integrations_owned_by_user_platform",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_integration_status": {
+ "name": "IDX_platform_integrations_integration_status",
+ "columns": [
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_kilo_requester": {
+ "name": "IDX_platform_integrations_kilo_requester",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kilo_requester_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_integrations_platform_requester": {
+ "name": "IDX_platform_integrations_platform_requester",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_requester_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "integration_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "platform_integrations_owned_by_organization_id_organizations_id_fk": {
+ "name": "platform_integrations_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "platform_integrations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "platform_integrations_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "platform_integrations_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "platform_integrations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "platform_integrations_owner_check": {
+ "name": "platform_integrations_owner_check",
+ "value": "(\n (\"platform_integrations\".\"owned_by_user_id\" IS NOT NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NULL) OR\n (\"platform_integrations\".\"owned_by_user_id\" IS NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.platform_oauth_credentials": {
+ "name": "platform_oauth_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorized_by_user_id": {
+ "name": "authorized_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject_id": {
+ "name": "provider_subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_subject_login": {
+ "name": "provider_subject_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_encrypted": {
+ "name": "access_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_reason": {
+ "name": "revocation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_platform_oauth_credentials_platform_integration_id": {
+ "name": "UQ_platform_oauth_credentials_platform_integration_id",
+ "columns": [
+ {
+ "expression": "platform_integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_platform_oauth_credentials_authorized_by_user_id": {
+ "name": "IDX_platform_oauth_credentials_authorized_by_user_id",
+ "columns": [
+ {
+ "expression": "authorized_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk": {
+ "name": "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "platform_oauth_credentials",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk": {
+ "name": "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "platform_oauth_credentials",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "authorized_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.referral_code_usages": {
+ "name": "referral_code_usages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "referring_kilo_user_id": {
+ "name": "referring_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redeeming_kilo_user_id": {
+ "name": "redeeming_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_usd": {
+ "name": "amount_usd",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "paid_at": {
+ "name": "paid_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_referral_code_usages_redeeming_kilo_user_id": {
+ "name": "IDX_referral_code_usages_redeeming_kilo_user_id",
+ "columns": [
+ {
+ "expression": "redeeming_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_referral_code_usages_redeeming_user_id_code": {
+ "name": "UQ_referral_code_usages_redeeming_user_id_code",
+ "nullsNotDistinct": false,
+ "columns": [
+ "redeeming_kilo_user_id",
+ "referring_kilo_user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.referral_codes": {
+ "name": "referral_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "max_redemptions": {
+ "name": "max_redemptions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 10
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_referral_codes_kilo_user_id": {
+ "name": "UQ_referral_codes_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_referral_codes_code": {
+ "name": "IDX_referral_codes_code",
+ "columns": [
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_check_catalog": {
+ "name": "security_advisor_check_catalog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "check_id": {
+ "name": "check_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "explanation": {
+ "name": "explanation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "risk": {
+ "name": "risk",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_check_catalog_check_id_unique": {
+ "name": "security_advisor_check_catalog_check_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "check_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "security_advisor_check_catalog_severity_check": {
+ "name": "security_advisor_check_catalog_severity_check",
+ "value": "\"security_advisor_check_catalog\".\"severity\" in ('critical', 'warn', 'info')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_content": {
+ "name": "security_advisor_content",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_content_key_unique": {
+ "name": "security_advisor_content_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_kiloclaw_coverage": {
+ "name": "security_advisor_kiloclaw_coverage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "area": {
+ "name": "area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "detail": {
+ "name": "detail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "match_check_ids": {
+ "name": "match_check_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "security_advisor_kiloclaw_coverage_area_unique": {
+ "name": "security_advisor_kiloclaw_coverage_area_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "area"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_advisor_scans": {
+ "name": "security_advisor_scans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_platform": {
+ "name": "source_platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_method": {
+ "name": "source_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plugin_version": {
+ "name": "plugin_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "openclaw_version": {
+ "name": "openclaw_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_ip": {
+ "name": "public_ip",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "findings_critical": {
+ "name": "findings_critical",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "findings_warn": {
+ "name": "findings_warn",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "findings_info": {
+ "name": "findings_info",
+ "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": {
+ "idx_security_advisor_scans_user_created_at": {
+ "name": "idx_security_advisor_scans_user_created_at",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_advisor_scans_created_at": {
+ "name": "idx_security_advisor_scans_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_advisor_scans_platform": {
+ "name": "idx_security_advisor_scans_platform",
+ "columns": [
+ {
+ "expression": "source_platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.security_agent_commands": {
+ "name": "security_agent_commands",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "command_type": {
+ "name": "command_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'accepted'"
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_metadata": {
+ "name": "result_metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_security_agent_commands_org_created": {
+ "name": "idx_security_agent_commands_org_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_user_created": {
+ "name": "idx_security_agent_commands_user_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_status_updated": {
+ "name": "idx_security_agent_commands_status_updated",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_agent_commands_finding_created": {
+ "name": "idx_security_agent_commands_finding_created",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_agent_commands_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_agent_commands_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_commands_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_agent_commands_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_commands_finding_id_security_findings_id_fk": {
+ "name": "security_agent_commands_finding_id_security_findings_id_fk",
+ "tableFrom": "security_agent_commands",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_agent_commands_owner_check": {
+ "name": "security_agent_commands_owner_check",
+ "value": "(\n (\"security_agent_commands\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_commands\".\"owned_by_user_id\" IS NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_agent_commands_type_check": {
+ "name": "security_agent_commands_type_check",
+ "value": "\"security_agent_commands\".\"command_type\" IN ('sync', 'dismiss_finding', 'start_analysis', 'apply_auto_remediation')"
+ },
+ "security_agent_commands_origin_check": {
+ "name": "security_agent_commands_origin_check",
+ "value": "\"security_agent_commands\".\"origin\" IN ('manual', 'dashboard_refresh', 'enable_initial_sync', 'settings_include_existing')"
+ },
+ "security_agent_commands_status_check": {
+ "name": "security_agent_commands_status_check",
+ "value": "\"security_agent_commands\".\"status\" IN ('accepted', 'running', 'succeeded', 'failed', 'no_op')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_agent_repository_sync_state": {
+ "name": "security_agent_repository_sync_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_attempted_at": {
+ "name": "last_attempted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_succeeded_at": {
+ "name": "last_succeeded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_failure_code": {
+ "name": "last_failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_agent_repository_sync_state_org_repo": {
+ "name": "UQ_security_agent_repository_sync_state_org_repo",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_agent_repository_sync_state\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_agent_repository_sync_state_user_repo": {
+ "name": "UQ_security_agent_repository_sync_state_user_repo",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_agent_repository_sync_state\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_agent_repository_sync_state",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_agent_repository_sync_state",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_agent_repository_sync_state_owner_check": {
+ "name": "security_agent_repository_sync_state_owner_check",
+ "value": "(\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_analysis_owner_state": {
+ "name": "security_analysis_owner_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_analysis_enabled_at": {
+ "name": "auto_analysis_enabled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_until": {
+ "name": "blocked_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reason": {
+ "name": "block_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consecutive_actor_resolution_failures": {
+ "name": "consecutive_actor_resolution_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_actor_resolution_failure_at": {
+ "name": "last_actor_resolution_failure_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_analysis_owner_state_org_owner": {
+ "name": "UQ_security_analysis_owner_state_org_owner",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_analysis_owner_state\".\"owned_by_organization_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_analysis_owner_state_user_owner": {
+ "name": "UQ_security_analysis_owner_state_user_owner",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_analysis_owner_state\".\"owned_by_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_analysis_owner_state",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_analysis_owner_state",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_analysis_owner_state_owner_check": {
+ "name": "security_analysis_owner_state_owner_check",
+ "value": "(\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_analysis_owner_state_block_reason_check": {
+ "name": "security_analysis_owner_state_block_reason_check",
+ "value": "\"security_analysis_owner_state\".\"block_reason\" IS NULL OR \"security_analysis_owner_state\".\"block_reason\" IN ('INSUFFICIENT_CREDITS', 'ACTOR_RESOLUTION_FAILED', 'OPERATOR_PAUSE')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_analysis_queue": {
+ "name": "security_analysis_queue",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "queue_status": {
+ "name": "queue_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity_rank": {
+ "name": "severity_rank",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_by_job_id": {
+ "name": "claimed_by_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claim_token": {
+ "name": "claim_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "reopen_requeue_count": {
+ "name": "reopen_requeue_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_analysis_queue_finding_id": {
+ "name": "UQ_security_analysis_queue_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_claim_path_org": {
+ "name": "idx_security_analysis_queue_claim_path_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "severity_rank",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_claim_path_user": {
+ "name": "idx_security_analysis_queue_claim_path_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "severity_rank",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_in_flight_org": {
+ "name": "idx_security_analysis_queue_in_flight_org",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queue_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_in_flight_user": {
+ "name": "idx_security_analysis_queue_in_flight_user",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queue_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_lag_dashboards": {
+ "name": "idx_security_analysis_queue_lag_dashboards",
+ "columns": [
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_pending_reconciliation": {
+ "name": "idx_security_analysis_queue_pending_reconciliation",
+ "columns": [
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_running_reconciliation": {
+ "name": "idx_security_analysis_queue_running_reconciliation",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"queue_status\" = 'running'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_analysis_queue_failure_trend": {
+ "name": "idx_security_analysis_queue_failure_trend",
+ "columns": [
+ {
+ "expression": "failure_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_analysis_queue\".\"failure_code\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_analysis_queue_finding_id_security_findings_id_fk": {
+ "name": "security_analysis_queue_finding_id_security_findings_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_queue_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_analysis_queue_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_analysis_queue",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_analysis_queue_owner_check": {
+ "name": "security_analysis_queue_owner_check",
+ "value": "(\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_analysis_queue_status_check": {
+ "name": "security_analysis_queue_status_check",
+ "value": "\"security_analysis_queue\".\"queue_status\" IN ('queued', 'pending', 'running', 'failed', 'completed')"
+ },
+ "security_analysis_queue_claim_token_required_check": {
+ "name": "security_analysis_queue_claim_token_required_check",
+ "value": "\"security_analysis_queue\".\"queue_status\" NOT IN ('pending', 'running') OR \"security_analysis_queue\".\"claim_token\" IS NOT NULL"
+ },
+ "security_analysis_queue_attempt_count_non_negative_check": {
+ "name": "security_analysis_queue_attempt_count_non_negative_check",
+ "value": "\"security_analysis_queue\".\"attempt_count\" >= 0"
+ },
+ "security_analysis_queue_reopen_requeue_count_non_negative_check": {
+ "name": "security_analysis_queue_reopen_requeue_count_non_negative_check",
+ "value": "\"security_analysis_queue\".\"reopen_requeue_count\" >= 0"
+ },
+ "security_analysis_queue_severity_rank_check": {
+ "name": "security_analysis_queue_severity_rank_check",
+ "value": "\"security_analysis_queue\".\"severity_rank\" IN (0, 1, 2, 3)"
+ },
+ "security_analysis_queue_failure_code_check": {
+ "name": "security_analysis_queue_failure_code_check",
+ "value": "\"security_analysis_queue\".\"failure_code\" IS NULL OR \"security_analysis_queue\".\"failure_code\" IN (\n 'NETWORK_TIMEOUT',\n 'UPSTREAM_5XX',\n 'TEMP_TOKEN_FAILURE',\n 'START_CALL_AMBIGUOUS',\n 'REQUEUE_TEMPORARY_PRECONDITION',\n 'ACTOR_RESOLUTION_FAILED',\n 'GITHUB_TOKEN_UNAVAILABLE',\n 'INVALID_CONFIG',\n 'MISSING_OWNERSHIP',\n 'PERMISSION_DENIED_PERMANENT',\n 'UNSUPPORTED_SEVERITY',\n 'INSUFFICIENT_CREDITS',\n 'STATE_GUARD_REJECTED',\n 'SKIPPED_ALREADY_IN_PROGRESS',\n 'SKIPPED_NO_LONGER_ELIGIBLE',\n 'REOPEN_LOOP_GUARD',\n 'RUN_LOST'\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_audit_log": {
+ "name": "security_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "before_state": {
+ "name": "before_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "after_state": {
+ "name": "after_state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_occurred_at": {
+ "name": "source_occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_key": {
+ "name": "event_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_version": {
+ "name": "schema_version",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_snapshot": {
+ "name": "finding_snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_context": {
+ "name": "source_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_security_audit_log_org_created": {
+ "name": "IDX_security_audit_log_org_created",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_user_created": {
+ "name": "IDX_security_audit_log_user_created",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_resource": {
+ "name": "IDX_security_audit_log_resource",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_actor": {
+ "name": "IDX_security_audit_log_actor",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_action": {
+ "name": "IDX_security_audit_log_action",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_audit_log_org_event_key": {
+ "name": "UQ_security_audit_log_org_event_key",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_audit_log_user_event_key": {
+ "name": "UQ_security_audit_log_user_event_key",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_org_occurred": {
+ "name": "IDX_security_audit_log_org_occurred",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_security_audit_log_user_occurred": {
+ "name": "IDX_security_audit_log_user_occurred",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_audit_log_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_audit_log_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_audit_log",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_audit_log_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_audit_log_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_audit_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_audit_log_owner_check": {
+ "name": "security_audit_log_owner_check",
+ "value": "(\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NULL) OR (\"security_audit_log\".\"owned_by_user_id\" IS NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL)"
+ },
+ "security_audit_log_action_check": {
+ "name": "security_audit_log_action_check",
+ "value": "\"security_audit_log\".\"action\" IN ('security.finding.created', 'security.finding.severity_changed', 'security.finding.status_change', 'security.finding.dismissed', 'security.finding.auto_dismissed', 'security.finding.superseded', 'security.finding.analysis_started', 'security.finding.analysis_completed', 'security.finding.analysis_failed', 'security.remediation.queued', 'security.remediation.started', 'security.remediation.pr_opened', 'security.remediation.failed', 'security.remediation.blocked', 'security.remediation.no_changes_needed', 'security.remediation.cancelled', 'security.remediation.retried', 'security.finding.deleted', 'security.config.enabled', 'security.config.disabled', 'security.config.updated', 'security.sync.triggered', 'security.sync.completed', 'security.audit_log.exported', 'security.audit_report.generated')"
+ },
+ "security_audit_log_actor_type_check": {
+ "name": "security_audit_log_actor_type_check",
+ "value": "\"security_audit_log\".\"actor_type\" IN ('customer_user', 'kilo_admin', 'system')"
+ },
+ "security_audit_log_source_context_check": {
+ "name": "security_audit_log_source_context_check",
+ "value": "\"security_audit_log\".\"source_context\" IN ('security_sync', 'web', 'analysis_worker', 'remediation_callback', 'rollout_baseline')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_finding_notifications": {
+ "name": "security_finding_notifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient_user_id": {
+ "name": "recipient_user_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": "'staged'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_security_finding_notifications_finding_recipient_kind": {
+ "name": "uq_security_finding_notifications_finding_recipient_kind",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recipient_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_pending": {
+ "name": "idx_security_finding_notifications_pending",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_finding_notifications\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_staged": {
+ "name": "idx_security_finding_notifications_staged",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_finding_notifications\".\"status\" = 'staged'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_finding_id": {
+ "name": "idx_security_finding_notifications_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_finding_notifications_recipient_user_id": {
+ "name": "idx_security_finding_notifications_recipient_user_id",
+ "columns": [
+ {
+ "expression": "recipient_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_finding_notifications_finding_fk": {
+ "name": "security_finding_notifications_finding_fk",
+ "tableFrom": "security_finding_notifications",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_finding_notifications_recipient_fk": {
+ "name": "security_finding_notifications_recipient_fk",
+ "tableFrom": "security_finding_notifications",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "recipient_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_finding_notifications_kind_check": {
+ "name": "security_finding_notifications_kind_check",
+ "value": "\"security_finding_notifications\".\"kind\" IN ('new_finding', 'sla_warning', 'sla_breach')"
+ },
+ "security_finding_notifications_status_check": {
+ "name": "security_finding_notifications_status_check",
+ "value": "\"security_finding_notifications\".\"status\" IN ('staged', 'pending', 'sending', 'sent', 'failed', 'cancelled')"
+ },
+ "security_finding_notifications_attempt_count_check": {
+ "name": "security_finding_notifications_attempt_count_check",
+ "value": "\"security_finding_notifications\".\"attempt_count\" >= 0"
+ },
+ "security_finding_notifications_claimed_at_check": {
+ "name": "security_finding_notifications_claimed_at_check",
+ "value": "(\n (\"security_finding_notifications\".\"status\" = 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NULL)\n )"
+ },
+ "security_finding_notifications_sent_at_check": {
+ "name": "security_finding_notifications_sent_at_check",
+ "value": "(\n (\"security_finding_notifications\".\"status\" = 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NULL)\n )"
+ },
+ "security_finding_notifications_error_message_length_check": {
+ "name": "security_finding_notifications_error_message_length_check",
+ "value": "\"security_finding_notifications\".\"error_message\" IS NULL OR length(\"security_finding_notifications\".\"error_message\") <= 500"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_findings": {
+ "name": "security_findings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ghsa_id": {
+ "name": "ghsa_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cve_id": {
+ "name": "cve_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "package_name": {
+ "name": "package_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "package_ecosystem": {
+ "name": "package_ecosystem",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "vulnerable_version_range": {
+ "name": "vulnerable_version_range",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patched_version": {
+ "name": "patched_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manifest_path": {
+ "name": "manifest_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "ignored_reason": {
+ "name": "ignored_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ignored_by": {
+ "name": "ignored_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_at": {
+ "name": "fixed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sla_due_at": {
+ "name": "sla_due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dependabot_html_url": {
+ "name": "dependabot_html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cwe_ids": {
+ "name": "cwe_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cvss_score": {
+ "name": "cvss_score",
+ "type": "numeric(3, 1)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dependency_scope": {
+ "name": "dependency_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_status": {
+ "name": "analysis_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_started_at": {
+ "name": "analysis_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_completed_at": {
+ "name": "analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_error": {
+ "name": "analysis_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis": {
+ "name": "analysis",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "raw_data": {
+ "name": "raw_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_detected_at": {
+ "name": "first_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_security_findings_user_source": {
+ "name": "uq_security_findings_user_source",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_findings\".\"owned_by_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "uq_security_findings_org_source": {
+ "name": "uq_security_findings_org_source",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_findings\".\"owned_by_organization_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_org_id": {
+ "name": "idx_security_findings_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_user_id": {
+ "name": "idx_security_findings_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_repo": {
+ "name": "idx_security_findings_repo",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_severity": {
+ "name": "idx_security_findings_severity",
+ "columns": [
+ {
+ "expression": "severity",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_status": {
+ "name": "idx_security_findings_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_package": {
+ "name": "idx_security_findings_package",
+ "columns": [
+ {
+ "expression": "package_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_sla_due_at": {
+ "name": "idx_security_findings_sla_due_at",
+ "columns": [
+ {
+ "expression": "sla_due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_session_id": {
+ "name": "idx_security_findings_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_cli_session_id": {
+ "name": "idx_security_findings_cli_session_id",
+ "columns": [
+ {
+ "expression": "cli_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_analysis_status": {
+ "name": "idx_security_findings_analysis_status",
+ "columns": [
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_org_analysis_in_flight": {
+ "name": "idx_security_findings_org_analysis_in_flight",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_findings_user_analysis_in_flight": {
+ "name": "idx_security_findings_user_analysis_in_flight",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_findings_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_findings_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_findings_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_findings_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_findings_platform_integration_id_platform_integrations_id_fk": {
+ "name": "security_findings_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "security_findings",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_findings_owner_check": {
+ "name": "security_findings_owner_check",
+ "value": "(\n (\"security_findings\".\"owned_by_user_id\" IS NOT NULL AND \"security_findings\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_findings\".\"owned_by_user_id\" IS NULL AND \"security_findings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_remediation_attempts": {
+ "name": "security_remediation_attempts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "remediation_id": {
+ "name": "remediation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_number": {
+ "name": "attempt_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "retry_of_attempt_id": {
+ "name": "retry_of_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_by_user_id": {
+ "name": "requested_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "analysis_fingerprint": {
+ "name": "analysis_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "analysis_completed_at": {
+ "name": "analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remediation_model_slug": {
+ "name": "remediation_model_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_session_id": {
+ "name": "kilo_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_id": {
+ "name": "execution_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 50
+ },
+ "claim_token": {
+ "name": "claim_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_by_job_id": {
+ "name": "claimed_by_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "launch_attempt_count": {
+ "name": "launch_attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "callback_attempt_token_hash": {
+ "name": "callback_attempt_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error_redacted": {
+ "name": "last_error_redacted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "structured_result": {
+ "name": "structured_result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "final_assistant_message": {
+ "name": "final_assistant_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "validation_evidence": {
+ "name": "validation_evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "risk_notes": {
+ "name": "risk_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draft_reason": {
+ "name": "draft_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_draft": {
+ "name": "pr_draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_branch": {
+ "name": "pr_head_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_base_branch": {
+ "name": "pr_base_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_requested_at": {
+ "name": "cancellation_requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_requested_by_user_id": {
+ "name": "cancellation_requested_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "queued_at": {
+ "name": "queued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "launched_at": {
+ "name": "launched_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_remediation_attempts_number": {
+ "name": "UQ_security_remediation_attempts_number",
+ "columns": [
+ {
+ "expression": "remediation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "attempt_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_active_finding": {
+ "name": "UQ_security_remediation_attempts_active_finding",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_active_remediation": {
+ "name": "UQ_security_remediation_attempts_active_remediation",
+ "columns": [
+ {
+ "expression": "remediation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_security_remediation_attempts_finding_fingerprint_terminal": {
+ "name": "UQ_security_remediation_attempts_finding_fingerprint_terminal",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_org_claim": {
+ "name": "idx_security_remediation_attempts_org_claim",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_user_claim": {
+ "name": "idx_security_remediation_attempts_user_claim",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_repo_claim": {
+ "name": "idx_security_remediation_attempts_repo_claim",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "queued_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_org_inflight": {
+ "name": "idx_security_remediation_attempts_org_inflight",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_user_inflight": {
+ "name": "idx_security_remediation_attempts_user_inflight",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_repo_inflight": {
+ "name": "idx_security_remediation_attempts_repo_inflight",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_cloud_agent_session": {
+ "name": "idx_security_remediation_attempts_cloud_agent_session",
+ "columns": [
+ {
+ "expression": "cloud_agent_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediation_attempts_finding_fingerprint": {
+ "name": "idx_security_remediation_attempts_finding_fingerprint",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "analysis_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_remediation_attempts_remediation_id_security_remediations_id_fk": {
+ "name": "security_remediation_attempts_remediation_id_security_remediations_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "security_remediations",
+ "columnsFrom": [
+ "remediation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_finding_id_security_findings_id_fk": {
+ "name": "security_remediation_attempts_finding_id_security_findings_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_remediation_attempts_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "requested_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediation_attempts",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "cancellation_requested_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_remediation_attempts_owner_check": {
+ "name": "security_remediation_attempts_owner_check",
+ "value": "(\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_remediation_attempts_status_check": {
+ "name": "security_remediation_attempts_status_check",
+ "value": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
+ },
+ "security_remediation_attempts_origin_check": {
+ "name": "security_remediation_attempts_origin_check",
+ "value": "\"security_remediation_attempts\".\"origin\" IN ('auto_policy', 'bulk_existing', 'manual')"
+ },
+ "security_remediation_attempts_attempt_number_check": {
+ "name": "security_remediation_attempts_attempt_number_check",
+ "value": "\"security_remediation_attempts\".\"attempt_number\" >= 1"
+ },
+ "security_remediation_attempts_launch_attempt_count_check": {
+ "name": "security_remediation_attempts_launch_attempt_count_check",
+ "value": "\"security_remediation_attempts\".\"launch_attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.security_remediations": {
+ "name": "security_remediations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finding_id": {
+ "name": "finding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "latest_attempt_id": {
+ "name": "latest_attempt_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latest_analysis_fingerprint": {
+ "name": "latest_analysis_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latest_analysis_completed_at": {
+ "name": "latest_analysis_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_url": {
+ "name": "pr_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_number": {
+ "name": "pr_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_draft": {
+ "name": "pr_draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_head_branch": {
+ "name": "pr_head_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pr_base_branch": {
+ "name": "pr_base_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_code": {
+ "name": "failure_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_summary": {
+ "name": "outcome_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_security_remediations_finding_id": {
+ "name": "UQ_security_remediations_finding_id",
+ "columns": [
+ {
+ "expression": "finding_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_org_status": {
+ "name": "idx_security_remediations_org_status",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_user_status": {
+ "name": "idx_security_remediations_user_status",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_repo_status": {
+ "name": "idx_security_remediations_repo_status",
+ "columns": [
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_security_remediations_latest_attempt": {
+ "name": "idx_security_remediations_latest_attempt",
+ "columns": [
+ {
+ "expression": "latest_attempt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "security_remediations_owned_by_organization_id_organizations_id_fk": {
+ "name": "security_remediations_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediations_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "security_remediations_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "security_remediations_finding_id_security_findings_id_fk": {
+ "name": "security_remediations_finding_id_security_findings_id_fk",
+ "tableFrom": "security_remediations",
+ "tableTo": "security_findings",
+ "columnsFrom": [
+ "finding_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "security_remediations_owner_check": {
+ "name": "security_remediations_owner_check",
+ "value": "(\n (\"security_remediations\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediations\".\"owned_by_user_id\" IS NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ },
+ "security_remediations_status_check": {
+ "name": "security_remediations_status_check",
+ "value": "\"security_remediations\".\"status\" IN ('queued', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.shared_cli_sessions": {
+ "name": "shared_cli_sessions",
+ "schema": "",
+ "columns": {
+ "share_id": {
+ "name": "share_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "shared_state": {
+ "name": "shared_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "api_conversation_history_blob_url": {
+ "name": "api_conversation_history_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_metadata_blob_url": {
+ "name": "task_metadata_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ui_messages_blob_url": {
+ "name": "ui_messages_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "git_state_blob_url": {
+ "name": "git_state_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_shared_cli_sessions_session_id": {
+ "name": "IDX_shared_cli_sessions_session_id",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_shared_cli_sessions_created_at": {
+ "name": "IDX_shared_cli_sessions_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_cli_sessions_session_id_cli_sessions_session_id_fk": {
+ "name": "shared_cli_sessions_session_id_cli_sessions_session_id_fk",
+ "tableFrom": "shared_cli_sessions",
+ "tableTo": "cli_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "session_id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk": {
+ "name": "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "shared_cli_sessions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "shared_cli_sessions_shared_state_check": {
+ "name": "shared_cli_sessions_shared_state_check",
+ "value": "\"shared_cli_sessions\".\"shared_state\" IN ('public', 'organization')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.slack_bot_requests": {
+ "name": "slack_bot_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform_integration_id": {
+ "name": "platform_integration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slack_team_id": {
+ "name": "slack_team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_team_name": {
+ "name": "slack_team_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slack_channel_id": {
+ "name": "slack_channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_user_id": {
+ "name": "slack_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slack_thread_ts": {
+ "name": "slack_thread_ts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message": {
+ "name": "user_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_message_truncated": {
+ "name": "user_message_truncated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_used": {
+ "name": "model_used",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_calls_made": {
+ "name": "tool_calls_made",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_agent_session_id": {
+ "name": "cloud_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_slack_bot_requests_created_at": {
+ "name": "idx_slack_bot_requests_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_slack_team_id": {
+ "name": "idx_slack_bot_requests_slack_team_id",
+ "columns": [
+ {
+ "expression": "slack_team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_owned_by_org_id": {
+ "name": "idx_slack_bot_requests_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_owned_by_user_id": {
+ "name": "idx_slack_bot_requests_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_status": {
+ "name": "idx_slack_bot_requests_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_event_type": {
+ "name": "idx_slack_bot_requests_event_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_slack_bot_requests_team_created": {
+ "name": "idx_slack_bot_requests_team_created",
+ "columns": [
+ {
+ "expression": "slack_team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "slack_bot_requests_owned_by_organization_id_organizations_id_fk": {
+ "name": "slack_bot_requests_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "slack_bot_requests_platform_integration_id_platform_integrations_id_fk": {
+ "name": "slack_bot_requests_platform_integration_id_platform_integrations_id_fk",
+ "tableFrom": "slack_bot_requests",
+ "tableTo": "platform_integrations",
+ "columnsFrom": [
+ "platform_integration_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "slack_bot_requests_owner_check": {
+ "name": "slack_bot_requests_owner_check",
+ "value": "(\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NOT NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NOT NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.source_embeddings": {
+ "name": "source_embeddings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "embedding": {
+ "name": "embedding",
+ "type": "vector(1536)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_path": {
+ "name": "file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_hash": {
+ "name": "file_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_line": {
+ "name": "start_line",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_line": {
+ "name": "end_line",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "git_branch": {
+ "name": "git_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "is_base_branch": {
+ "name": "is_base_branch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_source_embeddings_organization_id": {
+ "name": "IDX_source_embeddings_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_kilo_user_id": {
+ "name": "IDX_source_embeddings_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_project_id": {
+ "name": "IDX_source_embeddings_project_id",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_created_at": {
+ "name": "IDX_source_embeddings_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_updated_at": {
+ "name": "IDX_source_embeddings_updated_at",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_file_path_lower": {
+ "name": "IDX_source_embeddings_file_path_lower",
+ "columns": [
+ {
+ "expression": "LOWER(\"file_path\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_git_branch": {
+ "name": "IDX_source_embeddings_git_branch",
+ "columns": [
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_source_embeddings_org_project_branch": {
+ "name": "IDX_source_embeddings_org_project_branch",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "git_branch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "source_embeddings_organization_id_organizations_id_fk": {
+ "name": "source_embeddings_organization_id_organizations_id_fk",
+ "tableFrom": "source_embeddings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "source_embeddings_kilo_user_id_kilocode_users_id_fk": {
+ "name": "source_embeddings_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "source_embeddings",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_source_embeddings_org_project_branch_file_lines": {
+ "name": "UQ_source_embeddings_org_project_branch_file_lines",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "project_id",
+ "git_branch",
+ "file_path",
+ "start_line",
+ "end_line"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.stripe_dispute_actions": {
+ "name": "stripe_dispute_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "case_id": {
+ "name": "case_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_key": {
+ "name": "target_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_reference_id": {
+ "name": "result_reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_dispute_actions_case_id": {
+ "name": "IDX_stripe_dispute_actions_case_id",
+ "columns": [
+ {
+ "expression": "case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_actions_claim_path": {
+ "name": "IDX_stripe_dispute_actions_claim_path",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk": {
+ "name": "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk",
+ "tableFrom": "stripe_dispute_actions",
+ "tableTo": "stripe_dispute_cases",
+ "columnsFrom": [
+ "case_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_dispute_actions_case_type_target": {
+ "name": "UQ_stripe_dispute_actions_case_type_target",
+ "nullsNotDistinct": false,
+ "columns": [
+ "case_id",
+ "action_type",
+ "target_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_dispute_actions_action_type_check": {
+ "name": "stripe_dispute_actions_action_type_check",
+ "value": "\"stripe_dispute_actions\".\"action_type\" IN ('stripe_acceptance', 'user_block', 'auto_top_up_disable', 'credit_balance_reset', 'subscription_cancellation', 'access_termination', 'kiloclaw_suspension')"
+ },
+ "stripe_dispute_actions_status_check": {
+ "name": "stripe_dispute_actions_status_check",
+ "value": "\"stripe_dispute_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'skipped')"
+ },
+ "stripe_dispute_actions_attempt_count_non_negative_check": {
+ "name": "stripe_dispute_actions_attempt_count_non_negative_check",
+ "value": "\"stripe_dispute_actions\".\"attempt_count\" >= 0"
+ },
+ "stripe_dispute_actions_target_key_not_empty_check": {
+ "name": "stripe_dispute_actions_target_key_not_empty_check",
+ "value": "length(\"stripe_dispute_actions\".\"target_key\") > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_dispute_cases": {
+ "name": "stripe_dispute_cases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_dispute_id": {
+ "name": "stripe_dispute_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_event_created_at": {
+ "name": "stripe_event_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_intent_id": {
+ "name": "stripe_payment_intent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_minor_units": {
+ "name": "amount_minor_units",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dispute_reason": {
+ "name": "dispute_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_status": {
+ "name": "stripe_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_classification": {
+ "name": "owner_classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'needs_action'"
+ },
+ "status_reason": {
+ "name": "status_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_created_at": {
+ "name": "stripe_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence_due_by": {
+ "name": "evidence_due_by",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by_kilo_user_id": {
+ "name": "accepted_by_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "acceptance_started_at": {
+ "name": "acceptance_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enforcement_completed_at": {
+ "name": "enforcement_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_required_at": {
+ "name": "review_required_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_dispute_cases_event_id": {
+ "name": "IDX_stripe_dispute_cases_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_charge_id": {
+ "name": "IDX_stripe_dispute_cases_charge_id",
+ "columns": [
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_payment_intent_id": {
+ "name": "IDX_stripe_dispute_cases_payment_intent_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_intent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_customer_id": {
+ "name": "IDX_stripe_dispute_cases_customer_id",
+ "columns": [
+ {
+ "expression": "stripe_customer_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_kilo_user_id": {
+ "name": "IDX_stripe_dispute_cases_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_organization_id": {
+ "name": "IDX_stripe_dispute_cases_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_dispute_cases_status_due_by": {
+ "name": "IDX_stripe_dispute_cases_status_due_by",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "evidence_due_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stripe_created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_dispute_cases_organization_id_organizations_id_fk": {
+ "name": "stripe_dispute_cases_organization_id_organizations_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_dispute_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "accepted_by_kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_dispute_cases_dispute_id": {
+ "name": "UQ_stripe_dispute_cases_dispute_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_dispute_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_dispute_cases_owner_classification_check": {
+ "name": "stripe_dispute_cases_owner_classification_check",
+ "value": "\"stripe_dispute_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
+ },
+ "stripe_dispute_cases_status_check": {
+ "name": "stripe_dispute_cases_status_check",
+ "value": "\"stripe_dispute_cases\".\"status\" IN ('needs_action', 'processing', 'accepted', 'acceptance_failed', 'enforcement_failed', 'review_required', 'closed')"
+ },
+ "stripe_dispute_cases_amount_minor_units_non_negative_check": {
+ "name": "stripe_dispute_cases_amount_minor_units_non_negative_check",
+ "value": "\"stripe_dispute_cases\".\"amount_minor_units\" IS NULL OR \"stripe_dispute_cases\".\"amount_minor_units\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_early_fraud_warning_actions": {
+ "name": "stripe_early_fraud_warning_actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "case_id": {
+ "name": "case_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_type": {
+ "name": "action_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_key": {
+ "name": "target_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_code": {
+ "name": "result_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result_reference_id": {
+ "name": "result_reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_early_fraud_warning_actions_case_id": {
+ "name": "IDX_stripe_early_fraud_warning_actions_case_id",
+ "columns": [
+ {
+ "expression": "case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_actions_claim_path": {
+ "name": "IDX_stripe_early_fraud_warning_actions_claim_path",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk": {
+ "name": "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_actions",
+ "tableTo": "stripe_early_fraud_warning_cases",
+ "columnsFrom": [
+ "case_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_early_fraud_warning_actions_case_type_target": {
+ "name": "UQ_stripe_early_fraud_warning_actions_case_type_target",
+ "nullsNotDistinct": false,
+ "columns": [
+ "case_id",
+ "action_type",
+ "target_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_early_fraud_warning_actions_action_type_check": {
+ "name": "stripe_early_fraud_warning_actions_action_type_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"action_type\" IN ('containment', 'refund', 'payment_value_clawback', 'subscription_termination', 'access_termination', 'kiloclaw_suspension', 'affiliate_payout_reversal', 'referral_reward_reversal', 'user_notice')"
+ },
+ "stripe_early_fraud_warning_actions_status_check": {
+ "name": "stripe_early_fraud_warning_actions_status_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'review_required', 'dismissed')"
+ },
+ "stripe_early_fraud_warning_actions_attempt_count_non_negative_check": {
+ "name": "stripe_early_fraud_warning_actions_attempt_count_non_negative_check",
+ "value": "\"stripe_early_fraud_warning_actions\".\"attempt_count\" >= 0"
+ },
+ "stripe_early_fraud_warning_actions_target_key_not_empty_check": {
+ "name": "stripe_early_fraud_warning_actions_target_key_not_empty_check",
+ "value": "length(\"stripe_early_fraud_warning_actions\".\"target_key\") > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stripe_early_fraud_warning_cases": {
+ "name": "stripe_early_fraud_warning_cases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "stripe_early_fraud_warning_id": {
+ "name": "stripe_early_fraud_warning_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_event_id": {
+ "name": "stripe_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_payment_intent_id": {
+ "name": "stripe_payment_intent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stripe_customer_id": {
+ "name": "stripe_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "amount_minor_units": {
+ "name": "amount_minor_units",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_classification": {
+ "name": "owner_classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_context": {
+ "name": "failure_context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warning_created_at": {
+ "name": "warning_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contained_at": {
+ "name": "contained_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processing_started_at": {
+ "name": "processing_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_required_at": {
+ "name": "review_required_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remediated_at": {
+ "name": "remediated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dismissed_at": {
+ "name": "dismissed_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_stripe_early_fraud_warning_cases_event_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_event_id",
+ "columns": [
+ {
+ "expression": "stripe_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_charge_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_charge_id",
+ "columns": [
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_payment_intent_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_payment_intent_id",
+ "columns": [
+ {
+ "expression": "stripe_payment_intent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_customer_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_customer_id",
+ "columns": [
+ {
+ "expression": "stripe_customer_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_kilo_user_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_organization_id": {
+ "name": "IDX_stripe_early_fraud_warning_cases_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_stripe_early_fraud_warning_cases_status_created_at": {
+ "name": "IDX_stripe_early_fraud_warning_cases_status_created_at",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk": {
+ "name": "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_cases",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk": {
+ "name": "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk",
+ "tableFrom": "stripe_early_fraud_warning_cases",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_stripe_early_fraud_warning_cases_warning_id": {
+ "name": "UQ_stripe_early_fraud_warning_cases_warning_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "stripe_early_fraud_warning_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "stripe_early_fraud_warning_cases_owner_classification_check": {
+ "name": "stripe_early_fraud_warning_cases_owner_classification_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
+ },
+ "stripe_early_fraud_warning_cases_status_check": {
+ "name": "stripe_early_fraud_warning_cases_status_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"status\" IN ('queued', 'contained', 'processing', 'completed', 'review_required', 'failed', 'remediated', 'dismissed')"
+ },
+ "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check": {
+ "name": "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check",
+ "value": "\"stripe_early_fraud_warning_cases\".\"amount_minor_units\" IS NULL OR \"stripe_early_fraud_warning_cases\".\"amount_minor_units\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.stytch_fingerprints": {
+ "name": "stytch_fingerprints",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visitor_fingerprint": {
+ "name": "visitor_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "browser_fingerprint": {
+ "name": "browser_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "browser_id": {
+ "name": "browser_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hardware_fingerprint": {
+ "name": "hardware_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "network_fingerprint": {
+ "name": "network_fingerprint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visitor_id": {
+ "name": "visitor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verdict_action": {
+ "name": "verdict_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "detected_device_type": {
+ "name": "detected_device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_authentic_device": {
+ "name": "is_authentic_device",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reasons": {
+ "name": "reasons",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{\"\"}'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fingerprint_data": {
+ "name": "fingerprint_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_free_tier_allowed": {
+ "name": "kilo_free_tier_allowed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_hardware_fingerprint": {
+ "name": "idx_hardware_fingerprint",
+ "columns": [
+ {
+ "expression": "hardware_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_kilo_user_id": {
+ "name": "idx_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_stytch_fingerprints_reasons_gin": {
+ "name": "idx_stytch_fingerprints_reasons_gin",
+ "columns": [
+ {
+ "expression": "reasons",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ },
+ "idx_verdict_action": {
+ "name": "idx_verdict_action",
+ "columns": [
+ {
+ "expression": "verdict_action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_visitor_fingerprint": {
+ "name": "idx_visitor_fingerprint",
+ "columns": [
+ {
+ "expression": "visitor_fingerprint",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "schema": "",
+ "columns": {
+ "system_prompt_prefix_id": {
+ "name": "system_prompt_prefix_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_system_prompt_prefix": {
+ "name": "UQ_system_prompt_prefix",
+ "columns": [
+ {
+ "expression": "system_prompt_prefix",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.transactional_email_log": {
+ "name": "transactional_email_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_type": {
+ "name": "email_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_transactional_email_log_type_idempotency_key": {
+ "name": "UQ_transactional_email_log_type_idempotency_key",
+ "columns": [
+ {
+ "expression": "email_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_transactional_email_log_user_id": {
+ "name": "IDX_transactional_email_log_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_transactional_email_log_organization_id": {
+ "name": "IDX_transactional_email_log_organization_id",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "transactional_email_log_user_id_kilocode_users_id_fk": {
+ "name": "transactional_email_log_user_id_kilocode_users_id_fk",
+ "tableFrom": "transactional_email_log",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "transactional_email_log_organization_id_organizations_id_fk": {
+ "name": "transactional_email_log_organization_id_organizations_id_fk",
+ "tableFrom": "transactional_email_log",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "CHK_transactional_email_log_owner": {
+ "name": "CHK_transactional_email_log_owner",
+ "value": "\"transactional_email_log\".\"user_id\" IS NOT NULL OR \"transactional_email_log\".\"organization_id\" IS NOT NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_admin_notes": {
+ "name": "user_admin_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note_content": {
+ "name": "note_content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "admin_kilo_user_id": {
+ "name": "admin_kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_34517df0b385234babc38fe81b": {
+ "name": "IDX_34517df0b385234babc38fe81b",
+ "columns": [
+ {
+ "expression": "admin_kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_ccbde98c4c14046daa5682ec4f": {
+ "name": "IDX_ccbde98c4c14046daa5682ec4f",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_d0270eb24ef6442d65a0b7853c": {
+ "name": "IDX_d0270eb24ef6442d65a0b7853c",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_affiliate_attributions": {
+ "name": "user_affiliate_attributions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tracking_id": {
+ "name": "tracking_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_affiliate_attributions_user_id": {
+ "name": "IDX_user_affiliate_attributions_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_affiliate_attributions_user_id_kilocode_users_id_fk": {
+ "name": "user_affiliate_attributions_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_affiliate_attributions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_user_affiliate_attributions_user_provider": {
+ "name": "UQ_user_affiliate_attributions_user_provider",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "provider"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "user_affiliate_attributions_provider_check": {
+ "name": "user_affiliate_attributions_provider_check",
+ "value": "\"user_affiliate_attributions\".\"provider\" IN ('impact')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_affiliate_events": {
+ "name": "user_affiliate_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_event_id": {
+ "name": "parent_event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delivery_state": {
+ "name": "delivery_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "payload_json": {
+ "name": "payload_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stripe_charge_id": {
+ "name": "stripe_charge_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_action_id": {
+ "name": "impact_action_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_submission_uri": {
+ "name": "impact_submission_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempt_count": {
+ "name": "attempt_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_retry_at": {
+ "name": "next_retry_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_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": {
+ "IDX_user_affiliate_events_claim_path": {
+ "name": "IDX_user_affiliate_events_claim_path",
+ "columns": [
+ {
+ "expression": "delivery_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_affiliate_events_parent_event_id": {
+ "name": "IDX_user_affiliate_events_parent_event_id",
+ "columns": [
+ {
+ "expression": "parent_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_affiliate_events_provider_event_type_charge": {
+ "name": "IDX_user_affiliate_events_provider_event_type_charge",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "stripe_charge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_affiliate_events_user_id_kilocode_users_id_fk": {
+ "name": "user_affiliate_events_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_affiliate_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_affiliate_events_parent_event_id_fk": {
+ "name": "user_affiliate_events_parent_event_id_fk",
+ "tableFrom": "user_affiliate_events",
+ "tableTo": "user_affiliate_events",
+ "columnsFrom": [
+ "parent_event_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_user_affiliate_events_dedupe_key": {
+ "name": "UQ_user_affiliate_events_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "user_affiliate_events_provider_check": {
+ "name": "user_affiliate_events_provider_check",
+ "value": "\"user_affiliate_events\".\"provider\" IN ('impact')"
+ },
+ "user_affiliate_events_event_type_check": {
+ "name": "user_affiliate_events_event_type_check",
+ "value": "\"user_affiliate_events\".\"event_type\" IN ('signup', 'trial_start', 'trial_end', 'sale', 'sale_reversal')"
+ },
+ "user_affiliate_events_delivery_state_check": {
+ "name": "user_affiliate_events_delivery_state_check",
+ "value": "\"user_affiliate_events\".\"delivery_state\" IN ('queued', 'blocked', 'sending', 'delivered', 'failed')"
+ },
+ "user_affiliate_events_attempt_count_non_negative_check": {
+ "name": "user_affiliate_events_attempt_count_non_negative_check",
+ "value": "\"user_affiliate_events\".\"attempt_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_auth_provider": {
+ "name": "user_auth_provider",
+ "schema": "",
+ "columns": {
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_account_id": {
+ "name": "provider_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hosted_domain": {
+ "name": "hosted_domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_auth_provider_kilo_user_id": {
+ "name": "IDX_user_auth_provider_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_auth_provider_hosted_domain": {
+ "name": "IDX_user_auth_provider_hosted_domain",
+ "columns": [
+ {
+ "expression": "hosted_domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "user_auth_provider_provider_provider_account_id_pk": {
+ "name": "user_auth_provider_provider_provider_account_id_pk",
+ "columns": [
+ "provider",
+ "provider_account_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feedback": {
+ "name": "user_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_text": {
+ "name": "feedback_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feedback_for": {
+ "name": "feedback_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "feedback_batch": {
+ "name": "feedback_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "context_json": {
+ "name": "context_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_user_feedback_created_at": {
+ "name": "IDX_user_feedback_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_kilo_user_id": {
+ "name": "IDX_user_feedback_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_feedback_for": {
+ "name": "IDX_user_feedback_feedback_for",
+ "columns": [
+ {
+ "expression": "feedback_for",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_feedback_batch": {
+ "name": "IDX_user_feedback_feedback_batch",
+ "columns": [
+ {
+ "expression": "feedback_batch",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_feedback_source": {
+ "name": "IDX_user_feedback_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feedback_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_feedback_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_feedback",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_github_app_tokens": {
+ "name": "user_github_app_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_app_type": {
+ "name": "github_app_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'standard'"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_encrypted": {
+ "name": "access_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_encrypted": {
+ "name": "refresh_token_encrypted",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_version": {
+ "name": "credential_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revocation_reason": {
+ "name": "revocation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_user_github_app_tokens_user_app": {
+ "name": "UQ_user_github_app_tokens_user_app",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "github_app_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_github_app_tokens_github_user_app": {
+ "name": "UQ_user_github_app_tokens_github_user_app",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "github_app_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_github_app_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_github_app_tokens_app_type_check": {
+ "name": "user_github_app_tokens_app_type_check",
+ "value": "\"user_github_app_tokens\".\"github_app_type\" IN ('standard', 'lite')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_period_cache": {
+ "name": "user_period_cache",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_type": {
+ "name": "cache_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_type": {
+ "name": "period_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_key": {
+ "name": "period_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "computed_at": {
+ "name": "computed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "shared_url_token": {
+ "name": "shared_url_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "shared_at": {
+ "name": "shared_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "IDX_user_period_cache_kilo_user_id": {
+ "name": "IDX_user_period_cache_kilo_user_id",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_period_cache": {
+ "name": "UQ_user_period_cache",
+ "columns": [
+ {
+ "expression": "kilo_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "cache_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_period_cache_lookup": {
+ "name": "IDX_user_period_cache_lookup",
+ "columns": [
+ {
+ "expression": "cache_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "period_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "UQ_user_period_cache_share_token": {
+ "name": "UQ_user_period_cache_share_token",
+ "columns": [
+ {
+ "expression": "shared_url_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_period_cache\".\"shared_url_token\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_period_cache_kilo_user_id_kilocode_users_id_fk": {
+ "name": "user_period_cache_kilo_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_period_cache",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "kilo_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_period_cache_period_type_check": {
+ "name": "user_period_cache_period_type_check",
+ "value": "\"user_period_cache\".\"period_type\" IN ('year', 'quarter', 'month', 'week', 'custom')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_push_tokens": {
+ "name": "user_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "UQ_user_push_tokens_token": {
+ "name": "UQ_user_push_tokens_token",
+ "columns": [
+ {
+ "expression": "token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_user_push_tokens_user_id": {
+ "name": "IDX_user_push_tokens_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_push_tokens_user_id_kilocode_users_id_fk": {
+ "name": "user_push_tokens_user_id_kilocode_users_id_fk",
+ "tableFrom": "user_push_tokens",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.vercel_ip_city": {
+ "name": "vercel_ip_city",
+ "schema": "",
+ "columns": {
+ "vercel_ip_city_id": {
+ "name": "vercel_ip_city_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "vercel_ip_city": {
+ "name": "vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_vercel_ip_city": {
+ "name": "UQ_vercel_ip_city",
+ "columns": [
+ {
+ "expression": "vercel_ip_city",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.vercel_ip_country": {
+ "name": "vercel_ip_country",
+ "schema": "",
+ "columns": {
+ "vercel_ip_country_id": {
+ "name": "vercel_ip_country_id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "vercel_ip_country": {
+ "name": "vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "UQ_vercel_ip_country": {
+ "name": "UQ_vercel_ip_country",
+ "columns": [
+ {
+ "expression": "vercel_ip_country",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook_events": {
+ "name": "webhook_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "owned_by_organization_id": {
+ "name": "owned_by_organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owned_by_user_id": {
+ "name": "owned_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_action": {
+ "name": "event_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "headers": {
+ "name": "headers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "processed": {
+ "name": "processed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "handlers_triggered": {
+ "name": "handlers_triggered",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "errors": {
+ "name": "errors",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_signature": {
+ "name": "event_signature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "IDX_webhook_events_owned_by_org_id": {
+ "name": "IDX_webhook_events_owned_by_org_id",
+ "columns": [
+ {
+ "expression": "owned_by_organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_owned_by_user_id": {
+ "name": "IDX_webhook_events_owned_by_user_id",
+ "columns": [
+ {
+ "expression": "owned_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_platform": {
+ "name": "IDX_webhook_events_platform",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_event_type": {
+ "name": "IDX_webhook_events_event_type",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_webhook_events_created_at": {
+ "name": "IDX_webhook_events_created_at",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_events_owned_by_organization_id_organizations_id_fk": {
+ "name": "webhook_events_owned_by_organization_id_organizations_id_fk",
+ "tableFrom": "webhook_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "owned_by_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "webhook_events_owned_by_user_id_kilocode_users_id_fk": {
+ "name": "webhook_events_owned_by_user_id_kilocode_users_id_fk",
+ "tableFrom": "webhook_events",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "owned_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_webhook_events_signature": {
+ "name": "UQ_webhook_events_signature",
+ "nullsNotDistinct": false,
+ "columns": [
+ "event_signature"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "webhook_events_owner_check": {
+ "name": "webhook_events_owner_check",
+ "value": "(\n (\"webhook_events\".\"owned_by_user_id\" IS NOT NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"webhook_events\".\"owned_by_user_id\" IS NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
+ }
+ },
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {
+ "public.microdollar_usage_view": {
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kilo_user_id": {
+ "name": "kilo_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_write_tokens": {
+ "name": "cache_write_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_hit_tokens": {
+ "name": "cache_hit_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "http_x_forwarded_for": {
+ "name": "http_x_forwarded_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_city": {
+ "name": "http_x_vercel_ip_city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_country": {
+ "name": "http_x_vercel_ip_country",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_latitude": {
+ "name": "http_x_vercel_ip_latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ip_longitude": {
+ "name": "http_x_vercel_ip_longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_x_vercel_ja4_digest": {
+ "name": "http_x_vercel_ja4_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_model": {
+ "name": "requested_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_prompt_prefix": {
+ "name": "user_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_prefix": {
+ "name": "system_prompt_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_prompt_length": {
+ "name": "system_prompt_length",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "http_user_agent": {
+ "name": "http_user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_discount": {
+ "name": "cache_discount",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_tokens": {
+ "name": "max_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_middle_out_transform": {
+ "name": "has_middle_out_transform",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_error": {
+ "name": "has_error",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "abuse_classification": {
+ "name": "abuse_classification",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_provider": {
+ "name": "inference_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "upstream_id": {
+ "name": "upstream_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finish_reason": {
+ "name": "finish_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency": {
+ "name": "latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderation_latency": {
+ "name": "moderation_latency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_time": {
+ "name": "generation_time",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_byok": {
+ "name": "is_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_user_byok": {
+ "name": "is_user_byok",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "streamed": {
+ "name": "streamed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled": {
+ "name": "cancelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_name": {
+ "name": "editor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_kind": {
+ "name": "api_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_tools": {
+ "name": "has_tools",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "machine_id": {
+ "name": "machine_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auto_model": {
+ "name": "auto_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_cost": {
+ "name": "market_cost",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_free": {
+ "name": "is_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_delay": {
+ "name": "abuse_delay",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abuse_downgraded_from": {
+ "name": "abuse_downgraded_from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "definition": "\n SELECT\n mu.id,\n mu.kilo_user_id,\n meta.message_id,\n mu.cost,\n mu.input_tokens,\n mu.output_tokens,\n mu.cache_write_tokens,\n mu.cache_hit_tokens,\n mu.created_at,\n ip.http_ip AS http_x_forwarded_for,\n city.vercel_ip_city AS http_x_vercel_ip_city,\n country.vercel_ip_country AS http_x_vercel_ip_country,\n meta.vercel_ip_latitude AS http_x_vercel_ip_latitude,\n meta.vercel_ip_longitude AS http_x_vercel_ip_longitude,\n ja4.ja4_digest AS http_x_vercel_ja4_digest,\n mu.provider,\n mu.model,\n mu.requested_model,\n meta.user_prompt_prefix,\n spp.system_prompt_prefix,\n meta.system_prompt_length,\n ua.http_user_agent,\n mu.cache_discount,\n meta.max_tokens,\n meta.has_middle_out_transform,\n mu.has_error,\n mu.abuse_classification,\n mu.organization_id,\n mu.inference_provider,\n mu.project_id,\n meta.status_code,\n meta.upstream_id,\n frfr.finish_reason,\n meta.latency,\n meta.moderation_latency,\n meta.generation_time,\n meta.is_byok,\n meta.is_user_byok,\n meta.streamed,\n meta.cancelled,\n edit.editor_name,\n ak.api_kind,\n meta.has_tools,\n meta.machine_id,\n feat.feature,\n meta.session_id,\n md.mode,\n am.auto_model,\n meta.market_cost,\n meta.is_free,\n meta.abuse_delay,\n meta.abuse_downgraded_from\n FROM \"microdollar_usage\" mu\n LEFT JOIN \"microdollar_usage_metadata\" meta ON mu.id = meta.id\n LEFT JOIN \"http_ip\" ip ON meta.http_ip_id = ip.http_ip_id\n LEFT JOIN \"vercel_ip_city\" city ON meta.vercel_ip_city_id = city.vercel_ip_city_id\n LEFT JOIN \"vercel_ip_country\" country ON meta.vercel_ip_country_id = country.vercel_ip_country_id\n LEFT JOIN \"ja4_digest\" ja4 ON meta.ja4_digest_id = ja4.ja4_digest_id\n LEFT JOIN \"system_prompt_prefix\" spp ON meta.system_prompt_prefix_id = spp.system_prompt_prefix_id\n LEFT JOIN \"http_user_agent\" ua ON meta.http_user_agent_id = ua.http_user_agent_id\n LEFT JOIN \"finish_reason\" frfr ON meta.finish_reason_id = frfr.finish_reason_id\n LEFT JOIN \"editor_name\" edit ON meta.editor_name_id = edit.editor_name_id\n LEFT JOIN \"api_kind\" ak ON meta.api_kind_id = ak.api_kind_id\n LEFT JOIN \"feature\" feat ON meta.feature_id = feat.feature_id\n LEFT JOIN \"mode\" md ON meta.mode_id = md.mode_id\n LEFT JOIN \"auto_model\" am ON meta.auto_model_id = am.auto_model_id\n",
+ "name": "microdollar_usage_view",
+ "schema": "public",
+ "isExisting": false,
+ "materialized": false
+ }
+ },
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.json
index ca0632c955..bda7265b50 100644
--- a/packages/db/src/migrations/meta/_journal.json
+++ b/packages/db/src/migrations/meta/_journal.json
@@ -1226,6 +1226,13 @@
"when": 1782402944684,
"tag": "0174_omniscient_tenebrous",
"breakpoints": true
+ },
+ {
+ "idx": 175,
+ "version": "7",
+ "when": 1782407182910,
+ "tag": "0175_aspiring_omega_flight",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts
index bfb957e643..37592f941b 100644
--- a/packages/db/src/schema.ts
+++ b/packages/db/src/schema.ts
@@ -2660,6 +2660,10 @@ export const organizations = pgTable(
},
table => [
check('organizations_name_not_empty_check', sql`length(trim(${table.name})) > 0`),
+ check(
+ 'organizations_slug_max_length_check',
+ sql`${table.slug} IS NULL OR length(${table.slug}) <= 32`
+ ),
check(
'organizations_not_parented_by_self_check',
sql`${table.parent_organization_id} IS NULL OR ${table.parent_organization_id} <> ${table.id}`
From 7e2b438d1de7e24e0a3fecf9e38bfffab8897b89 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 12:28:04 -0500
Subject: [PATCH 08/33] Enforce org slug max length + Add resolution helper in
the code
---
.../organization-route-utils.test.ts | 19 +++++++++++++++++++
.../organizations/organization-route-utils.ts | 12 ++++++++++++
.../organizations/organization-router.ts | 6 +++++-
3 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 apps/web/src/lib/organizations/organization-route-utils.test.ts
create mode 100644 apps/web/src/lib/organizations/organization-route-utils.ts
diff --git a/apps/web/src/lib/organizations/organization-route-utils.test.ts b/apps/web/src/lib/organizations/organization-route-utils.test.ts
new file mode 100644
index 0000000000..d17b4a5193
--- /dev/null
+++ b/apps/web/src/lib/organizations/organization-route-utils.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from '@jest/globals';
+import {
+ getOrganizationRouteIdentifier,
+ ORGANIZATION_SLUG_MAX_LENGTH,
+} from './organization-route-utils';
+
+describe('getOrganizationRouteIdentifier', () => {
+ it('uses the slug when one exists', () => {
+ expect(getOrganizationRouteIdentifier({ id: 'org-id', slug: 'acme' })).toBe('acme');
+ });
+
+ it('falls back to the organization id when no slug exists', () => {
+ expect(getOrganizationRouteIdentifier({ id: 'org-id', slug: null })).toBe('org-id');
+ });
+
+ it('exports the organization slug route length', () => {
+ expect(ORGANIZATION_SLUG_MAX_LENGTH).toBe(32);
+ });
+});
diff --git a/apps/web/src/lib/organizations/organization-route-utils.ts b/apps/web/src/lib/organizations/organization-route-utils.ts
new file mode 100644
index 0000000000..f47498bfdc
--- /dev/null
+++ b/apps/web/src/lib/organizations/organization-route-utils.ts
@@ -0,0 +1,12 @@
+export const ORGANIZATION_SLUG_MAX_LENGTH = 32;
+
+export type OrganizationRouteIdentifierInput = {
+ id: string;
+ slug: string | null;
+};
+
+export function getOrganizationRouteIdentifier(
+ organization: OrganizationRouteIdentifierInput
+): string {
+ return organization.slug ?? organization.id;
+}
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index b8246fb4c5..cc4a3c710f 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -64,6 +64,7 @@ import { organizationAutoFixRouter } from '@/routers/organizations/organization-
import { organizationAutoTopUpRouter } from '@/routers/organizations/organization-auto-top-up-router';
import { organizationKiloclawRouter } from '@/routers/organizations/organization-kiloclaw-router';
import { organizationBitbucketRouter } from '@/routers/organizations/organization-bitbucket-router';
+import { ORGANIZATION_SLUG_MAX_LENGTH } from '@/lib/organizations/organization-route-utils';
const OrganizationUpdateSchema = OrganizationIdInputSchema.extend({
name: OrganizationNameSchema,
@@ -73,7 +74,10 @@ const OrganizationSlugSchema = z
.string()
.trim()
.min(1, 'Organization slug is required')
- .max(100, 'Organization slug must be less than 100 characters')
+ .max(
+ ORGANIZATION_SLUG_MAX_LENGTH,
+ `Organization slug must be less than ${ORGANIZATION_SLUG_MAX_LENGTH} characters`
+ )
.regex(
/^[a-z0-9][a-z0-9-]*$/,
'Organization slug must use lowercase letters, numbers, and hyphens'
From ce83454e9a14491b5fce4c43e7828308be915955 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 14:12:36 -0500
Subject: [PATCH 09/33] Org slugs resolve in url (init)
---
.../components/OrganizationAppSidebar.tsx | 67 +++++++++++--------
.../(app)/components/OrganizationSwitcher.tsx | 17 +++--
.../api/organizations/[id]/models/route.ts | 8 ++-
.../[id]/models/validate/route.ts | 7 +-
.../src/app/api/organizations/[id]/route.ts | 9 ++-
.../organizations/[id]/user-tokens/route.ts | 5 +-
.../OrganizationByPageLayout.tsx | 16 +++++
.../OrganizationChildOrganizationsCard.tsx | 3 +-
.../organizations/OrganizationInfoCard.tsx | 10 ++-
.../organizations/OrganizationMembersCard.tsx | 7 +-
.../lib/organizations/organization-auth.ts | 17 +++--
.../organization-route-utils.server.ts | 49 ++++++++++++++
.../organization-route-utils.test.ts | 62 ++++++++++++++++-
.../lib/organizations/organization-types.ts | 2 +
.../src/lib/organizations/organizations.ts | 1 +
.../organizations/organization-router.ts | 10 ++-
16 files changed, 239 insertions(+), 51 deletions(-)
create mode 100644 apps/web/src/lib/organizations/organization-route-utils.server.ts
diff --git a/apps/web/src/app/(app)/components/OrganizationAppSidebar.tsx b/apps/web/src/app/(app)/components/OrganizationAppSidebar.tsx
index ae45076ae7..8c7fbd5de7 100644
--- a/apps/web/src/app/(app)/components/OrganizationAppSidebar.tsx
+++ b/apps/web/src/app/(app)/components/OrganizationAppSidebar.tsx
@@ -39,6 +39,7 @@ import SidebarMenuList from './SidebarMenuList';
import SidebarUserFooter from './SidebarUserFooter';
import { ENABLE_DEPLOY_FEATURE } from '@/lib/constants';
import { useFeatureFlagEnabled } from 'posthog-js/react';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
type OrganizationAppSidebarProps = React.ComponentProps & {
organizationId: string;
@@ -62,6 +63,9 @@ export default function OrganizationAppSidebar({
// Get current organization role and data
const currentOrg = organizationData;
+ const organizationRouteIdentifier = currentOrg
+ ? getOrganizationRouteIdentifier(currentOrg)
+ : organizationId;
const actualRole =
currentOrg?.members.find(member => {
if (member.status !== 'active') return false;
@@ -111,19 +115,19 @@ export default function OrganizationAppSidebar({
{
title: 'Welcome',
icon: Sparkles,
- url: `/organizations/${organizationId}/welcome`,
+ url: `/organizations/${organizationRouteIdentifier}/welcome`,
},
]
: []),
{
title: 'Organization',
icon: Building,
- url: `/organizations/${organizationId}`,
+ url: `/organizations/${organizationRouteIdentifier}`,
},
{
title: 'Usage',
icon: ChartColumnIncreasing,
- url: `/organizations/${organizationId}/usage-details`,
+ url: `/organizations/${organizationRouteIdentifier}/usage-details`,
},
];
@@ -139,7 +143,7 @@ export default function OrganizationAppSidebar({
{
title: 'Chat',
icon: MessageSquare,
- url: `/organizations/${organizationId}/claw/chat`,
+ url: `/organizations/${organizationRouteIdentifier}/claw/chat`,
},
// Agent management is admin-only for now.
...(user?.is_admin
@@ -147,19 +151,19 @@ export default function OrganizationAppSidebar({
{
title: 'Agents',
icon: Bot,
- url: `/organizations/${organizationId}/claw/agents`,
+ url: `/organizations/${organizationRouteIdentifier}/claw/agents`,
},
]
: []),
{
title: 'Settings',
icon: Settings,
- url: `/organizations/${organizationId}/claw/settings`,
+ url: `/organizations/${organizationRouteIdentifier}/claw/settings`,
},
{
title: "What's New",
icon: Sparkles,
- url: `/organizations/${organizationId}/claw/changelog`,
+ url: `/organizations/${organizationRouteIdentifier}/claw/changelog`,
},
];
@@ -175,24 +179,24 @@ export default function OrganizationAppSidebar({
{
title: 'App Builder',
icon: Plus,
- url: `/organizations/${organizationId}/app-builder`,
+ url: `/organizations/${organizationRouteIdentifier}/app-builder`,
},
]
: []),
{
title: 'Cloud Agent',
icon: Cloud,
- url: `/organizations/${organizationId}/cloud`,
+ url: `/organizations/${organizationRouteIdentifier}/cloud`,
},
{
title: 'Sessions',
icon: List,
- url: `/organizations/${organizationId}/cloud/sessions`,
+ url: `/organizations/${organizationRouteIdentifier}/cloud/sessions`,
},
{
title: 'Webhooks / Triggers',
icon: Webhook,
- url: `/organizations/${organizationId}/cloud/triggers`,
+ url: `/organizations/${organizationRouteIdentifier}/cloud/triggers`,
},
// Gastown requires non-billing_manager role; hide for billing-only users
...(currentRole !== 'billing_manager'
@@ -200,28 +204,32 @@ export default function OrganizationAppSidebar({
{
title: 'Gas Town',
icon: Bot,
- url: `/organizations/${organizationId}/gastown`,
+ url: `/organizations/${organizationRouteIdentifier}/gastown`,
},
]
: []),
{
title: 'Code Reviewer',
icon: Bot,
- url: `/organizations/${organizationId}/code-reviews`,
+ url: `/organizations/${organizationRouteIdentifier}/code-reviews`,
},
{
title: 'Security Agent',
icon: Shield,
- url: `/organizations/${organizationId}/security-agent`,
+ url: `/organizations/${organizationRouteIdentifier}/security-agent`,
},
...(isAutoTriageFeatureEnabled || isDevelopment
? [
{
title: 'Auto Triage',
icon: ListChecks,
- url: `/organizations/${organizationId}/auto-triage`,
+ url: `/organizations/${organizationRouteIdentifier}/auto-triage`,
+ },
+ {
+ title: 'Auto Fix',
+ icon: Wrench,
+ url: `/organizations/${organizationRouteIdentifier}/auto-fix`,
},
- { title: 'Auto Fix', icon: Wrench, url: `/organizations/${organizationId}/auto-fix` },
]
: []),
...(ENABLE_DEPLOY_FEATURE
@@ -229,7 +237,7 @@ export default function OrganizationAppSidebar({
{
title: 'Deploy',
icon: Rocket,
- url: `/organizations/${organizationId}/deploy`,
+ url: `/organizations/${organizationRouteIdentifier}/deploy`,
},
]
: []),
@@ -238,7 +246,7 @@ export default function OrganizationAppSidebar({
{
title: 'Managed Indexing',
icon: Database,
- url: `/organizations/${organizationId}/code-indexing`,
+ url: `/organizations/${organizationRouteIdentifier}/code-indexing`,
},
]
: []),
@@ -247,7 +255,7 @@ export default function OrganizationAppSidebar({
{
title: 'MCP Gateway',
icon: Cable,
- url: `/organizations/${organizationId}/cloud/mcp-gateway`,
+ url: `/organizations/${organizationRouteIdentifier}/cloud/mcp-gateway`,
},
]
: []),
@@ -265,7 +273,7 @@ export default function OrganizationAppSidebar({
{
title: 'Subscriptions',
icon: Users,
- url: `/organizations/${organizationId}/subscriptions`,
+ url: `/organizations/${organizationRouteIdentifier}/subscriptions`,
},
]
: []),
@@ -274,7 +282,7 @@ export default function OrganizationAppSidebar({
{
title: 'Integrations',
icon: Cable,
- url: `/organizations/${organizationId}/integrations`,
+ url: `/organizations/${organizationRouteIdentifier}/integrations`,
},
]
: []),
@@ -283,21 +291,21 @@ export default function OrganizationAppSidebar({
{
title: 'Model Access',
icon: Layers,
- url: `/organizations/${organizationId}/providers-and-models`,
+ url: `/organizations/${organizationRouteIdentifier}/providers-and-models`,
},
]
: []),
{
title: 'Custom Modes',
icon: Sliders,
- url: `/organizations/${organizationId}/custom-modes`,
+ url: `/organizations/${organizationRouteIdentifier}/custom-modes`,
},
...(hasOwnerLevelAccess && currentOrg?.plan === 'enterprise'
? [
{
title: 'Audit Logs',
icon: Activity,
- url: `/organizations/${organizationId}/audit-logs`,
+ url: `/organizations/${organizationRouteIdentifier}/audit-logs`,
},
]
: []),
@@ -306,25 +314,28 @@ export default function OrganizationAppSidebar({
{
title: 'Invoices',
icon: CreditCard,
- url: `/organizations/${organizationId}/payment-details`,
+ url: `/organizations/${organizationRouteIdentifier}/payment-details`,
},
{
title: 'Bring Your Own Key (BYOK)',
icon: Key,
- url: `/organizations/${organizationId}/byok`,
+ url: `/organizations/${organizationRouteIdentifier}/byok`,
},
]
: []),
];
- const kiloClawBaseUrl = `/organizations/${organizationId}/claw`;
+ const kiloClawBaseUrl = `/organizations/${organizationRouteIdentifier}/claw`;
+ const kiloClawCanonicalBaseUrl = `/organizations/${organizationId}/claw`;
const kiloClawInstanceState = kiloClawNavStateQuery.isSuccess
? kiloClawNavStateQuery.data.hasActiveInstance
? 'present'
: 'absent'
: 'unknown';
const hasKiloClawInstance = kiloClawInstanceState === 'present';
- const isKiloClawPath = pathname === kiloClawBaseUrl || pathname.startsWith(kiloClawBaseUrl + '/');
+ const isKiloClawPath = [kiloClawBaseUrl, kiloClawCanonicalBaseUrl].some(
+ basePath => pathname === basePath || pathname.startsWith(basePath + '/')
+ );
const [sidebarMenu, setSidebarMenu] = useState<'main' | 'kiloClaw'>(
isKiloClawPath && hasKiloClawInstance ? 'kiloClaw' : 'main'
);
diff --git a/apps/web/src/app/(app)/components/OrganizationSwitcher.tsx b/apps/web/src/app/(app)/components/OrganizationSwitcher.tsx
index 0a4c6eeca4..fd834a6a13 100644
--- a/apps/web/src/app/(app)/components/OrganizationSwitcher.tsx
+++ b/apps/web/src/app/(app)/components/OrganizationSwitcher.tsx
@@ -14,6 +14,7 @@ import { cn } from '@/lib/utils';
import { Check, ChevronDown } from 'lucide-react';
import { useQuery } from '@tanstack/react-query';
import { useRouter } from 'next/navigation';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
type OrganizationSwitcherProps = {
organizationId?: string | null;
@@ -21,6 +22,7 @@ type OrganizationSwitcherProps = {
export type OrganizationSwitcherOrganization = {
organizationId: string;
+ organizationSlug: string | null;
organizationName: string;
role: string;
};
@@ -29,7 +31,7 @@ type OrganizationSwitcherViewProps = {
organizationId?: string | null;
organizations?: OrganizationSwitcherOrganization[];
isPending?: boolean;
- onOrganizationSwitch: (organizationId: string | null) => void;
+ onOrganizationSwitch: (organization: OrganizationSwitcherOrganization | null) => void;
};
const triggerClassName =
@@ -58,9 +60,14 @@ export default function OrganizationSwitcher({ organizationId = null }: Organiza
})
);
- const handleOrganizationSwitch = (orgId: string | null) => {
- if (orgId) {
- router.push(`/organizations/${orgId}`);
+ const handleOrganizationSwitch = (organization: OrganizationSwitcherOrganization | null) => {
+ if (organization) {
+ router.push(
+ `/organizations/${getOrganizationRouteIdentifier({
+ id: organization.organizationId,
+ slug: organization.organizationSlug,
+ })}`
+ );
} else {
router.push('/profile');
}
@@ -142,7 +149,7 @@ export function OrganizationSwitcherView({
{organizations.map(org => (
onOrganizationSwitch(org.organizationId)}
+ onClick={() => onOrganizationSwitch(org)}
className={cn(
menuItemClassName,
organizationId === org.organizationId && selectedMenuItemClassName
diff --git a/apps/web/src/app/api/organizations/[id]/models/route.ts b/apps/web/src/app/api/organizations/[id]/models/route.ts
index 1a47cf6ba5..c4c50a95fd 100644
--- a/apps/web/src/app/api/organizations/[id]/models/route.ts
+++ b/apps/web/src/app/api/organizations/[id]/models/route.ts
@@ -1,11 +1,17 @@
import type { NextRequest } from 'next/server';
+import { NextResponse } from 'next/server';
import type { OpenRouterModelsResponse } from '@/lib/organizations/organization-types';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
import { FEATURE_HEADER, validateFeatureHeader } from '@/lib/feature-detection';
import { filterByFeature } from '@/lib/ai-gateway/models';
+import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
- const organizationId = (await params).id;
+ const routeIdentifier = (await params).id;
+ const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
+ if (!organizationId) {
+ return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
+ }
const feature = validateFeatureHeader(request.headers.get(FEATURE_HEADER));
return handleTRPCRequest(request, async caller => {
diff --git a/apps/web/src/app/api/organizations/[id]/models/validate/route.ts b/apps/web/src/app/api/organizations/[id]/models/validate/route.ts
index cb4dc1e42e..1668a302b7 100644
--- a/apps/web/src/app/api/organizations/[id]/models/validate/route.ts
+++ b/apps/web/src/app/api/organizations/[id]/models/validate/route.ts
@@ -4,6 +4,7 @@ import * as z from 'zod';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
import { FEATURE_HEADER, validateFeatureHeader } from '@/lib/feature-detection';
import { filterByFeature } from '@/lib/ai-gateway/models';
+import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
const BodySchema = z.object({ modelId: z.string().trim().min(1) });
@@ -28,7 +29,11 @@ export async function POST(
);
}
- const organizationId = (await params).id;
+ const routeIdentifier = (await params).id;
+ const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
+ if (!organizationId) {
+ return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
+ }
const feature = validateFeatureHeader(request.headers.get(FEATURE_HEADER));
return handleTRPCRequest(request, async caller => {
diff --git a/apps/web/src/app/api/organizations/[id]/route.ts b/apps/web/src/app/api/organizations/[id]/route.ts
index 1d66fa0e90..6cd0dcc39e 100644
--- a/apps/web/src/app/api/organizations/[id]/route.ts
+++ b/apps/web/src/app/api/organizations/[id]/route.ts
@@ -1,8 +1,15 @@
import type { NextRequest } from 'next/server';
+import { NextResponse } from 'next/server';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
+import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
- const organizationId = (await params).id;
+ const routeIdentifier = (await params).id;
+ const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
+
+ if (!organizationId) {
+ return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
+ }
return handleTRPCRequest(request, async caller => {
const org = await caller.organizations.withMembers({ organizationId });
diff --git a/apps/web/src/app/api/organizations/[id]/user-tokens/route.ts b/apps/web/src/app/api/organizations/[id]/user-tokens/route.ts
index a64d1a617f..d4bc931ac5 100644
--- a/apps/web/src/app/api/organizations/[id]/user-tokens/route.ts
+++ b/apps/web/src/app/api/organizations/[id]/user-tokens/route.ts
@@ -5,16 +5,17 @@ import { generateOrganizationApiToken } from '@/lib/tokens';
import { createAuditLog } from '@/lib/organizations/organization-audit-logs';
export async function POST(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
- const organizationId = (await params).id;
+ const routeIdentifier = (await params).id;
// Verify user has access to the organization (any member role is sufficient)
- const result = await getAuthorizedOrgContext(organizationId);
+ const result = await getAuthorizedOrgContext(routeIdentifier);
if (!result.success) {
return result.nextResponse;
}
const { user, organization } = result.data;
+ const organizationId = organization.id;
// Generate the organization-scoped JWT token (15 minute expiration)
const { token, expiresAt } = generateOrganizationApiToken(user, organizationId, user.role);
diff --git a/apps/web/src/components/organizations/OrganizationByPageLayout.tsx b/apps/web/src/components/organizations/OrganizationByPageLayout.tsx
index c829ba6e73..9866380599 100644
--- a/apps/web/src/components/organizations/OrganizationByPageLayout.tsx
+++ b/apps/web/src/components/organizations/OrganizationByPageLayout.tsx
@@ -4,8 +4,13 @@ import { signInUrlWithCallbackPath } from '@/lib/user/server';
import type { OrganizationRole } from '@/lib/organizations/organization-types';
import type { Organization } from '@kilocode/db/schema';
import { redirect } from 'next/navigation';
+import { headers } from 'next/headers';
import type { JSX } from 'react';
import { OrganizationTrialWrapper } from './OrganizationTrialWrapper';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
+
+const UUID_ROUTE_IDENTIFIER_PATTERN =
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
export async function OrganizationByPageLayout({
params,
@@ -37,6 +42,17 @@ export async function OrganizationByPageLayout({
redirect('/profile');
}
const { user, organization } = result.data;
+ const organizationRouteIdentifier = getOrganizationRouteIdentifier(organization);
+ if (
+ UUID_ROUTE_IDENTIFIER_PATTERN.test(organizationId) &&
+ organizationRouteIdentifier !== organizationId
+ ) {
+ const pathname = (await headers()).get('x-pathname') ?? `/organizations/${id}`;
+ redirect(
+ pathname.replace(`/organizations/${id}`, `/organizations/${organizationRouteIdentifier}`)
+ );
+ }
+
const role = user.is_admin ? 'owner' : user.role;
return (
diff --git a/apps/web/src/components/organizations/OrganizationChildOrganizationsCard.tsx b/apps/web/src/components/organizations/OrganizationChildOrganizationsCard.tsx
index 11632bcc05..6b12b6c4da 100644
--- a/apps/web/src/components/organizations/OrganizationChildOrganizationsCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationChildOrganizationsCard.tsx
@@ -4,6 +4,7 @@ import Link from 'next/link';
import { Building2, ChevronRight } from 'lucide-react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { useOrganizationChildren } from '@/app/api/organizations/hooks';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
type Props = {
organizationId: string;
@@ -36,7 +37,7 @@ export function OrganizationChildOrganizationsCard({ organizationId }: Props) {
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index aa94fb9998..623be933fc 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -50,6 +50,7 @@ import { SpendingAlertsModal } from './SpendingAlertsModal';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
import { useExpiringCredits } from './useExpiringCredits';
import { useAdminOrganizationHierarchy } from '@/app/admin/api/organizations/hooks';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString('en-US', {
@@ -166,6 +167,7 @@ function Inner(props: InnerProps) {
deleted_at,
auto_top_up_enabled,
} = info;
+ const organizationRouteIdentifier = getOrganizationRouteIdentifier(info);
const [isEditing, setIsEditing] = useState(false);
const [editedName, setEditedName] = useState(name);
@@ -719,7 +721,7 @@ function Inner(props: InnerProps) {
{auto_top_up_enabled && isAutoTopUpEnabled && (
Auto Top-up: On
@@ -729,7 +731,9 @@ function Inner(props: InnerProps) {
- View Payments
+
+ View Payments
+
{expiringBlocks.length > 0 && earliestExpiry && (
@@ -747,7 +751,7 @@ function Inner(props: InnerProps) {
Quick Actions
-
+
View Organization Page
diff --git a/apps/web/src/components/organizations/OrganizationMembersCard.tsx b/apps/web/src/components/organizations/OrganizationMembersCard.tsx
index 307f64200e..36332fc26c 100644
--- a/apps/web/src/components/organizations/OrganizationMembersCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationMembersCard.tsx
@@ -43,6 +43,7 @@ import {
import { useSession } from 'next-auth/react';
import { toast } from 'sonner';
import { useOrganizationReadOnly } from '@/lib/organizations/use-organization-read-only';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString('en-US', {
@@ -353,7 +354,11 @@ function ChildTeamsControl({
asChild
className="text-xs font-normal hover:bg-accent focus-visible:ring-ring/50 focus-visible:ring-[3px]"
>
- {label}
+
+ {label}
+
);
})}
diff --git a/apps/web/src/lib/organizations/organization-auth.ts b/apps/web/src/lib/organizations/organization-auth.ts
index 6101f1d92a..4fe76bb9e2 100644
--- a/apps/web/src/lib/organizations/organization-auth.ts
+++ b/apps/web/src/lib/organizations/organization-auth.ts
@@ -11,6 +11,7 @@ import type { CustomResult } from '@/lib/maybe-result';
import { successResult } from '@/lib/maybe-result';
import { getOrganizationById } from '@/lib/organizations/organizations';
import z from 'zod';
+import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
const warnInSentry = sentryLogger('org_auth', 'warning');
@@ -54,12 +55,18 @@ export async function getAuthorizedOrgContext(
if (authFailedResponse) {
return { success: false, nextResponse: authFailedResponse };
}
- const { success, data, error } = UUIDSchema.safeParse(id);
+ const { success, data } = UUIDSchema.safeParse(id);
if (!success) {
- return {
- success: false,
- nextResponse: NextResponse.json({ error: error?.message || 'Invalid data' }, { status: 400 }),
- };
+ const organizationIdForSlug = await resolveOrganizationRouteIdentifier(id);
+ if (!organizationIdForSlug) {
+ const res = NextResponse.json({ error: 'Organization not found' }, { status: 404 });
+ return {
+ success: false,
+ nextResponse: res,
+ };
+ }
+
+ return getAuthorizedOrgContext(organizationIdForSlug, roles, getUserFromAuthOverride);
}
const organizationId = data;
diff --git a/apps/web/src/lib/organizations/organization-route-utils.server.ts b/apps/web/src/lib/organizations/organization-route-utils.server.ts
new file mode 100644
index 0000000000..f4535c93f8
--- /dev/null
+++ b/apps/web/src/lib/organizations/organization-route-utils.server.ts
@@ -0,0 +1,49 @@
+import 'server-only';
+
+import { organizations } from '@kilocode/db/schema';
+import { and, eq, isNull } from 'drizzle-orm';
+import { db } from '@/lib/drizzle';
+import {
+ getOrganizationRouteIdentifier,
+ type OrganizationRouteIdentifierInput,
+} from '@/lib/organizations/organization-route-utils';
+
+export type ResolvedOrganizationRouteIdentifier = OrganizationRouteIdentifierInput & {
+ routeIdentifier: string;
+};
+
+const UUID_ROUTE_IDENTIFIER_PATTERN =
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
+
+export async function resolveOrganizationRouteIdentifierDetails(
+ identifier: string
+): Promise {
+ const [organization] = await db
+ .select({ id: organizations.id, slug: organizations.slug })
+ .from(organizations)
+ .where(
+ and(
+ UUID_ROUTE_IDENTIFIER_PATTERN.test(identifier)
+ ? eq(organizations.id, identifier)
+ : eq(organizations.slug, identifier),
+ isNull(organizations.deleted_at)
+ )
+ )
+ .limit(1);
+
+ if (!organization) {
+ return null;
+ }
+
+ return {
+ ...organization,
+ routeIdentifier: getOrganizationRouteIdentifier(organization),
+ };
+}
+
+export async function resolveOrganizationRouteIdentifier(
+ identifier: string
+): Promise {
+ const organization = await resolveOrganizationRouteIdentifierDetails(identifier);
+ return organization?.id ?? null;
+}
diff --git a/apps/web/src/lib/organizations/organization-route-utils.test.ts b/apps/web/src/lib/organizations/organization-route-utils.test.ts
index d17b4a5193..6222e677ae 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.test.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.test.ts
@@ -1,8 +1,15 @@
-import { describe, expect, it } from '@jest/globals';
+import { afterEach, describe, expect, it } from '@jest/globals';
+import { db } from '@/lib/drizzle';
+import { organizations } from '@kilocode/db/schema';
+import { inArray } from 'drizzle-orm';
import {
getOrganizationRouteIdentifier,
ORGANIZATION_SLUG_MAX_LENGTH,
} from './organization-route-utils';
+import {
+ resolveOrganizationRouteIdentifierDetails,
+ resolveOrganizationRouteIdentifier,
+} from './organization-route-utils.server';
describe('getOrganizationRouteIdentifier', () => {
it('uses the slug when one exists', () => {
@@ -17,3 +24,56 @@ describe('getOrganizationRouteIdentifier', () => {
expect(ORGANIZATION_SLUG_MAX_LENGTH).toBe(32);
});
});
+
+describe('resolveOrganizationRouteIdentifier', () => {
+ afterEach(async () => {
+ await db
+ .delete(organizations)
+ .where(inArray(organizations.slug, ['route-id-org', 'route-slug-org', 'deleted-route-org']));
+ });
+
+ it('resolves organization ids', async () => {
+ const [organization] = await db
+ .insert(organizations)
+ .values({ name: 'Route ID Org', slug: 'route-id-org' })
+ .returning();
+
+ await expect(resolveOrganizationRouteIdentifier(organization.id)).resolves.toBe(
+ organization.id
+ );
+ });
+
+ it('resolves organization slugs', async () => {
+ const [organization] = await db
+ .insert(organizations)
+ .values({ name: 'Route Slug Org', slug: 'route-slug-org' })
+ .returning();
+
+ await expect(resolveOrganizationRouteIdentifier('route-slug-org')).resolves.toBe(
+ organization.id
+ );
+ });
+
+ it('returns the canonical route identifier', async () => {
+ const [organization] = await db
+ .insert(organizations)
+ .values({ name: 'Route Slug Org', slug: 'route-slug-org' })
+ .returning();
+
+ await expect(resolveOrganizationRouteIdentifierDetails(organization.id)).resolves.toEqual({
+ id: organization.id,
+ slug: 'route-slug-org',
+ routeIdentifier: 'route-slug-org',
+ });
+ });
+
+ it('does not resolve deleted organizations', async () => {
+ await db.insert(organizations).values({
+ name: 'Deleted Route Org',
+ slug: 'deleted-route-org',
+ deleted_at: new Date().toISOString(),
+ });
+
+ await expect(resolveOrganizationRouteIdentifier('deleted-route-org')).resolves.toBeNull();
+ });
+});
diff --git a/apps/web/src/lib/organizations/organization-types.ts b/apps/web/src/lib/organizations/organization-types.ts
index 22ee89e27f..a86dcd0625 100644
--- a/apps/web/src/lib/organizations/organization-types.ts
+++ b/apps/web/src/lib/organizations/organization-types.ts
@@ -80,6 +80,7 @@ export const OrganizationSchema = z.object({
export type UserOrganizationWithSeats = {
organizationName: string;
organizationId: Organization['id'];
+ organizationSlug: Organization['slug'];
role: OrganizationRole;
memberCount: number;
balance: number;
@@ -121,6 +122,7 @@ export type OrganizationMember = InvitedMember | ActiveMember;
export type ChildOrganizationSummary = {
id: string;
name: string;
+ slug: string | null;
};
export type ChildOrganizationMembership = ChildOrganizationSummary & {
diff --git a/apps/web/src/lib/organizations/organizations.ts b/apps/web/src/lib/organizations/organizations.ts
index 7613aacbd7..c310249ad5 100644
--- a/apps/web/src/lib/organizations/organizations.ts
+++ b/apps/web/src/lib/organizations/organizations.ts
@@ -88,6 +88,7 @@ export async function getUserOrganizationsWithSeats(
return results.map(result => ({
organizationName: result.organization.name,
organizationId: result.organization.id,
+ organizationSlug: result.organization.slug,
role: result.membership.role,
memberCount: result.total_member_count,
balance:
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index cc4a3c710f..0bc081a7a4 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -294,7 +294,7 @@ export const organizationsRouter = createTRPCRouter({
getOrganizationMembers(organizationId),
resolveEffectiveOrganizationSsoPolicy(organizationId),
db
- .select({ id: organizations.id, name: organizations.name })
+ .select({ id: organizations.id, name: organizations.name, slug: organizations.slug })
.from(organizations)
.where(
and(
@@ -328,7 +328,12 @@ export const organizationsRouter = createTRPCRouter({
const childOrganizationsById = new Map(childOrganizations.map(child => [child.id, child]));
const childMembershipsByUserId = new Map<
string,
- Array<{ id: string; name: string; role: (typeof childMembershipRows)[number]['role'] }>
+ Array<{
+ id: string;
+ name: string;
+ slug: string | null;
+ role: (typeof childMembershipRows)[number]['role'];
+ }>
>();
for (const row of childMembershipRows) {
const childOrganization = childOrganizationsById.get(row.organizationId);
@@ -376,6 +381,7 @@ export const organizationsRouter = createTRPCRouter({
.select({
id: organizations.id,
name: organizations.name,
+ slug: organizations.slug,
})
.from(organizations)
.where(
From 76d579567be546b152f1612888fd2eb9c83297ec Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 14:20:30 -0500
Subject: [PATCH 10/33] Streamline migration
---
apps/web/src/app/api/organizations/hooks.ts | 57 +-
.../organizations/OrganizationInfoCard.tsx | 165 -
.../auto-model-change-log.test.ts | 1 -
.../lib/organizations/organization-types.ts | 1 -
.../organization-admin-router.ts | 1 -
.../organizations/organization-router.ts | 61 +-
.../migrations/0174_omniscient_tenebrous.sql | 3 -
.../src/migrations/0174_quick_kat_farrell.sql | 3 +
.../migrations/0175_aspiring_omega_flight.sql | 1 -
.../db/src/migrations/meta/0174_snapshot.json | 12 +-
.../db/src/migrations/meta/0175_snapshot.json | 32122 ----------------
packages/db/src/migrations/meta/_journal.json | 11 +-
packages/db/src/schema.ts | 1 -
13 files changed, 15 insertions(+), 32424 deletions(-)
delete mode 100644 packages/db/src/migrations/0174_omniscient_tenebrous.sql
create mode 100644 packages/db/src/migrations/0174_quick_kat_farrell.sql
delete mode 100644 packages/db/src/migrations/0175_aspiring_omega_flight.sql
delete mode 100644 packages/db/src/migrations/meta/0175_snapshot.json
diff --git a/apps/web/src/app/api/organizations/hooks.ts b/apps/web/src/app/api/organizations/hooks.ts
index b28706d90f..ea63c36de4 100644
--- a/apps/web/src/app/api/organizations/hooks.ts
+++ b/apps/web/src/app/api/organizations/hooks.ts
@@ -105,20 +105,6 @@ export function useOrganizationUsageStats(organizationId: string) {
return useQuery(trpc.organizations.usageStats.queryOptions({ organizationId }));
}
-export function useRequestedSlugAvailability(
- organizationId: string,
- requestedSlug: string | null,
- options?: { enabled?: boolean }
-) {
- const trpc = useTRPC();
- return useQuery(
- trpc.organizations.requestedSlugAvailability.queryOptions(
- { organizationId, requested_slug: requestedSlug },
- options
- )
- );
-}
-
export function useSlugAvailability(
organizationId: string,
slug: string | null,
@@ -126,10 +112,7 @@ export function useSlugAvailability(
) {
const trpc = useTRPC();
return useQuery(
- trpc.organizations.requestedSlugAvailability.queryOptions(
- { organizationId, requested_slug: slug },
- options
- )
+ trpc.organizations.slugAvailability.queryOptions({ organizationId, slug }, options)
);
}
@@ -217,16 +200,6 @@ export function useUpdateOrganizationName() {
);
}
-export function useUpdateOrganizationRequestedSlug() {
- const trpc = useTRPC();
- const onSuccess = useInvalidateOrganizationAndMembers();
- return useMutation(
- trpc.organizations.updateRequestedSlug.mutationOptions({
- onSuccess,
- })
- );
-}
-
export function useAdminUpdateOrganizationSlug() {
const trpc = useTRPC();
const invalidate = useInvalidateAllOrganizationData();
@@ -241,34 +214,6 @@ export function useAdminUpdateOrganizationSlug() {
);
}
-export function useAdminAcceptRequestedSlug() {
- const trpc = useTRPC();
- const invalidate = useInvalidateAllOrganizationData();
- const queryClient = useQueryClient();
- return useMutation(
- trpc.organizations.acceptRequestedSlug.mutationOptions({
- onSuccess: () => {
- void queryClient.invalidateQueries({ queryKey: ['admin-organizations'] });
- void invalidate();
- },
- })
- );
-}
-
-export function useAdminDeclineRequestedSlug() {
- const trpc = useTRPC();
- const invalidate = useInvalidateAllOrganizationData();
- const queryClient = useQueryClient();
- return useMutation(
- trpc.organizations.declineRequestedSlug.mutationOptions({
- onSuccess: () => {
- void queryClient.invalidateQueries({ queryKey: ['admin-organizations'] });
- void invalidate();
- },
- })
- );
-}
-
export function useUpdateCompanyDomain() {
const trpc = useTRPC();
const onSuccess = useInvalidateOrganizationAndMembers();
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index 623be933fc..7ac7532f92 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -5,12 +5,8 @@ import { Button } from '@/components/ui/button';
import { BooleanBadge } from '@/components/ui/boolean-badge';
import {
useUpdateOrganizationName,
- useUpdateOrganizationRequestedSlug,
- useRequestedSlugAvailability,
useSlugAvailability,
useAdminUpdateOrganizationSlug,
- useAdminAcceptRequestedSlug,
- useAdminDeclineRequestedSlug,
useUpdateCompanyDomain,
useOrganizationWithMembers,
useAdminToggleCodeIndexing,
@@ -171,9 +167,6 @@ function Inner(props: InnerProps) {
const [isEditing, setIsEditing] = useState(false);
const [editedName, setEditedName] = useState(name);
- const [isEditingRequestedSlug, setIsEditingRequestedSlug] = useState(false);
- const [editedRequestedSlug, setEditedRequestedSlug] = useState(info.requested_slug ?? '');
- const [requestedSlugError, setRequestedSlugError] = useState(null);
const [isEditingSlug, setIsEditingSlug] = useState(false);
const [editedSlug, setEditedSlug] = useState(info.slug ?? '');
const [slugError, setSlugError] = useState(null);
@@ -187,33 +180,16 @@ function Inner(props: InnerProps) {
const [isSpendingAlertsModalOpen, setIsSpendingAlertsModalOpen] = useState(false);
const [ossSponsorshipDialogOpen, setOssSponsorshipDialogOpen] = useState(false);
const updateOrganizationName = useUpdateOrganizationName();
- const updateOrganizationRequestedSlug = useUpdateOrganizationRequestedSlug();
const adminUpdateOrganizationSlug = useAdminUpdateOrganizationSlug();
- const adminAcceptRequestedSlug = useAdminAcceptRequestedSlug();
- const adminDeclineRequestedSlug = useAdminDeclineRequestedSlug();
const updateCompanyDomain = useUpdateCompanyDomain();
const adminToggleCodeIndexing = useAdminToggleCodeIndexing();
const updateSuppressTrialMessaging = useUpdateSuppressTrialMessaging();
const { expiringBlocks, expiring_mUsd, earliestExpiry } = useExpiringCredits(id);
- const requestedSlugAvailability = useRequestedSlugAvailability(id, info.requested_slug, {
- enabled: Boolean(info.requested_slug),
- });
const editedSlugAvailability = useSlugAvailability(id, editedSlug.trim() || null, {
enabled: isEditingSlug && Boolean(editedSlug.trim()) && editedSlug.trim() !== info.slug,
});
- const isRequestedSlugAvailable = requestedSlugAvailability.data?.available ?? true;
const isEditedSlugAvailable = editedSlugAvailability.data?.available ?? true;
- const requestedSlugMutationPending =
- updateOrganizationRequestedSlug.isPending ||
- adminAcceptRequestedSlug.isPending ||
- adminDeclineRequestedSlug.isPending;
-
- useEffect(() => {
- if (!isEditingRequestedSlug) {
- setEditedRequestedSlug(info.requested_slug ?? '');
- }
- }, [info.requested_slug, isEditingRequestedSlug]);
useEffect(() => {
if (!isEditingSlug) {
@@ -253,43 +229,6 @@ function Inner(props: InnerProps) {
}
};
- const handleRequestedSlugSave = async () => {
- setRequestedSlugError(null);
- const nextRequestedSlug = editedRequestedSlug.trim() || null;
- if (nextRequestedSlug === info.requested_slug) {
- setEditedRequestedSlug(info.requested_slug ?? '');
- setIsEditingRequestedSlug(false);
- return;
- }
-
- try {
- await updateOrganizationRequestedSlug.mutateAsync({
- organizationId: id,
- requested_slug: nextRequestedSlug,
- });
- setIsEditingRequestedSlug(false);
- } catch (error) {
- console.error('Failed to update requested organization slug:', error);
- setRequestedSlugError(
- error instanceof Error ? error.message : 'Requested slug is not available'
- );
- }
- };
-
- const handleRequestedSlugCancel = () => {
- setEditedRequestedSlug(info.requested_slug ?? '');
- setRequestedSlugError(null);
- setIsEditingRequestedSlug(false);
- };
-
- const handleRequestedSlugKeyDown = (e: React.KeyboardEvent) => {
- if (e.key === 'Enter') {
- void handleRequestedSlugSave();
- } else if (e.key === 'Escape') {
- handleRequestedSlugCancel();
- }
- };
-
const handleSlugSave = async () => {
setSlugError(null);
const nextSlug = editedSlug.trim() || null;
@@ -376,7 +315,6 @@ function Inner(props: InnerProps) {
const isAutoTopUpEnabled = useIsAutoTopUpEnabled();
const isInAdminDashboard = isKiloAdmin && showAdminControls;
const isOrgOwner = useCanManagePaymentInfo();
- const canManageRequestedSlug = isOrgOwner || isKiloAdmin;
const hierarchyQuery = useAdminOrganizationHierarchy(id, isInAdminDashboard);
const handleSeatsRequirementEdit = () => {
@@ -533,109 +471,6 @@ function Inner(props: InnerProps) {
)}
- {canManageRequestedSlug ? (
-
-
Requested Slug
- {isEditingRequestedSlug ? (
-
-
- {
- setEditedRequestedSlug(e.target.value);
- setRequestedSlugError(null);
- }}
- onKeyDown={handleRequestedSlugKeyDown}
- className={`font-mono text-sm ${requestedSlugError ? 'border-red-400' : ''}`}
- autoFocus
- disabled={updateOrganizationRequestedSlug.isPending}
- />
-
-
-
-
-
-
-
- {requestedSlugError ? (
-
{requestedSlugError}
- ) : null}
-
- ) : (
-
-
- {info.requested_slug || Not set }
-
- {info.requested_slug && !isRequestedSlugAvailable ? (
-
- Not Available
-
- ) : null}
- {isOrgOwner && (
-
setIsEditingRequestedSlug(true)}
- className="hover:bg-muted inline-flex cursor-pointer items-center gap-1 rounded p-1 transition-all duration-200 focus:outline-none"
- title="Edit requested organization slug"
- >
-
-
- )}
- {isKiloAdmin && info.requested_slug ? (
- <>
-
- adminAcceptRequestedSlug.mutate({
- organizationId: id,
- })
- }
- disabled={requestedSlugMutationPending || !isRequestedSlugAvailable}
- className="h-8 w-8 p-0"
- aria-label="Accept requested organization slug"
- title={
- isRequestedSlugAvailable
- ? 'Accept requested organization slug'
- : 'Requested slug is not available'
- }
- >
-
-
-
- adminDeclineRequestedSlug.mutate({
- organizationId: id,
- })
- }
- disabled={requestedSlugMutationPending}
- className="h-8 w-8 p-0"
- aria-label="Decline requested organization slug"
- title="Decline requested organization slug"
- >
-
-
- >
- ) : null}
-
- )}
-
- ) : null}
Company Domain
{isEditingDomain ? (
diff --git a/apps/web/src/lib/organizations/auto-model-change-log.test.ts b/apps/web/src/lib/organizations/auto-model-change-log.test.ts
index f782fedc56..0e8a4c2237 100644
--- a/apps/web/src/lib/organizations/auto-model-change-log.test.ts
+++ b/apps/web/src/lib/organizations/auto-model-change-log.test.ts
@@ -68,7 +68,6 @@ function buildEnterpriseOrg(overrides: Partial
= {}): Organization
free_trial_end_at: null,
company_domain: null,
slug: null,
- requested_slug: null,
...overrides,
} satisfies Organization;
}
diff --git a/apps/web/src/lib/organizations/organization-types.ts b/apps/web/src/lib/organizations/organization-types.ts
index a86dcd0625..e68da116bf 100644
--- a/apps/web/src/lib/organizations/organization-types.ts
+++ b/apps/web/src/lib/organizations/organization-types.ts
@@ -74,7 +74,6 @@ export const OrganizationSchema = z.object({
free_trial_end_at: z.string().nullable(),
company_domain: z.string().nullable(),
slug: z.string().nullable(),
- requested_slug: z.string().nullable(),
});
export type UserOrganizationWithSeats = {
diff --git a/apps/web/src/routers/organizations/organization-admin-router.ts b/apps/web/src/routers/organizations/organization-admin-router.ts
index ade3a5ae2e..9ba24591e6 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.ts
@@ -1012,7 +1012,6 @@ export const organizationAdminRouter = createTRPCRouter({
free_trial_end_at: organizations.free_trial_end_at,
company_domain: organizations.company_domain,
slug: organizations.slug,
- requested_slug: organizations.requested_slug,
// Null out subscription_amount_usd for non-billable statuses so the
// "Subscription" column doesn't display the dollar amount of a churned
// plan as if it were current MRR. Reading "latest_stripe_status" tells
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index 0bc081a7a4..da86d2cc9b 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -83,10 +83,6 @@ const OrganizationSlugSchema = z
'Organization slug must use lowercase letters, numbers, and hyphens'
);
-const OrganizationRequestedSlugUpdateSchema = OrganizationIdInputSchema.extend({
- requested_slug: OrganizationSlugSchema.nullable(),
-});
-
const OrganizationSlugUpdateSchema = OrganizationIdInputSchema.extend({
slug: OrganizationSlugSchema.nullable(),
});
@@ -234,25 +230,15 @@ export const organizationsRouter = createTRPCRouter({
return successResult();
}),
- updateRequestedSlug: organizationBillingMutationProcedure
- .input(OrganizationRequestedSlugUpdateSchema)
- .mutation(async opts => {
- await db
- .update(organizations)
- .set({ requested_slug: opts.input.requested_slug })
- .where(eq(organizations.id, opts.input.organizationId));
- return successResult();
- }),
-
- requestedSlugAvailability: organizationMemberProcedure
- .input(OrganizationRequestedSlugUpdateSchema)
+ slugAvailability: organizationMemberProcedure
+ .input(OrganizationSlugUpdateSchema)
.query(async opts => {
- if (!opts.input.requested_slug) {
+ if (!opts.input.slug) {
return { available: true };
}
const existingOrganization = await getOrganizationByActiveSlug(
- opts.input.requested_slug,
+ opts.input.slug,
opts.input.organizationId
);
@@ -461,45 +447,6 @@ export const organizationsRouter = createTRPCRouter({
};
}),
- acceptRequestedSlug: adminProcedure.input(OrganizationIdInputSchema).mutation(async opts => {
- await ensureOrganizationAccess(opts.ctx, opts.input.organizationId, ['owner']);
- const organization = await getOrganizationById(opts.input.organizationId);
- if (!organization) {
- throw new TRPCError({ code: 'NOT_FOUND', message: 'Organization not found' });
- }
-
- const requestedSlug = OrganizationSlugSchema.parse(organization.requested_slug);
- await assertActiveSlugAvailable(requestedSlug, opts.input.organizationId);
-
- await db
- .update(organizations)
- .set({ slug: requestedSlug, requested_slug: null })
- .where(eq(organizations.id, opts.input.organizationId));
-
- return {
- organization: {
- id: opts.input.organizationId,
- slug: requestedSlug,
- requested_slug: null,
- },
- };
- }),
-
- declineRequestedSlug: adminProcedure.input(OrganizationIdInputSchema).mutation(async opts => {
- await ensureOrganizationAccess(opts.ctx, opts.input.organizationId, ['owner']);
- await db
- .update(organizations)
- .set({ requested_slug: null })
- .where(eq(organizations.id, opts.input.organizationId));
-
- return {
- organization: {
- id: opts.input.organizationId,
- requested_slug: null,
- },
- };
- }),
-
usageStats: organizationMemberProcedure.output(UsageStatsSchema).query(async opts => {
// Fetch and return usage stats for the organization (last 30 days)
// Get usage statistics
diff --git a/packages/db/src/migrations/0174_omniscient_tenebrous.sql b/packages/db/src/migrations/0174_omniscient_tenebrous.sql
deleted file mode 100644
index d898be05f0..0000000000
--- a/packages/db/src/migrations/0174_omniscient_tenebrous.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "slug" text;--> statement-breakpoint
-ALTER TABLE "organizations" ADD COLUMN IF NOT EXISTS "requested_slug" text;--> statement-breakpoint
-ALTER TABLE "organizations" ADD CONSTRAINT IF NOT EXISTS "organizations_slug_unique" UNIQUE("slug");
diff --git a/packages/db/src/migrations/0174_quick_kat_farrell.sql b/packages/db/src/migrations/0174_quick_kat_farrell.sql
new file mode 100644
index 0000000000..bf5bd59485
--- /dev/null
+++ b/packages/db/src/migrations/0174_quick_kat_farrell.sql
@@ -0,0 +1,3 @@
+ALTER TABLE "organizations" ADD COLUMN "slug" text;--> statement-breakpoint
+ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_unique" UNIQUE("slug");--> statement-breakpoint
+ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_max_length_check" CHECK ("organizations"."slug" IS NULL OR length("organizations"."slug") <= 32);
\ No newline at end of file
diff --git a/packages/db/src/migrations/0175_aspiring_omega_flight.sql b/packages/db/src/migrations/0175_aspiring_omega_flight.sql
deleted file mode 100644
index 747cedddfd..0000000000
--- a/packages/db/src/migrations/0175_aspiring_omega_flight.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE "organizations" ADD CONSTRAINT "organizations_slug_max_length_check" CHECK ("organizations"."slug" IS NULL OR length("organizations"."slug") <= 32);
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/0174_snapshot.json b/packages/db/src/migrations/meta/0174_snapshot.json
index 9a78c54ebb..11b0bd44ac 100644
--- a/packages/db/src/migrations/meta/0174_snapshot.json
+++ b/packages/db/src/migrations/meta/0174_snapshot.json
@@ -1,5 +1,5 @@
{
- "id": "ae36098e-33f9-4138-895b-c0e0098b822a",
+ "id": "184e6a97-4322-4d78-b2f6-e8e6b0eb4aae",
"prevId": "06265fd6-428e-4b7d-9092-dba307d6255e",
"version": "7",
"dialect": "postgresql",
@@ -23137,12 +23137,6 @@
"type": "text",
"primaryKey": false,
"notNull": false
- },
- "requested_slug": {
- "name": "requested_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
}
},
"indexes": {
@@ -23208,6 +23202,10 @@
"name": "organizations_name_not_empty_check",
"value": "length(trim(\"organizations\".\"name\")) > 0"
},
+ "organizations_slug_max_length_check": {
+ "name": "organizations_slug_max_length_check",
+ "value": "\"organizations\".\"slug\" IS NULL OR length(\"organizations\".\"slug\") <= 32"
+ },
"organizations_not_parented_by_self_check": {
"name": "organizations_not_parented_by_self_check",
"value": "\"organizations\".\"parent_organization_id\" IS NULL OR \"organizations\".\"parent_organization_id\" <> \"organizations\".\"id\""
diff --git a/packages/db/src/migrations/meta/0175_snapshot.json b/packages/db/src/migrations/meta/0175_snapshot.json
deleted file mode 100644
index 0056df97c6..0000000000
--- a/packages/db/src/migrations/meta/0175_snapshot.json
+++ /dev/null
@@ -1,32122 +0,0 @@
-{
- "id": "a61286a8-e035-4479-8dba-3b034b3ba1b6",
- "prevId": "ae36098e-33f9-4138-895b-c0e0098b822a",
- "version": "7",
- "dialect": "postgresql",
- "tables": {
- "public.agent_configs": {
- "name": "agent_configs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "agent_type": {
- "name": "agent_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "is_enabled": {
- "name": "is_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "runtime_state": {
- "name": "runtime_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false,
- "default": "'{}'::jsonb"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_configs_org_id": {
- "name": "IDX_agent_configs_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_configs_owned_by_user_id": {
- "name": "IDX_agent_configs_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_configs_agent_type": {
- "name": "IDX_agent_configs_agent_type",
- "columns": [
- {
- "expression": "agent_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_configs_platform": {
- "name": "IDX_agent_configs_platform",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_configs_owned_by_organization_id_organizations_id_fk": {
- "name": "agent_configs_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "agent_configs",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_configs_owned_by_user_id_kilocode_users_id_fk": {
- "name": "agent_configs_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "agent_configs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_configs_org_agent_platform": {
- "name": "UQ_agent_configs_org_agent_platform",
- "nullsNotDistinct": false,
- "columns": [
- "owned_by_organization_id",
- "agent_type",
- "platform"
- ]
- },
- "UQ_agent_configs_user_agent_platform": {
- "name": "UQ_agent_configs_user_agent_platform",
- "nullsNotDistinct": false,
- "columns": [
- "owned_by_user_id",
- "agent_type",
- "platform"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "agent_configs_owner_check": {
- "name": "agent_configs_owner_check",
- "value": "(\n (\"agent_configs\".\"owned_by_user_id\" IS NOT NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_configs\".\"owned_by_user_id\" IS NULL AND \"agent_configs\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "agent_configs_agent_type_check": {
- "name": "agent_configs_agent_type_check",
- "value": "\"agent_configs\".\"agent_type\" IN ('code_review', 'auto_triage', 'auto_fix', 'security_scan')"
- }
- },
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_agents": {
- "name": "agent_environment_profile_agents",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_agents_profile_id": {
- "name": "IDX_agent_env_profile_agents_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_agents_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_agents",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_agents_profile_slug": {
- "name": "UQ_agent_env_profile_agents_profile_slug",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_commands": {
- "name": "agent_environment_profile_commands",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "sequence": {
- "name": "sequence",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "command": {
- "name": "command",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_commands_profile_id": {
- "name": "IDX_agent_env_profile_commands_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_commands_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_commands",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_commands_profile_sequence": {
- "name": "UQ_agent_env_profile_commands_profile_sequence",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "sequence"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_kilo_commands": {
- "name": "agent_environment_profile_kilo_commands",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "template": {
- "name": "template",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "agent": {
- "name": "agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "subtask": {
- "name": "subtask",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "sort_order": {
- "name": "sort_order",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_kilo_cmds_profile_id": {
- "name": "IDX_agent_env_profile_kilo_cmds_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_kilo_commands_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_kilo_commands",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_kilo_cmds_profile_name": {
- "name": "UQ_agent_env_profile_kilo_cmds_profile_name",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_mcp_servers": {
- "name": "agent_environment_profile_mcp_servers",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "timeout": {
- "name": "timeout",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_mcp_servers_profile_id": {
- "name": "IDX_agent_env_profile_mcp_servers_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_mcp_servers_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_mcp_servers",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_mcp_servers_profile_name": {
- "name": "UQ_agent_env_profile_mcp_servers_profile_name",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_repo_bindings": {
- "name": "agent_environment_profile_repo_bindings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_agent_env_profile_repo_bindings_user": {
- "name": "UQ_agent_env_profile_repo_bindings_user",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profile_repo_bindings_org": {
- "name": "UQ_agent_env_profile_repo_bindings_org",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_repo_bindings_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_repo_bindings",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk": {
- "name": "agent_environment_profile_repo_bindings_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "agent_environment_profile_repo_bindings",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk": {
- "name": "agent_environment_profile_repo_bindings_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "agent_environment_profile_repo_bindings",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "agent_env_profile_repo_bindings_owner_check": {
- "name": "agent_env_profile_repo_bindings_owner_check",
- "value": "(\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profile_repo_bindings\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profile_repo_bindings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_skills": {
- "name": "agent_environment_profile_skills",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_type": {
- "name": "source_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_url": {
- "name": "source_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "raw_markdown": {
- "name": "raw_markdown",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "files": {
- "name": "files",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_skills_profile_id": {
- "name": "IDX_agent_env_profile_skills_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_skills_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_skills",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_skills_profile_name": {
- "name": "UQ_agent_env_profile_skills_profile_name",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profile_vars": {
- "name": "agent_environment_profile_vars",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "key": {
- "name": "key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_secret": {
- "name": "is_secret",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_agent_env_profile_vars_profile_id": {
- "name": "IDX_agent_env_profile_vars_profile_id",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk": {
- "name": "agent_environment_profile_vars_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "agent_environment_profile_vars",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_agent_env_profile_vars_profile_key": {
- "name": "UQ_agent_env_profile_vars_profile_key",
- "nullsNotDistinct": false,
- "columns": [
- "profile_id",
- "key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_environment_profiles": {
- "name": "agent_environment_profiles",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_default": {
- "name": "is_default",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_agent_env_profiles_org_name": {
- "name": "UQ_agent_env_profiles_org_name",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profiles_user_name": {
- "name": "UQ_agent_env_profiles_user_name",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profiles_org_default": {
- "name": "UQ_agent_env_profiles_org_default",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_agent_env_profiles_user_default": {
- "name": "UQ_agent_env_profiles_user_default",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_environment_profiles\".\"is_default\" = true AND \"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_env_profiles_org_id": {
- "name": "IDX_agent_env_profiles_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_env_profiles_user_id": {
- "name": "IDX_agent_env_profiles_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_agent_env_profiles_created_by_user_id": {
- "name": "IDX_agent_env_profiles_created_by_user_id",
- "columns": [
- {
- "expression": "created_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_environment_profiles_owned_by_organization_id_organizations_id_fk": {
- "name": "agent_environment_profiles_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "agent_environment_profiles",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk": {
- "name": "agent_environment_profiles_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "agent_environment_profiles",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "agent_env_profiles_owner_check": {
- "name": "agent_env_profiles_owner_check",
- "value": "(\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NOT NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NULL) OR\n (\"agent_environment_profiles\".\"owned_by_user_id\" IS NULL AND \"agent_environment_profiles\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.api_kind": {
- "name": "api_kind",
- "schema": "",
- "columns": {
- "api_kind_id": {
- "name": "api_kind_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "api_kind": {
- "name": "api_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_api_kind": {
- "name": "UQ_api_kind",
- "columns": [
- {
- "expression": "api_kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.api_request_compress_log": {
- "name": "api_request_compress_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "bigserial",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "request": {
- "name": "request",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "result": {
- "name": "result",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "idx_api_request_compress_log_created_at": {
- "name": "idx_api_request_compress_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.api_request_log": {
- "name": "api_request_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "bigserial",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status_code": {
- "name": "status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "request": {
- "name": "request",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response": {
- "name": "response",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error": {
- "name": "error",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_api_request_log_created_at": {
- "name": "idx_api_request_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_builder_feedback": {
- "name": "app_builder_feedback",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "preview_status": {
- "name": "preview_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_streaming": {
- "name": "is_streaming",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "message_count": {
- "name": "message_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "feedback_text": {
- "name": "feedback_text",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "recent_messages": {
- "name": "recent_messages",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_app_builder_feedback_created_at": {
- "name": "IDX_app_builder_feedback_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_feedback_kilo_user_id": {
- "name": "IDX_app_builder_feedback_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_feedback_project_id": {
- "name": "IDX_app_builder_feedback_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "app_builder_feedback_kilo_user_id_kilocode_users_id_fk": {
- "name": "app_builder_feedback_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "app_builder_feedback",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "app_builder_feedback_project_id_app_builder_projects_id_fk": {
- "name": "app_builder_feedback_project_id_app_builder_projects_id_fk",
- "tableFrom": "app_builder_feedback",
- "tableTo": "app_builder_projects",
- "columnsFrom": [
- "project_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_builder_project_sessions": {
- "name": "app_builder_project_sessions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "project_id": {
- "name": "project_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_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
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "worker_version": {
- "name": "worker_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'v2'"
- }
- },
- "indexes": {
- "IDX_app_builder_project_sessions_project_id": {
- "name": "IDX_app_builder_project_sessions_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "app_builder_project_sessions_project_id_app_builder_projects_id_fk": {
- "name": "app_builder_project_sessions_project_id_app_builder_projects_id_fk",
- "tableFrom": "app_builder_project_sessions",
- "tableTo": "app_builder_projects",
- "columnsFrom": [
- "project_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_app_builder_project_sessions_cloud_agent_session_id": {
- "name": "UQ_app_builder_project_sessions_cloud_agent_session_id",
- "nullsNotDistinct": false,
- "columns": [
- "cloud_agent_session_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_builder_projects": {
- "name": "app_builder_projects",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model_id": {
- "name": "model_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "template": {
- "name": "template",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "last_message_at": {
- "name": "last_message_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "git_repo_full_name": {
- "name": "git_repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_platform_integration_id": {
- "name": "git_platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "migrated_at": {
- "name": "migrated_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_app_builder_projects_created_by_user_id": {
- "name": "IDX_app_builder_projects_created_by_user_id",
- "columns": [
- {
- "expression": "created_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_owned_by_user_id": {
- "name": "IDX_app_builder_projects_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_owned_by_organization_id": {
- "name": "IDX_app_builder_projects_owned_by_organization_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_created_at": {
- "name": "IDX_app_builder_projects_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_last_message_at": {
- "name": "IDX_app_builder_projects_last_message_at",
- "columns": [
- {
- "expression": "last_message_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_app_builder_projects_git_repo_integration": {
- "name": "IDX_app_builder_projects_git_repo_integration",
- "columns": [
- {
- "expression": "git_repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"app_builder_projects\".\"git_repo_full_name\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "app_builder_projects_owned_by_user_id_kilocode_users_id_fk": {
- "name": "app_builder_projects_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "app_builder_projects_owned_by_organization_id_organizations_id_fk": {
- "name": "app_builder_projects_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "app_builder_projects_deployment_id_deployments_id_fk": {
- "name": "app_builder_projects_deployment_id_deployments_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk": {
- "name": "app_builder_projects_git_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "app_builder_projects",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "git_platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "app_builder_projects_owner_check": {
- "name": "app_builder_projects_owner_check",
- "value": "(\n (\"app_builder_projects\".\"owned_by_user_id\" IS NOT NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NULL) OR\n (\"app_builder_projects\".\"owned_by_user_id\" IS NULL AND \"app_builder_projects\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.app_min_versions": {
- "name": "app_min_versions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "ios_min_version": {
- "name": "ios_min_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'1.0.0'"
- },
- "android_min_version": {
- "name": "android_min_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'1.0.0'"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.app_reported_messages": {
- "name": "app_reported_messages",
- "schema": "",
- "columns": {
- "report_id": {
- "name": "report_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "report_type": {
- "name": "report_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "signature": {
- "name": "signature",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "message": {
- "name": "message",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "app_reported_messages_cli_session_id_cli_sessions_session_id_fk": {
- "name": "app_reported_messages_cli_session_id_cli_sessions_session_id_fk",
- "tableFrom": "app_reported_messages",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "cli_session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.auto_fix_tickets": {
- "name": "auto_fix_tickets",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "triage_ticket_id": {
- "name": "triage_ticket_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_number": {
- "name": "issue_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "issue_url": {
- "name": "issue_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_title": {
- "name": "issue_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_body": {
- "name": "issue_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "issue_author": {
- "name": "issue_author",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_labels": {
- "name": "issue_labels",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false,
- "default": "'{}'"
- },
- "trigger_source": {
- "name": "trigger_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'label'"
- },
- "review_comment_id": {
- "name": "review_comment_id",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "review_comment_body": {
- "name": "review_comment_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "file_path": {
- "name": "file_path",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "line_number": {
- "name": "line_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "diff_hunk": {
- "name": "diff_hunk",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_ref": {
- "name": "pr_head_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "classification": {
- "name": "classification",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "confidence": {
- "name": "confidence",
- "type": "numeric(3, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "intent_summary": {
- "name": "intent_summary",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "related_files": {
- "name": "related_files",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_branch": {
- "name": "pr_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_auto_fix_tickets_repo_issue": {
- "name": "UQ_auto_fix_tickets_repo_issue",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "issue_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_fix_tickets\".\"trigger_source\" = 'label'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_auto_fix_tickets_repo_review_comment": {
- "name": "UQ_auto_fix_tickets_repo_review_comment",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "review_comment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_fix_tickets\".\"review_comment_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_owned_by_org": {
- "name": "IDX_auto_fix_tickets_owned_by_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_owned_by_user": {
- "name": "IDX_auto_fix_tickets_owned_by_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_status": {
- "name": "IDX_auto_fix_tickets_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_created_at": {
- "name": "IDX_auto_fix_tickets_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_triage_ticket_id": {
- "name": "IDX_auto_fix_tickets_triage_ticket_id",
- "columns": [
- {
- "expression": "triage_ticket_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_fix_tickets_session_id": {
- "name": "IDX_auto_fix_tickets_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "auto_fix_tickets_owned_by_organization_id_organizations_id_fk": {
- "name": "auto_fix_tickets_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk": {
- "name": "auto_fix_tickets_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk": {
- "name": "auto_fix_tickets_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk": {
- "name": "auto_fix_tickets_triage_ticket_id_auto_triage_tickets_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "auto_triage_tickets",
- "columnsFrom": [
- "triage_ticket_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk": {
- "name": "auto_fix_tickets_cli_session_id_cli_sessions_session_id_fk",
- "tableFrom": "auto_fix_tickets",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "cli_session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "auto_fix_tickets_owner_check": {
- "name": "auto_fix_tickets_owner_check",
- "value": "(\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_fix_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_fix_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "auto_fix_tickets_status_check": {
- "name": "auto_fix_tickets_status_check",
- "value": "\"auto_fix_tickets\".\"status\" IN ('pending', 'running', 'completed', 'failed', 'cancelled')"
- },
- "auto_fix_tickets_classification_check": {
- "name": "auto_fix_tickets_classification_check",
- "value": "\"auto_fix_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'unclear')"
- },
- "auto_fix_tickets_confidence_check": {
- "name": "auto_fix_tickets_confidence_check",
- "value": "\"auto_fix_tickets\".\"confidence\" >= 0 AND \"auto_fix_tickets\".\"confidence\" <= 1"
- },
- "auto_fix_tickets_trigger_source_check": {
- "name": "auto_fix_tickets_trigger_source_check",
- "value": "\"auto_fix_tickets\".\"trigger_source\" IN ('label', 'review_comment')"
- }
- },
- "isRLSEnabled": false
- },
- "public.auto_model": {
- "name": "auto_model",
- "schema": "",
- "columns": {
- "auto_model_id": {
- "name": "auto_model_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "auto_model": {
- "name": "auto_model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_auto_model": {
- "name": "UQ_auto_model",
- "columns": [
- {
- "expression": "auto_model",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.auto_top_up_configs": {
- "name": "auto_top_up_configs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_method_id": {
- "name": "stripe_payment_method_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_cents": {
- "name": "amount_cents",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 5000
- },
- "last_auto_top_up_at": {
- "name": "last_auto_top_up_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_started_at": {
- "name": "attempt_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "disabled_reason": {
- "name": "disabled_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_auto_top_up_configs_owned_by_user_id": {
- "name": "UQ_auto_top_up_configs_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_auto_top_up_configs_owned_by_organization_id": {
- "name": "UQ_auto_top_up_configs_owned_by_organization_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk": {
- "name": "auto_top_up_configs_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "auto_top_up_configs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "auto_top_up_configs_owned_by_organization_id_organizations_id_fk": {
- "name": "auto_top_up_configs_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "auto_top_up_configs",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "auto_top_up_configs_exactly_one_owner": {
- "name": "auto_top_up_configs_exactly_one_owner",
- "value": "(\"auto_top_up_configs\".\"owned_by_user_id\" IS NOT NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NULL) OR (\"auto_top_up_configs\".\"owned_by_user_id\" IS NULL AND \"auto_top_up_configs\".\"owned_by_organization_id\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.auto_triage_tickets": {
- "name": "auto_triage_tickets",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_number": {
- "name": "issue_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "issue_url": {
- "name": "issue_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_title": {
- "name": "issue_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_body": {
- "name": "issue_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "issue_author": {
- "name": "issue_author",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_type": {
- "name": "issue_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "issue_labels": {
- "name": "issue_labels",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false,
- "default": "'{}'"
- },
- "classification": {
- "name": "classification",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "confidence": {
- "name": "confidence",
- "type": "numeric(3, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "intent_summary": {
- "name": "intent_summary",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "related_files": {
- "name": "related_files",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "is_duplicate": {
- "name": "is_duplicate",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false,
- "default": false
- },
- "duplicate_of_ticket_id": {
- "name": "duplicate_of_ticket_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "similarity_score": {
- "name": "similarity_score",
- "type": "numeric(3, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "qdrant_point_id": {
- "name": "qdrant_point_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "should_auto_fix": {
- "name": "should_auto_fix",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false,
- "default": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "action_taken": {
- "name": "action_taken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "action_metadata": {
- "name": "action_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_auto_triage_tickets_repo_issue": {
- "name": "UQ_auto_triage_tickets_repo_issue",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "issue_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_owned_by_org": {
- "name": "IDX_auto_triage_tickets_owned_by_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_owned_by_user": {
- "name": "IDX_auto_triage_tickets_owned_by_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_status": {
- "name": "IDX_auto_triage_tickets_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_created_at": {
- "name": "IDX_auto_triage_tickets_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_qdrant_point_id": {
- "name": "IDX_auto_triage_tickets_qdrant_point_id",
- "columns": [
- {
- "expression": "qdrant_point_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_owner_status_created": {
- "name": "IDX_auto_triage_tickets_owner_status_created",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_user_status_created": {
- "name": "IDX_auto_triage_tickets_user_status_created",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_auto_triage_tickets_repo_classification": {
- "name": "IDX_auto_triage_tickets_repo_classification",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "classification",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "auto_triage_tickets_owned_by_organization_id_organizations_id_fk": {
- "name": "auto_triage_tickets_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk": {
- "name": "auto_triage_tickets_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk": {
- "name": "auto_triage_tickets_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk": {
- "name": "auto_triage_tickets_duplicate_of_ticket_id_auto_triage_tickets_id_fk",
- "tableFrom": "auto_triage_tickets",
- "tableTo": "auto_triage_tickets",
- "columnsFrom": [
- "duplicate_of_ticket_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "auto_triage_tickets_owner_check": {
- "name": "auto_triage_tickets_owner_check",
- "value": "(\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NOT NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NULL) OR\n (\"auto_triage_tickets\".\"owned_by_user_id\" IS NULL AND \"auto_triage_tickets\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "auto_triage_tickets_issue_type_check": {
- "name": "auto_triage_tickets_issue_type_check",
- "value": "\"auto_triage_tickets\".\"issue_type\" IN ('issue', 'pull_request')"
- },
- "auto_triage_tickets_classification_check": {
- "name": "auto_triage_tickets_classification_check",
- "value": "\"auto_triage_tickets\".\"classification\" IN ('bug', 'feature', 'question', 'duplicate', 'unclear')"
- },
- "auto_triage_tickets_confidence_check": {
- "name": "auto_triage_tickets_confidence_check",
- "value": "\"auto_triage_tickets\".\"confidence\" >= 0 AND \"auto_triage_tickets\".\"confidence\" <= 1"
- },
- "auto_triage_tickets_similarity_score_check": {
- "name": "auto_triage_tickets_similarity_score_check",
- "value": "\"auto_triage_tickets\".\"similarity_score\" >= 0 AND \"auto_triage_tickets\".\"similarity_score\" <= 1"
- },
- "auto_triage_tickets_status_check": {
- "name": "auto_triage_tickets_status_check",
- "value": "\"auto_triage_tickets\".\"status\" IN ('pending', 'analyzing', 'actioned', 'failed', 'skipped')"
- },
- "auto_triage_tickets_action_taken_check": {
- "name": "auto_triage_tickets_action_taken_check",
- "value": "\"auto_triage_tickets\".\"action_taken\" IN ('pr_created', 'comment_posted', 'closed_duplicate', 'needs_clarification')"
- }
- },
- "isRLSEnabled": false
- },
- "public.bot_request_cloud_agent_sessions": {
- "name": "bot_request_cloud_agent_sessions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "bot_request_id": {
- "name": "bot_request_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "spawn_group_id": {
- "name": "spawn_group_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_session_id": {
- "name": "kilo_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "execution_id": {
- "name": "execution_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'running'"
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "github_repo": {
- "name": "github_repo",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "gitlab_project": {
- "name": "gitlab_project",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "callback_step": {
- "name": "callback_step",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "final_message": {
- "name": "final_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "final_message_fetched_at": {
- "name": "final_message_fetched_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "final_message_error": {
- "name": "final_message_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "continuation_started_at": {
- "name": "continuation_started_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_bot_request_cas_cloud_agent_session_id": {
- "name": "UQ_bot_request_cas_cloud_agent_session_id",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_request_cas_bot_request_id": {
- "name": "IDX_bot_request_cas_bot_request_id",
- "columns": [
- {
- "expression": "bot_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_request_cas_bot_request_id_spawn_group_id": {
- "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id",
- "columns": [
- {
- "expression": "bot_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "spawn_group_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_request_cas_bot_request_id_spawn_group_id_status": {
- "name": "IDX_bot_request_cas_bot_request_id_spawn_group_id_status",
- "columns": [
- {
- "expression": "bot_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "spawn_group_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk": {
- "name": "bot_request_cloud_agent_sessions_bot_request_id_bot_requests_id_fk",
- "tableFrom": "bot_request_cloud_agent_sessions",
- "tableTo": "bot_requests",
- "columnsFrom": [
- "bot_request_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.bot_requests": {
- "name": "bot_requests",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_thread_id": {
- "name": "platform_thread_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_message_id": {
- "name": "platform_message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_message": {
- "name": "user_message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model_used": {
- "name": "model_used",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "steps": {
- "name": "steps",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "response_time_ms": {
- "name": "response_time_ms",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_bot_requests_created_at": {
- "name": "IDX_bot_requests_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_created_by": {
- "name": "IDX_bot_requests_created_by",
- "columns": [
- {
- "expression": "created_by",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_organization_id": {
- "name": "IDX_bot_requests_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_platform_integration_id": {
- "name": "IDX_bot_requests_platform_integration_id",
- "columns": [
- {
- "expression": "platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_bot_requests_status": {
- "name": "IDX_bot_requests_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "bot_requests_created_by_kilocode_users_id_fk": {
- "name": "bot_requests_created_by_kilocode_users_id_fk",
- "tableFrom": "bot_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "bot_requests_organization_id_organizations_id_fk": {
- "name": "bot_requests_organization_id_organizations_id_fk",
- "tableFrom": "bot_requests",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "bot_requests_platform_integration_id_platform_integrations_id_fk": {
- "name": "bot_requests_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "bot_requests",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.byok_api_keys": {
- "name": "byok_api_keys",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider_id": {
- "name": "provider_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_api_key": {
- "name": "encrypted_api_key",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "management_source": {
- "name": "management_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'user'"
- },
- "is_enabled": {
- "name": "is_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "IDX_byok_api_keys_organization_id": {
- "name": "IDX_byok_api_keys_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_byok_api_keys_kilo_user_id": {
- "name": "IDX_byok_api_keys_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_byok_api_keys_provider_id": {
- "name": "IDX_byok_api_keys_provider_id",
- "columns": [
- {
- "expression": "provider_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "byok_api_keys_organization_id_organizations_id_fk": {
- "name": "byok_api_keys_organization_id_organizations_id_fk",
- "tableFrom": "byok_api_keys",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "byok_api_keys_kilo_user_id_kilocode_users_id_fk": {
- "name": "byok_api_keys_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "byok_api_keys",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_byok_api_keys_org_provider": {
- "name": "UQ_byok_api_keys_org_provider",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "provider_id"
- ]
- },
- "UQ_byok_api_keys_user_provider": {
- "name": "UQ_byok_api_keys_user_provider",
- "nullsNotDistinct": false,
- "columns": [
- "kilo_user_id",
- "provider_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "byok_api_keys_management_source_check": {
- "name": "byok_api_keys_management_source_check",
- "value": "\"byok_api_keys\".\"management_source\" IN ('user', 'coding_plan')"
- },
- "byok_api_keys_owner_check": {
- "name": "byok_api_keys_owner_check",
- "value": "(\n (\"byok_api_keys\".\"kilo_user_id\" IS NOT NULL AND \"byok_api_keys\".\"organization_id\" IS NULL) OR\n (\"byok_api_keys\".\"kilo_user_id\" IS NULL AND \"byok_api_keys\".\"organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.cli_sessions": {
- "name": "cli_sessions",
- "schema": "",
- "columns": {
- "session_id": {
- "name": "session_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_on_platform": {
- "name": "created_on_platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "api_conversation_history_blob_url": {
- "name": "api_conversation_history_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "task_metadata_blob_url": {
- "name": "task_metadata_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ui_messages_blob_url": {
- "name": "ui_messages_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_state_blob_url": {
- "name": "git_state_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_url": {
- "name": "git_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "forked_from": {
- "name": "forked_from",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "parent_session_id": {
- "name": "parent_session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "last_mode": {
- "name": "last_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_model": {
- "name": "last_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_cli_sessions_kilo_user_id": {
- "name": "IDX_cli_sessions_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_created_at": {
- "name": "IDX_cli_sessions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_updated_at": {
- "name": "IDX_cli_sessions_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_organization_id": {
- "name": "IDX_cli_sessions_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_user_updated": {
- "name": "IDX_cli_sessions_user_updated",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cli_sessions_kilo_user_id_kilocode_users_id_fk": {
- "name": "cli_sessions_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "cli_sessions_forked_from_cli_sessions_session_id_fk": {
- "name": "cli_sessions_forked_from_cli_sessions_session_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "forked_from"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "cli_sessions_parent_session_id_cli_sessions_session_id_fk": {
- "name": "cli_sessions_parent_session_id_cli_sessions_session_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "parent_session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "cli_sessions_organization_id_organizations_id_fk": {
- "name": "cli_sessions_organization_id_organizations_id_fk",
- "tableFrom": "cli_sessions",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "cli_sessions_cloud_agent_session_id_unique": {
- "name": "cli_sessions_cloud_agent_session_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "cloud_agent_session_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.cli_sessions_v2": {
- "name": "cli_sessions_v2",
- "schema": "",
- "columns": {
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "version": {
- "name": "version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "public_id": {
- "name": "public_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "parent_session_id": {
- "name": "parent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_on_platform": {
- "name": "created_on_platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "git_url": {
- "name": "git_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status_updated_at": {
- "name": "status_updated_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_cli_sessions_v2_parent_session_id_kilo_user_id": {
- "name": "IDX_cli_sessions_v2_parent_session_id_kilo_user_id",
- "columns": [
- {
- "expression": "parent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cli_sessions_v2_public_id": {
- "name": "UQ_cli_sessions_v2_public_id",
- "columns": [
- {
- "expression": "public_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cli_sessions_v2\".\"public_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cli_sessions_v2_cloud_agent_session_id": {
- "name": "UQ_cli_sessions_v2_cloud_agent_session_id",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cli_sessions_v2\".\"cloud_agent_session_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_organization_id": {
- "name": "IDX_cli_sessions_v2_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_kilo_user_id": {
- "name": "IDX_cli_sessions_v2_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_created_at": {
- "name": "IDX_cli_sessions_v2_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cli_sessions_v2_user_updated": {
- "name": "IDX_cli_sessions_v2_user_updated",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "cli_sessions_v2_git_url_branch_idx": {
- "name": "cli_sessions_v2_git_url_branch_idx",
- "columns": [
- {
- "expression": "git_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk": {
- "name": "cli_sessions_v2_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "cli_sessions_v2",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "cli_sessions_v2_organization_id_organizations_id_fk": {
- "name": "cli_sessions_v2_organization_id_organizations_id_fk",
- "tableFrom": "cli_sessions_v2",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "cli_sessions_v2_parent_session_id_kilo_user_id_fk": {
- "name": "cli_sessions_v2_parent_session_id_kilo_user_id_fk",
- "tableFrom": "cli_sessions_v2",
- "tableTo": "cli_sessions_v2",
- "columnsFrom": [
- "parent_session_id",
- "kilo_user_id"
- ],
- "columnsTo": [
- "session_id",
- "kilo_user_id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "cli_sessions_v2_session_id_kilo_user_id_pk": {
- "name": "cli_sessions_v2_session_id_kilo_user_id_pk",
- "columns": [
- "session_id",
- "kilo_user_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.cloud_agent_code_review_attempts": {
- "name": "cloud_agent_code_review_attempts",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code_review_id": {
- "name": "code_review_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "attempt_number": {
- "name": "attempt_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "retry_of_attempt_id": {
- "name": "retry_of_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "retry_reason": {
- "name": "retry_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "execution_id": {
- "name": "execution_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analytics_enabled_at_dispatch": {
- "name": "analytics_enabled_at_dispatch",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_reason": {
- "name": "terminal_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_cloud_agent_code_review_attempts_review_attempt_number": {
- "name": "UQ_cloud_agent_code_review_attempts_review_attempt_number",
- "columns": [
- {
- "expression": "code_review_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "attempt_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_code_review_id": {
- "name": "idx_cloud_agent_code_review_attempts_code_review_id",
- "columns": [
- {
- "expression": "code_review_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_session_id": {
- "name": "idx_cloud_agent_code_review_attempts_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_cli_session_id": {
- "name": "idx_cloud_agent_code_review_attempts_cli_session_id",
- "columns": [
- {
- "expression": "cli_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_status": {
- "name": "idx_cloud_agent_code_review_attempts_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_review_attempts_retry_reason": {
- "name": "idx_cloud_agent_code_review_attempts_retry_reason",
- "columns": [
- {
- "expression": "retry_reason",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk": {
- "name": "cloud_agent_code_review_attempts_code_review_id_cloud_agent_code_reviews_id_fk",
- "tableFrom": "cloud_agent_code_review_attempts",
- "tableTo": "cloud_agent_code_reviews",
- "columnsFrom": [
- "code_review_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk": {
- "name": "cloud_agent_code_review_attempts_retry_of_attempt_id_cloud_agent_code_review_attempts_id_fk",
- "tableFrom": "cloud_agent_code_review_attempts",
- "tableTo": "cloud_agent_code_review_attempts",
- "columnsFrom": [
- "retry_of_attempt_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_code_review_attempts_attempt_number_check": {
- "name": "cloud_agent_code_review_attempts_attempt_number_check",
- "value": "\"cloud_agent_code_review_attempts\".\"attempt_number\" >= 1"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_code_reviews": {
- "name": "cloud_agent_code_reviews",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_title": {
- "name": "pr_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_author": {
- "name": "pr_author",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_author_github_id": {
- "name": "pr_author_github_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "base_ref": {
- "name": "base_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "head_ref": {
- "name": "head_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "head_sha": {
- "name": "head_sha",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "platform_project_id": {
- "name": "platform_project_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "dispatch_reservation_id": {
- "name": "dispatch_reservation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_reason": {
- "name": "terminal_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "agent_version": {
- "name": "agent_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'v1'"
- },
- "check_run_id": {
- "name": "check_run_id",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "repository_review_instructions_used": {
- "name": "repository_review_instructions_used",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "repository_review_instructions_ref": {
- "name": "repository_review_instructions_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repository_review_instructions_truncated": {
- "name": "repository_review_instructions_truncated",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "previous_summary_body": {
- "name": "previous_summary_body",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "previous_summary_head_sha": {
- "name": "previous_summary_head_sha",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "total_tokens_in": {
- "name": "total_tokens_in",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_tokens_out": {
- "name": "total_tokens_out",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_cost_musd": {
- "name": "total_cost_musd",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_cloud_agent_code_reviews_repo_pr_sha": {
- "name": "UQ_cloud_agent_code_reviews_repo_pr_sha",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "pr_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "head_sha",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_owned_by_org_id": {
- "name": "idx_cloud_agent_code_reviews_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_owned_by_user_id": {
- "name": "idx_cloud_agent_code_reviews_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_session_id": {
- "name": "idx_cloud_agent_code_reviews_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_cli_session_id": {
- "name": "idx_cloud_agent_code_reviews_cli_session_id",
- "columns": [
- {
- "expression": "cli_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_status": {
- "name": "idx_cloud_agent_code_reviews_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_repo": {
- "name": "idx_cloud_agent_code_reviews_repo",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_pr_number": {
- "name": "idx_cloud_agent_code_reviews_pr_number",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "pr_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_created_at": {
- "name": "idx_cloud_agent_code_reviews_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_cloud_agent_code_reviews_pr_author_github_id": {
- "name": "idx_cloud_agent_code_reviews_pr_author_github_id",
- "columns": [
- {
- "expression": "pr_author_github_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk": {
- "name": "cloud_agent_code_reviews_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "cloud_agent_code_reviews",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk": {
- "name": "cloud_agent_code_reviews_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "cloud_agent_code_reviews",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk": {
- "name": "cloud_agent_code_reviews_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "cloud_agent_code_reviews",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_code_reviews_owner_check": {
- "name": "cloud_agent_code_reviews_owner_check",
- "value": "(\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NOT NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NULL) OR\n (\"cloud_agent_code_reviews\".\"owned_by_user_id\" IS NULL AND \"cloud_agent_code_reviews\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_feedback": {
- "name": "cloud_agent_feedback",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repository": {
- "name": "repository",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_streaming": {
- "name": "is_streaming",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "message_count": {
- "name": "message_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "feedback_text": {
- "name": "feedback_text",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "recent_messages": {
- "name": "recent_messages",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_cloud_agent_feedback_created_at": {
- "name": "IDX_cloud_agent_feedback_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_feedback_kilo_user_id": {
- "name": "IDX_cloud_agent_feedback_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_feedback_cloud_agent_session_id": {
- "name": "IDX_cloud_agent_feedback_cloud_agent_session_id",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk": {
- "name": "cloud_agent_feedback_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "cloud_agent_feedback",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "cloud_agent_feedback_organization_id_organizations_id_fk": {
- "name": "cloud_agent_feedback_organization_id_organizations_id_fk",
- "tableFrom": "cloud_agent_feedback",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.cloud_agent_session_runs": {
- "name": "cloud_agent_session_runs",
- "schema": "",
- "columns": {
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "message_id": {
- "name": "message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "wrapper_run_id": {
- "name": "wrapper_run_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "queued_at": {
- "name": "queued_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "dispatch_accepted_at": {
- "name": "dispatch_accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "agent_activity_observed_at": {
- "name": "agent_activity_observed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "failure_stage": {
- "name": "failure_stage",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message_redacted": {
- "name": "error_message_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_expires_at": {
- "name": "error_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_cloud_agent_session_runs_wrapper_run_id": {
- "name": "IDX_cloud_agent_session_runs_wrapper_run_id",
- "columns": [
- {
- "expression": "wrapper_run_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_session_runs\".\"wrapper_run_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_session_queued": {
- "name": "IDX_cloud_agent_session_runs_session_queued",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_queued_at": {
- "name": "IDX_cloud_agent_session_runs_queued_at",
- "columns": [
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_terminal_at": {
- "name": "IDX_cloud_agent_session_runs_terminal_at",
- "columns": [
- {
- "expression": "terminal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_status_terminal": {
- "name": "IDX_cloud_agent_session_runs_status_terminal",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "terminal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_failure_terminal": {
- "name": "IDX_cloud_agent_session_runs_failure_terminal",
- "columns": [
- {
- "expression": "failure_stage",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "terminal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_session_runs_error_expires_at": {
- "name": "IDX_cloud_agent_session_runs_error_expires_at",
- "columns": [
- {
- "expression": "error_expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_session_runs\".\"error_expires_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk": {
- "name": "cloud_agent_session_runs_cloud_agent_session_id_cloud_agent_sessions_cloud_agent_session_id_fk",
- "tableFrom": "cloud_agent_session_runs",
- "tableTo": "cloud_agent_sessions",
- "columnsFrom": [
- "cloud_agent_session_id"
- ],
- "columnsTo": [
- "cloud_agent_session_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk": {
- "name": "cloud_agent_session_runs_cloud_agent_session_id_message_id_pk",
- "columns": [
- "cloud_agent_session_id",
- "message_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_session_runs_status_check": {
- "name": "cloud_agent_session_runs_status_check",
- "value": "\"cloud_agent_session_runs\".\"status\" IN ('queued', 'accepted', 'completed', 'failed', 'interrupted')"
- },
- "cloud_agent_session_runs_failure_classification_check": {
- "name": "cloud_agent_session_runs_failure_classification_check",
- "value": "(\"cloud_agent_session_runs\".\"failure_stage\" IS NULL AND \"cloud_agent_session_runs\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'pre_dispatch' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('sandbox_connect_failed', 'workspace_setup_failed', 'kilo_server_failed', 'wrapper_start_failed', 'invalid_delivery_request', 'session_metadata_missing', 'model_missing', 'delivery_failure_unknown')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'post_dispatch_no_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('wrapper_disconnected', 'wrapper_no_output', 'wrapper_ping_timeout', 'wrapper_error_before_activity', 'missing_assistant_reply')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'agent_activity' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('assistant_error', 'wrapper_error_after_activity')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'interruption' AND \"cloud_agent_session_runs\".\"failure_code\" IN ('user_interrupt', 'container_shutdown', 'system_interrupt')) OR\n (\"cloud_agent_session_runs\".\"failure_stage\" = 'unknown' AND \"cloud_agent_session_runs\".\"failure_code\" = 'unclassified')"
- },
- "cloud_agent_session_runs_error_message_bounded_check": {
- "name": "cloud_agent_session_runs_error_message_bounded_check",
- "value": "\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_session_runs\".\"error_message_redacted\") <= 4096"
- },
- "cloud_agent_session_runs_error_expiry_check": {
- "name": "cloud_agent_session_runs_error_expiry_check",
- "value": "(\"cloud_agent_session_runs\".\"error_message_redacted\" IS NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_session_runs\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_session_runs\".\"error_expires_at\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_sessions": {
- "name": "cloud_agent_sessions",
- "schema": "",
- "columns": {
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "kilo_session_id": {
- "name": "kilo_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "initial_message_id": {
- "name": "initial_message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sandbox_id": {
- "name": "sandbox_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "failure_at": {
- "name": "failure_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "failure_stage": {
- "name": "failure_stage",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message_redacted": {
- "name": "error_message_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_expires_at": {
- "name": "error_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_cloud_agent_sessions_kilo_session_id": {
- "name": "UQ_cloud_agent_sessions_kilo_session_id",
- "columns": [
- {
- "expression": "kilo_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cloud_agent_sessions_initial_message_id": {
- "name": "UQ_cloud_agent_sessions_initial_message_id",
- "columns": [
- {
- "expression": "initial_message_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_sandbox_id": {
- "name": "IDX_cloud_agent_sessions_sandbox_id",
- "columns": [
- {
- "expression": "sandbox_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"sandbox_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_created_at": {
- "name": "IDX_cloud_agent_sessions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_failure_created": {
- "name": "IDX_cloud_agent_sessions_failure_created",
- "columns": [
- {
- "expression": "failure_stage",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_failure_at": {
- "name": "IDX_cloud_agent_sessions_failure_at",
- "columns": [
- {
- "expression": "failure_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_failure_classification_at": {
- "name": "IDX_cloud_agent_sessions_failure_classification_at",
- "columns": [
- {
- "expression": "failure_stage",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "failure_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"failure_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_sessions_error_expires_at": {
- "name": "IDX_cloud_agent_sessions_error_expires_at",
- "columns": [
- {
- "expression": "error_expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"cloud_agent_sessions\".\"error_expires_at\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "cloud_agent_sessions_failure_classification_check": {
- "name": "cloud_agent_sessions_failure_classification_check",
- "value": "(\"cloud_agent_sessions\".\"failure_at\" IS NULL AND \"cloud_agent_sessions\".\"failure_stage\" IS NULL AND \"cloud_agent_sessions\".\"failure_code\" IS NULL) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'sandbox_identity' AND \"cloud_agent_sessions\".\"failure_code\" = 'sandbox_id_derivation_failed') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'registration' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_registration_rejected') OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'initial_admission' AND \"cloud_agent_sessions\".\"failure_code\" IN ('initial_admission_rejected', 'initial_queue_full', 'invalid_initial_intent')) OR\n (\"cloud_agent_sessions\".\"failure_at\" IS NOT NULL AND \"cloud_agent_sessions\".\"failure_stage\" = 'transport' AND \"cloud_agent_sessions\".\"failure_code\" = 'do_rpc_outcome_unknown')"
- },
- "cloud_agent_sessions_error_message_bounded_check": {
- "name": "cloud_agent_sessions_error_message_bounded_check",
- "value": "\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL OR char_length(\"cloud_agent_sessions\".\"error_message_redacted\") <= 4096"
- },
- "cloud_agent_sessions_error_expiry_check": {
- "name": "cloud_agent_sessions_error_expiry_check",
- "value": "(\"cloud_agent_sessions\".\"error_message_redacted\" IS NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NULL) OR\n (\"cloud_agent_sessions\".\"error_message_redacted\" IS NOT NULL AND \"cloud_agent_sessions\".\"error_expires_at\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.cloud_agent_webhook_triggers": {
- "name": "cloud_agent_webhook_triggers",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "trigger_id": {
- "name": "trigger_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "target_type": {
- "name": "target_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'cloud_agent'"
- },
- "kiloclaw_instance_id": {
- "name": "kiloclaw_instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "activation_mode": {
- "name": "activation_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'webhook'"
- },
- "cron_expression": {
- "name": "cron_expression",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cron_timezone": {
- "name": "cron_timezone",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'UTC'"
- },
- "github_repo": {
- "name": "github_repo",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "profile_id": {
- "name": "profile_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_cloud_agent_webhook_triggers_user_trigger": {
- "name": "UQ_cloud_agent_webhook_triggers_user_trigger",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "trigger_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cloud_agent_webhook_triggers\".\"user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_cloud_agent_webhook_triggers_org_trigger": {
- "name": "UQ_cloud_agent_webhook_triggers_org_trigger",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "trigger_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"cloud_agent_webhook_triggers\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_user": {
- "name": "IDX_cloud_agent_webhook_triggers_user",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_org": {
- "name": "IDX_cloud_agent_webhook_triggers_org",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_active": {
- "name": "IDX_cloud_agent_webhook_triggers_active",
- "columns": [
- {
- "expression": "is_active",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_cloud_agent_webhook_triggers_profile": {
- "name": "IDX_cloud_agent_webhook_triggers_profile",
- "columns": [
- {
- "expression": "profile_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk": {
- "name": "cloud_agent_webhook_triggers_user_id_kilocode_users_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_webhook_triggers_organization_id_organizations_id_fk": {
- "name": "cloud_agent_webhook_triggers_organization_id_organizations_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk": {
- "name": "cloud_agent_webhook_triggers_kiloclaw_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "kiloclaw_instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk": {
- "name": "cloud_agent_webhook_triggers_profile_id_agent_environment_profiles_id_fk",
- "tableFrom": "cloud_agent_webhook_triggers",
- "tableTo": "agent_environment_profiles",
- "columnsFrom": [
- "profile_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "CHK_cloud_agent_webhook_triggers_owner": {
- "name": "CHK_cloud_agent_webhook_triggers_owner",
- "value": "(\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NULL) OR\n (\"cloud_agent_webhook_triggers\".\"user_id\" IS NULL AND \"cloud_agent_webhook_triggers\".\"organization_id\" IS NOT NULL)\n )"
- },
- "CHK_cloud_agent_webhook_triggers_cloud_agent_fields": {
- "name": "CHK_cloud_agent_webhook_triggers_cloud_agent_fields",
- "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'cloud_agent' OR\n (\"cloud_agent_webhook_triggers\".\"github_repo\" IS NOT NULL AND \"cloud_agent_webhook_triggers\".\"profile_id\" IS NOT NULL)\n )"
- },
- "CHK_cloud_agent_webhook_triggers_kiloclaw_fields": {
- "name": "CHK_cloud_agent_webhook_triggers_kiloclaw_fields",
- "value": "(\n \"cloud_agent_webhook_triggers\".\"target_type\" != 'kiloclaw_chat' OR\n \"cloud_agent_webhook_triggers\".\"kiloclaw_instance_id\" IS NOT NULL\n )"
- },
- "CHK_cloud_agent_webhook_triggers_scheduled_fields": {
- "name": "CHK_cloud_agent_webhook_triggers_scheduled_fields",
- "value": "(\n \"cloud_agent_webhook_triggers\".\"activation_mode\" != 'scheduled' OR\n \"cloud_agent_webhook_triggers\".\"cron_expression\" IS NOT NULL\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_indexing_manifest": {
- "name": "code_indexing_manifest",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "file_hash": {
- "name": "file_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "file_path": {
- "name": "file_path",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "chunk_count": {
- "name": "chunk_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "total_lines": {
- "name": "total_lines",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_ai_lines": {
- "name": "total_ai_lines",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_code_indexing_manifest_organization_id": {
- "name": "IDX_code_indexing_manifest_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_kilo_user_id": {
- "name": "IDX_code_indexing_manifest_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_project_id": {
- "name": "IDX_code_indexing_manifest_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_git_branch": {
- "name": "IDX_code_indexing_manifest_git_branch",
- "columns": [
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_manifest_created_at": {
- "name": "IDX_code_indexing_manifest_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk": {
- "name": "code_indexing_manifest_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "code_indexing_manifest",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_indexing_manifest_org_user_project_hash_branch": {
- "name": "UQ_code_indexing_manifest_org_user_project_hash_branch",
- "nullsNotDistinct": true,
- "columns": [
- "organization_id",
- "kilo_user_id",
- "project_id",
- "file_path",
- "git_branch"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.code_indexing_search": {
- "name": "code_indexing_search",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "query": {
- "name": "query",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_code_indexing_search_organization_id": {
- "name": "IDX_code_indexing_search_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_search_kilo_user_id": {
- "name": "IDX_code_indexing_search_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_search_project_id": {
- "name": "IDX_code_indexing_search_project_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_code_indexing_search_created_at": {
- "name": "IDX_code_indexing_search_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_indexing_search_kilo_user_id_kilocode_users_id_fk": {
- "name": "code_indexing_search_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "code_indexing_search",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.code_review_analytics_findings": {
- "name": "code_review_analytics_findings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "analytics_result_id": {
- "name": "analytics_result_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "ordinal": {
- "name": "ordinal",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "severity": {
- "name": "severity",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "category": {
- "name": "category",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "security_class": {
- "name": "security_class",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk": {
- "name": "code_review_analytics_findings_analytics_result_id_code_review_analytics_results_id_fk",
- "tableFrom": "code_review_analytics_findings",
- "tableTo": "code_review_analytics_results",
- "columnsFrom": [
- "analytics_result_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_review_analytics_findings_result_ordinal": {
- "name": "UQ_code_review_analytics_findings_result_ordinal",
- "nullsNotDistinct": false,
- "columns": [
- "analytics_result_id",
- "ordinal"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "code_review_analytics_findings_severity_check": {
- "name": "code_review_analytics_findings_severity_check",
- "value": "\"code_review_analytics_findings\".\"severity\" IN ('critical', 'warning', 'suggestion')"
- },
- "code_review_analytics_findings_category_check": {
- "name": "code_review_analytics_findings_category_check",
- "value": "\"code_review_analytics_findings\".\"category\" IN ('security', 'correctness', 'reliability', 'data_integrity', 'performance', 'compatibility', 'maintainability', 'test_quality', 'documentation', 'accessibility', 'other')"
- },
- "code_review_analytics_findings_security_class_check": {
- "name": "code_review_analytics_findings_security_class_check",
- "value": "\"code_review_analytics_findings\".\"security_class\" IN ('auth_access', 'injection', 'data_protection', 'request_resource_boundary', 'deserialization_object_integrity', 'dependency_supply_chain', 'memory_safety', 'availability', 'concurrency', 'security_configuration', 'other')"
- },
- "code_review_analytics_findings_ordinal_check": {
- "name": "code_review_analytics_findings_ordinal_check",
- "value": "\"code_review_analytics_findings\".\"ordinal\" >= 0"
- },
- "code_review_analytics_findings_security_class_presence_check": {
- "name": "code_review_analytics_findings_security_class_presence_check",
- "value": "(\n (\"code_review_analytics_findings\".\"category\" = 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NOT NULL) OR\n (\"code_review_analytics_findings\".\"category\" <> 'security' AND \"code_review_analytics_findings\".\"security_class\" IS NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_review_analytics_results": {
- "name": "code_review_analytics_results",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code_review_id": {
- "name": "code_review_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "source_attempt_id": {
- "name": "source_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "capture_status": {
- "name": "capture_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "schema_version": {
- "name": "schema_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "taxonomy_version": {
- "name": "taxonomy_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "change_type": {
- "name": "change_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "impact_level": {
- "name": "impact_level",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "complexity_level": {
- "name": "complexity_level",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "classification_confidence": {
- "name": "classification_confidence",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finalized_at": {
- "name": "finalized_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_code_review_analytics_results_source_attempt_id": {
- "name": "idx_code_review_analytics_results_source_attempt_id",
- "columns": [
- {
- "expression": "source_attempt_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_analytics_results_finalized_at": {
- "name": "idx_code_review_analytics_results_finalized_at",
- "columns": [
- {
- "expression": "finalized_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk": {
- "name": "code_review_analytics_results_code_review_id_cloud_agent_code_reviews_id_fk",
- "tableFrom": "code_review_analytics_results",
- "tableTo": "cloud_agent_code_reviews",
- "columnsFrom": [
- "code_review_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk": {
- "name": "code_review_analytics_results_source_attempt_id_cloud_agent_code_review_attempts_id_fk",
- "tableFrom": "code_review_analytics_results",
- "tableTo": "cloud_agent_code_review_attempts",
- "columnsFrom": [
- "source_attempt_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_review_analytics_results_code_review_id": {
- "name": "UQ_code_review_analytics_results_code_review_id",
- "nullsNotDistinct": false,
- "columns": [
- "code_review_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "code_review_analytics_results_capture_status_check": {
- "name": "code_review_analytics_results_capture_status_check",
- "value": "\"code_review_analytics_results\".\"capture_status\" IN ('captured', 'missing', 'invalid', 'omitted')"
- },
- "code_review_analytics_results_change_type_check": {
- "name": "code_review_analytics_results_change_type_check",
- "value": "\"code_review_analytics_results\".\"change_type\" IN ('bug_fix', 'feature', 'refactor', 'maintenance', 'dependency', 'test', 'documentation', 'mixed', 'other')"
- },
- "code_review_analytics_results_impact_level_check": {
- "name": "code_review_analytics_results_impact_level_check",
- "value": "\"code_review_analytics_results\".\"impact_level\" IN ('low', 'medium', 'high')"
- },
- "code_review_analytics_results_complexity_level_check": {
- "name": "code_review_analytics_results_complexity_level_check",
- "value": "\"code_review_analytics_results\".\"complexity_level\" IN ('low', 'medium', 'high')"
- },
- "code_review_analytics_results_classification_confidence_check": {
- "name": "code_review_analytics_results_classification_confidence_check",
- "value": "\"code_review_analytics_results\".\"classification_confidence\" IN ('low', 'medium', 'high')"
- },
- "code_review_analytics_results_classification_presence_check": {
- "name": "code_review_analytics_results_classification_presence_check",
- "value": "(\n (\n \"code_review_analytics_results\".\"capture_status\" = 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NOT NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NOT NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NOT NULL\n ) OR (\n \"code_review_analytics_results\".\"capture_status\" <> 'captured'\n AND \"code_review_analytics_results\".\"change_type\" IS NULL\n AND \"code_review_analytics_results\".\"impact_level\" IS NULL\n AND \"code_review_analytics_results\".\"complexity_level\" IS NULL\n AND \"code_review_analytics_results\".\"classification_confidence\" IS NULL\n )\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_review_feedback_events": {
- "name": "code_review_feedback_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_comment_id": {
- "name": "kilo_comment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reply_excerpt": {
- "name": "reply_excerpt",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_comment_excerpt": {
- "name": "kilo_comment_excerpt",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "dedupe_hash": {
- "name": "dedupe_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "occurred_at": {
- "name": "occurred_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_code_review_feedback_events_owned_by_org_id": {
- "name": "idx_code_review_feedback_events_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_feedback_events_owned_by_user_id": {
- "name": "idx_code_review_feedback_events_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_feedback_events_platform_repo": {
- "name": "idx_code_review_feedback_events_platform_repo",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_feedback_events_created_at": {
- "name": "idx_code_review_feedback_events_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_review_feedback_events_owned_by_organization_id_organizations_id_fk": {
- "name": "code_review_feedback_events_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "code_review_feedback_events",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk": {
- "name": "code_review_feedback_events_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "code_review_feedback_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_code_review_feedback_events_dedupe_hash": {
- "name": "UQ_code_review_feedback_events_dedupe_hash",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_hash"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "code_review_feedback_events_owner_check": {
- "name": "code_review_feedback_events_owner_check",
- "value": "(\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_feedback_events\".\"owned_by_user_id\" IS NULL AND \"code_review_feedback_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.code_review_memory_proposals": {
- "name": "code_review_memory_proposals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'open'"
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "rationale": {
- "name": "rationale",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "proposed_markdown": {
- "name": "proposed_markdown",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "evidence": {
- "name": "evidence",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'[]'::jsonb"
- },
- "positive_count": {
- "name": "positive_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "negative_count": {
- "name": "negative_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "neutral_count": {
- "name": "neutral_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "change_request_url": {
- "name": "change_request_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_code_review_memory_proposals_owned_by_org_id": {
- "name": "idx_code_review_memory_proposals_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_memory_proposals_owned_by_user_id": {
- "name": "idx_code_review_memory_proposals_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_memory_proposals_platform_repo_status": {
- "name": "idx_code_review_memory_proposals_platform_repo_status",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_code_review_memory_proposals_updated_at": {
- "name": "idx_code_review_memory_proposals_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_code_review_memory_proposals_org_active_scope": {
- "name": "UQ_code_review_memory_proposals_org_active_scope",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_code_review_memory_proposals_user_active_scope": {
- "name": "UQ_code_review_memory_proposals_user_active_scope",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"status\" IN ('open', 'edited', 'opening_change_request')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk": {
- "name": "code_review_memory_proposals_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "code_review_memory_proposals",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk": {
- "name": "code_review_memory_proposals_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "code_review_memory_proposals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "code_review_memory_proposals_owner_check": {
- "name": "code_review_memory_proposals_owner_check",
- "value": "(\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NOT NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NULL) OR\n (\"code_review_memory_proposals\".\"owned_by_user_id\" IS NULL AND \"code_review_memory_proposals\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.coding_plan_availability_intents": {
- "name": "coding_plan_availability_intents",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_availability_intents_user_plan": {
- "name": "UQ_coding_plan_availability_intents_user_plan",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_availability_intents_plan": {
- "name": "IDX_coding_plan_availability_intents_plan",
- "columns": [
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_availability_intents_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_availability_intents_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_availability_intents",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.coding_plan_key_inventory": {
- "name": "coding_plan_key_inventory",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_id": {
- "name": "provider_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "upstream_plan_id": {
- "name": "upstream_plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_api_key": {
- "name": "encrypted_api_key",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "credential_fingerprint": {
- "name": "credential_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'available'"
- },
- "assigned_to_user_id": {
- "name": "assigned_to_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "assigned_at": {
- "name": "assigned_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_requested_at": {
- "name": "revocation_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_attempt_count": {
- "name": "revocation_attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "last_revocation_error": {
- "name": "last_revocation_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_key_inv_fingerprint": {
- "name": "UQ_coding_plan_key_inv_fingerprint",
- "columns": [
- {
- "expression": "credential_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_key_inv_plan_status": {
- "name": "IDX_coding_plan_key_inv_plan_status",
- "columns": [
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_key_inv_available": {
- "name": "IDX_coding_plan_key_inv_available",
- "columns": [
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"coding_plan_key_inventory\".\"status\" = 'available'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_key_inventory_assigned_to_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_key_inventory",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "assigned_to_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "coding_plan_key_inventory_status_check": {
- "name": "coding_plan_key_inventory_status_check",
- "value": "\"coding_plan_key_inventory\".\"status\" IN ('available', 'assigned', 'revocation_pending', 'revoked', 'revocation_failed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.coding_plan_subscriptions": {
- "name": "coding_plan_subscriptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_id": {
- "name": "provider_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "key_inventory_id": {
- "name": "key_inventory_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "installed_byok_key_id": {
- "name": "installed_byok_key_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cost_microdollars": {
- "name": "cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "billing_period_days": {
- "name": "billing_period_days",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "current_period_start": {
- "name": "current_period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "current_period_end": {
- "name": "current_period_end",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "credit_renewal_at": {
- "name": "credit_renewal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "cancel_at_period_end": {
- "name": "cancel_at_period_end",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "past_due_started_at": {
- "name": "past_due_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "payment_grace_expires_at": {
- "name": "payment_grace_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_top_up_attempted_for_due": {
- "name": "auto_top_up_attempted_for_due",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "canceled_at": {
- "name": "canceled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "cancellation_reason": {
- "name": "cancellation_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_sub_live_user_plan": {
- "name": "UQ_coding_plan_sub_live_user_plan",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_sub_status": {
- "name": "IDX_coding_plan_sub_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_sub_renewal": {
- "name": "IDX_coding_plan_sub_renewal",
- "columns": [
- {
- "expression": "credit_renewal_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_sub_inventory": {
- "name": "IDX_coding_plan_sub_inventory",
- "columns": [
- {
- "expression": "key_inventory_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_subscriptions_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_subscriptions_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_subscriptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk": {
- "name": "coding_plan_subscriptions_key_inventory_id_coding_plan_key_inventory_id_fk",
- "tableFrom": "coding_plan_subscriptions",
- "tableTo": "coding_plan_key_inventory",
- "columnsFrom": [
- "key_inventory_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk": {
- "name": "coding_plan_subscriptions_installed_byok_key_id_byok_api_keys_id_fk",
- "tableFrom": "coding_plan_subscriptions",
- "tableTo": "byok_api_keys",
- "columnsFrom": [
- "installed_byok_key_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "coding_plan_subscriptions_status_check": {
- "name": "coding_plan_subscriptions_status_check",
- "value": "\"coding_plan_subscriptions\".\"status\" IN ('active', 'past_due', 'canceled')"
- },
- "coding_plan_subscriptions_live_access_check": {
- "name": "coding_plan_subscriptions_live_access_check",
- "value": "\"coding_plan_subscriptions\".\"status\" = 'canceled' OR \"coding_plan_subscriptions\".\"key_inventory_id\" IS NOT NULL"
- }
- },
- "isRLSEnabled": false
- },
- "public.coding_plan_terms": {
- "name": "coding_plan_terms",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan_id": {
- "name": "plan_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kind": {
- "name": "kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_start": {
- "name": "period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "period_end": {
- "name": "period_end",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "cost_microdollars": {
- "name": "cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "credit_transaction_id": {
- "name": "credit_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_coding_plan_terms_request": {
- "name": "UQ_coding_plan_terms_request",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "plan_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "idempotency_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_coding_plan_terms_subscription": {
- "name": "IDX_coding_plan_terms_subscription",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk": {
- "name": "coding_plan_terms_subscription_id_coding_plan_subscriptions_id_fk",
- "tableFrom": "coding_plan_terms",
- "tableTo": "coding_plan_subscriptions",
- "columnsFrom": [
- "subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "coding_plan_terms_user_id_kilocode_users_id_fk": {
- "name": "coding_plan_terms_user_id_kilocode_users_id_fk",
- "tableFrom": "coding_plan_terms",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk": {
- "name": "coding_plan_terms_credit_transaction_id_credit_transactions_id_fk",
- "tableFrom": "coding_plan_terms",
- "tableTo": "credit_transactions",
- "columnsFrom": [
- "credit_transaction_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "coding_plan_terms_kind_check": {
- "name": "coding_plan_terms_kind_check",
- "value": "\"coding_plan_terms\".\"kind\" IN ('activation', 'extension', 'renewal')"
- }
- },
- "isRLSEnabled": false
- },
- "public.contributor_champion_contributors": {
- "name": "contributor_champion_contributors",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "github_login": {
- "name": "github_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_profile_url": {
- "name": "github_profile_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_user_id": {
- "name": "github_user_id",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "first_contribution_at": {
- "name": "first_contribution_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_contribution_at": {
- "name": "last_contribution_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "all_time_contributions": {
- "name": "all_time_contributions",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "manual_email": {
- "name": "manual_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_contributor_champion_contributors_last_contribution_at": {
- "name": "IDX_contributor_champion_contributors_last_contribution_at",
- "columns": [
- {
- "expression": "last_contribution_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_contributors_manual_email": {
- "name": "IDX_contributor_champion_contributors_manual_email",
- "columns": [
- {
- "expression": "manual_email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_contributor_champion_contributors_github_login": {
- "name": "UQ_contributor_champion_contributors_github_login",
- "nullsNotDistinct": false,
- "columns": [
- "github_login"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.contributor_champion_events": {
- "name": "contributor_champion_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "contributor_id": {
- "name": "contributor_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_pr_number": {
- "name": "github_pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "github_pr_url": {
- "name": "github_pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_pr_title": {
- "name": "github_pr_title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_author_login": {
- "name": "github_author_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_author_email": {
- "name": "github_author_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "merged_at": {
- "name": "merged_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_contributor_champion_events_contributor_id": {
- "name": "IDX_contributor_champion_events_contributor_id",
- "columns": [
- {
- "expression": "contributor_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_events_merged_at": {
- "name": "IDX_contributor_champion_events_merged_at",
- "columns": [
- {
- "expression": "merged_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_events_author_email": {
- "name": "IDX_contributor_champion_events_author_email",
- "columns": [
- {
- "expression": "github_author_email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk": {
- "name": "contributor_champion_events_contributor_id_contributor_champion_contributors_id_fk",
- "tableFrom": "contributor_champion_events",
- "tableTo": "contributor_champion_contributors",
- "columnsFrom": [
- "contributor_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_contributor_champion_events_repo_pr": {
- "name": "UQ_contributor_champion_events_repo_pr",
- "nullsNotDistinct": false,
- "columns": [
- "repo_full_name",
- "github_pr_number"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.contributor_champion_memberships": {
- "name": "contributor_champion_memberships",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "contributor_id": {
- "name": "contributor_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "selected_tier": {
- "name": "selected_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "enrolled_tier": {
- "name": "enrolled_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "enrolled_at": {
- "name": "enrolled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "credit_amount_microdollars": {
- "name": "credit_amount_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "credits_last_granted_at": {
- "name": "credits_last_granted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "linked_kilo_user_id": {
- "name": "linked_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_contributor_champion_memberships_credits_due": {
- "name": "IDX_contributor_champion_memberships_credits_due",
- "columns": [
- {
- "expression": "credits_last_granted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NOT NULL AND \"contributor_champion_memberships\".\"credit_amount_microdollars\" > 0",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_contributor_champion_memberships_linked_kilo_user_id": {
- "name": "IDX_contributor_champion_memberships_linked_kilo_user_id",
- "columns": [
- {
- "expression": "linked_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk": {
- "name": "contributor_champion_memberships_contributor_id_contributor_champion_contributors_id_fk",
- "tableFrom": "contributor_champion_memberships",
- "tableTo": "contributor_champion_contributors",
- "columnsFrom": [
- "contributor_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk": {
- "name": "contributor_champion_memberships_linked_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "contributor_champion_memberships",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "linked_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_contributor_champion_memberships_contributor_id": {
- "name": "UQ_contributor_champion_memberships_contributor_id",
- "nullsNotDistinct": false,
- "columns": [
- "contributor_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "contributor_champion_memberships_selected_tier_check": {
- "name": "contributor_champion_memberships_selected_tier_check",
- "value": "\"contributor_champion_memberships\".\"selected_tier\" IS NULL OR \"contributor_champion_memberships\".\"selected_tier\" IN ('contributor', 'ambassador', 'champion')"
- },
- "contributor_champion_memberships_enrolled_tier_check": {
- "name": "contributor_champion_memberships_enrolled_tier_check",
- "value": "\"contributor_champion_memberships\".\"enrolled_tier\" IS NULL OR \"contributor_champion_memberships\".\"enrolled_tier\" IN ('contributor', 'ambassador', 'champion')"
- }
- },
- "isRLSEnabled": false
- },
- "public.contributor_champion_sync_state": {
- "name": "contributor_champion_sync_state",
- "schema": "",
- "columns": {
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "last_merged_at": {
- "name": "last_merged_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_synced_at": {
- "name": "last_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.credit_campaigns": {
- "name": "credit_campaigns",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "credit_category": {
- "name": "credit_category",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_microdollars": {
- "name": "amount_microdollars",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "credit_expiry_hours": {
- "name": "credit_expiry_hours",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "campaign_ends_at": {
- "name": "campaign_ends_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "total_redemptions_allowed": {
- "name": "total_redemptions_allowed",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "active": {
- "name": "active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_credit_campaigns_slug": {
- "name": "UQ_credit_campaigns_slug",
- "columns": [
- {
- "expression": "slug",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_credit_campaigns_credit_category": {
- "name": "UQ_credit_campaigns_credit_category",
- "columns": [
- {
- "expression": "credit_category",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "credit_campaigns_slug_format_check": {
- "name": "credit_campaigns_slug_format_check",
- "value": "\"credit_campaigns\".\"slug\" ~ '^[a-z0-9-]{5,40}$'"
- },
- "credit_campaigns_amount_positive_check": {
- "name": "credit_campaigns_amount_positive_check",
- "value": "\"credit_campaigns\".\"amount_microdollars\" > 0"
- },
- "credit_campaigns_credit_expiry_hours_positive_check": {
- "name": "credit_campaigns_credit_expiry_hours_positive_check",
- "value": "\"credit_campaigns\".\"credit_expiry_hours\" IS NULL OR \"credit_campaigns\".\"credit_expiry_hours\" > 0"
- },
- "credit_campaigns_total_redemptions_allowed_positive_check": {
- "name": "credit_campaigns_total_redemptions_allowed_positive_check",
- "value": "\"credit_campaigns\".\"total_redemptions_allowed\" > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.credit_transactions": {
- "name": "credit_transactions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_microdollars": {
- "name": "amount_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "expiration_baseline_microdollars_used": {
- "name": "expiration_baseline_microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "original_baseline_microdollars_used": {
- "name": "original_baseline_microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "is_free": {
- "name": "is_free",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "original_transaction_id": {
- "name": "original_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_id": {
- "name": "stripe_payment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "coinbase_credit_block_id": {
- "name": "coinbase_credit_block_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "credit_category": {
- "name": "credit_category",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "expiry_date": {
- "name": "expiry_date",
- "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()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "check_category_uniqueness": {
- "name": "check_category_uniqueness",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- }
- },
- "indexes": {
- "IDX_credit_transactions_created_at": {
- "name": "IDX_credit_transactions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_is_free": {
- "name": "IDX_credit_transactions_is_free",
- "columns": [
- {
- "expression": "is_free",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_kilo_user_id": {
- "name": "IDX_credit_transactions_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_credit_category": {
- "name": "IDX_credit_transactions_credit_category",
- "columns": [
- {
- "expression": "credit_category",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_stripe_payment_id": {
- "name": "IDX_credit_transactions_stripe_payment_id",
- "columns": [
- {
- "expression": "stripe_payment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_original_transaction_id": {
- "name": "IDX_credit_transactions_original_transaction_id",
- "columns": [
- {
- "expression": "original_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_coinbase_credit_block_id": {
- "name": "IDX_credit_transactions_coinbase_credit_block_id",
- "columns": [
- {
- "expression": "coinbase_credit_block_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_organization_id": {
- "name": "IDX_credit_transactions_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_credit_transactions_unique_category": {
- "name": "IDX_credit_transactions_unique_category",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "credit_category",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"credit_transactions\".\"check_category_uniqueness\" = TRUE",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "credit_transactions_created_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "credit_transactions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.custom_llm2": {
- "name": "custom_llm2",
- "schema": "",
- "columns": {
- "public_id": {
- "name": "public_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "definition": {
- "name": "definition",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deleted_user_email_tombstones": {
- "name": "deleted_user_email_tombstones",
- "schema": "",
- "columns": {
- "normalized_email_hash": {
- "name": "normalized_email_hash",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_builds": {
- "name": "deployment_builds",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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": {
- "idx_deployment_builds_deployment_id": {
- "name": "idx_deployment_builds_deployment_id",
- "columns": [
- {
- "expression": "deployment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_builds_status": {
- "name": "idx_deployment_builds_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_builds_deployment_id_deployments_id_fk": {
- "name": "deployment_builds_deployment_id_deployments_id_fk",
- "tableFrom": "deployment_builds",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_env_vars": {
- "name": "deployment_env_vars",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "key": {
- "name": "key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_secret": {
- "name": "is_secret",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_deployment_env_vars_deployment_id": {
- "name": "idx_deployment_env_vars_deployment_id",
- "columns": [
- {
- "expression": "deployment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_env_vars_deployment_id_deployments_id_fk": {
- "name": "deployment_env_vars_deployment_id_deployments_id_fk",
- "tableFrom": "deployment_env_vars",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_deployment_env_vars_deployment_key": {
- "name": "UQ_deployment_env_vars_deployment_key",
- "nullsNotDistinct": false,
- "columns": [
- "deployment_id",
- "key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_events": {
- "name": "deployment_events",
- "schema": "",
- "columns": {
- "build_id": {
- "name": "build_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "event_id": {
- "name": "event_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'log'"
- },
- "timestamp": {
- "name": "timestamp",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "payload": {
- "name": "payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "idx_deployment_events_build_id": {
- "name": "idx_deployment_events_build_id",
- "columns": [
- {
- "expression": "build_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_events_timestamp": {
- "name": "idx_deployment_events_timestamp",
- "columns": [
- {
- "expression": "timestamp",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_events_type": {
- "name": "idx_deployment_events_type",
- "columns": [
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_events_build_id_deployment_builds_id_fk": {
- "name": "deployment_events_build_id_deployment_builds_id_fk",
- "tableFrom": "deployment_events",
- "tableTo": "deployment_builds",
- "columnsFrom": [
- "build_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "deployment_events_build_id_event_id_pk": {
- "name": "deployment_events_build_id_event_id_pk",
- "columns": [
- "build_id",
- "event_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployment_threat_detections": {
- "name": "deployment_threat_detections",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "deployment_id": {
- "name": "deployment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "build_id": {
- "name": "build_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "threat_type": {
- "name": "threat_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_deployment_threat_detections_deployment_id": {
- "name": "idx_deployment_threat_detections_deployment_id",
- "columns": [
- {
- "expression": "deployment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployment_threat_detections_created_at": {
- "name": "idx_deployment_threat_detections_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployment_threat_detections_deployment_id_deployments_id_fk": {
- "name": "deployment_threat_detections_deployment_id_deployments_id_fk",
- "tableFrom": "deployment_threat_detections",
- "tableTo": "deployments",
- "columnsFrom": [
- "deployment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "deployment_threat_detections_build_id_deployment_builds_id_fk": {
- "name": "deployment_threat_detections_build_id_deployment_builds_id_fk",
- "tableFrom": "deployment_threat_detections",
- "tableTo": "deployment_builds",
- "columnsFrom": [
- "build_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.deployments": {
- "name": "deployments",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "deployment_slug": {
- "name": "deployment_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "internal_worker_name": {
- "name": "internal_worker_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "repository_source": {
- "name": "repository_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "branch": {
- "name": "branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "deployment_url": {
- "name": "deployment_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "source_type": {
- "name": "source_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'github'"
- },
- "git_auth_token": {
- "name": "git_auth_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "last_deployed_at": {
- "name": "last_deployed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_build_id": {
- "name": "last_build_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "threat_status": {
- "name": "threat_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_from": {
- "name": "created_from",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_deployments_owned_by_user_id": {
- "name": "idx_deployments_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_owned_by_organization_id": {
- "name": "idx_deployments_owned_by_organization_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_platform_integration_id": {
- "name": "idx_deployments_platform_integration_id",
- "columns": [
- {
- "expression": "platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_repository_source_branch": {
- "name": "idx_deployments_repository_source_branch",
- "columns": [
- {
- "expression": "repository_source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_threat_status_pending": {
- "name": "idx_deployments_threat_status_pending",
- "columns": [
- {
- "expression": "threat_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"deployments\".\"threat_status\" = 'pending_scan'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployments_owned_by_user_id_kilocode_users_id_fk": {
- "name": "deployments_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "deployments",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "deployments_owned_by_organization_id_organizations_id_fk": {
- "name": "deployments_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "deployments",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_deployments_deployment_slug": {
- "name": "UQ_deployments_deployment_slug",
- "nullsNotDistinct": false,
- "columns": [
- "deployment_slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "deployments_owner_check": {
- "name": "deployments_owner_check",
- "value": "(\n (\"deployments\".\"owned_by_user_id\" IS NOT NULL AND \"deployments\".\"owned_by_organization_id\" IS NULL) OR\n (\"deployments\".\"owned_by_user_id\" IS NULL AND \"deployments\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "deployments_source_type_check": {
- "name": "deployments_source_type_check",
- "value": "\"deployments\".\"source_type\" IN ('github', 'git', 'app-builder')"
- }
- },
- "isRLSEnabled": false
- },
- "public.deployments_ephemeral": {
- "name": "deployments_ephemeral",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_type": {
- "name": "source_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "internal_worker_name": {
- "name": "internal_worker_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "deployment_slug": {
- "name": "deployment_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "next_cleanup_at": {
- "name": "next_cleanup_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "cleanup_claim_token": {
- "name": "cleanup_claim_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "cleanup_claimed_until": {
- "name": "cleanup_claimed_until",
- "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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_deployments_ephemeral_owned_by_user_id": {
- "name": "idx_deployments_ephemeral_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_deployments_ephemeral_next_cleanup_at": {
- "name": "idx_deployments_ephemeral_next_cleanup_at",
- "columns": [
- {
- "expression": "next_cleanup_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk": {
- "name": "deployments_ephemeral_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "deployments_ephemeral",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_deployments_ephemeral_internal_worker_name": {
- "name": "UQ_deployments_ephemeral_internal_worker_name",
- "nullsNotDistinct": false,
- "columns": [
- "internal_worker_name"
- ]
- },
- "UQ_deployments_ephemeral_deployment_slug": {
- "name": "UQ_deployments_ephemeral_deployment_slug",
- "nullsNotDistinct": false,
- "columns": [
- "deployment_slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "deployments_ephemeral_source_type_check": {
- "name": "deployments_ephemeral_source_type_check",
- "value": "\"deployments_ephemeral\".\"source_type\" IN ('html')"
- },
- "deployments_ephemeral_status_check": {
- "name": "deployments_ephemeral_status_check",
- "value": "\"deployments_ephemeral\".\"status\" IN ('pending', 'active', 'cleanup_retry')"
- },
- "deployments_ephemeral_claim_fields_check": {
- "name": "deployments_ephemeral_claim_fields_check",
- "value": "(\"deployments_ephemeral\".\"cleanup_claim_token\" IS NULL) = (\"deployments_ephemeral\".\"cleanup_claimed_until\" IS NULL)"
- },
- "deployments_ephemeral_active_fields_check": {
- "name": "deployments_ephemeral_active_fields_check",
- "value": "\"deployments_ephemeral\".\"status\" <> 'active' OR (\"deployments_ephemeral\".\"deployment_slug\" IS NOT NULL AND \"deployments_ephemeral\".\"expires_at\" IS NOT NULL)"
- }
- },
- "isRLSEnabled": false
- },
- "public.device_auth_requests": {
- "name": "device_auth_requests",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "approved_at": {
- "name": "approved_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "user_agent": {
- "name": "user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ip_address": {
- "name": "ip_address",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_device_auth_requests_code": {
- "name": "UQ_device_auth_requests_code",
- "columns": [
- {
- "expression": "code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_device_auth_requests_status": {
- "name": "IDX_device_auth_requests_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_device_auth_requests_expires_at": {
- "name": "IDX_device_auth_requests_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_device_auth_requests_kilo_user_id": {
- "name": "IDX_device_auth_requests_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "device_auth_requests_kilo_user_id_kilocode_users_id_fk": {
- "name": "device_auth_requests_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "device_auth_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.discord_gateway_listener": {
- "name": "discord_gateway_listener",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "default": 1
- },
- "listener_id": {
- "name": "listener_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "started_at": {
- "name": "started_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": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.editor_name": {
- "name": "editor_name",
- "schema": "",
- "columns": {
- "editor_name_id": {
- "name": "editor_name_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "editor_name": {
- "name": "editor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_editor_name": {
- "name": "UQ_editor_name",
- "columns": [
- {
- "expression": "editor_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.enrichment_data": {
- "name": "enrichment_data",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_enrichment_data": {
- "name": "github_enrichment_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "linkedin_enrichment_data": {
- "name": "linkedin_enrichment_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "clay_enrichment_data": {
- "name": "clay_enrichment_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_enrichment_data_user_id": {
- "name": "IDX_enrichment_data_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "enrichment_data_user_id_kilocode_users_id_fk": {
- "name": "enrichment_data_user_id_kilocode_users_id_fk",
- "tableFrom": "enrichment_data",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_enrichment_data_user_id": {
- "name": "UQ_enrichment_data_user_id",
- "nullsNotDistinct": false,
- "columns": [
- "user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.exa_monthly_usage": {
- "name": "exa_monthly_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "month": {
- "name": "month",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "total_cost_microdollars": {
- "name": "total_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "total_charged_microdollars": {
- "name": "total_charged_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "request_count": {
- "name": "request_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "free_allowance_microdollars": {
- "name": "free_allowance_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 10000000
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_exa_monthly_usage_personal": {
- "name": "idx_exa_monthly_usage_personal",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "month",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"exa_monthly_usage\".\"organization_id\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_exa_monthly_usage_org": {
- "name": "idx_exa_monthly_usage_org",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "month",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"exa_monthly_usage\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.exa_usage_log": {
- "name": "exa_usage_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "path": {
- "name": "path",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cost_microdollars": {
- "name": "cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "charged_to_balance": {
- "name": "charged_to_balance",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "feature_id": {
- "name": "feature_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_exa_usage_log_user_created": {
- "name": "idx_exa_usage_log_user_created",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {
- "exa_usage_log_id_created_at_pk": {
- "name": "exa_usage_log_id_created_at_pk",
- "columns": [
- "id",
- "created_at"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.feature": {
- "name": "feature",
- "schema": "",
- "columns": {
- "feature_id": {
- "name": "feature_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "feature": {
- "name": "feature",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_feature": {
- "name": "UQ_feature",
- "columns": [
- {
- "expression": "feature",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.finish_reason": {
- "name": "finish_reason",
- "schema": "",
- "columns": {
- "finish_reason_id": {
- "name": "finish_reason_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "finish_reason": {
- "name": "finish_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_finish_reason": {
- "name": "UQ_finish_reason",
- "columns": [
- {
- "expression": "finish_reason",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.free_model_usage": {
- "name": "free_model_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "ip_address": {
- "name": "ip_address",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_free_model_usage_ip_created_at": {
- "name": "idx_free_model_usage_ip_created_at",
- "columns": [
- {
- "expression": "ip_address",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_free_model_usage_created_at": {
- "name": "idx_free_model_usage_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.github_branch_pull_requests": {
- "name": "github_branch_pull_requests",
- "schema": "",
- "columns": {
- "git_url": {
- "name": "git_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_state": {
- "name": "pr_state",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_title": {
- "name": "pr_title",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_sha": {
- "name": "pr_head_sha",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_review_decision": {
- "name": "pr_review_decision",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "review_decision_pending": {
- "name": "review_decision_pending",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "review_decision_fetching_at": {
- "name": "review_decision_fetching_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "pr_last_synced_at": {
- "name": "pr_last_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_github_branch_prs_org": {
- "name": "UQ_github_branch_prs_org",
- "columns": [
- {
- "expression": "git_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"github_branch_pull_requests\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_github_branch_prs_user": {
- "name": "UQ_github_branch_prs_user",
- "columns": [
- {
- "expression": "git_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"github_branch_pull_requests\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk": {
- "name": "github_branch_pull_requests_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "github_branch_pull_requests",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk": {
- "name": "github_branch_pull_requests_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "github_branch_pull_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "github_branch_pull_requests_owner_check": {
- "name": "github_branch_pull_requests_owner_check",
- "value": "(\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NOT NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NULL) OR\n (\"github_branch_pull_requests\".\"owned_by_organization_id\" IS NULL AND \"github_branch_pull_requests\".\"owned_by_user_id\" IS NOT NULL)\n )"
- },
- "github_branch_pull_requests_review_decision_check": {
- "name": "github_branch_pull_requests_review_decision_check",
- "value": "\"github_branch_pull_requests\".\"pr_review_decision\" IS NULL OR \"github_branch_pull_requests\".\"pr_review_decision\" IN ('approved', 'changes_requested', 'review_required')"
- }
- },
- "isRLSEnabled": false
- },
- "public.http_ip": {
- "name": "http_ip",
- "schema": "",
- "columns": {
- "http_ip_id": {
- "name": "http_ip_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "http_ip": {
- "name": "http_ip",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_http_ip": {
- "name": "UQ_http_ip",
- "columns": [
- {
- "expression": "http_ip",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.http_user_agent": {
- "name": "http_user_agent",
- "schema": "",
- "columns": {
- "http_user_agent_id": {
- "name": "http_user_agent_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "http_user_agent": {
- "name": "http_user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_http_user_agent": {
- "name": "UQ_http_user_agent",
- "columns": [
- {
- "expression": "http_user_agent",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.impact_advocate_participants": {
- "name": "impact_advocate_participants",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "program_key": {
- "name": "program_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "advocate_id": {
- "name": "advocate_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "advocate_account_id": {
- "name": "advocate_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "opaque_referral_identifier": {
- "name": "opaque_referral_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "contact_email": {
- "name": "contact_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "locale": {
- "name": "locale",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "country_code": {
- "name": "country_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "registration_state": {
- "name": "registration_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "registered_at": {
- "name": "registered_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_registration_attempt_at": {
- "name": "last_registration_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_code": {
- "name": "last_error_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_message": {
- "name": "last_error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_impact_advocate_participants_program_referral_identifier": {
- "name": "UQ_impact_advocate_participants_program_referral_identifier",
- "columns": [
- {
- "expression": "program_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "opaque_referral_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"impact_advocate_participants\".\"opaque_referral_identifier\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_advocate_participants_registration_state": {
- "name": "IDX_impact_advocate_participants_registration_state",
- "columns": [
- {
- "expression": "registration_state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_advocate_participants_user_id_kilocode_users_id_fk": {
- "name": "impact_advocate_participants_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_advocate_participants",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_advocate_participants_program_user": {
- "name": "UQ_impact_advocate_participants_program_user",
- "nullsNotDistinct": false,
- "columns": [
- "program_key",
- "user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_advocate_participants_program_key_check": {
- "name": "impact_advocate_participants_program_key_check",
- "value": "\"impact_advocate_participants\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_advocate_participants_registration_state_check": {
- "name": "impact_advocate_participants_registration_state_check",
- "value": "\"impact_advocate_participants\".\"registration_state\" IN ('pending', 'retrying', 'registered', 'failed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_advocate_registration_attempts": {
- "name": "impact_advocate_registration_attempts",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "program_key": {
- "name": "program_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "participant_id": {
- "name": "participant_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "opaque_cookie_value": {
- "name": "opaque_cookie_value",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cookie_value_length": {
- "name": "cookie_value_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "delivery_state": {
- "name": "delivery_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "request_payload": {
- "name": "request_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_payload": {
- "name": "response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_status_code": {
- "name": "response_status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_advocate_registration_attempts_participant_id": {
- "name": "IDX_impact_advocate_registration_attempts_participant_id",
- "columns": [
- {
- "expression": "participant_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_advocate_registration_attempts_delivery_state": {
- "name": "IDX_impact_advocate_registration_attempts_delivery_state",
- "columns": [
- {
- "expression": "delivery_state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk": {
- "name": "impact_advocate_registration_attempts_participant_id_impact_advocate_participants_id_fk",
- "tableFrom": "impact_advocate_registration_attempts",
- "tableTo": "impact_advocate_participants",
- "columnsFrom": [
- "participant_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_advocate_registration_attempts_dedupe_key": {
- "name": "UQ_impact_advocate_registration_attempts_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_advocate_registration_attempts_program_key_check": {
- "name": "impact_advocate_registration_attempts_program_key_check",
- "value": "\"impact_advocate_registration_attempts\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_advocate_registration_attempts_delivery_state_check": {
- "name": "impact_advocate_registration_attempts_delivery_state_check",
- "value": "\"impact_advocate_registration_attempts\".\"delivery_state\" IN ('queued', 'sending', 'succeeded', 'failed')"
- },
- "impact_advocate_registration_attempts_cookie_value_length_non_negative_check": {
- "name": "impact_advocate_registration_attempts_cookie_value_length_non_negative_check",
- "value": "\"impact_advocate_registration_attempts\".\"cookie_value_length\" >= 0"
- },
- "impact_advocate_registration_attempts_attempt_count_non_negative_check": {
- "name": "impact_advocate_registration_attempts_attempt_count_non_negative_check",
- "value": "\"impact_advocate_registration_attempts\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_advocate_reward_redemptions": {
- "name": "impact_advocate_reward_redemptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "reward_id": {
- "name": "reward_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "state": {
- "name": "state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "impact_reward_id": {
- "name": "impact_reward_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "request_payload": {
- "name": "request_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "lookup_response_payload": {
- "name": "lookup_response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "redeem_response_payload": {
- "name": "redeem_response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_status_code": {
- "name": "response_status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "redeemed_at": {
- "name": "redeemed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_advocate_reward_redemptions_beneficiary_user_id": {
- "name": "IDX_impact_advocate_reward_redemptions_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_advocate_reward_redemptions_state": {
- "name": "IDX_impact_advocate_reward_redemptions_state",
- "columns": [
- {
- "expression": "state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk": {
- "name": "impact_advocate_reward_redemptions_reward_id_impact_referral_rewards_id_fk",
- "tableFrom": "impact_advocate_reward_redemptions",
- "tableTo": "impact_referral_rewards",
- "columnsFrom": [
- "reward_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_advocate_reward_redemptions_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_advocate_reward_redemptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_advocate_reward_redemptions_reward_id": {
- "name": "UQ_impact_advocate_reward_redemptions_reward_id",
- "nullsNotDistinct": false,
- "columns": [
- "reward_id"
- ]
- },
- "UQ_impact_advocate_reward_redemptions_dedupe_key": {
- "name": "UQ_impact_advocate_reward_redemptions_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_advocate_reward_redemptions_state_check": {
- "name": "impact_advocate_reward_redemptions_state_check",
- "value": "\"impact_advocate_reward_redemptions\".\"state\" IN ('queued', 'retrying', 'redeemed', 'failed')"
- },
- "impact_advocate_reward_redemptions_attempt_count_non_negative_check": {
- "name": "impact_advocate_reward_redemptions_attempt_count_non_negative_check",
- "value": "\"impact_advocate_reward_redemptions\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_attribution_touches": {
- "name": "impact_attribution_touches",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "program_key": {
- "name": "program_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'kiloclaw'"
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "anonymous_id": {
- "name": "anonymous_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "touch_type": {
- "name": "touch_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "opaque_tracking_value": {
- "name": "opaque_tracking_value",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "tracking_value_length": {
- "name": "tracking_value_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "is_tracking_value_accepted": {
- "name": "is_tracking_value_accepted",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "rs_code": {
- "name": "rs_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "rs_share_medium": {
- "name": "rs_share_medium",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "rs_engagement_medium": {
- "name": "rs_engagement_medium",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "im_ref": {
- "name": "im_ref",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "landing_path": {
- "name": "landing_path",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_source": {
- "name": "utm_source",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_medium": {
- "name": "utm_medium",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_campaign": {
- "name": "utm_campaign",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_term": {
- "name": "utm_term",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "utm_content": {
- "name": "utm_content",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "touched_at": {
- "name": "touched_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "sale_attributed_at": {
- "name": "sale_attributed_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": {
- "IDX_impact_attribution_touches_product_user_id": {
- "name": "IDX_impact_attribution_touches_product_user_id",
- "columns": [
- {
- "expression": "product",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_user_id": {
- "name": "IDX_impact_attribution_touches_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_anonymous_id": {
- "name": "IDX_impact_attribution_touches_anonymous_id",
- "columns": [
- {
- "expression": "anonymous_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_expires_at": {
- "name": "IDX_impact_attribution_touches_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_attribution_touches_sale_attributed_at": {
- "name": "IDX_impact_attribution_touches_sale_attributed_at",
- "columns": [
- {
- "expression": "sale_attributed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_attribution_touches_user_id_kilocode_users_id_fk": {
- "name": "impact_attribution_touches_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_attribution_touches",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_attribution_touches_dedupe_key": {
- "name": "UQ_impact_attribution_touches_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_attribution_touches_product_check": {
- "name": "impact_attribution_touches_product_check",
- "value": "\"impact_attribution_touches\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_attribution_touches_program_key_check": {
- "name": "impact_attribution_touches_program_key_check",
- "value": "\"impact_attribution_touches\".\"program_key\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_attribution_touches_touch_type_check": {
- "name": "impact_attribution_touches_touch_type_check",
- "value": "\"impact_attribution_touches\".\"touch_type\" IN ('affiliate', 'referral')"
- },
- "impact_attribution_touches_provider_check": {
- "name": "impact_attribution_touches_provider_check",
- "value": "\"impact_attribution_touches\".\"provider\" IN ('impact_performance', 'impact_advocate')"
- },
- "impact_attribution_touches_tracking_value_length_non_negative_check": {
- "name": "impact_attribution_touches_tracking_value_length_non_negative_check",
- "value": "\"impact_attribution_touches\".\"tracking_value_length\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_conversion_reports": {
- "name": "impact_conversion_reports",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "conversion_id": {
- "name": "conversion_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "action_tracker_id": {
- "name": "action_tracker_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "order_id": {
- "name": "order_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "state": {
- "name": "state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "request_payload": {
- "name": "request_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_payload": {
- "name": "response_payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "response_status_code": {
- "name": "response_status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "delivered_at": {
- "name": "delivered_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_conversion_reports_conversion_id": {
- "name": "IDX_impact_conversion_reports_conversion_id",
- "columns": [
- {
- "expression": "conversion_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_conversion_reports_state": {
- "name": "IDX_impact_conversion_reports_state",
- "columns": [
- {
- "expression": "state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk": {
- "name": "impact_conversion_reports_conversion_id_impact_referral_conversions_id_fk",
- "tableFrom": "impact_conversion_reports",
- "tableTo": "impact_referral_conversions",
- "columnsFrom": [
- "conversion_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_conversion_reports_dedupe_key": {
- "name": "UQ_impact_conversion_reports_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_conversion_reports_state_check": {
- "name": "impact_conversion_reports_state_check",
- "value": "\"impact_conversion_reports\".\"state\" IN ('queued', 'retrying', 'delivered', 'failed')"
- },
- "impact_conversion_reports_attempt_count_non_negative_check": {
- "name": "impact_conversion_reports_attempt_count_non_negative_check",
- "value": "\"impact_conversion_reports\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_conversions": {
- "name": "impact_referral_conversions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "referee_user_id": {
- "name": "referee_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "referrer_user_id": {
- "name": "referrer_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_touch_id": {
- "name": "source_touch_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "winning_touch_type": {
- "name": "winning_touch_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'credits'"
- },
- "source_payment_id": {
- "name": "source_payment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "qualified": {
- "name": "qualified",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "disqualification_reason": {
- "name": "disqualification_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "converted_at": {
- "name": "converted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_conversions_referee_user_id": {
- "name": "IDX_impact_referral_conversions_referee_user_id",
- "columns": [
- {
- "expression": "referee_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referral_conversions_referrer_user_id": {
- "name": "IDX_impact_referral_conversions_referrer_user_id",
- "columns": [
- {
- "expression": "referrer_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_conversions_referee_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_conversions_referee_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_conversions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referee_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_conversions_referrer_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_conversions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referrer_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk": {
- "name": "impact_referral_conversions_source_touch_id_impact_attribution_touches_id_fk",
- "tableFrom": "impact_referral_conversions",
- "tableTo": "impact_attribution_touches",
- "columnsFrom": [
- "source_touch_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referral_conversions_product_payment_source": {
- "name": "UQ_impact_referral_conversions_product_payment_source",
- "nullsNotDistinct": false,
- "columns": [
- "product",
- "payment_provider",
- "source_payment_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referral_conversions_product_check": {
- "name": "impact_referral_conversions_product_check",
- "value": "\"impact_referral_conversions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_referral_conversions_winning_touch_type_check": {
- "name": "impact_referral_conversions_winning_touch_type_check",
- "value": "\"impact_referral_conversions\".\"winning_touch_type\" IN ('referral', 'affiliate', 'none')"
- },
- "impact_referral_conversions_payment_provider_check": {
- "name": "impact_referral_conversions_payment_provider_check",
- "value": "\"impact_referral_conversions\".\"payment_provider\" IN ('stripe', 'credits', 'app_store', 'google_play')"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_reward_applications": {
- "name": "impact_referral_reward_applications",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "reward_id": {
- "name": "reward_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "previous_renewal_boundary": {
- "name": "previous_renewal_boundary",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "new_renewal_boundary": {
- "name": "new_renewal_boundary",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "local_operation_id": {
- "name": "local_operation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_operation_id": {
- "name": "stripe_operation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_idempotency_key": {
- "name": "stripe_idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "applied_at": {
- "name": "applied_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_reward_applications_reward_id": {
- "name": "IDX_impact_referral_reward_applications_reward_id",
- "columns": [
- {
- "expression": "reward_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referral_reward_applications_beneficiary_user_id": {
- "name": "IDX_impact_referral_reward_applications_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk": {
- "name": "impact_referral_reward_applications_reward_id_impact_referral_rewards_id_fk",
- "tableFrom": "impact_referral_reward_applications",
- "tableTo": "impact_referral_rewards",
- "columnsFrom": [
- "reward_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_reward_applications",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "impact_referral_reward_applications_product_check": {
- "name": "impact_referral_reward_applications_product_check",
- "value": "\"impact_referral_reward_applications\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_reward_decisions": {
- "name": "impact_referral_reward_decisions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "conversion_id": {
- "name": "conversion_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_role": {
- "name": "beneficiary_role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "outcome": {
- "name": "outcome",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "reward_kind": {
- "name": "reward_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw_free_month'"
- },
- "months_granted": {
- "name": "months_granted",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "reward_percent": {
- "name": "reward_percent",
- "type": "numeric(6, 4)",
- "primaryKey": false,
- "notNull": false
- },
- "source_tier": {
- "name": "source_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "reward_amount_usd": {
- "name": "reward_amount_usd",
- "type": "numeric(12, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_reward_decisions_beneficiary_user_id": {
- "name": "IDX_impact_referral_reward_decisions_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk": {
- "name": "impact_referral_reward_decisions_conversion_id_impact_referral_conversions_id_fk",
- "tableFrom": "impact_referral_reward_decisions",
- "tableTo": "impact_referral_conversions",
- "columnsFrom": [
- "conversion_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_reward_decisions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referral_reward_decisions_conversion_role": {
- "name": "UQ_impact_referral_reward_decisions_conversion_role",
- "nullsNotDistinct": false,
- "columns": [
- "conversion_id",
- "beneficiary_role"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referral_reward_decisions_product_check": {
- "name": "impact_referral_reward_decisions_product_check",
- "value": "\"impact_referral_reward_decisions\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_referral_reward_decisions_beneficiary_role_check": {
- "name": "impact_referral_reward_decisions_beneficiary_role_check",
- "value": "\"impact_referral_reward_decisions\".\"beneficiary_role\" IN ('referrer', 'referee')"
- },
- "impact_referral_reward_decisions_outcome_check": {
- "name": "impact_referral_reward_decisions_outcome_check",
- "value": "\"impact_referral_reward_decisions\".\"outcome\" IN ('granted', 'cap_limited', 'disqualified')"
- },
- "impact_referral_reward_decisions_reward_kind_check": {
- "name": "impact_referral_reward_decisions_reward_kind_check",
- "value": "\"impact_referral_reward_decisions\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
- },
- "impact_referral_reward_decisions_months_granted_non_negative_check": {
- "name": "impact_referral_reward_decisions_months_granted_non_negative_check",
- "value": "\"impact_referral_reward_decisions\".\"months_granted\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referral_rewards": {
- "name": "impact_referral_rewards",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "conversion_id": {
- "name": "conversion_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "decision_id": {
- "name": "decision_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_user_id": {
- "name": "beneficiary_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "beneficiary_role": {
- "name": "beneficiary_role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reward_kind": {
- "name": "reward_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw_free_month'"
- },
- "months_granted": {
- "name": "months_granted",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "reward_percent": {
- "name": "reward_percent",
- "type": "numeric(6, 4)",
- "primaryKey": false,
- "notNull": false
- },
- "source_tier": {
- "name": "source_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "reward_amount_usd": {
- "name": "reward_amount_usd",
- "type": "numeric(12, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "applies_to_subscription_id": {
- "name": "applies_to_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "applies_to_kilo_pass_subscription_id": {
- "name": "applies_to_kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "consumed_kilo_pass_issuance_id": {
- "name": "consumed_kilo_pass_issuance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "consumed_kilo_pass_issuance_item_id": {
- "name": "consumed_kilo_pass_issuance_item_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "earned_at": {
- "name": "earned_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "applied_at": {
- "name": "applied_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "reversed_at": {
- "name": "reversed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "review_reason": {
- "name": "review_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referral_rewards_beneficiary_user_id": {
- "name": "IDX_impact_referral_rewards_beneficiary_user_id",
- "columns": [
- {
- "expression": "beneficiary_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referral_rewards_status": {
- "name": "IDX_impact_referral_rewards_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk": {
- "name": "impact_referral_rewards_conversion_id_impact_referral_conversions_id_fk",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "impact_referral_conversions",
- "columnsFrom": [
- "conversion_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk": {
- "name": "impact_referral_rewards_decision_id_impact_referral_reward_decisions_id_fk",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "impact_referral_reward_decisions",
- "columnsFrom": [
- "decision_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk": {
- "name": "impact_referral_rewards_beneficiary_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "beneficiary_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "FK_impact_referral_rewards_kilo_pass_subscription": {
- "name": "FK_impact_referral_rewards_kilo_pass_subscription",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "applies_to_kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "FK_impact_referral_rewards_kilo_pass_issuance": {
- "name": "FK_impact_referral_rewards_kilo_pass_issuance",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilo_pass_issuances",
- "columnsFrom": [
- "consumed_kilo_pass_issuance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "FK_impact_referral_rewards_kilo_pass_issuance_item": {
- "name": "FK_impact_referral_rewards_kilo_pass_issuance_item",
- "tableFrom": "impact_referral_rewards",
- "tableTo": "kilo_pass_issuance_items",
- "columnsFrom": [
- "consumed_kilo_pass_issuance_item_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referral_rewards_conversion_role": {
- "name": "UQ_impact_referral_rewards_conversion_role",
- "nullsNotDistinct": false,
- "columns": [
- "conversion_id",
- "beneficiary_role"
- ]
- },
- "UQ_impact_referral_rewards_decision_id": {
- "name": "UQ_impact_referral_rewards_decision_id",
- "nullsNotDistinct": false,
- "columns": [
- "decision_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referral_rewards_product_check": {
- "name": "impact_referral_rewards_product_check",
- "value": "\"impact_referral_rewards\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- },
- "impact_referral_rewards_beneficiary_role_check": {
- "name": "impact_referral_rewards_beneficiary_role_check",
- "value": "\"impact_referral_rewards\".\"beneficiary_role\" IN ('referrer', 'referee')"
- },
- "impact_referral_rewards_reward_kind_check": {
- "name": "impact_referral_rewards_reward_kind_check",
- "value": "\"impact_referral_rewards\".\"reward_kind\" IN ('kiloclaw_free_month', 'kilo_pass_bonus')"
- },
- "impact_referral_rewards_status_check": {
- "name": "impact_referral_rewards_status_check",
- "value": "\"impact_referral_rewards\".\"status\" IN ('pending', 'earned', 'applied', 'reversed', 'expired', 'canceled', 'review_required')"
- },
- "impact_referral_rewards_months_granted_non_negative_check": {
- "name": "impact_referral_rewards_months_granted_non_negative_check",
- "value": "\"impact_referral_rewards\".\"months_granted\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.impact_referrals": {
- "name": "impact_referrals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "product": {
- "name": "product",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kiloclaw'"
- },
- "referee_user_id": {
- "name": "referee_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "referrer_user_id": {
- "name": "referrer_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_touch_id": {
- "name": "source_touch_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "impact_referral_id": {
- "name": "impact_referral_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_impact_referrals_referrer_user_id": {
- "name": "IDX_impact_referrals_referrer_user_id",
- "columns": [
- {
- "expression": "referrer_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_impact_referrals_source_touch_id": {
- "name": "IDX_impact_referrals_source_touch_id",
- "columns": [
- {
- "expression": "source_touch_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "impact_referrals_referee_user_id_kilocode_users_id_fk": {
- "name": "impact_referrals_referee_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referrals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referee_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "impact_referrals_referrer_user_id_kilocode_users_id_fk": {
- "name": "impact_referrals_referrer_user_id_kilocode_users_id_fk",
- "tableFrom": "impact_referrals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "referrer_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "impact_referrals_source_touch_id_impact_attribution_touches_id_fk": {
- "name": "impact_referrals_source_touch_id_impact_attribution_touches_id_fk",
- "tableFrom": "impact_referrals",
- "tableTo": "impact_attribution_touches",
- "columnsFrom": [
- "source_touch_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_impact_referrals_product_referee_user_id": {
- "name": "UQ_impact_referrals_product_referee_user_id",
- "nullsNotDistinct": false,
- "columns": [
- "product",
- "referee_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "impact_referrals_product_check": {
- "name": "impact_referrals_product_check",
- "value": "\"impact_referrals\".\"product\" IN ('kiloclaw', 'kilo_pass')"
- }
- },
- "isRLSEnabled": false
- },
- "public.ja4_digest": {
- "name": "ja4_digest",
- "schema": "",
- "columns": {
- "ja4_digest_id": {
- "name": "ja4_digest_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "ja4_digest": {
- "name": "ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_ja4_digest": {
- "name": "UQ_ja4_digest",
- "columns": [
- {
- "expression": "ja4_digest",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kilo_pass_audit_log": {
- "name": "kilo_pass_audit_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "result": {
- "name": "result",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_event_id": {
- "name": "stripe_event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_invoice_id": {
- "name": "stripe_invoice_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "related_credit_transaction_id": {
- "name": "related_credit_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "related_monthly_issuance_id": {
- "name": "related_monthly_issuance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "payload_json": {
- "name": "payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- }
- },
- "indexes": {
- "IDX_kilo_pass_audit_log_created_at": {
- "name": "IDX_kilo_pass_audit_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_kilo_user_id": {
- "name": "IDX_kilo_pass_audit_log_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_kilo_pass_subscription_id": {
- "name": "IDX_kilo_pass_audit_log_kilo_pass_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_action": {
- "name": "IDX_kilo_pass_audit_log_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_result": {
- "name": "IDX_kilo_pass_audit_log_result",
- "columns": [
- {
- "expression": "result",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_idempotency_key": {
- "name": "IDX_kilo_pass_audit_log_idempotency_key",
- "columns": [
- {
- "expression": "idempotency_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_stripe_event_id": {
- "name": "IDX_kilo_pass_audit_log_stripe_event_id",
- "columns": [
- {
- "expression": "stripe_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_stripe_invoice_id": {
- "name": "IDX_kilo_pass_audit_log_stripe_invoice_id",
- "columns": [
- {
- "expression": "stripe_invoice_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_stripe_subscription_id": {
- "name": "IDX_kilo_pass_audit_log_stripe_subscription_id",
- "columns": [
- {
- "expression": "stripe_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_related_credit_transaction_id": {
- "name": "IDX_kilo_pass_audit_log_related_credit_transaction_id",
- "columns": [
- {
- "expression": "related_credit_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_audit_log_related_monthly_issuance_id": {
- "name": "IDX_kilo_pass_audit_log_related_monthly_issuance_id",
- "columns": [
- {
- "expression": "related_monthly_issuance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_audit_log_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_audit_log_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk": {
- "name": "kilo_pass_audit_log_related_credit_transaction_id_credit_transactions_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "credit_transactions",
- "columnsFrom": [
- "related_credit_transaction_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk": {
- "name": "kilo_pass_audit_log_related_monthly_issuance_id_kilo_pass_issuances_id_fk",
- "tableFrom": "kilo_pass_audit_log",
- "tableTo": "kilo_pass_issuances",
- "columnsFrom": [
- "related_monthly_issuance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_audit_log_action_check": {
- "name": "kilo_pass_audit_log_action_check",
- "value": "\"kilo_pass_audit_log\".\"action\" IN ('stripe_webhook_received', 'kilo_pass_invoice_paid_handled', 'store_purchase_completed', 'store_notification_received', 'store_subscription_renewed', 'store_subscription_canceled', 'store_subscription_expired', 'store_subscription_refunded', 'base_credits_issued', 'bonus_credits_issued', 'bonus_credits_skipped_idempotent', 'first_month_50pct_promo_issued', 'yearly_monthly_base_cron_started', 'yearly_monthly_base_cron_completed', 'issue_yearly_remaining_credits', 'duplicate_card_subscription_canceled', 'yearly_monthly_bonus_cron_started', 'yearly_monthly_bonus_cron_completed')"
- },
- "kilo_pass_audit_log_result_check": {
- "name": "kilo_pass_audit_log_result_check",
- "value": "\"kilo_pass_audit_log\".\"result\" IN ('success', 'skipped_idempotent', 'failed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_issuance_items": {
- "name": "kilo_pass_issuance_items",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_issuance_id": {
- "name": "kilo_pass_issuance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kind": {
- "name": "kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "credit_transaction_id": {
- "name": "credit_transaction_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "amount_usd": {
- "name": "amount_usd",
- "type": "numeric(12, 2)",
- "primaryKey": false,
- "notNull": true
- },
- "bonus_percent_applied": {
- "name": "bonus_percent_applied",
- "type": "numeric(6, 4)",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_issuance_items_issuance_id": {
- "name": "IDX_kilo_pass_issuance_items_issuance_id",
- "columns": [
- {
- "expression": "kilo_pass_issuance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_issuance_items_credit_transaction_id": {
- "name": "IDX_kilo_pass_issuance_items_credit_transaction_id",
- "columns": [
- {
- "expression": "credit_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk": {
- "name": "kilo_pass_issuance_items_kilo_pass_issuance_id_kilo_pass_issuances_id_fk",
- "tableFrom": "kilo_pass_issuance_items",
- "tableTo": "kilo_pass_issuances",
- "columnsFrom": [
- "kilo_pass_issuance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk": {
- "name": "kilo_pass_issuance_items_credit_transaction_id_credit_transactions_id_fk",
- "tableFrom": "kilo_pass_issuance_items",
- "tableTo": "credit_transactions",
- "columnsFrom": [
- "credit_transaction_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kilo_pass_issuance_items_credit_transaction_id_unique": {
- "name": "kilo_pass_issuance_items_credit_transaction_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "credit_transaction_id"
- ]
- },
- "UQ_kilo_pass_issuance_items_issuance_kind": {
- "name": "UQ_kilo_pass_issuance_items_issuance_kind",
- "nullsNotDistinct": false,
- "columns": [
- "kilo_pass_issuance_id",
- "kind"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_issuance_items_bonus_percent_applied_range_check": {
- "name": "kilo_pass_issuance_items_bonus_percent_applied_range_check",
- "value": "\"kilo_pass_issuance_items\".\"bonus_percent_applied\" IS NULL OR (\"kilo_pass_issuance_items\".\"bonus_percent_applied\" >= 0 AND \"kilo_pass_issuance_items\".\"bonus_percent_applied\" <= 1)"
- },
- "kilo_pass_issuance_items_amount_usd_non_negative_check": {
- "name": "kilo_pass_issuance_items_amount_usd_non_negative_check",
- "value": "\"kilo_pass_issuance_items\".\"amount_usd\" >= 0"
- },
- "kilo_pass_issuance_items_kind_check": {
- "name": "kilo_pass_issuance_items_kind_check",
- "value": "\"kilo_pass_issuance_items\".\"kind\" IN ('base', 'bonus', 'promo_first_month_50pct', 'referral_bonus')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_issuances": {
- "name": "kilo_pass_issuances",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "issue_month": {
- "name": "issue_month",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "source": {
- "name": "source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_invoice_id": {
- "name": "stripe_invoice_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "initial_welcome_promo_eligibility_reason": {
- "name": "initial_welcome_promo_eligibility_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kilo_pass_issuances_stripe_invoice_id": {
- "name": "UQ_kilo_pass_issuances_stripe_invoice_id",
- "columns": [
- {
- "expression": "stripe_invoice_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_issuances\".\"stripe_invoice_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_issuances_subscription_id": {
- "name": "IDX_kilo_pass_issuances_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_issuances_issue_month": {
- "name": "IDX_kilo_pass_issuances_issue_month",
- "columns": [
- {
- "expression": "issue_month",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_issuances_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_issuances",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_kilo_pass_issuances_subscription_issue_month": {
- "name": "UQ_kilo_pass_issuances_subscription_issue_month",
- "nullsNotDistinct": false,
- "columns": [
- "kilo_pass_subscription_id",
- "issue_month"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_issuances_issue_month_day_one_check": {
- "name": "kilo_pass_issuances_issue_month_day_one_check",
- "value": "EXTRACT(DAY FROM \"kilo_pass_issuances\".\"issue_month\") = 1"
- },
- "kilo_pass_issuances_source_check": {
- "name": "kilo_pass_issuances_source_check",
- "value": "\"kilo_pass_issuances\".\"source\" IN ('stripe_invoice', 'app_store_transaction', 'google_play_transaction', 'cron')"
- },
- "kilo_pass_issuances_initial_welcome_promo_reason_check": {
- "name": "kilo_pass_issuances_initial_welcome_promo_reason_check",
- "value": "\"kilo_pass_issuances\".\"initial_welcome_promo_eligibility_reason\" IN ('first_payment_fingerprint_claim', 'fingerprint_previously_claimed', 'missing_fingerprint', 'no_supported_fingerprint', 'no_positive_settlement', 'settlement_unresolved')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_pause_events": {
- "name": "kilo_pass_pause_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "paused_at": {
- "name": "paused_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "resumes_at": {
- "name": "resumes_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "resumed_at": {
- "name": "resumed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_pause_events_subscription_id": {
- "name": "IDX_kilo_pass_pause_events_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_pause_events_one_open_per_sub": {
- "name": "UQ_kilo_pass_pause_events_one_open_per_sub",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_pause_events_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_pause_events",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_pause_events_resumed_at_after_paused_at_check": {
- "name": "kilo_pass_pause_events_resumed_at_after_paused_at_check",
- "value": "\"kilo_pass_pause_events\".\"resumed_at\" IS NULL OR \"kilo_pass_pause_events\".\"resumed_at\" >= \"kilo_pass_pause_events\".\"paused_at\""
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_scheduled_changes": {
- "name": "kilo_pass_scheduled_changes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "from_tier": {
- "name": "from_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "from_cadence": {
- "name": "from_cadence",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "to_tier": {
- "name": "to_tier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "to_cadence": {
- "name": "to_cadence",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_schedule_id": {
- "name": "stripe_schedule_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "effective_at": {
- "name": "effective_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "deleted_at": {
- "name": "deleted_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_scheduled_changes_kilo_user_id": {
- "name": "IDX_kilo_pass_scheduled_changes_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_status": {
- "name": "IDX_kilo_pass_scheduled_changes_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_stripe_subscription_id": {
- "name": "IDX_kilo_pass_scheduled_changes_stripe_subscription_id",
- "columns": [
- {
- "expression": "stripe_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id": {
- "name": "UQ_kilo_pass_scheduled_changes_active_stripe_subscription_id",
- "columns": [
- {
- "expression": "stripe_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_scheduled_changes\".\"deleted_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_effective_at": {
- "name": "IDX_kilo_pass_scheduled_changes_effective_at",
- "columns": [
- {
- "expression": "effective_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_scheduled_changes_deleted_at": {
- "name": "IDX_kilo_pass_scheduled_changes_deleted_at",
- "columns": [
- {
- "expression": "deleted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_scheduled_changes_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_scheduled_changes",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk": {
- "name": "kilo_pass_scheduled_changes_stripe_subscription_id_kilo_pass_subscriptions_stripe_subscription_id_fk",
- "tableFrom": "kilo_pass_scheduled_changes",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "stripe_subscription_id"
- ],
- "columnsTo": [
- "stripe_subscription_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_scheduled_changes_from_tier_check": {
- "name": "kilo_pass_scheduled_changes_from_tier_check",
- "value": "\"kilo_pass_scheduled_changes\".\"from_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
- },
- "kilo_pass_scheduled_changes_from_cadence_check": {
- "name": "kilo_pass_scheduled_changes_from_cadence_check",
- "value": "\"kilo_pass_scheduled_changes\".\"from_cadence\" IN ('monthly', 'yearly')"
- },
- "kilo_pass_scheduled_changes_to_tier_check": {
- "name": "kilo_pass_scheduled_changes_to_tier_check",
- "value": "\"kilo_pass_scheduled_changes\".\"to_tier\" IN ('tier_19', 'tier_49', 'tier_199')"
- },
- "kilo_pass_scheduled_changes_to_cadence_check": {
- "name": "kilo_pass_scheduled_changes_to_cadence_check",
- "value": "\"kilo_pass_scheduled_changes\".\"to_cadence\" IN ('monthly', 'yearly')"
- },
- "kilo_pass_scheduled_changes_status_check": {
- "name": "kilo_pass_scheduled_changes_status_check",
- "value": "\"kilo_pass_scheduled_changes\".\"status\" IN ('not_started', 'active', 'completed', 'released', 'canceled')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_store_events": {
- "name": "kilo_pass_store_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_id": {
- "name": "event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subscription_id": {
- "name": "provider_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider_transaction_id": {
- "name": "provider_transaction_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "app_account_token": {
- "name": "app_account_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "product_id": {
- "name": "product_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "environment": {
- "name": "environment",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payload_json": {
- "name": "payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "processing_started_at": {
- "name": "processing_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "processed_at": {
- "name": "processed_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": {
- "UQ_kilo_pass_store_events_provider_event": {
- "name": "UQ_kilo_pass_store_events_provider_event",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_events_provider_subscription": {
- "name": "IDX_kilo_pass_store_events_provider_subscription",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_events_app_account_token": {
- "name": "IDX_kilo_pass_store_events_app_account_token",
- "columns": [
- {
- "expression": "app_account_token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_store_events_payment_provider_check": {
- "name": "kilo_pass_store_events_payment_provider_check",
- "value": "\"kilo_pass_store_events\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_store_purchases": {
- "name": "kilo_pass_store_purchases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_pass_subscription_id": {
- "name": "kilo_pass_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "product_id": {
- "name": "product_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subscription_id": {
- "name": "provider_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_transaction_id": {
- "name": "provider_transaction_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_original_transaction_id": {
- "name": "provider_original_transaction_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "app_account_token": {
- "name": "app_account_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "purchase_token": {
- "name": "purchase_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "environment": {
- "name": "environment",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "purchased_at": {
- "name": "purchased_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "raw_payload_json": {
- "name": "raw_payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kilo_pass_store_purchases_provider_transaction": {
- "name": "UQ_kilo_pass_store_purchases_provider_transaction",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_transaction_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_subscription_id": {
- "name": "IDX_kilo_pass_store_purchases_subscription_id",
- "columns": [
- {
- "expression": "kilo_pass_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_user_id": {
- "name": "IDX_kilo_pass_store_purchases_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_app_account_token": {
- "name": "IDX_kilo_pass_store_purchases_app_account_token",
- "columns": [
- {
- "expression": "app_account_token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_store_purchases_latest_subscription_purchase": {
- "name": "IDX_kilo_pass_store_purchases_latest_subscription_purchase",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "purchased_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk": {
- "name": "kilo_pass_store_purchases_kilo_pass_subscription_id_kilo_pass_subscriptions_id_fk",
- "tableFrom": "kilo_pass_store_purchases",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_store_purchases_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_store_purchases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "FK_kilo_pass_store_purchases_subscription_owner_provider": {
- "name": "FK_kilo_pass_store_purchases_subscription_owner_provider",
- "tableFrom": "kilo_pass_store_purchases",
- "tableTo": "kilo_pass_subscriptions",
- "columnsFrom": [
- "kilo_pass_subscription_id",
- "kilo_user_id",
- "payment_provider",
- "provider_subscription_id"
- ],
- "columnsTo": [
- "id",
- "kilo_user_id",
- "payment_provider",
- "provider_subscription_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kilo_pass_store_purchases_store_provider_check": {
- "name": "kilo_pass_store_purchases_store_provider_check",
- "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('app_store', 'google_play')"
- },
- "kilo_pass_store_purchases_payment_provider_check": {
- "name": "kilo_pass_store_purchases_payment_provider_check",
- "value": "\"kilo_pass_store_purchases\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_subscriptions": {
- "name": "kilo_pass_subscriptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "payment_provider": {
- "name": "payment_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'stripe'"
- },
- "provider_subscription_id": {
- "name": "provider_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "tier": {
- "name": "tier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cadence": {
- "name": "cadence",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cancel_at_period_end": {
- "name": "cancel_at_period_end",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "ended_at": {
- "name": "ended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "current_streak_months": {
- "name": "current_streak_months",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_yearly_issue_at": {
- "name": "next_yearly_issue_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kilo_pass_subscriptions_kilo_user_id": {
- "name": "IDX_kilo_pass_subscriptions_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_subscriptions_payment_provider": {
- "name": "IDX_kilo_pass_subscriptions_payment_provider",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_subscriptions_status": {
- "name": "IDX_kilo_pass_subscriptions_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilo_pass_subscriptions_cadence": {
- "name": "IDX_kilo_pass_subscriptions_cadence",
- "columns": [
- {
- "expression": "cadence",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_subscriptions_provider_subscription": {
- "name": "UQ_kilo_pass_subscriptions_provider_subscription",
- "columns": [
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilo_pass_subscriptions_store_purchase_reference": {
- "name": "UQ_kilo_pass_subscriptions_store_purchase_reference",
- "columns": [
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "payment_provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "provider_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk": {
- "name": "kilo_pass_subscriptions_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kilo_pass_subscriptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kilo_pass_subscriptions_stripe_subscription_id_unique": {
- "name": "kilo_pass_subscriptions_stripe_subscription_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_subscription_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_subscriptions_current_streak_months_non_negative_check": {
- "name": "kilo_pass_subscriptions_current_streak_months_non_negative_check",
- "value": "\"kilo_pass_subscriptions\".\"current_streak_months\" >= 0"
- },
- "kilo_pass_subscriptions_provider_ids_check": {
- "name": "kilo_pass_subscriptions_provider_ids_check",
- "value": "(\n \"kilo_pass_subscriptions\".\"payment_provider\" = 'stripe'\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" = \"kilo_pass_subscriptions\".\"stripe_subscription_id\"\n ) OR (\n \"kilo_pass_subscriptions\".\"payment_provider\" IN ('app_store', 'google_play')\n AND \"kilo_pass_subscriptions\".\"provider_subscription_id\" IS NOT NULL\n AND \"kilo_pass_subscriptions\".\"stripe_subscription_id\" IS NULL\n )"
- },
- "kilo_pass_subscriptions_payment_provider_check": {
- "name": "kilo_pass_subscriptions_payment_provider_check",
- "value": "\"kilo_pass_subscriptions\".\"payment_provider\" IN ('stripe', 'app_store', 'google_play')"
- },
- "kilo_pass_subscriptions_tier_check": {
- "name": "kilo_pass_subscriptions_tier_check",
- "value": "\"kilo_pass_subscriptions\".\"tier\" IN ('tier_19', 'tier_49', 'tier_199')"
- },
- "kilo_pass_subscriptions_cadence_check": {
- "name": "kilo_pass_subscriptions_cadence_check",
- "value": "\"kilo_pass_subscriptions\".\"cadence\" IN ('monthly', 'yearly')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kilo_pass_welcome_promo_payment_fingerprint_claims": {
- "name": "kilo_pass_welcome_promo_payment_fingerprint_claims",
- "schema": "",
- "columns": {
- "stripe_payment_method_type": {
- "name": "stripe_payment_method_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_fingerprint": {
- "name": "stripe_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_stripe_invoice_id": {
- "name": "source_stripe_invoice_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {
- "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk": {
- "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_stripe_payment_method_type_stripe_fingerprint_pk",
- "columns": [
- "stripe_payment_method_type",
- "stripe_fingerprint"
- ]
- }
- },
- "uniqueConstraints": {
- "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id": {
- "name": "UQ_kilo_pass_welcome_promo_payment_fingerprint_claims_source_invoice_id",
- "nullsNotDistinct": false,
- "columns": [
- "source_stripe_invoice_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check": {
- "name": "kilo_pass_welcome_promo_payment_fingerprint_claims_type_check",
- "value": "\"kilo_pass_welcome_promo_payment_fingerprint_claims\".\"stripe_payment_method_type\" IN ('card', 'sepa_debit', 'us_bank_account', 'bacs_debit', 'au_becs_debit')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_access_codes": {
- "name": "kiloclaw_access_codes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "redeemed_at": {
- "name": "redeemed_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": {
- "UQ_kiloclaw_access_codes_code": {
- "name": "UQ_kiloclaw_access_codes_code",
- "columns": [
- {
- "expression": "code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_access_codes_user_status": {
- "name": "IDX_kiloclaw_access_codes_user_status",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_access_codes_one_active_per_user": {
- "name": "UQ_kiloclaw_access_codes_one_active_per_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "status = 'active'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_access_codes_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_access_codes",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_admin_audit_logs": {
- "name": "kiloclaw_admin_audit_logs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_email": {
- "name": "actor_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_name": {
- "name": "actor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "target_user_id": {
- "name": "target_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "message": {
- "name": "message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kiloclaw_admin_audit_logs_target_user_id": {
- "name": "IDX_kiloclaw_admin_audit_logs_target_user_id",
- "columns": [
- {
- "expression": "target_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_admin_audit_logs_action": {
- "name": "IDX_kiloclaw_admin_audit_logs_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_admin_audit_logs_created_at": {
- "name": "IDX_kiloclaw_admin_audit_logs_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_cli_runs": {
- "name": "kiloclaw_cli_runs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "initiated_by_admin_id": {
- "name": "initiated_by_admin_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "prompt": {
- "name": "prompt",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'running'"
- },
- "exit_code": {
- "name": "exit_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "output": {
- "name": "output",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_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": {
- "IDX_kiloclaw_cli_runs_user_id": {
- "name": "IDX_kiloclaw_cli_runs_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_cli_runs_started_at": {
- "name": "IDX_kiloclaw_cli_runs_started_at",
- "columns": [
- {
- "expression": "started_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_cli_runs_instance_id": {
- "name": "IDX_kiloclaw_cli_runs_instance_id",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_cli_runs_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_cli_runs_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_cli_runs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_cli_runs_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_cli_runs",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk": {
- "name": "kiloclaw_cli_runs_initiated_by_admin_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_cli_runs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "initiated_by_admin_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_earlybird_purchases": {
- "name": "kiloclaw_earlybird_purchases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "manual_payment_id": {
- "name": "manual_payment_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "amount_cents": {
- "name": "amount_cents",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_earlybird_purchases_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_earlybird_purchases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_earlybird_purchases_user_id_unique": {
- "name": "kiloclaw_earlybird_purchases_user_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "user_id"
- ]
- },
- "kiloclaw_earlybird_purchases_stripe_charge_id_unique": {
- "name": "kiloclaw_earlybird_purchases_stripe_charge_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_charge_id"
- ]
- },
- "kiloclaw_earlybird_purchases_manual_payment_id_unique": {
- "name": "kiloclaw_earlybird_purchases_manual_payment_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "manual_payment_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_email_log": {
- "name": "kiloclaw_email_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "email_type": {
- "name": "email_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_start": {
- "name": "period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "'epoch'"
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kiloclaw_email_log_user_type_global": {
- "name": "UQ_kiloclaw_email_log_user_type_global",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_email_log\".\"instance_id\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_email_log_user_instance_type_period": {
- "name": "UQ_kiloclaw_email_log_user_instance_type_period",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_start",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_email_log_type_sent_instance": {
- "name": "IDX_kiloclaw_email_log_type_sent_instance",
- "columns": [
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "sent_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_email_log\".\"instance_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_email_log_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_email_log_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_email_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_email_log_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_email_log",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_google_oauth_connections": {
- "name": "kiloclaw_google_oauth_connections",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'google'"
- },
- "account_email": {
- "name": "account_email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "account_subject": {
- "name": "account_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_secret_encrypted": {
- "name": "oauth_client_secret_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "credential_profile": {
- "name": "credential_profile",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'kilo_owned'"
- },
- "refresh_token_encrypted": {
- "name": "refresh_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "scopes": {
- "name": "scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "grants_by_source": {
- "name": "grants_by_source",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "capabilities": {
- "name": "capabilities",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "last_error": {
- "name": "last_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_at": {
- "name": "last_error_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "connected_at": {
- "name": "connected_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kiloclaw_google_oauth_connections_instance": {
- "name": "UQ_kiloclaw_google_oauth_connections_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_google_oauth_connections_status": {
- "name": "IDX_kiloclaw_google_oauth_connections_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_google_oauth_connections_provider": {
- "name": "IDX_kiloclaw_google_oauth_connections_provider",
- "columns": [
- {
- "expression": "provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_google_oauth_connections_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_google_oauth_connections",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kiloclaw_google_oauth_connections_status_check": {
- "name": "kiloclaw_google_oauth_connections_status_check",
- "value": "\"kiloclaw_google_oauth_connections\".\"status\" IN ('active', 'action_required', 'disconnected')"
- },
- "kiloclaw_google_oauth_connections_credential_profile_check": {
- "name": "kiloclaw_google_oauth_connections_credential_profile_check",
- "value": "\"kiloclaw_google_oauth_connections\".\"credential_profile\" IN ('legacy', 'kilo_owned')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_image_catalog": {
- "name": "kiloclaw_image_catalog",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "openclaw_version": {
- "name": "openclaw_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "variant": {
- "name": "variant",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'default'"
- },
- "image_tag": {
- "name": "image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "image_digest": {
- "name": "image_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'available'"
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "updated_by": {
- "name": "updated_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "published_at": {
- "name": "published_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "synced_at": {
- "name": "synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "rollout_percent": {
- "name": "rollout_percent",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "is_latest": {
- "name": "is_latest",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- }
- },
- "indexes": {
- "IDX_kiloclaw_image_catalog_status": {
- "name": "IDX_kiloclaw_image_catalog_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_image_catalog_variant": {
- "name": "IDX_kiloclaw_image_catalog_variant",
- "columns": [
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_image_catalog_one_latest_per_variant": {
- "name": "UQ_kiloclaw_image_catalog_one_latest_per_variant",
- "columns": [
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_image_catalog\".\"is_latest\" = true",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_image_catalog_one_candidate_per_variant": {
- "name": "UQ_kiloclaw_image_catalog_one_candidate_per_variant",
- "columns": [
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_image_catalog\".\"is_latest\" = false AND \"kiloclaw_image_catalog\".\"rollout_percent\" > 0 AND \"kiloclaw_image_catalog\".\"status\" = 'available'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_image_catalog_image_tag_unique": {
- "name": "kiloclaw_image_catalog_image_tag_unique",
- "nullsNotDistinct": false,
- "columns": [
- "image_tag"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_inbound_email_aliases": {
- "name": "kiloclaw_inbound_email_aliases",
- "schema": "",
- "columns": {
- "alias": {
- "name": "alias",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "retired_at": {
- "name": "retired_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_kiloclaw_inbound_email_aliases_instance_id": {
- "name": "IDX_kiloclaw_inbound_email_aliases_instance_id",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_inbound_email_aliases_active_instance": {
- "name": "UQ_kiloclaw_inbound_email_aliases_active_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_inbound_email_aliases\".\"retired_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_inbound_email_aliases_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_inbound_email_aliases",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_inbound_email_reserved_aliases": {
- "name": "kiloclaw_inbound_email_reserved_aliases",
- "schema": "",
- "columns": {
- "alias": {
- "name": "alias",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_instances": {
- "name": "kiloclaw_instances",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sandbox_id": {
- "name": "sandbox_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'fly'"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "inbound_email_enabled": {
- "name": "inbound_email_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "inactive_trial_stopped_at": {
- "name": "inactive_trial_stopped_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()"
- },
- "destroyed_at": {
- "name": "destroyed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "tracked_image_tag": {
- "name": "tracked_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "instance_type": {
- "name": "instance_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "admin_size_override": {
- "name": "admin_size_override",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_kiloclaw_instances_active": {
- "name": "UQ_kiloclaw_instances_active",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "sandbox_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_active_personal_by_user": {
- "name": "IDX_kiloclaw_instances_active_personal_by_user",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"organization_id\" IS NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_active_org_by_user_org": {
- "name": "IDX_kiloclaw_instances_active_org_by_user_org",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_active_org_by_org_created": {
- "name": "IDX_kiloclaw_instances_active_org_by_org_created",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"organization_id\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_user_id_created_at": {
- "name": "IDX_kiloclaw_instances_user_id_created_at",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_tracked_image_tag": {
- "name": "IDX_kiloclaw_instances_tracked_image_tag",
- "columns": [
- {
- "expression": "tracked_image_tag",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_instance_type": {
- "name": "IDX_kiloclaw_instances_instance_type",
- "columns": [
- {
- "expression": "instance_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"destroyed_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_instances_admin_size_override": {
- "name": "IDX_kiloclaw_instances_admin_size_override",
- "columns": [
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_instances\".\"admin_size_override\" IS NOT NULL AND \"kiloclaw_instances\".\"destroyed_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_instances_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_instances_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_instances",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_instances_organization_id_organizations_id_fk": {
- "name": "kiloclaw_instances_organization_id_organizations_id_fk",
- "tableFrom": "kiloclaw_instances",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "CHK_kiloclaw_instances_instance_type": {
- "name": "CHK_kiloclaw_instances_instance_type",
- "value": "\"kiloclaw_instances\".\"instance_type\" IS NULL OR \"kiloclaw_instances\".\"instance_type\" IN ('perf-1-3', 'perf-4-8', 'perf-4-16', 'shared-2-3', 'shared-2-4', 'custom')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_morning_briefing_configs": {
- "name": "kiloclaw_morning_briefing_configs",
- "schema": "",
- "columns": {
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "cron": {
- "name": "cron",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'0 7 * * *'"
- },
- "timezone": {
- "name": "timezone",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'UTC'"
- },
- "interest_topics": {
- "name": "interest_topics",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kiloclaw_morning_briefing_configs_enabled": {
- "name": "IDX_kiloclaw_morning_briefing_configs_enabled",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_morning_briefing_configs\".\"enabled\" = true",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_morning_briefing_configs_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_morning_briefing_configs",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_action_notifications": {
- "name": "kiloclaw_scheduled_action_notifications",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "target_id": {
- "name": "target_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "channel": {
- "name": "channel",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kind": {
- "name": "kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'notice'"
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel": {
- "name": "UQ_kiloclaw_scheduled_action_notifications_target_kind_channel",
- "columns": [
- {
- "expression": "target_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "channel",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_notifications_pending": {
- "name": "IDX_kiloclaw_scheduled_action_notifications_pending",
- "columns": [
- {
- "expression": "target_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_scheduled_action_notifications\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk": {
- "name": "kiloclaw_scheduled_action_notifications_target_id_kiloclaw_scheduled_action_targets_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_notifications",
- "tableTo": "kiloclaw_scheduled_action_targets",
- "columnsFrom": [
- "target_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_action_stages": {
- "name": "kiloclaw_scheduled_action_stages",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "scheduled_action_id": {
- "name": "scheduled_action_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "stage_index": {
- "name": "stage_index",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "scheduled_at": {
- "name": "scheduled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "notice_sent_at": {
- "name": "notice_sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "applied_count": {
- "name": "applied_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "skipped_count": {
- "name": "skipped_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "failed_count": {
- "name": "failed_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- }
- },
- "indexes": {
- "UQ_kiloclaw_scheduled_action_stages_parent_index": {
- "name": "UQ_kiloclaw_scheduled_action_stages_parent_index",
- "columns": [
- {
- "expression": "scheduled_action_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "stage_index",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_stages_notice_due": {
- "name": "IDX_kiloclaw_scheduled_action_stages_notice_due",
- "columns": [
- {
- "expression": "scheduled_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_scheduled_action_stages\".\"notice_sent_at\" IS NULL AND \"kiloclaw_scheduled_action_stages\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
- "name": "kiloclaw_scheduled_action_stages_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_stages",
- "tableTo": "kiloclaw_scheduled_actions",
- "columnsFrom": [
- "scheduled_action_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_action_targets": {
- "name": "kiloclaw_scheduled_action_targets",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "scheduled_action_id": {
- "name": "scheduled_action_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "stage_id": {
- "name": "stage_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "source_image_tag": {
- "name": "source_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "target_image_tag": {
- "name": "target_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "applied_at": {
- "name": "applied_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "skip_reason": {
- "name": "skip_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_kiloclaw_scheduled_action_targets_parent_instance": {
- "name": "UQ_kiloclaw_scheduled_action_targets_parent_instance",
- "columns": [
- {
- "expression": "scheduled_action_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_targets_stage": {
- "name": "IDX_kiloclaw_scheduled_action_targets_stage",
- "columns": [
- {
- "expression": "stage_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_action_targets_pending_by_instance": {
- "name": "IDX_kiloclaw_scheduled_action_targets_pending_by_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_scheduled_action_targets\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_scheduled_action_id_kiloclaw_scheduled_actions_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kiloclaw_scheduled_actions",
- "columnsFrom": [
- "scheduled_action_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_stage_id_kiloclaw_scheduled_action_stages_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kiloclaw_scheduled_action_stages",
- "columnsFrom": [
- "stage_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_scheduled_action_targets_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_scheduled_action_targets",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_scheduled_actions": {
- "name": "kiloclaw_scheduled_actions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "action_type": {
- "name": "action_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "target_image_tag": {
- "name": "target_image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "override_pins": {
- "name": "override_pins",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "notice_lead_hours": {
- "name": "notice_lead_hours",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 24
- },
- "notice_subject": {
- "name": "notice_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "''"
- },
- "notice_body": {
- "name": "notice_body",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "''"
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'scheduled'"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "cancelled_at": {
- "name": "cancelled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "total_count": {
- "name": "total_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "applied_count": {
- "name": "applied_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "skipped_count": {
- "name": "skipped_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "failed_count": {
- "name": "failed_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- }
- },
- "indexes": {
- "IDX_kiloclaw_scheduled_actions_status": {
- "name": "IDX_kiloclaw_scheduled_actions_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_actions_action_type": {
- "name": "IDX_kiloclaw_scheduled_actions_action_type",
- "columns": [
- {
- "expression": "action_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_scheduled_actions_created_by": {
- "name": "IDX_kiloclaw_scheduled_actions_created_by",
- "columns": [
- {
- "expression": "created_by",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk": {
- "name": "kiloclaw_scheduled_actions_target_image_tag_kiloclaw_image_catalog_image_tag_fk",
- "tableFrom": "kiloclaw_scheduled_actions",
- "tableTo": "kiloclaw_image_catalog",
- "columnsFrom": [
- "target_image_tag"
- ],
- "columnsTo": [
- "image_tag"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk": {
- "name": "kiloclaw_scheduled_actions_created_by_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_scheduled_actions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kiloclaw_subscription_change_log": {
- "name": "kiloclaw_subscription_change_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "actor_type": {
- "name": "actor_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "before_state": {
- "name": "before_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "after_state": {
- "name": "after_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_kiloclaw_subscription_change_log_subscription_created_at": {
- "name": "IDX_kiloclaw_subscription_change_log_subscription_created_at",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscription_change_log_created_at": {
- "name": "IDX_kiloclaw_subscription_change_log_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk": {
- "name": "kiloclaw_subscription_change_log_subscription_id_kiloclaw_subscriptions_id_fk",
- "tableFrom": "kiloclaw_subscription_change_log",
- "tableTo": "kiloclaw_subscriptions",
- "columnsFrom": [
- "subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kiloclaw_subscription_change_log_actor_type_check": {
- "name": "kiloclaw_subscription_change_log_actor_type_check",
- "value": "\"kiloclaw_subscription_change_log\".\"actor_type\" IN ('user', 'system')"
- },
- "kiloclaw_subscription_change_log_action_check": {
- "name": "kiloclaw_subscription_change_log_action_check",
- "value": "\"kiloclaw_subscription_change_log\".\"action\" IN ('created', 'status_changed', 'plan_switched', 'period_advanced', 'canceled', 'reactivated', 'suspended', 'destruction_scheduled', 'reassigned', 'backfilled', 'payment_source_changed', 'schedule_changed', 'admin_override')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_subscriptions": {
- "name": "kiloclaw_subscriptions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_subscription_id": {
- "name": "stripe_subscription_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_schedule_id": {
- "name": "stripe_schedule_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "transferred_to_subscription_id": {
- "name": "transferred_to_subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "access_origin": {
- "name": "access_origin",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "payment_source": {
- "name": "payment_source",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "kiloclaw_price_version": {
- "name": "kiloclaw_price_version",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plan": {
- "name": "plan",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "scheduled_plan": {
- "name": "scheduled_plan",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "scheduled_by": {
- "name": "scheduled_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cancel_at_period_end": {
- "name": "cancel_at_period_end",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "pending_conversion": {
- "name": "pending_conversion",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "trial_started_at": {
- "name": "trial_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "trial_ends_at": {
- "name": "trial_ends_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "current_period_start": {
- "name": "current_period_start",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "current_period_end": {
- "name": "current_period_end",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "credit_renewal_at": {
- "name": "credit_renewal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "commit_ends_at": {
- "name": "commit_ends_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "past_due_since": {
- "name": "past_due_since",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "suspended_at": {
- "name": "suspended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "destruction_deadline": {
- "name": "destruction_deadline",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_resume_requested_at": {
- "name": "auto_resume_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_resume_retry_after": {
- "name": "auto_resume_retry_after",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auto_resume_attempt_count": {
- "name": "auto_resume_attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "auto_top_up_triggered_for_period": {
- "name": "auto_top_up_triggered_for_period",
- "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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_kiloclaw_subscriptions_status": {
- "name": "IDX_kiloclaw_subscriptions_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_user_id": {
- "name": "IDX_kiloclaw_subscriptions_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_user_status": {
- "name": "IDX_kiloclaw_subscriptions_user_status",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_price_version": {
- "name": "IDX_kiloclaw_subscriptions_price_version",
- "columns": [
- {
- "expression": "kiloclaw_price_version",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_transferred_to": {
- "name": "IDX_kiloclaw_subscriptions_transferred_to",
- "columns": [
- {
- "expression": "transferred_to_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_stripe_schedule_id": {
- "name": "IDX_kiloclaw_subscriptions_stripe_schedule_id",
- "columns": [
- {
- "expression": "stripe_schedule_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_auto_resume_retry_after": {
- "name": "IDX_kiloclaw_subscriptions_auto_resume_retry_after",
- "columns": [
- {
- "expression": "auto_resume_retry_after",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_subscriptions_instance": {
- "name": "UQ_kiloclaw_subscriptions_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_subscriptions\".\"instance_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kiloclaw_subscriptions_transferred_to": {
- "name": "UQ_kiloclaw_subscriptions_transferred_to",
- "columns": [
- {
- "expression": "transferred_to_subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kiloclaw_subscriptions\".\"transferred_to_subscription_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_subscriptions_earlybird_origin": {
- "name": "IDX_kiloclaw_subscriptions_earlybird_origin",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "access_origin",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_subscriptions\".\"access_origin\" = 'earlybird'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_subscriptions_user_id_kilocode_users_id_fk": {
- "name": "kiloclaw_subscriptions_user_id_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_subscriptions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk": {
- "name": "kiloclaw_subscriptions_transferred_to_subscription_id_kiloclaw_subscriptions_id_fk",
- "tableFrom": "kiloclaw_subscriptions",
- "tableTo": "kiloclaw_subscriptions",
- "columnsFrom": [
- "transferred_to_subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_subscriptions_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_subscriptions",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_subscriptions_stripe_subscription_id_unique": {
- "name": "kiloclaw_subscriptions_stripe_subscription_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_subscription_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "kiloclaw_subscriptions_price_version_check": {
- "name": "kiloclaw_subscriptions_price_version_check",
- "value": "\"kiloclaw_subscriptions\".\"kiloclaw_price_version\" IN ('2026-03-19', '2026-05-10')"
- },
- "kiloclaw_subscriptions_plan_check": {
- "name": "kiloclaw_subscriptions_plan_check",
- "value": "\"kiloclaw_subscriptions\".\"plan\" IN ('trial', 'commit', 'standard')"
- },
- "kiloclaw_subscriptions_scheduled_plan_check": {
- "name": "kiloclaw_subscriptions_scheduled_plan_check",
- "value": "\"kiloclaw_subscriptions\".\"scheduled_plan\" IN ('commit', 'standard')"
- },
- "kiloclaw_subscriptions_scheduled_by_check": {
- "name": "kiloclaw_subscriptions_scheduled_by_check",
- "value": "\"kiloclaw_subscriptions\".\"scheduled_by\" IN ('auto', 'user')"
- },
- "kiloclaw_subscriptions_status_check": {
- "name": "kiloclaw_subscriptions_status_check",
- "value": "\"kiloclaw_subscriptions\".\"status\" IN ('trialing', 'active', 'past_due', 'canceled', 'unpaid')"
- },
- "kiloclaw_subscriptions_access_origin_check": {
- "name": "kiloclaw_subscriptions_access_origin_check",
- "value": "\"kiloclaw_subscriptions\".\"access_origin\" IN ('earlybird')"
- },
- "kiloclaw_subscriptions_payment_source_check": {
- "name": "kiloclaw_subscriptions_payment_source_check",
- "value": "\"kiloclaw_subscriptions\".\"payment_source\" IN ('stripe', 'credits')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_terminal_renewal_failures": {
- "name": "kiloclaw_terminal_renewal_failures",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "subscription_id": {
- "name": "subscription_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "renewal_boundary": {
- "name": "renewal_boundary",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unresolved'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "first_failure_at": {
- "name": "first_failure_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_failure_at": {
- "name": "last_failure_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_failure_code": {
- "name": "last_failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "last_failure_message": {
- "name": "last_failure_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_actor_type": {
- "name": "resolution_actor_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_actor_id": {
- "name": "resolution_actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_at": {
- "name": "resolution_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "resolution_reason": {
- "name": "resolution_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary": {
- "name": "UQ_kiloclaw_terminal_renewal_failures_subscription_boundary",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "renewal_boundary",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_terminal_renewal_failures_unresolved": {
- "name": "IDX_kiloclaw_terminal_renewal_failures_unresolved",
- "columns": [
- {
- "expression": "subscription_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "renewal_boundary",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"kiloclaw_terminal_renewal_failures\".\"status\" = 'unresolved'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at": {
- "name": "IDX_kiloclaw_terminal_renewal_failures_status_last_failure_at",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "last_failure_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk": {
- "name": "kiloclaw_terminal_renewal_failures_subscription_id_kiloclaw_subscriptions_id_fk",
- "tableFrom": "kiloclaw_terminal_renewal_failures",
- "tableTo": "kiloclaw_subscriptions",
- "columnsFrom": [
- "subscription_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "kiloclaw_terminal_renewal_failures_status_check": {
- "name": "kiloclaw_terminal_renewal_failures_status_check",
- "value": "\"kiloclaw_terminal_renewal_failures\".\"status\" IN ('unresolved', 'resolved', 'waived', 'superseded')"
- },
- "kiloclaw_terminal_renewal_failures_last_failure_code_check": {
- "name": "kiloclaw_terminal_renewal_failures_last_failure_code_check",
- "value": "\"kiloclaw_terminal_renewal_failures\".\"last_failure_code\" IN ('credit_balance_read_failed', 'renewal_transaction_failed', 'auto_top_up_marker_write_failed', 'worker_timeout', 'poison_payload', 'queue_delivery_exhausted')"
- },
- "kiloclaw_terminal_renewal_failures_resolution_actor_type_check": {
- "name": "kiloclaw_terminal_renewal_failures_resolution_actor_type_check",
- "value": "\"kiloclaw_terminal_renewal_failures\".\"resolution_actor_type\" IN ('operator', 'system')"
- }
- },
- "isRLSEnabled": false
- },
- "public.kiloclaw_version_pins": {
- "name": "kiloclaw_version_pins",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "image_tag": {
- "name": "image_tag",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "pinned_by": {
- "name": "pinned_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk": {
- "name": "kiloclaw_version_pins_instance_id_kiloclaw_instances_id_fk",
- "tableFrom": "kiloclaw_version_pins",
- "tableTo": "kiloclaw_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk": {
- "name": "kiloclaw_version_pins_image_tag_kiloclaw_image_catalog_image_tag_fk",
- "tableFrom": "kiloclaw_version_pins",
- "tableTo": "kiloclaw_image_catalog",
- "columnsFrom": [
- "image_tag"
- ],
- "columnsTo": [
- "image_tag"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- },
- "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk": {
- "name": "kiloclaw_version_pins_pinned_by_kilocode_users_id_fk",
- "tableFrom": "kiloclaw_version_pins",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "pinned_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kiloclaw_version_pins_instance_id_unique": {
- "name": "kiloclaw_version_pins_instance_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "instance_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.kilocode_users": {
- "name": "kilocode_users",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "google_user_email": {
- "name": "google_user_email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "google_user_name": {
- "name": "google_user_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "google_user_image_url": {
- "name": "google_user_image_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "hosted_domain": {
- "name": "hosted_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "microdollars_used": {
- "name": "microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "kilo_pass_threshold": {
- "name": "kilo_pass_threshold",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "app_store_account_token": {
- "name": "app_store_account_token",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "is_admin": {
- "name": "is_admin",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "can_manage_credits": {
- "name": "can_manage_credits",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "total_microdollars_acquired": {
- "name": "total_microdollars_acquired",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "next_credit_expiration_at": {
- "name": "next_credit_expiration_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "has_validation_stytch": {
- "name": "has_validation_stytch",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "has_validation_novel_card_with_hold": {
- "name": "has_validation_novel_card_with_hold",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "blocked_reason": {
- "name": "blocked_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_at": {
- "name": "blocked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_by_kilo_user_id": {
- "name": "blocked_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "api_token_pepper": {
- "name": "api_token_pepper",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "web_session_pepper": {
- "name": "web_session_pepper",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_top_up_enabled": {
- "name": "auto_top_up_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "is_bot": {
- "name": "is_bot",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "kiloclaw_early_access": {
- "name": "kiloclaw_early_access",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "default_model": {
- "name": "default_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cohorts": {
- "name": "cohorts",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "completed_welcome_form": {
- "name": "completed_welcome_form",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "linkedin_url": {
- "name": "linkedin_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "github_url": {
- "name": "github_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "discord_server_membership_verified_at": {
- "name": "discord_server_membership_verified_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "openrouter_upstream_safety_identifier": {
- "name": "openrouter_upstream_safety_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "openrouter_downstream_safety_identifier": {
- "name": "openrouter_downstream_safety_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_downstream_safety_identifier": {
- "name": "vercel_downstream_safety_identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "customer_source": {
- "name": "customer_source",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "signup_ip": {
- "name": "signup_ip",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "account_deletion_requested_at": {
- "name": "account_deletion_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "normalized_email": {
- "name": "normalized_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "email_domain": {
- "name": "email_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_kilocode_users_signup_ip_created_at": {
- "name": "IDX_kilocode_users_signup_ip_created_at",
- "columns": [
- {
- "expression": "signup_ip",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_blocked_at": {
- "name": "IDX_kilocode_users_blocked_at",
- "columns": [
- {
- "expression": "blocked_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_blocked_by_kilo_user_id": {
- "name": "IDX_kilocode_users_blocked_by_kilo_user_id",
- "columns": [
- {
- "expression": "blocked_by_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilocode_users_openrouter_upstream_safety_identifier": {
- "name": "UQ_kilocode_users_openrouter_upstream_safety_identifier",
- "columns": [
- {
- "expression": "openrouter_upstream_safety_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilocode_users\".\"openrouter_upstream_safety_identifier\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_kilocode_users_openrouter_downstream_safety_identifier": {
- "name": "UQ_kilocode_users_openrouter_downstream_safety_identifier",
- "columns": [
- {
- "expression": "openrouter_downstream_safety_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilocode_users\".\"openrouter_downstream_safety_identifier\" IS NOT NULL",
- "concurrently": true,
- "method": "btree",
- "with": {}
- },
- "UQ_kilocode_users_vercel_downstream_safety_identifier": {
- "name": "UQ_kilocode_users_vercel_downstream_safety_identifier",
- "columns": [
- {
- "expression": "vercel_downstream_safety_identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"kilocode_users\".\"vercel_downstream_safety_identifier\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_normalized_email": {
- "name": "IDX_kilocode_users_normalized_email",
- "columns": [
- {
- "expression": "normalized_email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_kilocode_users_email_domain": {
- "name": "IDX_kilocode_users_email_domain",
- "columns": [
- {
- "expression": "email_domain",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "kilocode_users_app_store_account_token_unique": {
- "name": "kilocode_users_app_store_account_token_unique",
- "nullsNotDistinct": false,
- "columns": [
- "app_store_account_token"
- ]
- },
- "UQ_b1afacbcf43f2c7c4cb9f7e7faa": {
- "name": "UQ_b1afacbcf43f2c7c4cb9f7e7faa",
- "nullsNotDistinct": false,
- "columns": [
- "google_user_email"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "blocked_reason_not_empty": {
- "name": "blocked_reason_not_empty",
- "value": "length(blocked_reason) > 0"
- },
- "kilocode_users_can_manage_credits_requires_admin_check": {
- "name": "kilocode_users_can_manage_credits_requires_admin_check",
- "value": "NOT \"kilocode_users\".\"can_manage_credits\" OR \"kilocode_users\".\"is_admin\""
- }
- },
- "isRLSEnabled": false
- },
- "public.magic_link_tokens": {
- "name": "magic_link_tokens",
- "schema": "",
- "columns": {
- "token_hash": {
- "name": "token_hash",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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": {
- "idx_magic_link_tokens_email": {
- "name": "idx_magic_link_tokens_email",
- "columns": [
- {
- "expression": "email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_magic_link_tokens_expires_at": {
- "name": "idx_magic_link_tokens_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "check_expires_at_future": {
- "name": "check_expires_at_future",
- "value": "\"magic_link_tokens\".\"expires_at\" > \"magic_link_tokens\".\"created_at\""
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_assignments": {
- "name": "mcp_gateway_assignments",
- "schema": "",
- "columns": {
- "assignment_id": {
- "name": "assignment_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "assigned_by_kilo_user_id": {
- "name": "assigned_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "single_user_slot": {
- "name": "single_user_slot",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_assignments_active": {
- "name": "UQ_mcp_gateway_assignments_active",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_mcp_gateway_assignments_single_user_slot": {
- "name": "UQ_mcp_gateway_assignments_single_user_slot",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "single_user_slot",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_assignments\".\"revoked_at\" is null and \"mcp_gateway_assignments\".\"single_user_slot\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_assignments_config": {
- "name": "IDX_mcp_gateway_assignments_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_assignments_user": {
- "name": "IDX_mcp_gateway_assignments_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_assignments_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_assignments",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_assignments_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_assignments",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_assignments_assigned_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_assignments",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "assigned_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.mcp_gateway_audit_events": {
- "name": "mcp_gateway_audit_events",
- "schema": "",
- "columns": {
- "audit_event_id": {
- "name": "audit_event_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "actor_kilo_user_id": {
- "name": "actor_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "connect_resource_id": {
- "name": "connect_resource_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "outcome": {
- "name": "outcome",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "correlation_metadata": {
- "name": "correlation_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_mcp_gateway_audit_events_config": {
- "name": "IDX_mcp_gateway_audit_events_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_audit_events_owner": {
- "name": "IDX_mcp_gateway_audit_events_owner",
- "columns": [
- {
- "expression": "owner_scope",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owner_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_audit_events_created_at": {
- "name": "IDX_mcp_gateway_audit_events_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_audit_events_actor_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "actor_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_audit_events_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk": {
- "name": "mcp_gateway_audit_events_connect_resource_id_mcp_gateway_connect_resources_connect_resource_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "mcp_gateway_connect_resources",
- "columnsFrom": [
- "connect_resource_id"
- ],
- "columnsTo": [
- "connect_resource_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_audit_events_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_audit_events",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_audit_events_owner_scope": {
- "name": "mcp_gateway_audit_events_owner_scope",
- "value": "\"mcp_gateway_audit_events\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_audit_events_outcome": {
- "name": "mcp_gateway_audit_events_outcome",
- "value": "\"mcp_gateway_audit_events\".\"outcome\" IN ('success', 'failure', 'blocked')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_authorization_codes": {
- "name": "mcp_gateway_authorization_codes",
- "schema": "",
- "columns": {
- "authorization_code_id": {
- "name": "authorization_code_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "code_hash": {
- "name": "code_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "authorization_request_id": {
- "name": "authorization_request_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redirect_uri": {
- "name": "redirect_uri",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "granted_scopes": {
- "name": "granted_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "code_challenge": {
- "name": "code_challenge",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "code_challenge_method": {
- "name": "code_challenge_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'S256'"
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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": {
- "UQ_mcp_gateway_authorization_codes_code_hash": {
- "name": "UQ_mcp_gateway_authorization_codes_code_hash",
- "columns": [
- {
- "expression": "code_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_codes_expires_at": {
- "name": "IDX_mcp_gateway_authorization_codes_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_codes_client": {
- "name": "IDX_mcp_gateway_authorization_codes_client",
- "columns": [
- {
- "expression": "oauth_client_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
- "name": "mcp_gateway_authorization_codes_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_authorization_requests",
- "columnsFrom": [
- "authorization_request_id"
- ],
- "columnsTo": [
- "authorization_request_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
- "name": "mcp_gateway_authorization_codes_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_oauth_clients",
- "columnsFrom": [
- "oauth_client_id"
- ],
- "columnsTo": [
- "oauth_client_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_authorization_codes_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_authorization_codes_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_authorization_codes_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_authorization_codes",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_authorization_codes_owner_scope": {
- "name": "mcp_gateway_authorization_codes_owner_scope",
- "value": "\"mcp_gateway_authorization_codes\".\"owner_scope\" IN ('personal', 'organization')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_authorization_requests": {
- "name": "mcp_gateway_authorization_requests",
- "schema": "",
- "columns": {
- "authorization_request_id": {
- "name": "authorization_request_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "request_state_hash": {
- "name": "request_state_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redirect_uri": {
- "name": "redirect_uri",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "requested_scopes": {
- "name": "requested_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "granted_scopes": {
- "name": "granted_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "oauth_state": {
- "name": "oauth_state",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "code_challenge": {
- "name": "code_challenge",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "code_challenge_method": {
- "name": "code_challenge_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'S256'"
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "request_status": {
- "name": "request_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_authorization_requests_state_hash": {
- "name": "UQ_mcp_gateway_authorization_requests_state_hash",
- "columns": [
- {
- "expression": "request_state_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_requests_config": {
- "name": "IDX_mcp_gateway_authorization_requests_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_requests_user": {
- "name": "IDX_mcp_gateway_authorization_requests_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_authorization_requests_expires_at": {
- "name": "IDX_mcp_gateway_authorization_requests_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
- "name": "mcp_gateway_authorization_requests_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "mcp_gateway_oauth_clients",
- "columnsFrom": [
- "oauth_client_id"
- ],
- "columnsTo": [
- "oauth_client_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_authorization_requests_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_authorization_requests_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_authorization_requests_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_authorization_requests",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_authorization_requests_owner_scope": {
- "name": "mcp_gateway_authorization_requests_owner_scope",
- "value": "\"mcp_gateway_authorization_requests\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_authorization_requests_status": {
- "name": "mcp_gateway_authorization_requests_status",
- "value": "\"mcp_gateway_authorization_requests\".\"request_status\" IN ('pending', 'completed', 'error')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_config_secrets": {
- "name": "mcp_gateway_config_secrets",
- "schema": "",
- "columns": {
- "config_secret_id": {
- "name": "config_secret_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "secret_kind": {
- "name": "secret_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_secret": {
- "name": "encrypted_secret",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "secret_version": {
- "name": "secret_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_config_secrets_active_kind": {
- "name": "UQ_mcp_gateway_config_secrets_active_kind",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "secret_kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_config_secrets\".\"revoked_at\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_config_secrets_config": {
- "name": "IDX_mcp_gateway_config_secrets_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_config_secrets_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_config_secrets",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_config_secrets_version_positive": {
- "name": "mcp_gateway_config_secrets_version_positive",
- "value": "\"mcp_gateway_config_secrets\".\"secret_version\" > 0"
- },
- "mcp_gateway_config_secrets_kind": {
- "name": "mcp_gateway_config_secrets_kind",
- "value": "\"mcp_gateway_config_secrets\".\"secret_kind\" IN ('static_provider_credentials', 'dynamic_registration', 'static_headers')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_configs": {
- "name": "mcp_gateway_configs",
- "schema": "",
- "columns": {
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "remote_url": {
- "name": "remote_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "auth_mode": {
- "name": "auth_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sharing_mode": {
- "name": "sharing_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_scopes": {
- "name": "provider_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "provider_scope_source": {
- "name": "provider_scope_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'none'"
- },
- "provider_resource": {
- "name": "provider_resource",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "enabled": {
- "name": "enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "path_passthrough": {
- "name": "path_passthrough",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "config_version": {
- "name": "config_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "discovered_provider_metadata": {
- "name": "discovered_provider_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "registry_metadata": {
- "name": "registry_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "auxiliary_headers": {
- "name": "auxiliary_headers",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "deleted_at": {
- "name": "deleted_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_mcp_gateway_configs_owner": {
- "name": "IDX_mcp_gateway_configs_owner",
- "columns": [
- {
- "expression": "owner_scope",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owner_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_configs_enabled": {
- "name": "IDX_mcp_gateway_configs_enabled",
- "columns": [
- {
- "expression": "enabled",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_configs_remote_url": {
- "name": "IDX_mcp_gateway_configs_remote_url",
- "columns": [
- {
- "expression": "remote_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_configs_created_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_configs",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_configs_name_not_empty": {
- "name": "mcp_gateway_configs_name_not_empty",
- "value": "length(trim(\"mcp_gateway_configs\".\"name\")) > 0"
- },
- "mcp_gateway_configs_config_version_positive": {
- "name": "mcp_gateway_configs_config_version_positive",
- "value": "\"mcp_gateway_configs\".\"config_version\" > 0"
- },
- "mcp_gateway_configs_personal_single_user": {
- "name": "mcp_gateway_configs_personal_single_user",
- "value": "\"mcp_gateway_configs\".\"owner_scope\" <> 'personal' OR \"mcp_gateway_configs\".\"sharing_mode\" = 'single_user'"
- },
- "mcp_gateway_configs_owner_scope": {
- "name": "mcp_gateway_configs_owner_scope",
- "value": "\"mcp_gateway_configs\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_configs_auth_mode": {
- "name": "mcp_gateway_configs_auth_mode",
- "value": "\"mcp_gateway_configs\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
- },
- "mcp_gateway_configs_sharing_mode": {
- "name": "mcp_gateway_configs_sharing_mode",
- "value": "\"mcp_gateway_configs\".\"sharing_mode\" IN ('single_user', 'multi_user')"
- },
- "mcp_gateway_configs_provider_scope_source": {
- "name": "mcp_gateway_configs_provider_scope_source",
- "value": "\"mcp_gateway_configs\".\"provider_scope_source\" IN ('none', 'discovered', 'override')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_connect_resources": {
- "name": "mcp_gateway_connect_resources",
- "schema": "",
- "columns": {
- "connect_resource_id": {
- "name": "connect_resource_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_url": {
- "name": "canonical_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "route_status": {
- "name": "route_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "route_version": {
- "name": "route_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "rotated_at": {
- "name": "rotated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_connect_resources_route_key": {
- "name": "UQ_mcp_gateway_connect_resources_route_key",
- "columns": [
- {
- "expression": "route_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_mcp_gateway_connect_resources_active_config": {
- "name": "UQ_mcp_gateway_connect_resources_active_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_connect_resources\".\"route_status\" = 'active'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connect_resources_config": {
- "name": "IDX_mcp_gateway_connect_resources_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connect_resources_canonical_url": {
- "name": "IDX_mcp_gateway_connect_resources_canonical_url",
- "columns": [
- {
- "expression": "canonical_url",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_connect_resources_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_connect_resources",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_connect_resources_route_key_format": {
- "name": "mcp_gateway_connect_resources_route_key_format",
- "value": "\"mcp_gateway_connect_resources\".\"route_key\" ~ '^[A-Za-z0-9_-]{32,}$'"
- },
- "mcp_gateway_connect_resources_route_version_positive": {
- "name": "mcp_gateway_connect_resources_route_version_positive",
- "value": "\"mcp_gateway_connect_resources\".\"route_version\" > 0"
- },
- "mcp_gateway_connect_resources_owner_scope": {
- "name": "mcp_gateway_connect_resources_owner_scope",
- "value": "\"mcp_gateway_connect_resources\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_connect_resources_route_status": {
- "name": "mcp_gateway_connect_resources_route_status",
- "value": "\"mcp_gateway_connect_resources\".\"route_status\" IN ('active', 'rotated', 'revoked')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_connection_instances": {
- "name": "mcp_gateway_connection_instances",
- "schema": "",
- "columns": {
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_status": {
- "name": "instance_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "instance_version": {
- "name": "instance_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "last_used_at": {
- "name": "last_used_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "removed_at": {
- "name": "removed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_connection_instances_non_terminal": {
- "name": "UQ_mcp_gateway_connection_instances_non_terminal",
- "columns": [
- {
- "expression": "owner_scope",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "owner_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connection_instances_config": {
- "name": "IDX_mcp_gateway_connection_instances_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_connection_instances_user": {
- "name": "IDX_mcp_gateway_connection_instances_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_connection_instances_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_connection_instances",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_connection_instances_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_connection_instances",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_connection_instances_version_positive": {
- "name": "mcp_gateway_connection_instances_version_positive",
- "value": "\"mcp_gateway_connection_instances\".\"instance_version\" > 0"
- },
- "mcp_gateway_connection_instances_owner_scope": {
- "name": "mcp_gateway_connection_instances_owner_scope",
- "value": "\"mcp_gateway_connection_instances\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_connection_instances_status": {
- "name": "mcp_gateway_connection_instances_status",
- "value": "\"mcp_gateway_connection_instances\".\"instance_status\" IN ('active', 'needs_reauth', 'revoked', 'removed')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_oauth_clients": {
- "name": "mcp_gateway_oauth_clients",
- "schema": "",
- "columns": {
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "client_name": {
- "name": "client_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "registration_token_hash": {
- "name": "registration_token_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "client_secret_hash": {
- "name": "client_secret_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "token_endpoint_auth_method": {
- "name": "token_endpoint_auth_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redirect_uris": {
- "name": "redirect_uris",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "grant_types": {
- "name": "grant_types",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "response_types": {
- "name": "response_types",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "declared_scopes": {
- "name": "declared_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "registration_access_token_expires_at": {
- "name": "registration_access_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "deleted_at": {
- "name": "deleted_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_oauth_clients_client_id": {
- "name": "UQ_mcp_gateway_oauth_clients_client_id",
- "columns": [
- {
- "expression": "client_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_mcp_gateway_oauth_clients_registration_token_hash": {
- "name": "UQ_mcp_gateway_oauth_clients_registration_token_hash",
- "columns": [
- {
- "expression": "registration_token_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_oauth_clients_deleted_at": {
- "name": "IDX_mcp_gateway_oauth_clients_deleted_at",
- "columns": [
- {
- "expression": "deleted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_oauth_clients_client_id_format": {
- "name": "mcp_gateway_oauth_clients_client_id_format",
- "value": "\"mcp_gateway_oauth_clients\".\"client_id\" ~ '^[A-Za-z0-9._-]+:[A-Za-z0-9._-]+$'"
- },
- "mcp_gateway_oauth_clients_auth_method": {
- "name": "mcp_gateway_oauth_clients_auth_method",
- "value": "\"mcp_gateway_oauth_clients\".\"token_endpoint_auth_method\" IN ('none', 'client_secret_post', 'client_secret_basic')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_pending_provider_authorizations": {
- "name": "mcp_gateway_pending_provider_authorizations",
- "schema": "",
- "columns": {
- "pending_provider_authorization_id": {
- "name": "pending_provider_authorization_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "state_hash": {
- "name": "state_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "authorization_request_id": {
- "name": "authorization_request_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "remote_url": {
- "name": "remote_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "auth_mode": {
- "name": "auth_mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_authorization_endpoint": {
- "name": "provider_authorization_endpoint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_token_endpoint": {
- "name": "provider_token_endpoint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_state": {
- "name": "encrypted_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "config_version": {
- "name": "config_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "pending_status": {
- "name": "pending_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'pending'"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_pending_provider_authorizations_state_hash": {
- "name": "UQ_mcp_gateway_pending_provider_authorizations_state_hash",
- "columns": [
- {
- "expression": "state_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_pending_provider_authorizations_config": {
- "name": "IDX_mcp_gateway_pending_provider_authorizations_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_pending_provider_authorizations_expires_at": {
- "name": "IDX_mcp_gateway_pending_provider_authorizations_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_authorization_request_id_mcp_gateway_authorization_requests_authorization_request_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "mcp_gateway_authorization_requests",
- "columnsFrom": [
- "authorization_request_id"
- ],
- "columnsTo": [
- "authorization_request_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_pending_provider_authorizations_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_pending_provider_authorizations",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_pending_provider_authorizations_config_version_positive": {
- "name": "mcp_gateway_pending_provider_authorizations_config_version_positive",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"config_version\" > 0"
- },
- "mcp_gateway_pending_provider_authorizations_owner_scope": {
- "name": "mcp_gateway_pending_provider_authorizations_owner_scope",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"owner_scope\" IN ('personal', 'organization')"
- },
- "mcp_gateway_pending_provider_authorizations_auth_mode": {
- "name": "mcp_gateway_pending_provider_authorizations_auth_mode",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"auth_mode\" IN ('none', 'static_headers', 'oauth_dynamic', 'oauth_static')"
- },
- "mcp_gateway_pending_provider_authorizations_status": {
- "name": "mcp_gateway_pending_provider_authorizations_status",
- "value": "\"mcp_gateway_pending_provider_authorizations\".\"pending_status\" IN ('pending', 'completed', 'error')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_provider_grants": {
- "name": "mcp_gateway_provider_grants",
- "schema": "",
- "columns": {
- "provider_grant_id": {
- "name": "provider_grant_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_grant": {
- "name": "encrypted_grant",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subject": {
- "name": "provider_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "grant_scope": {
- "name": "grant_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "grant_status": {
- "name": "grant_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "grant_version": {
- "name": "grant_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "last_used_at": {
- "name": "last_used_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_provider_grants_active_instance": {
- "name": "UQ_mcp_gateway_provider_grants_active_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"mcp_gateway_provider_grants\".\"grant_status\" = 'active'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_provider_grants_instance": {
- "name": "IDX_mcp_gateway_provider_grants_instance",
- "columns": [
- {
- "expression": "instance_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_provider_grants_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_provider_grants",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_provider_grants_version_positive": {
- "name": "mcp_gateway_provider_grants_version_positive",
- "value": "\"mcp_gateway_provider_grants\".\"grant_version\" > 0"
- },
- "mcp_gateway_provider_grants_status": {
- "name": "mcp_gateway_provider_grants_status",
- "value": "\"mcp_gateway_provider_grants\".\"grant_status\" IN ('active', 'revoked')"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_rate_limit_windows": {
- "name": "mcp_gateway_rate_limit_windows",
- "schema": "",
- "columns": {
- "rate_limit_window_id": {
- "name": "rate_limit_window_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "ip_hash": {
- "name": "ip_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "window_started_at": {
- "name": "window_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "attempt_count": {
- "name": "attempt_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_mcp_gateway_rate_limit_windows_ip_window": {
- "name": "UQ_mcp_gateway_rate_limit_windows_ip_window",
- "columns": [
- {
- "expression": "ip_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "window_started_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_rate_limit_windows_window": {
- "name": "IDX_mcp_gateway_rate_limit_windows_window",
- "columns": [
- {
- "expression": "window_started_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_rate_limit_windows_attempt_count_non_negative": {
- "name": "mcp_gateway_rate_limit_windows_attempt_count_non_negative",
- "value": "\"mcp_gateway_rate_limit_windows\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.mcp_gateway_refresh_tokens": {
- "name": "mcp_gateway_refresh_tokens",
- "schema": "",
- "columns": {
- "refresh_token_id": {
- "name": "refresh_token_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "token_hash": {
- "name": "token_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "rotated_from_refresh_token_id": {
- "name": "rotated_from_refresh_token_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "oauth_client_id": {
- "name": "oauth_client_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "client_id": {
- "name": "client_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_scope": {
- "name": "owner_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owner_id": {
- "name": "owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "config_id": {
- "name": "config_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "route_key": {
- "name": "route_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "canonical_resource_url": {
- "name": "canonical_resource_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "granted_scopes": {
- "name": "granted_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "execution_context": {
- "name": "execution_context",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "instance_id": {
- "name": "instance_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "consumed_at": {
- "name": "consumed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revoked_at": {
- "name": "revoked_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": {
- "UQ_mcp_gateway_refresh_tokens_token_hash": {
- "name": "UQ_mcp_gateway_refresh_tokens_token_hash",
- "columns": [
- {
- "expression": "token_hash",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_refresh_tokens_user": {
- "name": "IDX_mcp_gateway_refresh_tokens_user",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_refresh_tokens_config": {
- "name": "IDX_mcp_gateway_refresh_tokens_config",
- "columns": [
- {
- "expression": "config_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_mcp_gateway_refresh_tokens_consumed_at": {
- "name": "IDX_mcp_gateway_refresh_tokens_consumed_at",
- "columns": [
- {
- "expression": "consumed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk": {
- "name": "mcp_gateway_refresh_tokens_oauth_client_id_mcp_gateway_oauth_clients_oauth_client_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "mcp_gateway_oauth_clients",
- "columnsFrom": [
- "oauth_client_id"
- ],
- "columnsTo": [
- "oauth_client_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk": {
- "name": "mcp_gateway_refresh_tokens_config_id_mcp_gateway_configs_config_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "mcp_gateway_configs",
- "columnsFrom": [
- "config_id"
- ],
- "columnsTo": [
- "config_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk": {
- "name": "mcp_gateway_refresh_tokens_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk": {
- "name": "mcp_gateway_refresh_tokens_instance_id_mcp_gateway_connection_instances_instance_id_fk",
- "tableFrom": "mcp_gateway_refresh_tokens",
- "tableTo": "mcp_gateway_connection_instances",
- "columnsFrom": [
- "instance_id"
- ],
- "columnsTo": [
- "instance_id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "mcp_gateway_refresh_tokens_owner_scope": {
- "name": "mcp_gateway_refresh_tokens_owner_scope",
- "value": "\"mcp_gateway_refresh_tokens\".\"owner_scope\" IN ('personal', 'organization')"
- }
- },
- "isRLSEnabled": false
- },
- "public.microdollar_usage": {
- "name": "microdollar_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cost": {
- "name": "cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "input_tokens": {
- "name": "input_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "output_tokens": {
- "name": "output_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_write_tokens": {
- "name": "cache_write_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_hit_tokens": {
- "name": "cache_hit_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "requested_model": {
- "name": "requested_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cache_discount": {
- "name": "cache_discount",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "has_error": {
- "name": "has_error",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "abuse_classification": {
- "name": "abuse_classification",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "inference_provider": {
- "name": "inference_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_created_at": {
- "name": "idx_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_abuse_classification": {
- "name": "idx_abuse_classification",
- "columns": [
- {
- "expression": "abuse_classification",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_kilo_user_id_created_at2": {
- "name": "idx_kilo_user_id_created_at2",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_microdollar_usage_organization_id": {
- "name": "idx_microdollar_usage_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"microdollar_usage\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.microdollar_usage_daily": {
- "name": "microdollar_usage_daily",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "usage_date": {
- "name": "usage_date",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "total_cost_microdollars": {
- "name": "total_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_microdollar_usage_daily_personal": {
- "name": "idx_microdollar_usage_daily_personal",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "usage_date",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"microdollar_usage_daily\".\"organization_id\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_microdollar_usage_daily_org": {
- "name": "idx_microdollar_usage_daily_org",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "usage_date",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"microdollar_usage_daily\".\"organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.microdollar_usage_metadata": {
- "name": "microdollar_usage_metadata",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "message_id": {
- "name": "message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "http_user_agent_id": {
- "name": "http_user_agent_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "http_ip_id": {
- "name": "http_ip_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_city_id": {
- "name": "vercel_ip_city_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_country_id": {
- "name": "vercel_ip_country_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_latitude": {
- "name": "vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "vercel_ip_longitude": {
- "name": "vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "ja4_digest_id": {
- "name": "ja4_digest_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "user_prompt_prefix": {
- "name": "user_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_prefix_id": {
- "name": "system_prompt_prefix_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_length": {
- "name": "system_prompt_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "max_tokens": {
- "name": "max_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "has_middle_out_transform": {
- "name": "has_middle_out_transform",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "status_code": {
- "name": "status_code",
- "type": "smallint",
- "primaryKey": false,
- "notNull": false
- },
- "upstream_id": {
- "name": "upstream_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finish_reason_id": {
- "name": "finish_reason_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "latency": {
- "name": "latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "moderation_latency": {
- "name": "moderation_latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "generation_time": {
- "name": "generation_time",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "is_byok": {
- "name": "is_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "is_user_byok": {
- "name": "is_user_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "streamed": {
- "name": "streamed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "cancelled": {
- "name": "cancelled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "editor_name_id": {
- "name": "editor_name_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "api_kind_id": {
- "name": "api_kind_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "has_tools": {
- "name": "has_tools",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "machine_id": {
- "name": "machine_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "feature_id": {
- "name": "feature_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "mode_id": {
- "name": "mode_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "auto_model_id": {
- "name": "auto_model_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "market_cost": {
- "name": "market_cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "is_free": {
- "name": "is_free",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_delay": {
- "name": "abuse_delay",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_downgraded_from": {
- "name": "abuse_downgraded_from",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_microdollar_usage_metadata_created_at": {
- "name": "idx_microdollar_usage_metadata_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_microdollar_usage_metadata_session_id": {
- "name": "idx_microdollar_usage_metadata_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"microdollar_usage_metadata\".\"session_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk": {
- "name": "microdollar_usage_metadata_http_user_agent_id_http_user_agent_http_user_agent_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "http_user_agent",
- "columnsFrom": [
- "http_user_agent_id"
- ],
- "columnsTo": [
- "http_user_agent_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk": {
- "name": "microdollar_usage_metadata_http_ip_id_http_ip_http_ip_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "http_ip",
- "columnsFrom": [
- "http_ip_id"
- ],
- "columnsTo": [
- "http_ip_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk": {
- "name": "microdollar_usage_metadata_vercel_ip_city_id_vercel_ip_city_vercel_ip_city_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "vercel_ip_city",
- "columnsFrom": [
- "vercel_ip_city_id"
- ],
- "columnsTo": [
- "vercel_ip_city_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk": {
- "name": "microdollar_usage_metadata_vercel_ip_country_id_vercel_ip_country_vercel_ip_country_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "vercel_ip_country",
- "columnsFrom": [
- "vercel_ip_country_id"
- ],
- "columnsTo": [
- "vercel_ip_country_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk": {
- "name": "microdollar_usage_metadata_ja4_digest_id_ja4_digest_ja4_digest_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "ja4_digest",
- "columnsFrom": [
- "ja4_digest_id"
- ],
- "columnsTo": [
- "ja4_digest_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk": {
- "name": "microdollar_usage_metadata_system_prompt_prefix_id_system_prompt_prefix_system_prompt_prefix_id_fk",
- "tableFrom": "microdollar_usage_metadata",
- "tableTo": "system_prompt_prefix",
- "columnsFrom": [
- "system_prompt_prefix_id"
- ],
- "columnsTo": [
- "system_prompt_prefix_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.mode": {
- "name": "mode",
- "schema": "",
- "columns": {
- "mode_id": {
- "name": "mode_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_mode": {
- "name": "UQ_mode",
- "columns": [
- {
- "expression": "mode",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.model_stats": {
- "name": "model_stats",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false,
- "default": true
- },
- "is_featured": {
- "name": "is_featured",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "is_stealth": {
- "name": "is_stealth",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "is_recommended": {
- "name": "is_recommended",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "openrouter_id": {
- "name": "openrouter_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "aa_slug": {
- "name": "aa_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model_creator": {
- "name": "model_creator",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "creator_slug": {
- "name": "creator_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "release_date": {
- "name": "release_date",
- "type": "date",
- "primaryKey": false,
- "notNull": false
- },
- "price_input": {
- "name": "price_input",
- "type": "numeric(10, 6)",
- "primaryKey": false,
- "notNull": false
- },
- "price_output": {
- "name": "price_output",
- "type": "numeric(10, 6)",
- "primaryKey": false,
- "notNull": false
- },
- "coding_index": {
- "name": "coding_index",
- "type": "numeric(5, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "speed_tokens_per_sec": {
- "name": "speed_tokens_per_sec",
- "type": "numeric(8, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "context_length": {
- "name": "context_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "max_output_tokens": {
- "name": "max_output_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "input_modalities": {
- "name": "input_modalities",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "openrouter_data": {
- "name": "openrouter_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "benchmarks": {
- "name": "benchmarks",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "chart_data": {
- "name": "chart_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_stats_openrouter_id": {
- "name": "IDX_model_stats_openrouter_id",
- "columns": [
- {
- "expression": "openrouter_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_slug": {
- "name": "IDX_model_stats_slug",
- "columns": [
- {
- "expression": "slug",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_is_active": {
- "name": "IDX_model_stats_is_active",
- "columns": [
- {
- "expression": "is_active",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_creator_slug": {
- "name": "IDX_model_stats_creator_slug",
- "columns": [
- {
- "expression": "creator_slug",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_price_input": {
- "name": "IDX_model_stats_price_input",
- "columns": [
- {
- "expression": "price_input",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_coding_index": {
- "name": "IDX_model_stats_coding_index",
- "columns": [
- {
- "expression": "coding_index",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_stats_context_length": {
- "name": "IDX_model_stats_context_length",
- "columns": [
- {
- "expression": "context_length",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "model_stats_openrouter_id_unique": {
- "name": "model_stats_openrouter_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "openrouter_id"
- ]
- },
- "model_stats_slug_unique": {
- "name": "model_stats_slug_unique",
- "nullsNotDistinct": false,
- "columns": [
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.model_eval_ingestions": {
- "name": "model_eval_ingestions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "bench_eval_name": {
- "name": "bench_eval_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "bench_eval_url": {
- "name": "bench_eval_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "model_stats_id": {
- "name": "model_stats_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "variant": {
- "name": "variant",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "task_source": {
- "name": "task_source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "n_total_trials": {
- "name": "n_total_trials",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "n_attempts": {
- "name": "n_attempts",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_score": {
- "name": "total_score",
- "type": "numeric(14, 6)",
- "primaryKey": false,
- "notNull": true
- },
- "overall_score": {
- "name": "overall_score",
- "type": "numeric(12, 8)",
- "primaryKey": false,
- "notNull": true
- },
- "n_errored": {
- "name": "n_errored",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "avg_cost_microdollars": {
- "name": "avg_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "total_cost_microdollars": {
- "name": "total_cost_microdollars",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_input_tokens": {
- "name": "avg_input_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_input_tokens": {
- "name": "total_input_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_output_tokens": {
- "name": "avg_output_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_output_tokens": {
- "name": "total_output_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_cache_read_tokens": {
- "name": "avg_cache_read_tokens",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "total_cache_read_tokens": {
- "name": "total_cache_read_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "avg_execution_ms": {
- "name": "avg_execution_ms",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "promoted_at": {
- "name": "promoted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "promoted_by_email": {
- "name": "promoted_by_email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "promotion_note": {
- "name": "promotion_note",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_eval_ingestions_lookup": {
- "name": "IDX_model_eval_ingestions_lookup",
- "columns": [
- {
- "expression": "provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "model",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "variant",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "task_source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "promoted_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_eval_ingestions_model_stats": {
- "name": "IDX_model_eval_ingestions_model_stats",
- "columns": [
- {
- "expression": "model_stats_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_eval_ingestions_promoted_by_email_lower": {
- "name": "IDX_model_eval_ingestions_promoted_by_email_lower",
- "columns": [
- {
- "expression": "LOWER(\"promoted_by_email\")",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_eval_ingestions_model_stats_id_model_stats_id_fk": {
- "name": "model_eval_ingestions_model_stats_id_model_stats_id_fk",
- "tableFrom": "model_eval_ingestions",
- "tableTo": "model_stats",
- "columnsFrom": [
- "model_stats_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "model_eval_ingestions_bench_eval_name_unique": {
- "name": "model_eval_ingestions_bench_eval_name_unique",
- "nullsNotDistinct": false,
- "columns": [
- "bench_eval_name"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.model_experiment": {
- "name": "model_experiment",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "public_model_id": {
- "name": "public_model_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'draft'"
- },
- "is_archived": {
- "name": "is_archived",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "ended_at": {
- "name": "ended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "UQ_model_experiment_public_model_id_routing": {
- "name": "UQ_model_experiment_public_model_id_routing",
- "columns": [
- {
- "expression": "public_model_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"model_experiment\".\"status\" IN ('active', 'paused')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_experiment_status": {
- "name": "IDX_model_experiment_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_created_by_user_id_kilocode_users_id_fk": {
- "name": "model_experiment_created_by_user_id_kilocode_users_id_fk",
- "tableFrom": "model_experiment",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "model_experiment_status_valid": {
- "name": "model_experiment_status_valid",
- "value": "\"model_experiment\".\"status\" IN ('draft', 'active', 'paused', 'completed')"
- },
- "model_experiment_active_not_archived": {
- "name": "model_experiment_active_not_archived",
- "value": "\"model_experiment\".\"status\" <> 'active' OR \"model_experiment\".\"is_archived\" = false"
- }
- },
- "isRLSEnabled": false
- },
- "public.model_experiment_request": {
- "name": "model_experiment_request",
- "schema": "",
- "columns": {
- "usage_id": {
- "name": "usage_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "variant_version_id": {
- "name": "variant_version_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "allocation_subject": {
- "name": "allocation_subject",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "client_request_id": {
- "name": "client_request_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "request_kind": {
- "name": "request_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "request_body_sha256": {
- "name": "request_body_sha256",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "was_truncated": {
- "name": "was_truncated",
- "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": {
- "IDX_model_experiment_request_variant_version_created_at": {
- "name": "IDX_model_experiment_request_variant_version_created_at",
- "columns": [
- {
- "expression": "variant_version_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_model_experiment_request_client_request_id": {
- "name": "IDX_model_experiment_request_client_request_id",
- "columns": [
- {
- "expression": "client_request_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"model_experiment_request\".\"client_request_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_request_usage_id_microdollar_usage_id_fk": {
- "name": "model_experiment_request_usage_id_microdollar_usage_id_fk",
- "tableFrom": "model_experiment_request",
- "tableTo": "microdollar_usage",
- "columnsFrom": [
- "usage_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk": {
- "name": "model_experiment_request_variant_version_id_model_experiment_variant_version_id_fk",
- "tableFrom": "model_experiment_request",
- "tableTo": "model_experiment_variant_version",
- "columnsFrom": [
- "variant_version_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "model_experiment_request_usage_id_created_at_pk": {
- "name": "model_experiment_request_usage_id_created_at_pk",
- "columns": [
- "usage_id",
- "created_at"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "model_experiment_request_allocation_subject_valid": {
- "name": "model_experiment_request_allocation_subject_valid",
- "value": "\"model_experiment_request\".\"allocation_subject\" IN ('user', 'machine', 'ip')"
- },
- "model_experiment_request_request_kind_valid": {
- "name": "model_experiment_request_request_kind_valid",
- "value": "\"model_experiment_request\".\"request_kind\" IN ('chat_completions', 'messages', 'responses')"
- },
- "model_experiment_request_request_body_sha256_format": {
- "name": "model_experiment_request_request_body_sha256_format",
- "value": "\"model_experiment_request\".\"request_body_sha256\" ~ '^[0-9a-f]{64}$' OR \"model_experiment_request\".\"request_body_sha256\" IN ('__failed__', '__deleted__')"
- }
- },
- "isRLSEnabled": false
- },
- "public.model_experiment_variant": {
- "name": "model_experiment_variant",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "experiment_id": {
- "name": "experiment_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "label": {
- "name": "label",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "weight": {
- "name": "weight",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_experiment_variant_experiment_id": {
- "name": "IDX_model_experiment_variant_experiment_id",
- "columns": [
- {
- "expression": "experiment_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_variant_experiment_id_model_experiment_id_fk": {
- "name": "model_experiment_variant_experiment_id_model_experiment_id_fk",
- "tableFrom": "model_experiment_variant",
- "tableTo": "model_experiment",
- "columnsFrom": [
- "experiment_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_model_experiment_variant_experiment_label": {
- "name": "UQ_model_experiment_variant_experiment_label",
- "nullsNotDistinct": false,
- "columns": [
- "experiment_id",
- "label"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "model_experiment_variant_weight_positive": {
- "name": "model_experiment_variant_weight_positive",
- "value": "\"model_experiment_variant\".\"weight\" > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.model_experiment_variant_version": {
- "name": "model_experiment_variant_version",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "variant_id": {
- "name": "variant_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "upstream": {
- "name": "upstream",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "encrypted_api_key": {
- "name": "encrypted_api_key",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "effective_at": {
- "name": "effective_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_model_experiment_variant_version_variant_effective": {
- "name": "IDX_model_experiment_variant_version_variant_effective",
- "columns": [
- {
- "expression": "variant_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "effective_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk": {
- "name": "model_experiment_variant_version_variant_id_model_experiment_variant_id_fk",
- "tableFrom": "model_experiment_variant_version",
- "tableTo": "model_experiment_variant",
- "columnsFrom": [
- "variant_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "model_experiment_variant_version_created_by_kilocode_users_id_fk": {
- "name": "model_experiment_variant_version_created_by_kilocode_users_id_fk",
- "tableFrom": "model_experiment_variant_version",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.models_by_provider": {
- "name": "models_by_provider",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "data": {
- "name": "data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "openrouter": {
- "name": "openrouter",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "vercel": {
- "name": "vercel",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_audit_logs": {
- "name": "organization_audit_logs",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_email": {
- "name": "actor_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_name": {
- "name": "actor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "message": {
- "name": "message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_audit_logs_organization_id": {
- "name": "IDX_organization_audit_logs_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_audit_logs_action": {
- "name": "IDX_organization_audit_logs_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_audit_logs_actor_id": {
- "name": "IDX_organization_audit_logs_actor_id",
- "columns": [
- {
- "expression": "actor_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_audit_logs_created_at": {
- "name": "IDX_organization_audit_logs_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_invitations": {
- "name": "organization_invitations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "invited_by": {
- "name": "invited_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "token": {
- "name": "token",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "accepted_at": {
- "name": "accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "authentication_requirement": {
- "name": "authentication_requirement",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'default'"
- },
- "sso_source_organization_id": {
- "name": "sso_source_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_organization_invitations_token": {
- "name": "UQ_organization_invitations_token",
- "columns": [
- {
- "expression": "token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_invitations_org_id": {
- "name": "IDX_organization_invitations_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_invitations_email": {
- "name": "IDX_organization_invitations_email",
- "columns": [
- {
- "expression": "email",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_invitations_expires_at": {
- "name": "IDX_organization_invitations_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "organization_invitations_sso_source_organization_id_organizations_id_fk": {
- "name": "organization_invitations_sso_source_organization_id_organizations_id_fk",
- "tableFrom": "organization_invitations",
- "tableTo": "organizations",
- "columnsFrom": [
- "sso_source_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_membership_removals": {
- "name": "organization_membership_removals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "removed_at": {
- "name": "removed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "removed_by": {
- "name": "removed_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "previous_role": {
- "name": "previous_role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "IDX_org_membership_removals_org_id": {
- "name": "IDX_org_membership_removals_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_org_membership_removals_user_id": {
- "name": "IDX_org_membership_removals_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_org_membership_removals_org_user": {
- "name": "UQ_org_membership_removals_org_user",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_memberships": {
- "name": "organization_memberships",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "joined_at": {
- "name": "joined_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "invited_by": {
- "name": "invited_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_memberships_org_id": {
- "name": "IDX_organization_memberships_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_memberships_user_id": {
- "name": "IDX_organization_memberships_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_memberships_org_user": {
- "name": "UQ_organization_memberships_org_user",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_recommendation_dismissals": {
- "name": "organization_recommendation_dismissals",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "recommendation_key": {
- "name": "recommendation_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "dismissed_by_user_id": {
- "name": "dismissed_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "dismissed_at": {
- "name": "dismissed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk": {
- "name": "organization_recommendation_dismissals_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "organization_recommendation_dismissals",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk": {
- "name": "organization_recommendation_dismissals_dismissed_by_user_id_kilocode_users_id_fk",
- "tableFrom": "organization_recommendation_dismissals",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "dismissed_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_org_recommendation_dismissals_org_key": {
- "name": "UQ_org_recommendation_dismissals_org_key",
- "nullsNotDistinct": false,
- "columns": [
- "owned_by_organization_id",
- "recommendation_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_seats_purchases": {
- "name": "organization_seats_purchases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "subscription_stripe_id": {
- "name": "subscription_stripe_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "seat_count": {
- "name": "seat_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "amount_usd": {
- "name": "amount_usd",
- "type": "numeric",
- "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
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "subscription_status": {
- "name": "subscription_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'active'"
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "starts_at": {
- "name": "starts_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "billing_cycle": {
- "name": "billing_cycle",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'monthly'"
- }
- },
- "indexes": {
- "IDX_organization_seats_org_id": {
- "name": "IDX_organization_seats_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_expires_at": {
- "name": "IDX_organization_seats_expires_at",
- "columns": [
- {
- "expression": "expires_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_created_at": {
- "name": "IDX_organization_seats_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_updated_at": {
- "name": "IDX_organization_seats_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_seats_starts_at": {
- "name": "IDX_organization_seats_starts_at",
- "columns": [
- {
- "expression": "starts_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_seats_idempotency_key": {
- "name": "UQ_organization_seats_idempotency_key",
- "nullsNotDistinct": false,
- "columns": [
- "idempotency_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_user_limits": {
- "name": "organization_user_limits",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "limit_type": {
- "name": "limit_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "microdollar_limit": {
- "name": "microdollar_limit",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_user_limits_org_id": {
- "name": "IDX_organization_user_limits_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_user_limits_user_id": {
- "name": "IDX_organization_user_limits_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_user_limits_org_user": {
- "name": "UQ_organization_user_limits_org_user",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id",
- "limit_type"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization_user_usage": {
- "name": "organization_user_usage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "usage_date": {
- "name": "usage_date",
- "type": "date",
- "primaryKey": false,
- "notNull": true
- },
- "limit_type": {
- "name": "limit_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "microdollar_usage": {
- "name": "microdollar_usage",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_organization_user_daily_usage_org_id": {
- "name": "IDX_organization_user_daily_usage_org_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organization_user_daily_usage_user_id": {
- "name": "IDX_organization_user_daily_usage_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_user_daily_usage_org_user_date": {
- "name": "UQ_organization_user_daily_usage_org_user_date",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "kilo_user_id",
- "limit_type",
- "usage_date"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organizations": {
- "name": "organizations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "microdollars_used": {
- "name": "microdollars_used",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "microdollars_balance": {
- "name": "microdollars_balance",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "total_microdollars_acquired": {
- "name": "total_microdollars_acquired",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true,
- "default": "'0'"
- },
- "next_credit_expiration_at": {
- "name": "next_credit_expiration_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_top_up_enabled": {
- "name": "auto_top_up_enabled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "settings": {
- "name": "settings",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "seat_count": {
- "name": "seat_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "require_seats": {
- "name": "require_seats",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_by_kilo_user_id": {
- "name": "created_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sso_domain": {
- "name": "sso_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "parent_organization_id": {
- "name": "parent_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "plan": {
- "name": "plan",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'teams'"
- },
- "free_trial_end_at": {
- "name": "free_trial_end_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "company_domain": {
- "name": "company_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "requested_slug": {
- "name": "requested_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_organizations_sso_domain": {
- "name": "IDX_organizations_sso_domain",
- "columns": [
- {
- "expression": "sso_domain",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_organizations_parent_organization_id": {
- "name": "IDX_organizations_parent_organization_id",
- "columns": [
- {
- "expression": "parent_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "organizations_parent_organization_id_organizations_id_fk": {
- "name": "organizations_parent_organization_id_organizations_id_fk",
- "tableFrom": "organizations",
- "tableTo": "organizations",
- "columnsFrom": [
- "parent_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "organizations_slug_unique": {
- "name": "organizations_slug_unique",
- "nullsNotDistinct": false,
- "columns": [
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "organizations_name_not_empty_check": {
- "name": "organizations_name_not_empty_check",
- "value": "length(trim(\"organizations\".\"name\")) > 0"
- },
- "organizations_slug_max_length_check": {
- "name": "organizations_slug_max_length_check",
- "value": "\"organizations\".\"slug\" IS NULL OR length(\"organizations\".\"slug\") <= 32"
- },
- "organizations_not_parented_by_self_check": {
- "name": "organizations_not_parented_by_self_check",
- "value": "\"organizations\".\"parent_organization_id\" IS NULL OR \"organizations\".\"parent_organization_id\" <> \"organizations\".\"id\""
- }
- },
- "isRLSEnabled": false
- },
- "public.organization_modes": {
- "name": "organization_modes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "config": {
- "name": "config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- }
- },
- "indexes": {
- "IDX_organization_modes_organization_id": {
- "name": "IDX_organization_modes_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_organization_modes_org_id_slug": {
- "name": "UQ_organization_modes_org_id_slug",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.payment_methods": {
- "name": "payment_methods",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "stripe_fingerprint": {
- "name": "stripe_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_id": {
- "name": "stripe_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "last4": {
- "name": "last4",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "brand": {
- "name": "brand",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_line1": {
- "name": "address_line1",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_line2": {
- "name": "address_line2",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_city": {
- "name": "address_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_state": {
- "name": "address_state",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_zip": {
- "name": "address_zip",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_country": {
- "name": "address_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "three_d_secure_supported": {
- "name": "three_d_secure_supported",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "funding": {
- "name": "funding",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "regulated_status": {
- "name": "regulated_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "address_line1_check_status": {
- "name": "address_line1_check_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "postal_code_check_status": {
- "name": "postal_code_check_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_forwarded_for": {
- "name": "http_x_forwarded_for",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_city": {
- "name": "http_x_vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_country": {
- "name": "http_x_vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_latitude": {
- "name": "http_x_vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_longitude": {
- "name": "http_x_vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ja4_digest": {
- "name": "http_x_vercel_ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "eligible_for_free_credits": {
- "name": "eligible_for_free_credits",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_data": {
- "name": "stripe_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_d7d7fb15569674aaadcfbc0428": {
- "name": "IDX_d7d7fb15569674aaadcfbc0428",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_e1feb919d0ab8a36381d5d5138": {
- "name": "IDX_e1feb919d0ab8a36381d5d5138",
- "columns": [
- {
- "expression": "stripe_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_payment_methods_organization_id": {
- "name": "IDX_payment_methods_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_29df1b0403df5792c96bbbfdbe6": {
- "name": "UQ_29df1b0403df5792c96bbbfdbe6",
- "nullsNotDistinct": false,
- "columns": [
- "user_id",
- "stripe_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.pending_impact_sale_reversals": {
- "name": "pending_impact_sale_reversals",
- "schema": "",
- "columns": {
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "dispute_id": {
- "name": "dispute_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount": {
- "name": "amount",
- "type": "real",
- "primaryKey": false,
- "notNull": true
- },
- "currency": {
- "name": "currency",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_date": {
- "name": "event_date",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "last_attempt_at": {
- "name": "last_attempt_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": {},
- "policies": {},
- "checkConstraints": {
- "pending_impact_sale_reversals_attempt_count_non_negative_check": {
- "name": "pending_impact_sale_reversals_attempt_count_non_negative_check",
- "value": "\"pending_impact_sale_reversals\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.platform_access_token_credentials": {
- "name": "platform_access_token_credentials",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "integration_type": {
- "name": "integration_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "token_encrypted": {
- "name": "token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "provider_credential_type": {
- "name": "provider_credential_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_scopes": {
- "name": "provider_scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "provider_verified_at": {
- "name": "provider_verified_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "credential_version": {
- "name": "credential_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "last_validated_at": {
- "name": "last_validated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_used_at": {
- "name": "last_used_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "FK_platform_access_token_credentials_parent": {
- "name": "FK_platform_access_token_credentials_parent",
- "tableFrom": "platform_access_token_credentials",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_platform_access_token_credentials_platform_integration_id": {
- "name": "UQ_platform_access_token_credentials_platform_integration_id",
- "nullsNotDistinct": false,
- "columns": [
- "platform_integration_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.platform_integrations": {
- "name": "platform_integrations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_by_user_id": {
- "name": "created_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "integration_type": {
- "name": "integration_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform_installation_id": {
- "name": "platform_installation_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_account_id": {
- "name": "platform_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_account_login": {
- "name": "platform_account_login",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "permissions": {
- "name": "permissions",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "scopes": {
- "name": "scopes",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "repository_access": {
- "name": "repository_access",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repositories": {
- "name": "repositories",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "repositories_synced_at": {
- "name": "repositories_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auth_invalid_at": {
- "name": "auth_invalid_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "auth_invalid_reason": {
- "name": "auth_invalid_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_requester_user_id": {
- "name": "kilo_requester_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_requester_account_id": {
- "name": "platform_requester_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "integration_status": {
- "name": "integration_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "suspended_at": {
- "name": "suspended_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "suspended_by": {
- "name": "suspended_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "github_app_type": {
- "name": "github_app_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "default": "'standard'"
- },
- "installed_at": {
- "name": "installed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_platform_integrations_owned_by_org_platform_inst": {
- "name": "UQ_platform_integrations_owned_by_org_platform_inst",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_owned_by_user_platform_inst": {
- "name": "UQ_platform_integrations_owned_by_user_platform_inst",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_slack_platform_inst": {
- "name": "UQ_platform_integrations_slack_platform_inst",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'slack' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_linear_platform_inst": {
- "name": "UQ_platform_integrations_linear_platform_inst",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'linear' AND \"platform_integrations\".\"platform_installation_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_user_bitbucket": {
- "name": "UQ_platform_integrations_user_bitbucket",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_platform_integrations_org_bitbucket": {
- "name": "UQ_platform_integrations_org_bitbucket",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"platform_integrations\".\"platform\" = 'bitbucket' AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_org_id": {
- "name": "IDX_platform_integrations_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_user_id": {
- "name": "IDX_platform_integrations_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_platform_inst_id": {
- "name": "IDX_platform_integrations_platform_inst_id",
- "columns": [
- {
- "expression": "platform_installation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_platform": {
- "name": "IDX_platform_integrations_platform",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_org_platform": {
- "name": "IDX_platform_integrations_owned_by_org_platform",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_owned_by_user_platform": {
- "name": "IDX_platform_integrations_owned_by_user_platform",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_integration_status": {
- "name": "IDX_platform_integrations_integration_status",
- "columns": [
- {
- "expression": "integration_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_kilo_requester": {
- "name": "IDX_platform_integrations_kilo_requester",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kilo_requester_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "integration_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_integrations_platform_requester": {
- "name": "IDX_platform_integrations_platform_requester",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "platform_requester_account_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "integration_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "platform_integrations_owned_by_organization_id_organizations_id_fk": {
- "name": "platform_integrations_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "platform_integrations",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "platform_integrations_owned_by_user_id_kilocode_users_id_fk": {
- "name": "platform_integrations_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "platform_integrations",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "platform_integrations_owner_check": {
- "name": "platform_integrations_owner_check",
- "value": "(\n (\"platform_integrations\".\"owned_by_user_id\" IS NOT NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NULL) OR\n (\"platform_integrations\".\"owned_by_user_id\" IS NULL AND \"platform_integrations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.platform_oauth_credentials": {
- "name": "platform_oauth_credentials",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "authorized_by_user_id": {
- "name": "authorized_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subject_id": {
- "name": "provider_subject_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_subject_login": {
- "name": "provider_subject_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_encrypted": {
- "name": "access_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_expires_at": {
- "name": "access_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "refresh_token_encrypted": {
- "name": "refresh_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "refresh_token_expires_at": {
- "name": "refresh_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "credential_version": {
- "name": "credential_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_reason": {
- "name": "revocation_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_used_at": {
- "name": "last_used_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_platform_oauth_credentials_platform_integration_id": {
- "name": "UQ_platform_oauth_credentials_platform_integration_id",
- "columns": [
- {
- "expression": "platform_integration_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_platform_oauth_credentials_authorized_by_user_id": {
- "name": "IDX_platform_oauth_credentials_authorized_by_user_id",
- "columns": [
- {
- "expression": "authorized_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk": {
- "name": "platform_oauth_credentials_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "platform_oauth_credentials",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk": {
- "name": "platform_oauth_credentials_authorized_by_user_id_kilocode_users_id_fk",
- "tableFrom": "platform_oauth_credentials",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "authorized_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.referral_code_usages": {
- "name": "referral_code_usages",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "referring_kilo_user_id": {
- "name": "referring_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "redeeming_kilo_user_id": {
- "name": "redeeming_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "amount_usd": {
- "name": "amount_usd",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "paid_at": {
- "name": "paid_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_referral_code_usages_redeeming_kilo_user_id": {
- "name": "IDX_referral_code_usages_redeeming_kilo_user_id",
- "columns": [
- {
- "expression": "redeeming_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_referral_code_usages_redeeming_user_id_code": {
- "name": "UQ_referral_code_usages_redeeming_user_id_code",
- "nullsNotDistinct": false,
- "columns": [
- "redeeming_kilo_user_id",
- "referring_kilo_user_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.referral_codes": {
- "name": "referral_codes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "code": {
- "name": "code",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "max_redemptions": {
- "name": "max_redemptions",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 10
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_referral_codes_kilo_user_id": {
- "name": "UQ_referral_codes_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_referral_codes_code": {
- "name": "IDX_referral_codes_code",
- "columns": [
- {
- "expression": "code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_advisor_check_catalog": {
- "name": "security_advisor_check_catalog",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "check_id": {
- "name": "check_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "severity": {
- "name": "severity",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "explanation": {
- "name": "explanation",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "risk": {
- "name": "risk",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "security_advisor_check_catalog_check_id_unique": {
- "name": "security_advisor_check_catalog_check_id_unique",
- "nullsNotDistinct": false,
- "columns": [
- "check_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "security_advisor_check_catalog_severity_check": {
- "name": "security_advisor_check_catalog_severity_check",
- "value": "\"security_advisor_check_catalog\".\"severity\" in ('critical', 'warn', 'info')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_advisor_content": {
- "name": "security_advisor_content",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "key": {
- "name": "key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "''"
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "security_advisor_content_key_unique": {
- "name": "security_advisor_content_key_unique",
- "nullsNotDistinct": false,
- "columns": [
- "key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_advisor_kiloclaw_coverage": {
- "name": "security_advisor_kiloclaw_coverage",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "area": {
- "name": "area",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "summary": {
- "name": "summary",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "detail": {
- "name": "detail",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "match_check_ids": {
- "name": "match_check_ids",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::text[]"
- },
- "is_active": {
- "name": "is_active",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "security_advisor_kiloclaw_coverage_area_unique": {
- "name": "security_advisor_kiloclaw_coverage_area_unique",
- "nullsNotDistinct": false,
- "columns": [
- "area"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_advisor_scans": {
- "name": "security_advisor_scans",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source_platform": {
- "name": "source_platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_method": {
- "name": "source_method",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "plugin_version": {
- "name": "plugin_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "openclaw_version": {
- "name": "openclaw_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "public_ip": {
- "name": "public_ip",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "findings_critical": {
- "name": "findings_critical",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "findings_warn": {
- "name": "findings_warn",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "findings_info": {
- "name": "findings_info",
- "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": {
- "idx_security_advisor_scans_user_created_at": {
- "name": "idx_security_advisor_scans_user_created_at",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_advisor_scans_created_at": {
- "name": "idx_security_advisor_scans_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_advisor_scans_platform": {
- "name": "idx_security_advisor_scans_platform",
- "columns": [
- {
- "expression": "source_platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.security_agent_commands": {
- "name": "security_agent_commands",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "command_type": {
- "name": "command_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "origin": {
- "name": "origin",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'accepted'"
- },
- "result_code": {
- "name": "result_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "result_metadata": {
- "name": "result_metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_redacted": {
- "name": "last_error_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "accepted_at": {
- "name": "accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "started_at": {
- "name": "started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_security_agent_commands_org_created": {
- "name": "idx_security_agent_commands_org_created",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_agent_commands_user_created": {
- "name": "idx_security_agent_commands_user_created",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_agent_commands_status_updated": {
- "name": "idx_security_agent_commands_status_updated",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_agent_commands_finding_created": {
- "name": "idx_security_agent_commands_finding_created",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": false,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_agent_commands_owned_by_organization_id_organizations_id_fk": {
- "name": "security_agent_commands_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_agent_commands",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_agent_commands_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_agent_commands_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_agent_commands",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_agent_commands_finding_id_security_findings_id_fk": {
- "name": "security_agent_commands_finding_id_security_findings_id_fk",
- "tableFrom": "security_agent_commands",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_agent_commands_owner_check": {
- "name": "security_agent_commands_owner_check",
- "value": "(\n (\"security_agent_commands\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_commands\".\"owned_by_user_id\" IS NULL AND \"security_agent_commands\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_agent_commands_type_check": {
- "name": "security_agent_commands_type_check",
- "value": "\"security_agent_commands\".\"command_type\" IN ('sync', 'dismiss_finding', 'start_analysis', 'apply_auto_remediation')"
- },
- "security_agent_commands_origin_check": {
- "name": "security_agent_commands_origin_check",
- "value": "\"security_agent_commands\".\"origin\" IN ('manual', 'dashboard_refresh', 'enable_initial_sync', 'settings_include_existing')"
- },
- "security_agent_commands_status_check": {
- "name": "security_agent_commands_status_check",
- "value": "\"security_agent_commands\".\"status\" IN ('accepted', 'running', 'succeeded', 'failed', 'no_op')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_agent_repository_sync_state": {
- "name": "security_agent_repository_sync_state",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "last_attempted_at": {
- "name": "last_attempted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "last_succeeded_at": {
- "name": "last_succeeded_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_failure_code": {
- "name": "last_failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_agent_repository_sync_state_org_repo": {
- "name": "UQ_security_agent_repository_sync_state_org_repo",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_agent_repository_sync_state\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_agent_repository_sync_state_user_repo": {
- "name": "UQ_security_agent_repository_sync_state_user_repo",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_agent_repository_sync_state\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk": {
- "name": "security_agent_repository_sync_state_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_agent_repository_sync_state",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_agent_repository_sync_state_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_agent_repository_sync_state",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_agent_repository_sync_state_owner_check": {
- "name": "security_agent_repository_sync_state_owner_check",
- "value": "(\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_agent_repository_sync_state\".\"owned_by_user_id\" IS NULL AND \"security_agent_repository_sync_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_analysis_owner_state": {
- "name": "security_analysis_owner_state",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_analysis_enabled_at": {
- "name": "auto_analysis_enabled_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_until": {
- "name": "blocked_until",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "block_reason": {
- "name": "block_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "consecutive_actor_resolution_failures": {
- "name": "consecutive_actor_resolution_failures",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "last_actor_resolution_failure_at": {
- "name": "last_actor_resolution_failure_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_analysis_owner_state_org_owner": {
- "name": "UQ_security_analysis_owner_state_org_owner",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_analysis_owner_state\".\"owned_by_organization_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_analysis_owner_state_user_owner": {
- "name": "UQ_security_analysis_owner_state_user_owner",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_analysis_owner_state\".\"owned_by_user_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk": {
- "name": "security_analysis_owner_state_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_analysis_owner_state",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_analysis_owner_state_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_analysis_owner_state",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_analysis_owner_state_owner_check": {
- "name": "security_analysis_owner_state_owner_check",
- "value": "(\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_owner_state\".\"owned_by_user_id\" IS NULL AND \"security_analysis_owner_state\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_analysis_owner_state_block_reason_check": {
- "name": "security_analysis_owner_state_block_reason_check",
- "value": "\"security_analysis_owner_state\".\"block_reason\" IS NULL OR \"security_analysis_owner_state\".\"block_reason\" IN ('INSUFFICIENT_CREDITS', 'ACTOR_RESOLUTION_FAILED', 'OPERATOR_PAUSE')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_analysis_queue": {
- "name": "security_analysis_queue",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "queue_status": {
- "name": "queue_status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "severity_rank": {
- "name": "severity_rank",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true
- },
- "queued_at": {
- "name": "queued_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_by_job_id": {
- "name": "claimed_by_job_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "claim_token": {
- "name": "claim_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "reopen_requeue_count": {
- "name": "reopen_requeue_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_redacted": {
- "name": "last_error_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_analysis_queue_finding_id": {
- "name": "UQ_security_analysis_queue_finding_id",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_claim_path_org": {
- "name": "idx_security_analysis_queue_claim_path_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "severity_rank",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_claim_path_user": {
- "name": "idx_security_analysis_queue_claim_path_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "severity_rank",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_in_flight_org": {
- "name": "idx_security_analysis_queue_in_flight_org",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queue_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_in_flight_user": {
- "name": "idx_security_analysis_queue_in_flight_user",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queue_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_lag_dashboards": {
- "name": "idx_security_analysis_queue_lag_dashboards",
- "columns": [
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_pending_reconciliation": {
- "name": "idx_security_analysis_queue_pending_reconciliation",
- "columns": [
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_running_reconciliation": {
- "name": "idx_security_analysis_queue_running_reconciliation",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"queue_status\" = 'running'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_analysis_queue_failure_trend": {
- "name": "idx_security_analysis_queue_failure_trend",
- "columns": [
- {
- "expression": "failure_code",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_analysis_queue\".\"failure_code\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_analysis_queue_finding_id_security_findings_id_fk": {
- "name": "security_analysis_queue_finding_id_security_findings_id_fk",
- "tableFrom": "security_analysis_queue",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_analysis_queue_owned_by_organization_id_organizations_id_fk": {
- "name": "security_analysis_queue_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_analysis_queue",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_analysis_queue_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_analysis_queue",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_analysis_queue_owner_check": {
- "name": "security_analysis_queue_owner_check",
- "value": "(\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NOT NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_analysis_queue\".\"owned_by_user_id\" IS NULL AND \"security_analysis_queue\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_analysis_queue_status_check": {
- "name": "security_analysis_queue_status_check",
- "value": "\"security_analysis_queue\".\"queue_status\" IN ('queued', 'pending', 'running', 'failed', 'completed')"
- },
- "security_analysis_queue_claim_token_required_check": {
- "name": "security_analysis_queue_claim_token_required_check",
- "value": "\"security_analysis_queue\".\"queue_status\" NOT IN ('pending', 'running') OR \"security_analysis_queue\".\"claim_token\" IS NOT NULL"
- },
- "security_analysis_queue_attempt_count_non_negative_check": {
- "name": "security_analysis_queue_attempt_count_non_negative_check",
- "value": "\"security_analysis_queue\".\"attempt_count\" >= 0"
- },
- "security_analysis_queue_reopen_requeue_count_non_negative_check": {
- "name": "security_analysis_queue_reopen_requeue_count_non_negative_check",
- "value": "\"security_analysis_queue\".\"reopen_requeue_count\" >= 0"
- },
- "security_analysis_queue_severity_rank_check": {
- "name": "security_analysis_queue_severity_rank_check",
- "value": "\"security_analysis_queue\".\"severity_rank\" IN (0, 1, 2, 3)"
- },
- "security_analysis_queue_failure_code_check": {
- "name": "security_analysis_queue_failure_code_check",
- "value": "\"security_analysis_queue\".\"failure_code\" IS NULL OR \"security_analysis_queue\".\"failure_code\" IN (\n 'NETWORK_TIMEOUT',\n 'UPSTREAM_5XX',\n 'TEMP_TOKEN_FAILURE',\n 'START_CALL_AMBIGUOUS',\n 'REQUEUE_TEMPORARY_PRECONDITION',\n 'ACTOR_RESOLUTION_FAILED',\n 'GITHUB_TOKEN_UNAVAILABLE',\n 'INVALID_CONFIG',\n 'MISSING_OWNERSHIP',\n 'PERMISSION_DENIED_PERMANENT',\n 'UNSUPPORTED_SEVERITY',\n 'INSUFFICIENT_CREDITS',\n 'STATE_GUARD_REJECTED',\n 'SKIPPED_ALREADY_IN_PROGRESS',\n 'SKIPPED_NO_LONGER_ELIGIBLE',\n 'REOPEN_LOOP_GUARD',\n 'RUN_LOST'\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_audit_log": {
- "name": "security_audit_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_id": {
- "name": "actor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_email": {
- "name": "actor_email",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_name": {
- "name": "actor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "actor_type": {
- "name": "actor_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "action": {
- "name": "action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "resource_type": {
- "name": "resource_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "resource_id": {
- "name": "resource_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "before_state": {
- "name": "before_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "after_state": {
- "name": "after_state",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "occurred_at": {
- "name": "occurred_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "source_occurred_at": {
- "name": "source_occurred_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "event_key": {
- "name": "event_key",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "schema_version": {
- "name": "schema_version",
- "type": "smallint",
- "primaryKey": false,
- "notNull": false
- },
- "finding_snapshot": {
- "name": "finding_snapshot",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "source_context": {
- "name": "source_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_security_audit_log_org_created": {
- "name": "IDX_security_audit_log_org_created",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_user_created": {
- "name": "IDX_security_audit_log_user_created",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_resource": {
- "name": "IDX_security_audit_log_resource",
- "columns": [
- {
- "expression": "resource_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "resource_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_actor": {
- "name": "IDX_security_audit_log_actor",
- "columns": [
- {
- "expression": "actor_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_action": {
- "name": "IDX_security_audit_log_action",
- "columns": [
- {
- "expression": "action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_audit_log_org_event_key": {
- "name": "UQ_security_audit_log_org_event_key",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_audit_log_user_event_key": {
- "name": "UQ_security_audit_log_user_event_key",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"event_key\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_org_occurred": {
- "name": "IDX_security_audit_log_org_occurred",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "occurred_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_security_audit_log_user_occurred": {
- "name": "IDX_security_audit_log_user_occurred",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "occurred_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"occurred_at\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_audit_log_owned_by_organization_id_organizations_id_fk": {
- "name": "security_audit_log_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_audit_log",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_audit_log_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_audit_log_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_audit_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_audit_log_owner_check": {
- "name": "security_audit_log_owner_check",
- "value": "(\"security_audit_log\".\"owned_by_user_id\" IS NOT NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NULL) OR (\"security_audit_log\".\"owned_by_user_id\" IS NULL AND \"security_audit_log\".\"owned_by_organization_id\" IS NOT NULL)"
- },
- "security_audit_log_action_check": {
- "name": "security_audit_log_action_check",
- "value": "\"security_audit_log\".\"action\" IN ('security.finding.created', 'security.finding.severity_changed', 'security.finding.status_change', 'security.finding.dismissed', 'security.finding.auto_dismissed', 'security.finding.superseded', 'security.finding.analysis_started', 'security.finding.analysis_completed', 'security.finding.analysis_failed', 'security.remediation.queued', 'security.remediation.started', 'security.remediation.pr_opened', 'security.remediation.failed', 'security.remediation.blocked', 'security.remediation.no_changes_needed', 'security.remediation.cancelled', 'security.remediation.retried', 'security.finding.deleted', 'security.config.enabled', 'security.config.disabled', 'security.config.updated', 'security.sync.triggered', 'security.sync.completed', 'security.audit_log.exported', 'security.audit_report.generated')"
- },
- "security_audit_log_actor_type_check": {
- "name": "security_audit_log_actor_type_check",
- "value": "\"security_audit_log\".\"actor_type\" IN ('customer_user', 'kilo_admin', 'system')"
- },
- "security_audit_log_source_context_check": {
- "name": "security_audit_log_source_context_check",
- "value": "\"security_audit_log\".\"source_context\" IN ('security_sync', 'web', 'analysis_worker', 'remediation_callback', 'rollout_baseline')"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_finding_notifications": {
- "name": "security_finding_notifications",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "recipient_user_id": {
- "name": "recipient_user_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": "'staged'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_attempt_at": {
- "name": "next_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "uq_security_finding_notifications_finding_recipient_kind": {
- "name": "uq_security_finding_notifications_finding_recipient_kind",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "recipient_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "kind",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_pending": {
- "name": "idx_security_finding_notifications_pending",
- "columns": [
- {
- "expression": "next_attempt_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_finding_notifications\".\"status\" = 'pending'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_staged": {
- "name": "idx_security_finding_notifications_staged",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_finding_notifications\".\"status\" = 'staged'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_finding_id": {
- "name": "idx_security_finding_notifications_finding_id",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_finding_notifications_recipient_user_id": {
- "name": "idx_security_finding_notifications_recipient_user_id",
- "columns": [
- {
- "expression": "recipient_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_finding_notifications_finding_fk": {
- "name": "security_finding_notifications_finding_fk",
- "tableFrom": "security_finding_notifications",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_finding_notifications_recipient_fk": {
- "name": "security_finding_notifications_recipient_fk",
- "tableFrom": "security_finding_notifications",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "recipient_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_finding_notifications_kind_check": {
- "name": "security_finding_notifications_kind_check",
- "value": "\"security_finding_notifications\".\"kind\" IN ('new_finding', 'sla_warning', 'sla_breach')"
- },
- "security_finding_notifications_status_check": {
- "name": "security_finding_notifications_status_check",
- "value": "\"security_finding_notifications\".\"status\" IN ('staged', 'pending', 'sending', 'sent', 'failed', 'cancelled')"
- },
- "security_finding_notifications_attempt_count_check": {
- "name": "security_finding_notifications_attempt_count_check",
- "value": "\"security_finding_notifications\".\"attempt_count\" >= 0"
- },
- "security_finding_notifications_claimed_at_check": {
- "name": "security_finding_notifications_claimed_at_check",
- "value": "(\n (\"security_finding_notifications\".\"status\" = 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sending' AND \"security_finding_notifications\".\"claimed_at\" IS NULL)\n )"
- },
- "security_finding_notifications_sent_at_check": {
- "name": "security_finding_notifications_sent_at_check",
- "value": "(\n (\"security_finding_notifications\".\"status\" = 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NOT NULL) OR\n (\"security_finding_notifications\".\"status\" <> 'sent' AND \"security_finding_notifications\".\"sent_at\" IS NULL)\n )"
- },
- "security_finding_notifications_error_message_length_check": {
- "name": "security_finding_notifications_error_message_length_check",
- "value": "\"security_finding_notifications\".\"error_message\" IS NULL OR length(\"security_finding_notifications\".\"error_message\") <= 500"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_findings": {
- "name": "security_findings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source": {
- "name": "source",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "source_id": {
- "name": "source_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "severity": {
- "name": "severity",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "ghsa_id": {
- "name": "ghsa_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cve_id": {
- "name": "cve_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "package_name": {
- "name": "package_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "package_ecosystem": {
- "name": "package_ecosystem",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "vulnerable_version_range": {
- "name": "vulnerable_version_range",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "patched_version": {
- "name": "patched_version",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "manifest_path": {
- "name": "manifest_path",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'open'"
- },
- "ignored_reason": {
- "name": "ignored_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ignored_by": {
- "name": "ignored_by",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "fixed_at": {
- "name": "fixed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "sla_due_at": {
- "name": "sla_due_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "dependabot_html_url": {
- "name": "dependabot_html_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cwe_ids": {
- "name": "cwe_ids",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "cvss_score": {
- "name": "cvss_score",
- "type": "numeric(3, 1)",
- "primaryKey": false,
- "notNull": false
- },
- "dependency_scope": {
- "name": "dependency_scope",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cli_session_id": {
- "name": "cli_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_status": {
- "name": "analysis_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_started_at": {
- "name": "analysis_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_completed_at": {
- "name": "analysis_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_error": {
- "name": "analysis_error",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis": {
- "name": "analysis",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "raw_data": {
- "name": "raw_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "first_detected_at": {
- "name": "first_detected_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "last_synced_at": {
- "name": "last_synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "uq_security_findings_user_source": {
- "name": "uq_security_findings_user_source",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_findings\".\"owned_by_user_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "uq_security_findings_org_source": {
- "name": "uq_security_findings_org_source",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "source_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_findings\".\"owned_by_organization_id\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_org_id": {
- "name": "idx_security_findings_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_user_id": {
- "name": "idx_security_findings_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_repo": {
- "name": "idx_security_findings_repo",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_severity": {
- "name": "idx_security_findings_severity",
- "columns": [
- {
- "expression": "severity",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_status": {
- "name": "idx_security_findings_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_package": {
- "name": "idx_security_findings_package",
- "columns": [
- {
- "expression": "package_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_sla_due_at": {
- "name": "idx_security_findings_sla_due_at",
- "columns": [
- {
- "expression": "sla_due_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_session_id": {
- "name": "idx_security_findings_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_cli_session_id": {
- "name": "idx_security_findings_cli_session_id",
- "columns": [
- {
- "expression": "cli_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_analysis_status": {
- "name": "idx_security_findings_analysis_status",
- "columns": [
- {
- "expression": "analysis_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_org_analysis_in_flight": {
- "name": "idx_security_findings_org_analysis_in_flight",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_findings_user_analysis_in_flight": {
- "name": "idx_security_findings_user_analysis_in_flight",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_findings\".\"analysis_status\" IN ('pending', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_findings_owned_by_organization_id_organizations_id_fk": {
- "name": "security_findings_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_findings",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_findings_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_findings_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_findings",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_findings_platform_integration_id_platform_integrations_id_fk": {
- "name": "security_findings_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "security_findings",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_findings_owner_check": {
- "name": "security_findings_owner_check",
- "value": "(\n (\"security_findings\".\"owned_by_user_id\" IS NOT NULL AND \"security_findings\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_findings\".\"owned_by_user_id\" IS NULL AND \"security_findings\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_remediation_attempts": {
- "name": "security_remediation_attempts",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "remediation_id": {
- "name": "remediation_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "origin": {
- "name": "origin",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "attempt_number": {
- "name": "attempt_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "retry_of_attempt_id": {
- "name": "retry_of_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "requested_by_user_id": {
- "name": "requested_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "analysis_fingerprint": {
- "name": "analysis_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "analysis_completed_at": {
- "name": "analysis_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "remediation_model_slug": {
- "name": "remediation_model_slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "branch_name": {
- "name": "branch_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_session_id": {
- "name": "kilo_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "execution_id": {
- "name": "execution_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "priority": {
- "name": "priority",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true,
- "default": 50
- },
- "claim_token": {
- "name": "claim_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_by_job_id": {
- "name": "claimed_by_job_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "launch_attempt_count": {
- "name": "launch_attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "callback_attempt_token_hash": {
- "name": "callback_attempt_token_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_reason": {
- "name": "blocked_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_error_redacted": {
- "name": "last_error_redacted",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "structured_result": {
- "name": "structured_result",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "final_assistant_message": {
- "name": "final_assistant_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "validation_evidence": {
- "name": "validation_evidence",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "risk_notes": {
- "name": "risk_notes",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "draft_reason": {
- "name": "draft_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_draft": {
- "name": "pr_draft",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_branch": {
- "name": "pr_head_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_base_branch": {
- "name": "pr_base_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cancellation_requested_at": {
- "name": "cancellation_requested_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "cancellation_requested_by_user_id": {
- "name": "cancellation_requested_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "queued_at": {
- "name": "queued_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "launched_at": {
- "name": "launched_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_remediation_attempts_number": {
- "name": "UQ_security_remediation_attempts_number",
- "columns": [
- {
- "expression": "remediation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "attempt_number",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_remediation_attempts_active_finding": {
- "name": "UQ_security_remediation_attempts_active_finding",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_remediation_attempts_active_remediation": {
- "name": "UQ_security_remediation_attempts_active_remediation",
- "columns": [
- {
- "expression": "remediation_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_security_remediation_attempts_finding_fingerprint_terminal": {
- "name": "UQ_security_remediation_attempts_finding_fingerprint_terminal",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_org_claim": {
- "name": "idx_security_remediation_attempts_org_claim",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "priority",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_user_claim": {
- "name": "idx_security_remediation_attempts_user_claim",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "priority",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_repo_claim": {
- "name": "idx_security_remediation_attempts_repo_claim",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "priority",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "queued_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" = 'queued'",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_org_inflight": {
- "name": "idx_security_remediation_attempts_org_inflight",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_user_inflight": {
- "name": "idx_security_remediation_attempts_user_inflight",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_repo_inflight": {
- "name": "idx_security_remediation_attempts_repo_inflight",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "where": "\"security_remediation_attempts\".\"status\" IN ('launching', 'running')",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_cloud_agent_session": {
- "name": "idx_security_remediation_attempts_cloud_agent_session",
- "columns": [
- {
- "expression": "cloud_agent_session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediation_attempts_finding_fingerprint": {
- "name": "idx_security_remediation_attempts_finding_fingerprint",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "analysis_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_remediation_attempts_remediation_id_security_remediations_id_fk": {
- "name": "security_remediation_attempts_remediation_id_security_remediations_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "security_remediations",
- "columnsFrom": [
- "remediation_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_finding_id_security_findings_id_fk": {
- "name": "security_remediation_attempts_finding_id_security_findings_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_owned_by_organization_id_organizations_id_fk": {
- "name": "security_remediation_attempts_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediation_attempts_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediation_attempts_requested_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "requested_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediation_attempts_cancellation_requested_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediation_attempts",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "cancellation_requested_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_remediation_attempts_owner_check": {
- "name": "security_remediation_attempts_owner_check",
- "value": "(\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediation_attempts\".\"owned_by_user_id\" IS NULL AND \"security_remediation_attempts\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_remediation_attempts_status_check": {
- "name": "security_remediation_attempts_status_check",
- "value": "\"security_remediation_attempts\".\"status\" IN ('queued', 'launching', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
- },
- "security_remediation_attempts_origin_check": {
- "name": "security_remediation_attempts_origin_check",
- "value": "\"security_remediation_attempts\".\"origin\" IN ('auto_policy', 'bulk_existing', 'manual')"
- },
- "security_remediation_attempts_attempt_number_check": {
- "name": "security_remediation_attempts_attempt_number_check",
- "value": "\"security_remediation_attempts\".\"attempt_number\" >= 1"
- },
- "security_remediation_attempts_launch_attempt_count_check": {
- "name": "security_remediation_attempts_launch_attempt_count_check",
- "value": "\"security_remediation_attempts\".\"launch_attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.security_remediations": {
- "name": "security_remediations",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finding_id": {
- "name": "finding_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "repo_full_name": {
- "name": "repo_full_name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "latest_attempt_id": {
- "name": "latest_attempt_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "latest_analysis_fingerprint": {
- "name": "latest_analysis_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "latest_analysis_completed_at": {
- "name": "latest_analysis_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "pr_url": {
- "name": "pr_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_number": {
- "name": "pr_number",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "pr_draft": {
- "name": "pr_draft",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "pr_head_branch": {
- "name": "pr_head_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "pr_base_branch": {
- "name": "pr_base_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_code": {
- "name": "failure_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_reason": {
- "name": "blocked_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "outcome_summary": {
- "name": "outcome_summary",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_security_remediations_finding_id": {
- "name": "UQ_security_remediations_finding_id",
- "columns": [
- {
- "expression": "finding_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_org_status": {
- "name": "idx_security_remediations_org_status",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_user_status": {
- "name": "idx_security_remediations_user_status",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_repo_status": {
- "name": "idx_security_remediations_repo_status",
- "columns": [
- {
- "expression": "repo_full_name",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_security_remediations_latest_attempt": {
- "name": "idx_security_remediations_latest_attempt",
- "columns": [
- {
- "expression": "latest_attempt_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "security_remediations_owned_by_organization_id_organizations_id_fk": {
- "name": "security_remediations_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "security_remediations",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediations_owned_by_user_id_kilocode_users_id_fk": {
- "name": "security_remediations_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "security_remediations",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "security_remediations_finding_id_security_findings_id_fk": {
- "name": "security_remediations_finding_id_security_findings_id_fk",
- "tableFrom": "security_remediations",
- "tableTo": "security_findings",
- "columnsFrom": [
- "finding_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "security_remediations_owner_check": {
- "name": "security_remediations_owner_check",
- "value": "(\n (\"security_remediations\".\"owned_by_user_id\" IS NOT NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NULL) OR\n (\"security_remediations\".\"owned_by_user_id\" IS NULL AND \"security_remediations\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- },
- "security_remediations_status_check": {
- "name": "security_remediations_status_check",
- "value": "\"security_remediations\".\"status\" IN ('queued', 'running', 'pr_opened', 'failed', 'blocked', 'no_changes_needed', 'cancelled')"
- }
- },
- "isRLSEnabled": false
- },
- "public.shared_cli_sessions": {
- "name": "shared_cli_sessions",
- "schema": "",
- "columns": {
- "share_id": {
- "name": "share_id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "session_id": {
- "name": "session_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "shared_state": {
- "name": "shared_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'public'"
- },
- "api_conversation_history_blob_url": {
- "name": "api_conversation_history_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "task_metadata_blob_url": {
- "name": "task_metadata_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "ui_messages_blob_url": {
- "name": "ui_messages_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "git_state_blob_url": {
- "name": "git_state_blob_url",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_shared_cli_sessions_session_id": {
- "name": "IDX_shared_cli_sessions_session_id",
- "columns": [
- {
- "expression": "session_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_shared_cli_sessions_created_at": {
- "name": "IDX_shared_cli_sessions_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "shared_cli_sessions_session_id_cli_sessions_session_id_fk": {
- "name": "shared_cli_sessions_session_id_cli_sessions_session_id_fk",
- "tableFrom": "shared_cli_sessions",
- "tableTo": "cli_sessions",
- "columnsFrom": [
- "session_id"
- ],
- "columnsTo": [
- "session_id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk": {
- "name": "shared_cli_sessions_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "shared_cli_sessions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "shared_cli_sessions_shared_state_check": {
- "name": "shared_cli_sessions_shared_state_check",
- "value": "\"shared_cli_sessions\".\"shared_state\" IN ('public', 'organization')"
- }
- },
- "isRLSEnabled": false
- },
- "public.slack_bot_requests": {
- "name": "slack_bot_requests",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform_integration_id": {
- "name": "platform_integration_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "slack_team_id": {
- "name": "slack_team_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slack_team_name": {
- "name": "slack_team_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "slack_channel_id": {
- "name": "slack_channel_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slack_user_id": {
- "name": "slack_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slack_thread_ts": {
- "name": "slack_thread_ts",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_message": {
- "name": "user_message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "user_message_truncated": {
- "name": "user_message_truncated",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "error_message": {
- "name": "error_message",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "response_time_ms": {
- "name": "response_time_ms",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "model_used": {
- "name": "model_used",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "tool_calls_made": {
- "name": "tool_calls_made",
- "type": "text[]",
- "primaryKey": false,
- "notNull": false
- },
- "cloud_agent_session_id": {
- "name": "cloud_agent_session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "idx_slack_bot_requests_created_at": {
- "name": "idx_slack_bot_requests_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_slack_team_id": {
- "name": "idx_slack_bot_requests_slack_team_id",
- "columns": [
- {
- "expression": "slack_team_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_owned_by_org_id": {
- "name": "idx_slack_bot_requests_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_owned_by_user_id": {
- "name": "idx_slack_bot_requests_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_status": {
- "name": "idx_slack_bot_requests_status",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_event_type": {
- "name": "idx_slack_bot_requests_event_type",
- "columns": [
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_slack_bot_requests_team_created": {
- "name": "idx_slack_bot_requests_team_created",
- "columns": [
- {
- "expression": "slack_team_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "slack_bot_requests_owned_by_organization_id_organizations_id_fk": {
- "name": "slack_bot_requests_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "slack_bot_requests",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk": {
- "name": "slack_bot_requests_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "slack_bot_requests",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "slack_bot_requests_platform_integration_id_platform_integrations_id_fk": {
- "name": "slack_bot_requests_platform_integration_id_platform_integrations_id_fk",
- "tableFrom": "slack_bot_requests",
- "tableTo": "platform_integrations",
- "columnsFrom": [
- "platform_integration_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "slack_bot_requests_owner_check": {
- "name": "slack_bot_requests_owner_check",
- "value": "(\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NOT NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NOT NULL) OR\n (\"slack_bot_requests\".\"owned_by_user_id\" IS NULL AND \"slack_bot_requests\".\"owned_by_organization_id\" IS NULL)\n )"
- }
- },
- "isRLSEnabled": false
- },
- "public.source_embeddings": {
- "name": "source_embeddings",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "embedding": {
- "name": "embedding",
- "type": "vector(1536)",
- "primaryKey": false,
- "notNull": true
- },
- "file_path": {
- "name": "file_path",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "file_hash": {
- "name": "file_hash",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "start_line": {
- "name": "start_line",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "end_line": {
- "name": "end_line",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "git_branch": {
- "name": "git_branch",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'main'"
- },
- "is_base_branch": {
- "name": "is_base_branch",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_source_embeddings_organization_id": {
- "name": "IDX_source_embeddings_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_kilo_user_id": {
- "name": "IDX_source_embeddings_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_project_id": {
- "name": "IDX_source_embeddings_project_id",
- "columns": [
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_created_at": {
- "name": "IDX_source_embeddings_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_updated_at": {
- "name": "IDX_source_embeddings_updated_at",
- "columns": [
- {
- "expression": "updated_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_file_path_lower": {
- "name": "IDX_source_embeddings_file_path_lower",
- "columns": [
- {
- "expression": "LOWER(\"file_path\")",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_git_branch": {
- "name": "IDX_source_embeddings_git_branch",
- "columns": [
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_source_embeddings_org_project_branch": {
- "name": "IDX_source_embeddings_org_project_branch",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "project_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "git_branch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "source_embeddings_organization_id_organizations_id_fk": {
- "name": "source_embeddings_organization_id_organizations_id_fk",
- "tableFrom": "source_embeddings",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "source_embeddings_kilo_user_id_kilocode_users_id_fk": {
- "name": "source_embeddings_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "source_embeddings",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_source_embeddings_org_project_branch_file_lines": {
- "name": "UQ_source_embeddings_org_project_branch_file_lines",
- "nullsNotDistinct": false,
- "columns": [
- "organization_id",
- "project_id",
- "git_branch",
- "file_path",
- "start_line",
- "end_line"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.stripe_dispute_actions": {
- "name": "stripe_dispute_actions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "case_id": {
- "name": "case_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "action_type": {
- "name": "action_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "target_key": {
- "name": "target_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_attempt_at": {
- "name": "last_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "result_code": {
- "name": "result_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "result_reference_id": {
- "name": "result_reference_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_dispute_actions_case_id": {
- "name": "IDX_stripe_dispute_actions_case_id",
- "columns": [
- {
- "expression": "case_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_actions_claim_path": {
- "name": "IDX_stripe_dispute_actions_claim_path",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk": {
- "name": "stripe_dispute_actions_case_id_stripe_dispute_cases_id_fk",
- "tableFrom": "stripe_dispute_actions",
- "tableTo": "stripe_dispute_cases",
- "columnsFrom": [
- "case_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_dispute_actions_case_type_target": {
- "name": "UQ_stripe_dispute_actions_case_type_target",
- "nullsNotDistinct": false,
- "columns": [
- "case_id",
- "action_type",
- "target_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_dispute_actions_action_type_check": {
- "name": "stripe_dispute_actions_action_type_check",
- "value": "\"stripe_dispute_actions\".\"action_type\" IN ('stripe_acceptance', 'user_block', 'auto_top_up_disable', 'credit_balance_reset', 'subscription_cancellation', 'access_termination', 'kiloclaw_suspension')"
- },
- "stripe_dispute_actions_status_check": {
- "name": "stripe_dispute_actions_status_check",
- "value": "\"stripe_dispute_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'skipped')"
- },
- "stripe_dispute_actions_attempt_count_non_negative_check": {
- "name": "stripe_dispute_actions_attempt_count_non_negative_check",
- "value": "\"stripe_dispute_actions\".\"attempt_count\" >= 0"
- },
- "stripe_dispute_actions_target_key_not_empty_check": {
- "name": "stripe_dispute_actions_target_key_not_empty_check",
- "value": "length(\"stripe_dispute_actions\".\"target_key\") > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stripe_dispute_cases": {
- "name": "stripe_dispute_cases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "stripe_dispute_id": {
- "name": "stripe_dispute_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_event_id": {
- "name": "stripe_event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_event_created_at": {
- "name": "stripe_event_created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_intent_id": {
- "name": "stripe_payment_intent_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "amount_minor_units": {
- "name": "amount_minor_units",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "currency": {
- "name": "currency",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "dispute_reason": {
- "name": "dispute_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_status": {
- "name": "stripe_status",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owner_classification": {
- "name": "owner_classification",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'needs_action'"
- },
- "status_reason": {
- "name": "status_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_created_at": {
- "name": "stripe_created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "evidence_due_by": {
- "name": "evidence_due_by",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "synced_at": {
- "name": "synced_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "accepted_by_kilo_user_id": {
- "name": "accepted_by_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "acceptance_started_at": {
- "name": "acceptance_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "accepted_at": {
- "name": "accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "enforcement_completed_at": {
- "name": "enforcement_completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "review_required_at": {
- "name": "review_required_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "closed_at": {
- "name": "closed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_dispute_cases_event_id": {
- "name": "IDX_stripe_dispute_cases_event_id",
- "columns": [
- {
- "expression": "stripe_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_charge_id": {
- "name": "IDX_stripe_dispute_cases_charge_id",
- "columns": [
- {
- "expression": "stripe_charge_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_payment_intent_id": {
- "name": "IDX_stripe_dispute_cases_payment_intent_id",
- "columns": [
- {
- "expression": "stripe_payment_intent_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_customer_id": {
- "name": "IDX_stripe_dispute_cases_customer_id",
- "columns": [
- {
- "expression": "stripe_customer_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_kilo_user_id": {
- "name": "IDX_stripe_dispute_cases_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_organization_id": {
- "name": "IDX_stripe_dispute_cases_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_dispute_cases_status_due_by": {
- "name": "IDX_stripe_dispute_cases_status_due_by",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "evidence_due_by",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "stripe_created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk": {
- "name": "stripe_dispute_cases_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "stripe_dispute_cases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "stripe_dispute_cases_organization_id_organizations_id_fk": {
- "name": "stripe_dispute_cases_organization_id_organizations_id_fk",
- "tableFrom": "stripe_dispute_cases",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk": {
- "name": "stripe_dispute_cases_accepted_by_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "stripe_dispute_cases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "accepted_by_kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_dispute_cases_dispute_id": {
- "name": "UQ_stripe_dispute_cases_dispute_id",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_dispute_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_dispute_cases_owner_classification_check": {
- "name": "stripe_dispute_cases_owner_classification_check",
- "value": "\"stripe_dispute_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
- },
- "stripe_dispute_cases_status_check": {
- "name": "stripe_dispute_cases_status_check",
- "value": "\"stripe_dispute_cases\".\"status\" IN ('needs_action', 'processing', 'accepted', 'acceptance_failed', 'enforcement_failed', 'review_required', 'closed')"
- },
- "stripe_dispute_cases_amount_minor_units_non_negative_check": {
- "name": "stripe_dispute_cases_amount_minor_units_non_negative_check",
- "value": "\"stripe_dispute_cases\".\"amount_minor_units\" IS NULL OR \"stripe_dispute_cases\".\"amount_minor_units\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stripe_early_fraud_warning_actions": {
- "name": "stripe_early_fraud_warning_actions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "case_id": {
- "name": "case_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "action_type": {
- "name": "action_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "target_key": {
- "name": "target_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "last_attempt_at": {
- "name": "last_attempt_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "terminal_at": {
- "name": "terminal_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "result_code": {
- "name": "result_code",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "result_reference_id": {
- "name": "result_reference_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_early_fraud_warning_actions_case_id": {
- "name": "IDX_stripe_early_fraud_warning_actions_case_id",
- "columns": [
- {
- "expression": "case_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_actions_claim_path": {
- "name": "IDX_stripe_early_fraud_warning_actions_claim_path",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk": {
- "name": "stripe_early_fraud_warning_actions_case_id_stripe_early_fraud_warning_cases_id_fk",
- "tableFrom": "stripe_early_fraud_warning_actions",
- "tableTo": "stripe_early_fraud_warning_cases",
- "columnsFrom": [
- "case_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "restrict",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_early_fraud_warning_actions_case_type_target": {
- "name": "UQ_stripe_early_fraud_warning_actions_case_type_target",
- "nullsNotDistinct": false,
- "columns": [
- "case_id",
- "action_type",
- "target_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_early_fraud_warning_actions_action_type_check": {
- "name": "stripe_early_fraud_warning_actions_action_type_check",
- "value": "\"stripe_early_fraud_warning_actions\".\"action_type\" IN ('containment', 'refund', 'payment_value_clawback', 'subscription_termination', 'access_termination', 'kiloclaw_suspension', 'affiliate_payout_reversal', 'referral_reward_reversal', 'user_notice')"
- },
- "stripe_early_fraud_warning_actions_status_check": {
- "name": "stripe_early_fraud_warning_actions_status_check",
- "value": "\"stripe_early_fraud_warning_actions\".\"status\" IN ('queued', 'processing', 'completed', 'failed', 'review_required', 'dismissed')"
- },
- "stripe_early_fraud_warning_actions_attempt_count_non_negative_check": {
- "name": "stripe_early_fraud_warning_actions_attempt_count_non_negative_check",
- "value": "\"stripe_early_fraud_warning_actions\".\"attempt_count\" >= 0"
- },
- "stripe_early_fraud_warning_actions_target_key_not_empty_check": {
- "name": "stripe_early_fraud_warning_actions_target_key_not_empty_check",
- "value": "length(\"stripe_early_fraud_warning_actions\".\"target_key\") > 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stripe_early_fraud_warning_cases": {
- "name": "stripe_early_fraud_warning_cases",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "stripe_early_fraud_warning_id": {
- "name": "stripe_early_fraud_warning_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_event_id": {
- "name": "stripe_event_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_payment_intent_id": {
- "name": "stripe_payment_intent_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "stripe_customer_id": {
- "name": "stripe_customer_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "amount_minor_units": {
- "name": "amount_minor_units",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "currency": {
- "name": "currency",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "owner_classification": {
- "name": "owner_classification",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "reason": {
- "name": "reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "failure_context": {
- "name": "failure_context",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "warning_created_at": {
- "name": "warning_created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "contained_at": {
- "name": "contained_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "processing_started_at": {
- "name": "processing_started_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "completed_at": {
- "name": "completed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "review_required_at": {
- "name": "review_required_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "remediated_at": {
- "name": "remediated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "dismissed_at": {
- "name": "dismissed_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_stripe_early_fraud_warning_cases_event_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_event_id",
- "columns": [
- {
- "expression": "stripe_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_charge_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_charge_id",
- "columns": [
- {
- "expression": "stripe_charge_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_payment_intent_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_payment_intent_id",
- "columns": [
- {
- "expression": "stripe_payment_intent_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_customer_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_customer_id",
- "columns": [
- {
- "expression": "stripe_customer_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_kilo_user_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_organization_id": {
- "name": "IDX_stripe_early_fraud_warning_cases_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_stripe_early_fraud_warning_cases_status_created_at": {
- "name": "IDX_stripe_early_fraud_warning_cases_status_created_at",
- "columns": [
- {
- "expression": "status",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk": {
- "name": "stripe_early_fraud_warning_cases_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "stripe_early_fraud_warning_cases",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- },
- "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk": {
- "name": "stripe_early_fraud_warning_cases_organization_id_organizations_id_fk",
- "tableFrom": "stripe_early_fraud_warning_cases",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_stripe_early_fraud_warning_cases_warning_id": {
- "name": "UQ_stripe_early_fraud_warning_cases_warning_id",
- "nullsNotDistinct": false,
- "columns": [
- "stripe_early_fraud_warning_id"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "stripe_early_fraud_warning_cases_owner_classification_check": {
- "name": "stripe_early_fraud_warning_cases_owner_classification_check",
- "value": "\"stripe_early_fraud_warning_cases\".\"owner_classification\" IN ('personal', 'organization', 'ambiguous', 'unmatched')"
- },
- "stripe_early_fraud_warning_cases_status_check": {
- "name": "stripe_early_fraud_warning_cases_status_check",
- "value": "\"stripe_early_fraud_warning_cases\".\"status\" IN ('queued', 'contained', 'processing', 'completed', 'review_required', 'failed', 'remediated', 'dismissed')"
- },
- "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check": {
- "name": "stripe_early_fraud_warning_cases_amount_minor_units_non_negative_check",
- "value": "\"stripe_early_fraud_warning_cases\".\"amount_minor_units\" IS NULL OR \"stripe_early_fraud_warning_cases\".\"amount_minor_units\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.stytch_fingerprints": {
- "name": "stytch_fingerprints",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "visitor_fingerprint": {
- "name": "visitor_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "browser_fingerprint": {
- "name": "browser_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "browser_id": {
- "name": "browser_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "hardware_fingerprint": {
- "name": "hardware_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "network_fingerprint": {
- "name": "network_fingerprint",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "visitor_id": {
- "name": "visitor_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "verdict_action": {
- "name": "verdict_action",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "detected_device_type": {
- "name": "detected_device_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "is_authentic_device": {
- "name": "is_authentic_device",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "reasons": {
- "name": "reasons",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{\"\"}'"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "status_code": {
- "name": "status_code",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "fingerprint_data": {
- "name": "fingerprint_data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_free_tier_allowed": {
- "name": "kilo_free_tier_allowed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "http_x_forwarded_for": {
- "name": "http_x_forwarded_for",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_city": {
- "name": "http_x_vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_country": {
- "name": "http_x_vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_latitude": {
- "name": "http_x_vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_longitude": {
- "name": "http_x_vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ja4_digest": {
- "name": "http_x_vercel_ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_user_agent": {
- "name": "http_user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "idx_hardware_fingerprint": {
- "name": "idx_hardware_fingerprint",
- "columns": [
- {
- "expression": "hardware_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_kilo_user_id": {
- "name": "idx_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_stytch_fingerprints_reasons_gin": {
- "name": "idx_stytch_fingerprints_reasons_gin",
- "columns": [
- {
- "expression": "reasons",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "gin",
- "with": {}
- },
- "idx_verdict_action": {
- "name": "idx_verdict_action",
- "columns": [
- {
- "expression": "verdict_action",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "idx_visitor_fingerprint": {
- "name": "idx_visitor_fingerprint",
- "columns": [
- {
- "expression": "visitor_fingerprint",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.system_prompt_prefix": {
- "name": "system_prompt_prefix",
- "schema": "",
- "columns": {
- "system_prompt_prefix_id": {
- "name": "system_prompt_prefix_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "system_prompt_prefix": {
- "name": "system_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_system_prompt_prefix": {
- "name": "UQ_system_prompt_prefix",
- "columns": [
- {
- "expression": "system_prompt_prefix",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.transactional_email_log": {
- "name": "transactional_email_log",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "email_type": {
- "name": "email_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "idempotency_key": {
- "name": "idempotency_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sent_at": {
- "name": "sent_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_transactional_email_log_type_idempotency_key": {
- "name": "UQ_transactional_email_log_type_idempotency_key",
- "columns": [
- {
- "expression": "email_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "idempotency_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_transactional_email_log_user_id": {
- "name": "IDX_transactional_email_log_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_transactional_email_log_organization_id": {
- "name": "IDX_transactional_email_log_organization_id",
- "columns": [
- {
- "expression": "organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "transactional_email_log_user_id_kilocode_users_id_fk": {
- "name": "transactional_email_log_user_id_kilocode_users_id_fk",
- "tableFrom": "transactional_email_log",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "transactional_email_log_organization_id_organizations_id_fk": {
- "name": "transactional_email_log_organization_id_organizations_id_fk",
- "tableFrom": "transactional_email_log",
- "tableTo": "organizations",
- "columnsFrom": [
- "organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "CHK_transactional_email_log_owner": {
- "name": "CHK_transactional_email_log_owner",
- "value": "\"transactional_email_log\".\"user_id\" IS NOT NULL OR \"transactional_email_log\".\"organization_id\" IS NOT NULL"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_admin_notes": {
- "name": "user_admin_notes",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "note_content": {
- "name": "note_content",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "admin_kilo_user_id": {
- "name": "admin_kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_34517df0b385234babc38fe81b": {
- "name": "IDX_34517df0b385234babc38fe81b",
- "columns": [
- {
- "expression": "admin_kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_ccbde98c4c14046daa5682ec4f": {
- "name": "IDX_ccbde98c4c14046daa5682ec4f",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_d0270eb24ef6442d65a0b7853c": {
- "name": "IDX_d0270eb24ef6442d65a0b7853c",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_affiliate_attributions": {
- "name": "user_affiliate_attributions",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "tracking_id": {
- "name": "tracking_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_user_affiliate_attributions_user_id": {
- "name": "IDX_user_affiliate_attributions_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_affiliate_attributions_user_id_kilocode_users_id_fk": {
- "name": "user_affiliate_attributions_user_id_kilocode_users_id_fk",
- "tableFrom": "user_affiliate_attributions",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_user_affiliate_attributions_user_provider": {
- "name": "UQ_user_affiliate_attributions_user_provider",
- "nullsNotDistinct": false,
- "columns": [
- "user_id",
- "provider"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "user_affiliate_attributions_provider_check": {
- "name": "user_affiliate_attributions_provider_check",
- "value": "\"user_affiliate_attributions\".\"provider\" IN ('impact')"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_affiliate_events": {
- "name": "user_affiliate_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "dedupe_key": {
- "name": "dedupe_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "parent_event_id": {
- "name": "parent_event_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "delivery_state": {
- "name": "delivery_state",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "payload_json": {
- "name": "payload_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "stripe_charge_id": {
- "name": "stripe_charge_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "impact_action_id": {
- "name": "impact_action_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "impact_submission_uri": {
- "name": "impact_submission_uri",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "attempt_count": {
- "name": "attempt_count",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 0
- },
- "next_retry_at": {
- "name": "next_retry_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_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": {
- "IDX_user_affiliate_events_claim_path": {
- "name": "IDX_user_affiliate_events_claim_path",
- "columns": [
- {
- "expression": "delivery_state",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "coalesce(\"next_retry_at\", '-infinity'::timestamptz)",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
- },
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_affiliate_events_parent_event_id": {
- "name": "IDX_user_affiliate_events_parent_event_id",
- "columns": [
- {
- "expression": "parent_event_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_affiliate_events_provider_event_type_charge": {
- "name": "IDX_user_affiliate_events_provider_event_type_charge",
- "columns": [
- {
- "expression": "provider",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "stripe_charge_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_affiliate_events_user_id_kilocode_users_id_fk": {
- "name": "user_affiliate_events_user_id_kilocode_users_id_fk",
- "tableFrom": "user_affiliate_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "user_affiliate_events_parent_event_id_fk": {
- "name": "user_affiliate_events_parent_event_id_fk",
- "tableFrom": "user_affiliate_events",
- "tableTo": "user_affiliate_events",
- "columnsFrom": [
- "parent_event_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_user_affiliate_events_dedupe_key": {
- "name": "UQ_user_affiliate_events_dedupe_key",
- "nullsNotDistinct": false,
- "columns": [
- "dedupe_key"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "user_affiliate_events_provider_check": {
- "name": "user_affiliate_events_provider_check",
- "value": "\"user_affiliate_events\".\"provider\" IN ('impact')"
- },
- "user_affiliate_events_event_type_check": {
- "name": "user_affiliate_events_event_type_check",
- "value": "\"user_affiliate_events\".\"event_type\" IN ('signup', 'trial_start', 'trial_end', 'sale', 'sale_reversal')"
- },
- "user_affiliate_events_delivery_state_check": {
- "name": "user_affiliate_events_delivery_state_check",
- "value": "\"user_affiliate_events\".\"delivery_state\" IN ('queued', 'blocked', 'sending', 'delivered', 'failed')"
- },
- "user_affiliate_events_attempt_count_non_negative_check": {
- "name": "user_affiliate_events_attempt_count_non_negative_check",
- "value": "\"user_affiliate_events\".\"attempt_count\" >= 0"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_auth_provider": {
- "name": "user_auth_provider",
- "schema": "",
- "columns": {
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "provider_account_id": {
- "name": "provider_account_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "avatar_url": {
- "name": "avatar_url",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "display_name": {
- "name": "display_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "hosted_domain": {
- "name": "hosted_domain",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_user_auth_provider_kilo_user_id": {
- "name": "IDX_user_auth_provider_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_auth_provider_hosted_domain": {
- "name": "IDX_user_auth_provider_hosted_domain",
- "columns": [
- {
- "expression": "hosted_domain",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {
- "user_auth_provider_provider_provider_account_id_pk": {
- "name": "user_auth_provider_provider_provider_account_id_pk",
- "columns": [
- "provider",
- "provider_account_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_feedback": {
- "name": "user_feedback",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "feedback_text": {
- "name": "feedback_text",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "feedback_for": {
- "name": "feedback_for",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "feedback_batch": {
- "name": "feedback_batch",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "source": {
- "name": "source",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'unknown'"
- },
- "context_json": {
- "name": "context_json",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'::jsonb"
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_user_feedback_created_at": {
- "name": "IDX_user_feedback_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_kilo_user_id": {
- "name": "IDX_user_feedback_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_feedback_for": {
- "name": "IDX_user_feedback_feedback_for",
- "columns": [
- {
- "expression": "feedback_for",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_feedback_batch": {
- "name": "IDX_user_feedback_feedback_batch",
- "columns": [
- {
- "expression": "feedback_batch",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_feedback_source": {
- "name": "IDX_user_feedback_source",
- "columns": [
- {
- "expression": "source",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_feedback_kilo_user_id_kilocode_users_id_fk": {
- "name": "user_feedback_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "user_feedback",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "set null",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_github_app_tokens": {
- "name": "user_github_app_tokens",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_app_type": {
- "name": "github_app_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'standard'"
- },
- "github_user_id": {
- "name": "github_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "github_login": {
- "name": "github_login",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_encrypted": {
- "name": "access_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "access_token_expires_at": {
- "name": "access_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "refresh_token_encrypted": {
- "name": "refresh_token_encrypted",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "refresh_token_expires_at": {
- "name": "refresh_token_expires_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "credential_version": {
- "name": "credential_version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "revoked_at": {
- "name": "revoked_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "revocation_reason": {
- "name": "revocation_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "last_used_at": {
- "name": "last_used_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()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_user_github_app_tokens_user_app": {
- "name": "UQ_user_github_app_tokens_user_app",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "github_app_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_user_github_app_tokens_github_user_app": {
- "name": "UQ_user_github_app_tokens_github_user_app",
- "columns": [
- {
- "expression": "github_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "github_app_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk": {
- "name": "user_github_app_tokens_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "user_github_app_tokens",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "user_github_app_tokens_app_type_check": {
- "name": "user_github_app_tokens_app_type_check",
- "value": "\"user_github_app_tokens\".\"github_app_type\" IN ('standard', 'lite')"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_period_cache": {
- "name": "user_period_cache",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "cache_type": {
- "name": "cache_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_type": {
- "name": "period_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "period_key": {
- "name": "period_key",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "data": {
- "name": "data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "computed_at": {
- "name": "computed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "version": {
- "name": "version",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "default": 1
- },
- "shared_url_token": {
- "name": "shared_url_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "shared_at": {
- "name": "shared_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {
- "IDX_user_period_cache_kilo_user_id": {
- "name": "IDX_user_period_cache_kilo_user_id",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_user_period_cache": {
- "name": "UQ_user_period_cache",
- "columns": [
- {
- "expression": "kilo_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "cache_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_period_cache_lookup": {
- "name": "IDX_user_period_cache_lookup",
- "columns": [
- {
- "expression": "cache_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "period_key",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "UQ_user_period_cache_share_token": {
- "name": "UQ_user_period_cache_share_token",
- "columns": [
- {
- "expression": "shared_url_token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"user_period_cache\".\"shared_url_token\" IS NOT NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_period_cache_kilo_user_id_kilocode_users_id_fk": {
- "name": "user_period_cache_kilo_user_id_kilocode_users_id_fk",
- "tableFrom": "user_period_cache",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "kilo_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {
- "user_period_cache_period_type_check": {
- "name": "user_period_cache_period_type_check",
- "value": "\"user_period_cache\".\"period_type\" IN ('year', 'quarter', 'month', 'week', 'custom')"
- }
- },
- "isRLSEnabled": false
- },
- "public.user_push_tokens": {
- "name": "user_push_tokens",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "token": {
- "name": "token",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "UQ_user_push_tokens_token": {
- "name": "UQ_user_push_tokens_token",
- "columns": [
- {
- "expression": "token",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_user_push_tokens_user_id": {
- "name": "IDX_user_push_tokens_user_id",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_push_tokens_user_id_kilocode_users_id_fk": {
- "name": "user_push_tokens_user_id_kilocode_users_id_fk",
- "tableFrom": "user_push_tokens",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.vercel_ip_city": {
- "name": "vercel_ip_city",
- "schema": "",
- "columns": {
- "vercel_ip_city_id": {
- "name": "vercel_ip_city_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "vercel_ip_city": {
- "name": "vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_vercel_ip_city": {
- "name": "UQ_vercel_ip_city",
- "columns": [
- {
- "expression": "vercel_ip_city",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.vercel_ip_country": {
- "name": "vercel_ip_country",
- "schema": "",
- "columns": {
- "vercel_ip_country_id": {
- "name": "vercel_ip_country_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "vercel_ip_country": {
- "name": "vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "UQ_vercel_ip_country": {
- "name": "UQ_vercel_ip_country",
- "columns": [
- {
- "expression": "vercel_ip_country",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.webhook_events": {
- "name": "webhook_events",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "pg_catalog.gen_random_uuid()"
- },
- "owned_by_organization_id": {
- "name": "owned_by_organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "owned_by_user_id": {
- "name": "owned_by_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "platform": {
- "name": "platform",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_type": {
- "name": "event_type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "event_action": {
- "name": "event_action",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "payload": {
- "name": "payload",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "headers": {
- "name": "headers",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": true
- },
- "processed": {
- "name": "processed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "processed_at": {
- "name": "processed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "handlers_triggered": {
- "name": "handlers_triggered",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true,
- "default": "'{}'"
- },
- "errors": {
- "name": "errors",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "event_signature": {
- "name": "event_signature",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "IDX_webhook_events_owned_by_org_id": {
- "name": "IDX_webhook_events_owned_by_org_id",
- "columns": [
- {
- "expression": "owned_by_organization_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_owned_by_user_id": {
- "name": "IDX_webhook_events_owned_by_user_id",
- "columns": [
- {
- "expression": "owned_by_user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_platform": {
- "name": "IDX_webhook_events_platform",
- "columns": [
- {
- "expression": "platform",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_event_type": {
- "name": "IDX_webhook_events_event_type",
- "columns": [
- {
- "expression": "event_type",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "IDX_webhook_events_created_at": {
- "name": "IDX_webhook_events_created_at",
- "columns": [
- {
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "webhook_events_owned_by_organization_id_organizations_id_fk": {
- "name": "webhook_events_owned_by_organization_id_organizations_id_fk",
- "tableFrom": "webhook_events",
- "tableTo": "organizations",
- "columnsFrom": [
- "owned_by_organization_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "webhook_events_owned_by_user_id_kilocode_users_id_fk": {
- "name": "webhook_events_owned_by_user_id_kilocode_users_id_fk",
- "tableFrom": "webhook_events",
- "tableTo": "kilocode_users",
- "columnsFrom": [
- "owned_by_user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "UQ_webhook_events_signature": {
- "name": "UQ_webhook_events_signature",
- "nullsNotDistinct": false,
- "columns": [
- "event_signature"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {
- "webhook_events_owner_check": {
- "name": "webhook_events_owner_check",
- "value": "(\n (\"webhook_events\".\"owned_by_user_id\" IS NOT NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NULL) OR\n (\"webhook_events\".\"owned_by_user_id\" IS NULL AND \"webhook_events\".\"owned_by_organization_id\" IS NOT NULL)\n )"
- }
- },
- "isRLSEnabled": false
- }
- },
- "enums": {},
- "schemas": {},
- "sequences": {},
- "roles": {},
- "policies": {},
- "views": {
- "public.microdollar_usage_view": {
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "kilo_user_id": {
- "name": "kilo_user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "message_id": {
- "name": "message_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cost": {
- "name": "cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "input_tokens": {
- "name": "input_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "output_tokens": {
- "name": "output_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_write_tokens": {
- "name": "cache_write_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "cache_hit_tokens": {
- "name": "cache_hit_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true
- },
- "http_x_forwarded_for": {
- "name": "http_x_forwarded_for",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_city": {
- "name": "http_x_vercel_ip_city",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_country": {
- "name": "http_x_vercel_ip_country",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_latitude": {
- "name": "http_x_vercel_ip_latitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ip_longitude": {
- "name": "http_x_vercel_ip_longitude",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "http_x_vercel_ja4_digest": {
- "name": "http_x_vercel_ja4_digest",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "model": {
- "name": "model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "requested_model": {
- "name": "requested_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "user_prompt_prefix": {
- "name": "user_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_prefix": {
- "name": "system_prompt_prefix",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "system_prompt_length": {
- "name": "system_prompt_length",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "http_user_agent": {
- "name": "http_user_agent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "cache_discount": {
- "name": "cache_discount",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "max_tokens": {
- "name": "max_tokens",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "has_middle_out_transform": {
- "name": "has_middle_out_transform",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "has_error": {
- "name": "has_error",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "abuse_classification": {
- "name": "abuse_classification",
- "type": "smallint",
- "primaryKey": false,
- "notNull": true
- },
- "organization_id": {
- "name": "organization_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "inference_provider": {
- "name": "inference_provider",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "project_id": {
- "name": "project_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "status_code": {
- "name": "status_code",
- "type": "smallint",
- "primaryKey": false,
- "notNull": false
- },
- "upstream_id": {
- "name": "upstream_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "finish_reason": {
- "name": "finish_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "latency": {
- "name": "latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "moderation_latency": {
- "name": "moderation_latency",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "generation_time": {
- "name": "generation_time",
- "type": "real",
- "primaryKey": false,
- "notNull": false
- },
- "is_byok": {
- "name": "is_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "is_user_byok": {
- "name": "is_user_byok",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "streamed": {
- "name": "streamed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "cancelled": {
- "name": "cancelled",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "editor_name": {
- "name": "editor_name",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "api_kind": {
- "name": "api_kind",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "has_tools": {
- "name": "has_tools",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "machine_id": {
- "name": "machine_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "feature": {
- "name": "feature",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "mode": {
- "name": "mode",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "auto_model": {
- "name": "auto_model",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "market_cost": {
- "name": "market_cost",
- "type": "bigint",
- "primaryKey": false,
- "notNull": false
- },
- "is_free": {
- "name": "is_free",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_delay": {
- "name": "abuse_delay",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "abuse_downgraded_from": {
- "name": "abuse_downgraded_from",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "definition": "\n SELECT\n mu.id,\n mu.kilo_user_id,\n meta.message_id,\n mu.cost,\n mu.input_tokens,\n mu.output_tokens,\n mu.cache_write_tokens,\n mu.cache_hit_tokens,\n mu.created_at,\n ip.http_ip AS http_x_forwarded_for,\n city.vercel_ip_city AS http_x_vercel_ip_city,\n country.vercel_ip_country AS http_x_vercel_ip_country,\n meta.vercel_ip_latitude AS http_x_vercel_ip_latitude,\n meta.vercel_ip_longitude AS http_x_vercel_ip_longitude,\n ja4.ja4_digest AS http_x_vercel_ja4_digest,\n mu.provider,\n mu.model,\n mu.requested_model,\n meta.user_prompt_prefix,\n spp.system_prompt_prefix,\n meta.system_prompt_length,\n ua.http_user_agent,\n mu.cache_discount,\n meta.max_tokens,\n meta.has_middle_out_transform,\n mu.has_error,\n mu.abuse_classification,\n mu.organization_id,\n mu.inference_provider,\n mu.project_id,\n meta.status_code,\n meta.upstream_id,\n frfr.finish_reason,\n meta.latency,\n meta.moderation_latency,\n meta.generation_time,\n meta.is_byok,\n meta.is_user_byok,\n meta.streamed,\n meta.cancelled,\n edit.editor_name,\n ak.api_kind,\n meta.has_tools,\n meta.machine_id,\n feat.feature,\n meta.session_id,\n md.mode,\n am.auto_model,\n meta.market_cost,\n meta.is_free,\n meta.abuse_delay,\n meta.abuse_downgraded_from\n FROM \"microdollar_usage\" mu\n LEFT JOIN \"microdollar_usage_metadata\" meta ON mu.id = meta.id\n LEFT JOIN \"http_ip\" ip ON meta.http_ip_id = ip.http_ip_id\n LEFT JOIN \"vercel_ip_city\" city ON meta.vercel_ip_city_id = city.vercel_ip_city_id\n LEFT JOIN \"vercel_ip_country\" country ON meta.vercel_ip_country_id = country.vercel_ip_country_id\n LEFT JOIN \"ja4_digest\" ja4 ON meta.ja4_digest_id = ja4.ja4_digest_id\n LEFT JOIN \"system_prompt_prefix\" spp ON meta.system_prompt_prefix_id = spp.system_prompt_prefix_id\n LEFT JOIN \"http_user_agent\" ua ON meta.http_user_agent_id = ua.http_user_agent_id\n LEFT JOIN \"finish_reason\" frfr ON meta.finish_reason_id = frfr.finish_reason_id\n LEFT JOIN \"editor_name\" edit ON meta.editor_name_id = edit.editor_name_id\n LEFT JOIN \"api_kind\" ak ON meta.api_kind_id = ak.api_kind_id\n LEFT JOIN \"feature\" feat ON meta.feature_id = feat.feature_id\n LEFT JOIN \"mode\" md ON meta.mode_id = md.mode_id\n LEFT JOIN \"auto_model\" am ON meta.auto_model_id = am.auto_model_id\n",
- "name": "microdollar_usage_view",
- "schema": "public",
- "isExisting": false,
- "materialized": false
- }
- },
- "_meta": {
- "columns": {},
- "schemas": {},
- "tables": {}
- }
-}
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.json
index bda7265b50..f7c9efc2f0 100644
--- a/packages/db/src/migrations/meta/_journal.json
+++ b/packages/db/src/migrations/meta/_journal.json
@@ -1223,15 +1223,8 @@
{
"idx": 174,
"version": "7",
- "when": 1782402944684,
- "tag": "0174_omniscient_tenebrous",
- "breakpoints": true
- },
- {
- "idx": 175,
- "version": "7",
- "when": 1782407182910,
- "tag": "0175_aspiring_omega_flight",
+ "when": 1782415062740,
+ "tag": "0174_quick_kat_farrell",
"breakpoints": true
}
]
diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts
index 37592f941b..cc8e16848d 100644
--- a/packages/db/src/schema.ts
+++ b/packages/db/src/schema.ts
@@ -2656,7 +2656,6 @@ export const organizations = pgTable(
free_trial_end_at: timestamp({ withTimezone: true, mode: 'string' }),
company_domain: text(),
slug: text().unique(),
- requested_slug: text(),
},
table => [
check('organizations_name_not_empty_check', sql`length(trim(${table.name})) > 0`),
From 4ed4ef8ea8040b5f6cb14ef96382da8ed4523a98 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 14:30:45 -0500
Subject: [PATCH 11/33] Allow org owners to edit slug
---
apps/web/src/app/api/organizations/hooks.ts | 2 +-
.../organizations/OrganizationInfoCard.tsx | 15 ++-
.../organizations/organization-router.test.ts | 121 +++++++++++++++++-
.../organizations/organization-router.ts | 31 ++++-
4 files changed, 157 insertions(+), 12 deletions(-)
diff --git a/apps/web/src/app/api/organizations/hooks.ts b/apps/web/src/app/api/organizations/hooks.ts
index ea63c36de4..bd25d67e99 100644
--- a/apps/web/src/app/api/organizations/hooks.ts
+++ b/apps/web/src/app/api/organizations/hooks.ts
@@ -200,7 +200,7 @@ export function useUpdateOrganizationName() {
);
}
-export function useAdminUpdateOrganizationSlug() {
+export function useUpdateOrganizationSlug() {
const trpc = useTRPC();
const invalidate = useInvalidateAllOrganizationData();
const queryClient = useQueryClient();
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index 7ac7532f92..ef63395773 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -6,7 +6,7 @@ import { BooleanBadge } from '@/components/ui/boolean-badge';
import {
useUpdateOrganizationName,
useSlugAvailability,
- useAdminUpdateOrganizationSlug,
+ useUpdateOrganizationSlug,
useUpdateCompanyDomain,
useOrganizationWithMembers,
useAdminToggleCodeIndexing,
@@ -180,7 +180,7 @@ function Inner(props: InnerProps) {
const [isSpendingAlertsModalOpen, setIsSpendingAlertsModalOpen] = useState(false);
const [ossSponsorshipDialogOpen, setOssSponsorshipDialogOpen] = useState(false);
const updateOrganizationName = useUpdateOrganizationName();
- const adminUpdateOrganizationSlug = useAdminUpdateOrganizationSlug();
+ const updateOrganizationSlug = useUpdateOrganizationSlug();
const updateCompanyDomain = useUpdateCompanyDomain();
const adminToggleCodeIndexing = useAdminToggleCodeIndexing();
const updateSuppressTrialMessaging = useUpdateSuppressTrialMessaging();
@@ -244,7 +244,7 @@ function Inner(props: InnerProps) {
}
try {
- await adminUpdateOrganizationSlug.mutateAsync({
+ await updateOrganizationSlug.mutateAsync({
organizationId: id,
slug: nextSlug,
});
@@ -315,6 +315,7 @@ function Inner(props: InnerProps) {
const isAutoTopUpEnabled = useIsAutoTopUpEnabled();
const isInAdminDashboard = isKiloAdmin && showAdminControls;
const isOrgOwner = useCanManagePaymentInfo();
+ const canEditSlug = isOrgOwner || isKiloAdmin;
const hierarchyQuery = useAdminOrganizationHierarchy(id, isInAdminDashboard);
const handleSeatsRequirementEdit = () => {
@@ -424,7 +425,7 @@ function Inner(props: InnerProps) {
onKeyDown={handleSlugKeyDown}
className={`font-mono text-sm ${slugError ? 'border-red-400' : ''}`}
autoFocus
- disabled={adminUpdateOrganizationSlug.isPending}
+ disabled={updateOrganizationSlug.isPending}
/>
{editedSlug.trim() && !isEditedSlugAvailable ? (
@@ -435,7 +436,7 @@ function Inner(props: InnerProps) {
size="sm"
variant="ghost"
onClick={handleSlugSave}
- disabled={adminUpdateOrganizationSlug.isPending || !isEditedSlugAvailable}
+ disabled={updateOrganizationSlug.isPending || !isEditedSlugAvailable}
className="h-8 w-8 p-0"
aria-label="Save organization slug"
>
@@ -445,7 +446,7 @@ function Inner(props: InnerProps) {
size="sm"
variant="ghost"
onClick={handleSlugCancel}
- disabled={adminUpdateOrganizationSlug.isPending}
+ disabled={updateOrganizationSlug.isPending}
className="h-8 w-8 p-0"
aria-label="Cancel organization slug edit"
>
@@ -459,7 +460,7 @@ function Inner(props: InnerProps) {
{info.slug || Not set }
- {isKiloAdmin && (
+ {canEditSlug && (
setIsEditingSlug(true)}
className="hover:bg-muted inline-flex cursor-pointer items-center gap-1 rounded p-1 transition-all duration-200 focus:outline-none"
diff --git a/apps/web/src/routers/organizations/organization-router.test.ts b/apps/web/src/routers/organizations/organization-router.test.ts
index 18cab30361..0f8cab3578 100644
--- a/apps/web/src/routers/organizations/organization-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-router.test.ts
@@ -9,6 +9,8 @@ import type { User, Organization } from '@kilocode/db/schema';
// Test users and organization will be created dynamically
let regularUser: User;
let adminUser: User;
+let creditManagerUser: User;
+let adminWithoutCreditAccessUser: User;
let memberUser: User;
let nonMemberUser: User;
let testOrganization: Organization;
@@ -28,6 +30,20 @@ describe('organizations trpc router', () => {
is_admin: true,
});
+ creditManagerUser = await insertTestUser({
+ google_user_email: 'credit-manager-org@admin.example.com',
+ google_user_name: 'Credit Manager Org User',
+ is_admin: true,
+ can_manage_credits: true,
+ });
+
+ adminWithoutCreditAccessUser = await insertTestUser({
+ google_user_email: 'admin-without-credit-org@admin.example.com',
+ google_user_name: 'Admin Without Credit Org User',
+ is_admin: true,
+ can_manage_credits: false,
+ });
+
memberUser = await insertTestUser({
google_user_email: 'member-org@example.com',
google_user_name: 'Member Org User',
@@ -231,7 +247,7 @@ describe('organizations trpc router', () => {
});
expect(result.childOrganizations).toEqual([
- { id: childOrganization.id, name: 'Child Label Organization' },
+ { id: childOrganization.id, name: 'Child Label Organization', slug: null },
]);
const member = result.members.find(m => m.status === 'active' && m.id === parentMember.id);
expect(member).toMatchObject({
@@ -544,6 +560,109 @@ describe('organizations trpc router', () => {
});
});
+ describe('updateSlug procedure', () => {
+ let slugConflictOrganization: Organization;
+
+ beforeAll(async () => {
+ slugConflictOrganization = await createOrganization(
+ 'Slug Conflict Organization',
+ memberUser.id
+ );
+ await db
+ .update(organizations)
+ .set({ slug: 'existing-slug' })
+ .where(eq(organizations.id, slugConflictOrganization.id));
+ });
+
+ afterAll(async () => {
+ await db.delete(organizations).where(eq(organizations.id, slugConflictOrganization.id));
+ });
+
+ afterEach(async () => {
+ await db
+ .update(organizations)
+ .set({ slug: null })
+ .where(eq(organizations.id, testOrganization.id));
+ });
+
+ it('updates organization slug for organization owner', async () => {
+ const caller = await createCallerForUser(regularUser.id);
+
+ const result = await caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'owner-slug',
+ });
+
+ expect(result).toEqual({
+ organization: {
+ id: testOrganization.id,
+ slug: 'owner-slug',
+ },
+ });
+
+ const [updatedOrg] = await db
+ .select({ slug: organizations.slug })
+ .from(organizations)
+ .where(eq(organizations.id, testOrganization.id));
+ expect(updatedOrg.slug).toBe('owner-slug');
+ });
+
+ it('updates organization slug for credit managers without org membership', async () => {
+ const caller = await createCallerForUser(creditManagerUser.id);
+
+ const result = await caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'support-slug',
+ });
+
+ expect(result.organization.slug).toBe('support-slug');
+ });
+
+ it('rejects admins without credit management access when they are not org members', async () => {
+ const caller = await createCallerForUser(adminWithoutCreditAccessUser.id);
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'admin-no-credit-slug',
+ })
+ ).rejects.toThrow('You do not have access to this organization');
+ });
+
+ it('rejects regular organization members', async () => {
+ const caller = await createCallerForUser(memberUser.id);
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'member-slug',
+ })
+ ).rejects.toThrow('You do not have the required organizational role to access this feature');
+ });
+
+ it('rejects non-members', async () => {
+ const caller = await createCallerForUser(nonMemberUser.id);
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'non-member-slug',
+ })
+ ).rejects.toThrow('You do not have access to this organization');
+ });
+
+ it('rejects unavailable slugs', async () => {
+ const caller = await createCallerForUser(regularUser.id);
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'existing-slug',
+ })
+ ).rejects.toThrow('Requested slug is not available');
+ });
+ });
+
describe('createOrganization with company_domain', () => {
let createdOrgId: string | undefined;
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index da86d2cc9b..abcdccc7cf 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -26,7 +26,7 @@ import {
import { getOrCreateStripeCustomerIdForOrganization } from '@/lib/organizations/organization-billing';
import { resolveEffectiveOrganizationSsoPolicy } from '@/lib/organizations/organization-sso-policy';
import { getStripeInvoices } from '@/lib/stripe';
-import { adminProcedure, baseProcedure, createTRPCRouter } from '@/lib/trpc/init';
+import { adminProcedure, baseProcedure, createTRPCRouter, type TRPCContext } from '@/lib/trpc/init';
import {
OrganizationIdInputSchema,
ensureOrganizationAccess,
@@ -41,6 +41,7 @@ import { organizationsUsageDetailsRouter } from '@/routers/organizations/organiz
import { TRPCError } from '@trpc/server';
import { and, asc, count, desc, eq, inArray, isNull, ne, sql } from 'drizzle-orm';
import * as z from 'zod';
+import { userCanManageCredits } from '@/lib/admin/credit-management';
import { getCreditTransactionsForOrganization } from '@/lib/creditTransactions';
import { getCreditBlocks } from '@/lib/getCreditBlocks';
import { processOrganizationExpirations } from '@/lib/creditExpiration';
@@ -91,6 +92,30 @@ const OrganizationSeatsUpdateSchema = OrganizationIdInputSchema.extend({
seatsRequired: z.boolean(),
});
+async function ensureOrganizationSlugUpdateAccess(ctx: TRPCContext, organizationId: string) {
+ if (userCanManageCredits(ctx.user)) return;
+
+ const [membership] = await db
+ .select({ role: organization_memberships.role })
+ .from(organization_memberships)
+ .where(
+ and(
+ eq(organization_memberships.kilo_user_id, ctx.user.id),
+ eq(organization_memberships.organization_id, organizationId)
+ )
+ )
+ .limit(1);
+
+ if (membership?.role === 'owner') return;
+
+ throw new TRPCError({
+ code: 'UNAUTHORIZED',
+ message: membership
+ ? 'You do not have the required organizational role to access this feature'
+ : 'You do not have access to this organization',
+ });
+}
+
const OrganizationInvoicesInputSchema = OrganizationIdInputSchema.extend({
period: TimePeriodSchema.optional().default('month'),
});
@@ -428,8 +453,8 @@ export const organizationsRouter = createTRPCRouter({
};
}),
- updateSlug: adminProcedure.input(OrganizationSlugUpdateSchema).mutation(async opts => {
- await ensureOrganizationAccess(opts.ctx, opts.input.organizationId, ['owner']);
+ updateSlug: baseProcedure.input(OrganizationSlugUpdateSchema).mutation(async opts => {
+ await ensureOrganizationSlugUpdateAccess(opts.ctx, opts.input.organizationId);
if (opts.input.slug) {
await assertActiveSlugAvailable(opts.input.slug, opts.input.organizationId);
}
From 5b5f534f252fa2f14df3e35c1a297ca1979bd791 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 14:46:01 -0500
Subject: [PATCH 12/33] fix(orgs): resolve slug route context in sidebar
---
.../src/app/(app)/components/AppSidebar.tsx | 67 +++++++++++++++----
.../src/hooks/useUrlOrganizationId.test.ts | 23 +++++++
apps/web/src/hooks/useUrlOrganizationId.ts | 21 ++++--
.../organization-route-utils.server.ts | 6 +-
.../organization-route-utils.test.ts | 44 ++++++++++++
.../organizations/organization-route-utils.ts | 24 +++++++
6 files changed, 161 insertions(+), 24 deletions(-)
create mode 100644 apps/web/src/hooks/useUrlOrganizationId.test.ts
diff --git a/apps/web/src/app/(app)/components/AppSidebar.tsx b/apps/web/src/app/(app)/components/AppSidebar.tsx
index 0496ffa13f..2d90a5bed5 100644
--- a/apps/web/src/app/(app)/components/AppSidebar.tsx
+++ b/apps/web/src/app/(app)/components/AppSidebar.tsx
@@ -2,14 +2,21 @@
import { useEffect, useRef } from 'react';
import { usePathname } from 'next/navigation';
+import { useQuery } from '@tanstack/react-query';
import { useSidebar, type Sidebar } from '@/components/ui/sidebar';
-import { useUrlOrganizationId } from '@/hooks/useUrlOrganizationId';
+import { useUrlOrganizationIdentifier } from '@/hooks/useUrlOrganizationId';
+import {
+ findOrganizationByRouteIdentifier,
+ isUuidOrganizationRouteIdentifier,
+} from '@/lib/organizations/organization-route-utils';
+import { useTRPC } from '@/lib/trpc/utils';
import PersonalAppSidebar from './PersonalAppSidebar';
import OrganizationAppSidebar from './OrganizationAppSidebar';
import { GastownTownSidebar } from '@/components/gastown/GastownTownSidebar';
import { WastelandSidebar } from '@/components/wasteland/WastelandSidebar';
const UUID = '[0-9a-f-]{36}';
+const ORG_ROUTE_IDENTIFIER = '[^/]+';
/** Extract the townId from a /gastown/[townId] pathname, or null. */
function extractGastownTownId(pathname: string): string | null {
@@ -17,14 +24,21 @@ function extractGastownTownId(pathname: string): string | null {
return match ? match[1] : null;
}
-/** Extract {orgId, townId} from an /organizations/[id]/gastown/[townId] pathname, or null. */
-function extractOrgGastownTownId(pathname: string): { orgId: string; townId: string } | null {
- const match = pathname.match(new RegExp(`^/organizations/(${UUID})/gastown/(${UUID})`));
- return match ? { orgId: match[1], townId: match[2] } : null;
+/** Extract {orgIdentifier, townId} from an /organizations/[id]/gastown/[townId] pathname, or null. */
+function extractOrgGastownTownId(
+ pathname: string
+): { orgIdentifier: string; townId: string } | null {
+ const match = pathname.match(
+ new RegExp(`^/organizations/(${ORG_ROUTE_IDENTIFIER})/gastown/(${UUID})`)
+ );
+ return match ? { orgIdentifier: decodeURIComponent(match[1]), townId: match[2] } : null;
}
function isKiloClawNewPath(pathname: string): boolean {
- return pathname === '/claw/new' || new RegExp(`^/organizations/${UUID}/claw/new$`).test(pathname);
+ return (
+ pathname === '/claw/new' ||
+ new RegExp(`^/organizations/${ORG_ROUTE_IDENTIFIER}/claw/new$`).test(pathname)
+ );
}
/** Extract the wastelandId from a /wasteland/[wastelandId] pathname, or null. */
@@ -33,19 +47,46 @@ function extractWastelandId(pathname: string): string | null {
return match ? match[1] : null;
}
-/** Extract {orgId, wastelandId} from an /organizations/[id]/wasteland/[wastelandId] pathname, or null. */
-function extractOrgWastelandId(pathname: string): { orgId: string; wastelandId: string } | null {
- const match = pathname.match(new RegExp(`^/organizations/(${UUID})/wasteland/(${UUID})`));
- return match ? { orgId: match[1], wastelandId: match[2] } : null;
+/** Extract {orgIdentifier, wastelandId} from an /organizations/[id]/wasteland/[wastelandId] pathname, or null. */
+function extractOrgWastelandId(
+ pathname: string
+): { orgIdentifier: string; wastelandId: string } | null {
+ const match = pathname.match(
+ new RegExp(`^/organizations/(${ORG_ROUTE_IDENTIFIER})/wasteland/(${UUID})`)
+ );
+ return match ? { orgIdentifier: decodeURIComponent(match[1]), wastelandId: match[2] } : null;
}
export default function AppSidebar(props: React.ComponentProps) {
- const currentOrgId = useUrlOrganizationId();
+ const trpc = useTRPC();
+ const currentOrgIdentifier = useUrlOrganizationIdentifier();
const pathname = usePathname();
const { open, setOpenMobile, setOpenTransient } = useSidebar();
const previousSidebarOpen = useRef(null);
const currentSidebarOpen = useRef(open);
const sidebarActions = useRef({ setOpenMobile, setOpenTransient });
+ const { data: organizations = [] } = useQuery(
+ trpc.organizations.list.queryOptions(undefined, {
+ enabled: Boolean(currentOrgIdentifier),
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ })
+ );
+ const currentOrgFromList = findOrganizationByRouteIdentifier(
+ organizations.map(org => ({
+ id: org.organizationId,
+ slug: org.organizationSlug,
+ })),
+ currentOrgIdentifier
+ );
+ const currentOrgId =
+ currentOrgFromList?.id ??
+ (currentOrgIdentifier && isUuidOrganizationRouteIdentifier(currentOrgIdentifier)
+ ? currentOrgIdentifier
+ : null);
useEffect(() => {
currentSidebarOpen.current = open;
@@ -80,7 +121,7 @@ export default function AppSidebar(props: React.ComponentProps)
// Org gastown town — show the same sidebar with org-prefixed paths
const orgGastown = extractOrgGastownTownId(pathname);
if (orgGastown) {
- const orgBase = `/organizations/${orgGastown.orgId}`;
+ const orgBase = `/organizations/${orgGastown.orgIdentifier}`;
return (
)
// Org wasteland — show the same sidebar with org-prefixed paths
const orgWasteland = extractOrgWastelandId(pathname);
if (orgWasteland) {
- const orgBase = `/organizations/${orgWasteland.orgId}`;
+ const orgBase = `/organizations/${orgWasteland.orgIdentifier}`;
return (
{
+ it('extracts UUID organization route identifiers', () => {
+ expect(
+ getUrlOrganizationIdentifier('/organizations/550e8400-e29b-41d4-a716-446655440000')
+ ).toBe('550e8400-e29b-41d4-a716-446655440000');
+ });
+
+ it('extracts slug organization route identifiers', () => {
+ expect(getUrlOrganizationIdentifier('/organizations/acme-inc/claw/chat')).toBe('acme-inc');
+ });
+
+ it('decodes route identifiers before using them as organization context keys', () => {
+ expect(getUrlOrganizationIdentifier('/organizations/acme%2Dinc/payment-details')).toBe(
+ 'acme-inc'
+ );
+ });
+
+ it('returns null outside organization routes', () => {
+ expect(getUrlOrganizationIdentifier('/profile')).toBeNull();
+ });
+});
diff --git a/apps/web/src/hooks/useUrlOrganizationId.ts b/apps/web/src/hooks/useUrlOrganizationId.ts
index 14e6fc99fd..3a0de05da8 100644
--- a/apps/web/src/hooks/useUrlOrganizationId.ts
+++ b/apps/web/src/hooks/useUrlOrganizationId.ts
@@ -1,20 +1,27 @@
import { usePathname } from 'next/navigation';
import { useMemo } from 'react';
-const ORG_PATH_REGEX =
- /^\/organizations\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
+const ORG_PATH_REGEX = /^\/organizations\/([^/?#]+)/;
+
+export function getUrlOrganizationIdentifier(pathname: string): string | null {
+ const orgMatch = pathname.match(ORG_PATH_REGEX);
+ return orgMatch ? decodeURIComponent(orgMatch[1]) : null;
+}
/**
- * Hook to extract organization ID from the current URL pathname.
+ * Hook to extract organization route identifier from the current URL pathname.
* Returns null if not viewing an organization page.
*
- * Uses useMemo (not useEffect) so the org ID is available on the first render,
+ * Uses useMemo (not useEffect) so the identifier is available on the first render,
* avoiding a flash of "Personal Workspace" before the org name appears.
*/
-export function useUrlOrganizationId(): string | null {
+export function useUrlOrganizationIdentifier(): string | null {
const pathname = usePathname();
return useMemo(() => {
- const orgMatch = pathname.match(ORG_PATH_REGEX);
- return orgMatch ? orgMatch[1] : null;
+ return getUrlOrganizationIdentifier(pathname);
}, [pathname]);
}
+
+export function useUrlOrganizationId(): string | null {
+ return useUrlOrganizationIdentifier();
+}
diff --git a/apps/web/src/lib/organizations/organization-route-utils.server.ts b/apps/web/src/lib/organizations/organization-route-utils.server.ts
index f4535c93f8..e7fc431be8 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.server.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.server.ts
@@ -5,6 +5,7 @@ import { and, eq, isNull } from 'drizzle-orm';
import { db } from '@/lib/drizzle';
import {
getOrganizationRouteIdentifier,
+ isUuidOrganizationRouteIdentifier,
type OrganizationRouteIdentifierInput,
} from '@/lib/organizations/organization-route-utils';
@@ -12,9 +13,6 @@ export type ResolvedOrganizationRouteIdentifier = OrganizationRouteIdentifierInp
routeIdentifier: string;
};
-const UUID_ROUTE_IDENTIFIER_PATTERN =
- /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
-
export async function resolveOrganizationRouteIdentifierDetails(
identifier: string
): Promise {
@@ -23,7 +21,7 @@ export async function resolveOrganizationRouteIdentifierDetails(
.from(organizations)
.where(
and(
- UUID_ROUTE_IDENTIFIER_PATTERN.test(identifier)
+ isUuidOrganizationRouteIdentifier(identifier)
? eq(organizations.id, identifier)
: eq(organizations.slug, identifier),
isNull(organizations.deleted_at)
diff --git a/apps/web/src/lib/organizations/organization-route-utils.test.ts b/apps/web/src/lib/organizations/organization-route-utils.test.ts
index 6222e677ae..1350b43802 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.test.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.test.ts
@@ -3,7 +3,10 @@ import { db } from '@/lib/drizzle';
import { organizations } from '@kilocode/db/schema';
import { inArray } from 'drizzle-orm';
import {
+ findOrganizationByRouteIdentifier,
getOrganizationRouteIdentifier,
+ isOrganizationRouteIdentifierMatch,
+ isUuidOrganizationRouteIdentifier,
ORGANIZATION_SLUG_MAX_LENGTH,
} from './organization-route-utils';
import {
@@ -25,6 +28,47 @@ describe('getOrganizationRouteIdentifier', () => {
});
});
+describe('organization route identifier matching', () => {
+ const organizationsForRouteMatching = [
+ { id: '550e8400-e29b-41d4-a716-446655440000', slug: 'acme' },
+ { id: '550e8400-e29b-41d4-a716-446655440001', slug: null },
+ ];
+
+ it('matches organizations by slug or id', () => {
+ expect(isOrganizationRouteIdentifierMatch(organizationsForRouteMatching[0], 'acme')).toBe(true);
+ expect(
+ isOrganizationRouteIdentifierMatch(
+ organizationsForRouteMatching[0],
+ '550e8400-e29b-41d4-a716-446655440000'
+ )
+ ).toBe(true);
+ });
+
+ it('finds an organization by slug route identifier', () => {
+ expect(findOrganizationByRouteIdentifier(organizationsForRouteMatching, 'acme')).toEqual(
+ organizationsForRouteMatching[0]
+ );
+ });
+
+ it('finds an organization by id route identifier', () => {
+ expect(
+ findOrganizationByRouteIdentifier(
+ organizationsForRouteMatching,
+ '550e8400-e29b-41d4-a716-446655440001'
+ )
+ ).toEqual(organizationsForRouteMatching[1]);
+ });
+
+ it('returns null when there is no route identifier', () => {
+ expect(findOrganizationByRouteIdentifier(organizationsForRouteMatching, null)).toBeNull();
+ });
+
+ it('detects UUID route identifiers', () => {
+ expect(isUuidOrganizationRouteIdentifier('550e8400-e29b-41d4-a716-446655440000')).toBe(true);
+ expect(isUuidOrganizationRouteIdentifier('acme')).toBe(false);
+ });
+});
+
describe('resolveOrganizationRouteIdentifier', () => {
afterEach(async () => {
await db
diff --git a/apps/web/src/lib/organizations/organization-route-utils.ts b/apps/web/src/lib/organizations/organization-route-utils.ts
index f47498bfdc..80613e88ab 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.ts
@@ -5,8 +5,32 @@ export type OrganizationRouteIdentifierInput = {
slug: string | null;
};
+const UUID_ROUTE_IDENTIFIER_PATTERN =
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
+
export function getOrganizationRouteIdentifier(
organization: OrganizationRouteIdentifierInput
): string {
return organization.slug ?? organization.id;
}
+
+export function isUuidOrganizationRouteIdentifier(identifier: string): boolean {
+ return UUID_ROUTE_IDENTIFIER_PATTERN.test(identifier);
+}
+
+export function isOrganizationRouteIdentifierMatch(
+ organization: OrganizationRouteIdentifierInput,
+ routeIdentifier: string
+): boolean {
+ return organization.id === routeIdentifier || organization.slug === routeIdentifier;
+}
+
+export function findOrganizationByRouteIdentifier(
+ organizations: readonly T[],
+ routeIdentifier: string | null | undefined
+): T | null {
+ if (!routeIdentifier) return null;
+ return (
+ organizations.find(org => isOrganizationRouteIdentifierMatch(org, routeIdentifier)) ?? null
+ );
+}
From f222f943256bf187343feb85e8a59f2f5ece61af Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 14:49:44 -0500
Subject: [PATCH 13/33] cleanly print slug name error
---
.../organizations/OrganizationInfoCard.tsx | 24 ++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index ef63395773..af2d0f7b07 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -86,6 +86,28 @@ type OrganizationHierarchySectionProps = {
parent: OrganizationHierarchySummary | null;
};
+function getOrganizationSlugErrorMessage(error: unknown): string {
+ if (!(error instanceof Error)) return 'Slug is not available';
+
+ try {
+ const parsed = JSON.parse(error.message) as unknown;
+ if (Array.isArray(parsed)) {
+ const firstIssue = parsed.find(
+ issue =>
+ typeof issue === 'object' &&
+ issue !== null &&
+ 'message' in issue &&
+ typeof issue.message === 'string'
+ );
+ if (firstIssue?.message) return firstIssue.message;
+ }
+ } catch {
+ // Non-JSON errors are already user-readable.
+ }
+
+ return error.message || 'Slug is not available';
+}
+
function OrganizationHierarchySection({ parent }: OrganizationHierarchySectionProps) {
if (!parent) {
return null;
@@ -251,7 +273,7 @@ function Inner(props: InnerProps) {
setIsEditingSlug(false);
} catch (error) {
console.error('Failed to update organization slug:', error);
- setSlugError(error instanceof Error ? error.message : 'Slug is not available');
+ setSlugError(getOrganizationSlugErrorMessage(error));
}
};
From addfc51baa100ff0d2a0999cfce7ac411d37e9ed Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 15:06:30 -0500
Subject: [PATCH 14/33] Forbid underscores
---
.../organizations/organization-slug.server.ts | 56 +++++++++++++++++++
.../lib/organizations/organization-slug.ts | 34 +++++++++++
.../lib/organizations/organizations.test.ts | 28 ++++++++++
.../src/lib/organizations/organizations.ts | 3 +
.../organization-admin-router.test.ts | 14 ++++-
.../organization-admin-router.ts | 3 +
.../organizations/organization-router.test.ts | 17 +++++-
7 files changed, 151 insertions(+), 4 deletions(-)
create mode 100644 apps/web/src/lib/organizations/organization-slug.server.ts
create mode 100644 apps/web/src/lib/organizations/organization-slug.ts
diff --git a/apps/web/src/lib/organizations/organization-slug.server.ts b/apps/web/src/lib/organizations/organization-slug.server.ts
new file mode 100644
index 0000000000..b73be5f9ab
--- /dev/null
+++ b/apps/web/src/lib/organizations/organization-slug.server.ts
@@ -0,0 +1,56 @@
+import 'server-only';
+
+import { randomBytes } from 'crypto';
+import { eq } from 'drizzle-orm';
+import { organizations } from '@kilocode/db/schema';
+import { sql, type DrizzleTransaction } from '@/lib/drizzle';
+import {
+ appendOrganizationSlugCollisionSuffix,
+ normalizeOrganizationSlug,
+ ORGANIZATION_SLUG_COLLISION_SUFFIX_LENGTH,
+} from '@/lib/organizations/organization-slug';
+
+const ORGANIZATION_SLUG_ALLOCATION_LOCK_KEY_1 = 20260625;
+const ORGANIZATION_SLUG_ALLOCATION_LOCK_KEY_2 = 1;
+const MAX_ORGANIZATION_SLUG_ALLOCATION_ATTEMPTS = 32;
+
+async function organizationSlugExists(slug: string, tx: DrizzleTransaction): Promise {
+ const [existingOrganization] = await tx
+ .select({ id: organizations.id })
+ .from(organizations)
+ .where(eq(organizations.slug, slug))
+ .limit(1);
+
+ return existingOrganization !== undefined;
+}
+
+function generateOrganizationSlugCollisionSuffix(): string {
+ return randomBytes(2).toString('hex').slice(0, ORGANIZATION_SLUG_COLLISION_SUFFIX_LENGTH);
+}
+
+export async function allocateOrganizationSlug(
+ name: string,
+ tx: DrizzleTransaction
+): Promise {
+ await tx.execute(
+ sql`SELECT pg_advisory_xact_lock(${ORGANIZATION_SLUG_ALLOCATION_LOCK_KEY_1}, ${ORGANIZATION_SLUG_ALLOCATION_LOCK_KEY_2})`
+ );
+
+ const baseSlug = normalizeOrganizationSlug(name);
+
+ for (let attempt = 0; attempt < MAX_ORGANIZATION_SLUG_ALLOCATION_ATTEMPTS; attempt += 1) {
+ const candidateSlug =
+ attempt === 0
+ ? baseSlug
+ : appendOrganizationSlugCollisionSuffix(
+ baseSlug,
+ generateOrganizationSlugCollisionSuffix()
+ );
+
+ if (!(await organizationSlugExists(candidateSlug, tx))) {
+ return candidateSlug;
+ }
+ }
+
+ throw new Error(`Failed to allocate organization slug for "${name}"`);
+}
diff --git a/apps/web/src/lib/organizations/organization-slug.ts b/apps/web/src/lib/organizations/organization-slug.ts
new file mode 100644
index 0000000000..55eba8e8b9
--- /dev/null
+++ b/apps/web/src/lib/organizations/organization-slug.ts
@@ -0,0 +1,34 @@
+import { ORGANIZATION_SLUG_MAX_LENGTH } from '@/lib/organizations/organization-route-utils';
+
+export const ORGANIZATION_SLUG_COLLISION_SUFFIX_LENGTH = 3;
+
+const ORGANIZATION_SLUG_FALLBACK_BASE = 'org';
+const ORGANIZATION_SLUG_SUFFIX_SEPARATOR_LENGTH = 1;
+
+function truncateSlug(slug: string, maxLength: number): string {
+ const truncated = slug.slice(0, maxLength).replace(/-+$/g, '');
+ return truncated || ORGANIZATION_SLUG_FALLBACK_BASE;
+}
+
+export function normalizeOrganizationSlug(name: string): string {
+ const slug = name
+ .normalize('NFKD')
+ .replace(/[\u0300-\u036f]/g, '')
+ .toLowerCase()
+ .replace(/3/g, 'e')
+ .replace(/[.\s]+/g, '-')
+ .replace(/[^a-z0-9-]/g, '')
+ .replace(/-+/g, '-')
+ .replace(/^-+|-+$/g, '');
+
+ return truncateSlug(slug || ORGANIZATION_SLUG_FALLBACK_BASE, ORGANIZATION_SLUG_MAX_LENGTH);
+}
+
+export function appendOrganizationSlugCollisionSuffix(slug: string, suffix: string): string {
+ const baseMaxLength =
+ ORGANIZATION_SLUG_MAX_LENGTH -
+ ORGANIZATION_SLUG_SUFFIX_SEPARATOR_LENGTH -
+ ORGANIZATION_SLUG_COLLISION_SUFFIX_LENGTH;
+ const base = truncateSlug(slug, baseMaxLength);
+ return `${base}-${suffix}`;
+}
diff --git a/apps/web/src/lib/organizations/organizations.test.ts b/apps/web/src/lib/organizations/organizations.test.ts
index 2bb4bc30bb..546712cf0a 100644
--- a/apps/web/src/lib/organizations/organizations.test.ts
+++ b/apps/web/src/lib/organizations/organizations.test.ts
@@ -22,6 +22,7 @@ import {
} from './organizations';
import { fromMicrodollars } from '@/lib/utils';
import { DEFAULT_MEMBER_DAILY_LIMIT_USD } from '@/lib/organizations/constants';
+import { normalizeOrganizationSlug } from '@/lib/organizations/organization-slug';
describe('Organizations', () => {
afterEach(async () => {
@@ -37,6 +38,33 @@ describe('Organizations', () => {
await db.delete(organizations);
});
+ describe('organization slug creation', () => {
+ test('normalizes organization names into reusable slugs', () => {
+ expect(normalizeOrganizationSlug("Evan's Test Org")).toBe('evans-test-org');
+ expect(normalizeOrganizationSlug('Money.7R33$')).toBe('money-7ree');
+ expect(normalizeOrganizationSlug('Team_Alpha Beta.Gamma!')).toBe('teamalpha-beta-gamma');
+ });
+
+ test('stores the normalized organization slug when creating an organization', async () => {
+ const user = await insertTestUser();
+
+ const organization = await createOrganization("Evan's Test Org", user.id);
+
+ expect(organization.slug).toBe('evans-test-org');
+ });
+
+ test('appends a three-character suffix when the normalized slug collides', async () => {
+ const firstUser = await insertTestUser();
+ const secondUser = await insertTestUser();
+
+ const firstOrganization = await createOrganization('Demo Example Org', firstUser.id);
+ const secondOrganization = await createOrganization('Demo Example Org', secondUser.id);
+
+ expect(firstOrganization.slug).toBe('demo-example-org');
+ expect(secondOrganization.slug).toMatch(/^demo-example-org-[0-9a-f]{3}$/);
+ });
+ });
+
describe('getUserOrganizationsWithSeats', () => {
test('should return empty array when user has no organizations', async () => {
const user = await insertTestUser();
diff --git a/apps/web/src/lib/organizations/organizations.ts b/apps/web/src/lib/organizations/organizations.ts
index c310249ad5..76e0ede14c 100644
--- a/apps/web/src/lib/organizations/organizations.ts
+++ b/apps/web/src/lib/organizations/organizations.ts
@@ -27,6 +27,7 @@ import { APP_URL } from '@/lib/constants';
import { createAuditLog } from '@/lib/organizations/organization-audit-logs';
import { failureResult, successResult } from '@/lib/maybe-result';
import { reportEvents } from '@/lib/ai-gateway/abuse-service';
+import { allocateOrganizationSlug } from '@/lib/organizations/organization-slug.server';
export async function getOrganizationById(
id: Organization['id'],
@@ -190,11 +191,13 @@ export async function createOrganization(
const organization = await db.transaction(async tx => {
const now = new Date();
const trialEndDate = new Date(now.getTime() + TRIAL_DURATION_DAYS * 24 * 60 * 60 * 1000);
+ const slug = await allocateOrganizationSlug(name, tx);
const [org] = await tx
.insert(organizations)
.values({
name,
+ slug,
require_seats: true,
created_by_kilo_user_id: userId,
free_trial_end_at: trialEndDate.toISOString(),
diff --git a/apps/web/src/routers/organizations/organization-admin-router.test.ts b/apps/web/src/routers/organizations/organization-admin-router.test.ts
index 41a100d84c..80a9851f81 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.test.ts
@@ -10,6 +10,7 @@ import {
import { eq, and, inArray, sql } from 'drizzle-orm';
import { insertTestUser } from '@/tests/helpers/user.helper';
import { createOrganization, addUserToOrganization } from '@/lib/organizations/organizations';
+import { normalizeOrganizationSlug } from '@/lib/organizations/organization-slug';
import { KiloPassCadence, KiloPassTier } from '@/lib/kilo-pass/enums';
import type { User, Organization } from '@kilocode/db/schema';
@@ -825,14 +826,18 @@ describe('organization admin router', () => {
describe('hierarchy management', () => {
it('creates an empty child organization under a parent organization', async () => {
- const searchPrefix = `Admin Create Child Org ${crypto.randomUUID()}`;
- const parentOrganization = await createOrganization(`${searchPrefix} parent`, adminUser.id);
+ const searchId = crypto.randomUUID();
+ const parentOrganization = await createOrganization(
+ `Parent Admin Org ${searchId}`,
+ adminUser.id
+ );
+ const childOrganizationName = `Child Admin Org ${searchId}`;
const caller = await createCallerForUser(adminUser.id);
let childOrganizationId: string | null = null;
try {
const result = await caller.organizations.admin.create({
- name: `${searchPrefix} child`,
+ name: childOrganizationName,
parentOrganizationId: parentOrganization.id,
});
childOrganizationId = result.organization.id;
@@ -842,6 +847,7 @@ describe('organization admin router', () => {
parent_organization_id: organizations.parent_organization_id,
require_seats: organizations.require_seats,
free_trial_end_at: organizations.free_trial_end_at,
+ slug: organizations.slug,
settings: organizations.settings,
member_count: sql`(
SELECT COUNT(*)::int
@@ -855,10 +861,12 @@ describe('organization admin router', () => {
expect(result.organization.parent_organization_id).toBe(parentOrganization.id);
expect(result.organization.require_seats).toBe(false);
expect(result.organization.free_trial_end_at).toBeNull();
+ expect(result.organization.slug).toBe(normalizeOrganizationSlug(childOrganizationName));
expect(result.organization.settings.suppress_trial_messaging).toBe(true);
expect(childOrganization.parent_organization_id).toBe(parentOrganization.id);
expect(childOrganization.require_seats).toBe(false);
expect(childOrganization.free_trial_end_at).toBeNull();
+ expect(childOrganization.slug).toBe(normalizeOrganizationSlug(childOrganizationName));
expect(childOrganization.settings.suppress_trial_messaging).toBe(true);
expect(childOrganization.member_count).toBe(0);
} finally {
diff --git a/apps/web/src/routers/organizations/organization-admin-router.ts b/apps/web/src/routers/organizations/organization-admin-router.ts
index 9ba24591e6..17dd63f60b 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.ts
@@ -51,6 +51,7 @@ import {
ORGANIZATION_TRIAL_ACTIVE_MIN_DAYS_REMAINING,
ORGANIZATION_TRIAL_DURATION_DAYS,
} from '@kilocode/organization-entitlement';
+import { allocateOrganizationSlug } from '@/lib/organizations/organization-slug.server';
const OrganizationListInputSchema = z.object({
page: z.number().int().min(1).default(1),
@@ -301,11 +302,13 @@ export const organizationAdminRouter = createTRPCRouter({
const organization = await db.transaction(async tx => {
await tx.execute(sql`SELECT pg_advisory_xact_lock(20260624, 1)`);
+ const slug = await allocateOrganizationSlug(opts.input.name, tx);
const [createdOrganization] = await tx
.insert(organizations)
.values({
name: opts.input.name,
+ slug,
require_seats: false,
free_trial_end_at: null,
parent_organization_id: parentOrganizationId,
diff --git a/apps/web/src/routers/organizations/organization-router.test.ts b/apps/web/src/routers/organizations/organization-router.test.ts
index 0f8cab3578..76f5be62a7 100644
--- a/apps/web/src/routers/organizations/organization-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-router.test.ts
@@ -247,7 +247,11 @@ describe('organizations trpc router', () => {
});
expect(result.childOrganizations).toEqual([
- { id: childOrganization.id, name: 'Child Label Organization', slug: null },
+ {
+ id: childOrganization.id,
+ name: 'Child Label Organization',
+ slug: 'child-label-organization',
+ },
]);
const member = result.members.find(m => m.status === 'active' && m.id === parentMember.id);
expect(member).toMatchObject({
@@ -661,6 +665,17 @@ describe('organizations trpc router', () => {
})
).rejects.toThrow('Requested slug is not available');
});
+
+ it('rejects slugs with underscores', async () => {
+ const caller = await createCallerForUser(regularUser.id);
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'invalid_slug',
+ })
+ ).rejects.toThrow('Organization slug must use lowercase letters, numbers, and hyphens');
+ });
});
describe('createOrganization with company_domain', () => {
From 312962e35894df516c3915f6be94c78caee26b14 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 15:16:29 -0500
Subject: [PATCH 15/33] fix(orgs): add admin slug backfill
---
.../organization-admin-router.test.ts | 93 +++++++++++++++++++
.../organization-admin-router.ts | 65 +++++++++++++
2 files changed, 158 insertions(+)
diff --git a/apps/web/src/routers/organizations/organization-admin-router.test.ts b/apps/web/src/routers/organizations/organization-admin-router.test.ts
index 80a9851f81..3331c422dd 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.test.ts
@@ -51,6 +51,99 @@ describe('organization admin router', () => {
await db.delete(organizations).where(eq(organizations.id, testOrganization.id));
});
+ describe('backfillMissingSlugs', () => {
+ it('rejects non-admin callers', async () => {
+ const organization = await createOrganization(
+ `Backfill Non Admin ${crypto.randomUUID()}`,
+ null
+ );
+
+ try {
+ await db
+ .update(organizations)
+ .set({ slug: null })
+ .where(eq(organizations.id, organization.id));
+
+ const caller = await createCallerForUser(nonAdminUser.id);
+ await expect(caller.organizations.admin.backfillMissingSlugs()).rejects.toThrow(
+ 'Admin access required'
+ );
+
+ const [unchangedOrganization] = await db
+ .select({ slug: organizations.slug })
+ .from(organizations)
+ .where(eq(organizations.id, organization.id));
+ expect(unchangedOrganization.slug).toBeNull();
+ } finally {
+ await db.delete(organizations).where(eq(organizations.id, organization.id));
+ }
+ });
+
+ it('backfills missing organization slugs once', async () => {
+ const suffix = crypto.randomUUID();
+ const existingOrganization = await createOrganization(`Backfill Legacy ${suffix}`, null);
+ const missingOrganization = await createOrganization(`Backfill Legacy ${suffix}`, null);
+ const otherMissingOrganization = await createOrganization(
+ `Backfill Other Legacy ${suffix}`,
+ null
+ );
+ const organizationIds = [
+ existingOrganization.id,
+ missingOrganization.id,
+ otherMissingOrganization.id,
+ ];
+
+ try {
+ await db
+ .update(organizations)
+ .set({ slug: null, total_microdollars_acquired: 1_000_000 })
+ .where(eq(organizations.id, missingOrganization.id));
+
+ await db
+ .update(organizations)
+ .set({ slug: null, total_microdollars_acquired: 2_000_000 })
+ .where(eq(organizations.id, otherMissingOrganization.id));
+
+ const caller = await createCallerForUser(adminUser.id);
+ const result = await caller.organizations.admin.backfillMissingSlugs();
+ const backfilledRows = result.organizations.filter(organization =>
+ organizationIds.includes(organization.id)
+ );
+
+ expect(backfilledRows).toHaveLength(2);
+ expect(backfilledRows.map(organization => organization.id)).toEqual([
+ otherMissingOrganization.id,
+ missingOrganization.id,
+ ]);
+ expect(result.updatedCount).toBeGreaterThanOrEqual(2);
+
+ const updatedOrganizations = await db
+ .select({ id: organizations.id, slug: organizations.slug })
+ .from(organizations)
+ .where(inArray(organizations.id, organizationIds));
+ const updatedSlugByOrganizationId = new Map(
+ updatedOrganizations.map(organization => [organization.id, organization.slug])
+ );
+
+ expect(updatedSlugByOrganizationId.get(existingOrganization.id)).toBe(
+ normalizeOrganizationSlug(existingOrganization.name)
+ );
+ expect(updatedSlugByOrganizationId.get(missingOrganization.id)).toBeTruthy();
+ expect(updatedSlugByOrganizationId.get(otherMissingOrganization.id)).toBe(
+ normalizeOrganizationSlug(otherMissingOrganization.name)
+ );
+ expect(updatedSlugByOrganizationId.get(missingOrganization.id)).not.toBe(
+ updatedSlugByOrganizationId.get(existingOrganization.id)
+ );
+
+ const secondResult = await caller.organizations.admin.backfillMissingSlugs();
+ expect(secondResult).toEqual({ updatedCount: 0, organizations: [] });
+ } finally {
+ await db.delete(organizations).where(inArray(organizations.id, organizationIds));
+ }
+ });
+ });
+
describe('nullifyCredits', () => {
beforeEach(async () => {
await db
diff --git a/apps/web/src/routers/organizations/organization-admin-router.ts b/apps/web/src/routers/organizations/organization-admin-router.ts
index 17dd63f60b..10789acf21 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.ts
@@ -190,6 +190,17 @@ const OrganizationMetricsSchema = z.object({
totalSeats: z.number(),
});
+const BackfillMissingSlugsOutputSchema = z.object({
+ updatedCount: z.number(),
+ organizations: z.array(
+ z.object({
+ id: z.string(),
+ name: z.string(),
+ slug: z.string(),
+ })
+ ),
+});
+
const AddMemberInputSchema = z.object({
organizationId: z.uuid(),
userId: z.string(),
@@ -291,6 +302,60 @@ async function validateParentOrganizationChange(
}
export const organizationAdminRouter = createTRPCRouter({
+ // Temporary one-time admin tool. Remove after legacy organizations have slugs.
+ backfillMissingSlugs: adminProcedure
+ .output(BackfillMissingSlugsOutputSchema)
+ .mutation(async () => {
+ const backfilledOrganizations = await db.transaction(async tx => {
+ const organizationsWithoutSlugs = await tx
+ .select({
+ id: organizations.id,
+ name: organizations.name,
+ })
+ .from(organizations)
+ .where(isNull(organizations.slug))
+ .orderBy(
+ desc(organizations.total_microdollars_acquired),
+ asc(organizations.created_at),
+ asc(organizations.id)
+ )
+ .for('update');
+
+ const updatedOrganizations: Array<{
+ id: string;
+ name: string;
+ slug: string;
+ }> = [];
+
+ for (const organization of organizationsWithoutSlugs) {
+ const slug = await allocateOrganizationSlug(organization.name, tx);
+ const [updatedOrganization] = await tx
+ .update(organizations)
+ .set({ slug })
+ .where(and(eq(organizations.id, organization.id), isNull(organizations.slug)))
+ .returning({
+ id: organizations.id,
+ name: organizations.name,
+ slug: organizations.slug,
+ });
+
+ if (updatedOrganization?.slug) {
+ updatedOrganizations.push({
+ ...updatedOrganization,
+ slug: updatedOrganization.slug,
+ });
+ }
+ }
+
+ return updatedOrganizations;
+ });
+
+ return {
+ updatedCount: backfilledOrganizations.length,
+ organizations: backfilledOrganizations,
+ };
+ }),
+
create: adminProcedure.input(OrganizationCreateInputSchema).mutation(async opts => {
const parentOrganizationId = opts.input.parentOrganizationId ?? null;
From 7487b7448a626581142058cf19fdb65f65efcf91 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 15:35:27 -0500
Subject: [PATCH 16/33] fix(orgs): restrict kilo slug generation
---
.../organization-route-utils.test.ts | 20 +++++-
.../lib/organizations/organization-slug.ts | 64 +++++++++++++++++--
.../lib/organizations/organizations.test.ts | 6 ++
.../organizations/organization-router.test.ts | 43 +++++++++++++
.../organizations/organization-router.ts | 15 +++++
5 files changed, 143 insertions(+), 5 deletions(-)
diff --git a/apps/web/src/lib/organizations/organization-route-utils.test.ts b/apps/web/src/lib/organizations/organization-route-utils.test.ts
index 1350b43802..c45e1fd0a3 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.test.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.test.ts
@@ -73,7 +73,14 @@ describe('resolveOrganizationRouteIdentifier', () => {
afterEach(async () => {
await db
.delete(organizations)
- .where(inArray(organizations.slug, ['route-id-org', 'route-slug-org', 'deleted-route-org']));
+ .where(
+ inArray(organizations.slug, [
+ 'route-id-org',
+ 'route-slug-org',
+ 'deleted-route-org',
+ 'persisted-kilocode-org',
+ ])
+ );
});
it('resolves organization ids', async () => {
@@ -98,6 +105,17 @@ describe('resolveOrganizationRouteIdentifier', () => {
);
});
+ it('resolves already persisted slugs containing reserved terms', async () => {
+ const [organization] = await db
+ .insert(organizations)
+ .values({ name: 'Persisted Kilo Slug Org', slug: 'persisted-kilocode-org' })
+ .returning();
+
+ await expect(resolveOrganizationRouteIdentifier('persisted-kilocode-org')).resolves.toBe(
+ organization.id
+ );
+ });
+
it('returns the canonical route identifier', async () => {
const [organization] = await db
.insert(organizations)
diff --git a/apps/web/src/lib/organizations/organization-slug.ts b/apps/web/src/lib/organizations/organization-slug.ts
index 55eba8e8b9..585148e432 100644
--- a/apps/web/src/lib/organizations/organization-slug.ts
+++ b/apps/web/src/lib/organizations/organization-slug.ts
@@ -2,12 +2,65 @@ import { ORGANIZATION_SLUG_MAX_LENGTH } from '@/lib/organizations/organization-r
export const ORGANIZATION_SLUG_COLLISION_SUFFIX_LENGTH = 3;
-const ORGANIZATION_SLUG_FALLBACK_BASE = 'org';
const ORGANIZATION_SLUG_SUFFIX_SEPARATOR_LENGTH = 1;
+const ORGANIZATION_SLUG_RESERVED_SUBSTRINGS = ['kilo'];
+const ORGANIZATION_SLUG_FALLBACK_ADJECTIVES = [
+ 'bright',
+ 'calm',
+ 'clear',
+ 'fresh',
+ 'kind',
+ 'lucky',
+ 'neat',
+ 'prime',
+ 'swift',
+ 'vivid',
+];
+const ORGANIZATION_SLUG_FALLBACK_NOUNS = [
+ 'atlas',
+ 'bridge',
+ 'field',
+ 'harbor',
+ 'lantern',
+ 'maple',
+ 'signal',
+ 'summit',
+ 'valley',
+ 'workshop',
+];
function truncateSlug(slug: string, maxLength: number): string {
- const truncated = slug.slice(0, maxLength).replace(/-+$/g, '');
- return truncated || ORGANIZATION_SLUG_FALLBACK_BASE;
+ return slug.slice(0, maxLength).replace(/-+$/g, '');
+}
+
+function pickRandomSlugWord(words: readonly string[]): string {
+ return words[Math.floor(Math.random() * words.length)] ?? words[0] ?? 'team';
+}
+
+function randomFallbackSlug(): string {
+ const adjective = pickRandomSlugWord(ORGANIZATION_SLUG_FALLBACK_ADJECTIVES);
+ const noun = pickRandomSlugWord(ORGANIZATION_SLUG_FALLBACK_NOUNS);
+
+ return `${adjective}-${noun}`;
+}
+
+function normalizeSlugSeparators(slug: string): string {
+ return slug.replace(/-+/g, '-').replace(/^-+|-+$/g, '');
+}
+
+function removeReservedSlugSubstrings(slug: string): string {
+ let cleanedSlug = slug;
+ for (const reservedSubstring of ORGANIZATION_SLUG_RESERVED_SUBSTRINGS) {
+ cleanedSlug = cleanedSlug.replaceAll(reservedSubstring, '');
+ }
+ return normalizeSlugSeparators(cleanedSlug);
+}
+
+export function organizationSlugContainsReservedSubstring(slug: string): boolean {
+ const normalizedSlug = slug.toLowerCase();
+ return ORGANIZATION_SLUG_RESERVED_SUBSTRINGS.some(reservedSubstring =>
+ normalizedSlug.includes(reservedSubstring)
+ );
}
export function normalizeOrganizationSlug(name: string): string {
@@ -21,7 +74,10 @@ export function normalizeOrganizationSlug(name: string): string {
.replace(/-+/g, '-')
.replace(/^-+|-+$/g, '');
- return truncateSlug(slug || ORGANIZATION_SLUG_FALLBACK_BASE, ORGANIZATION_SLUG_MAX_LENGTH);
+ const slugWithoutReservedSubstrings = removeReservedSlugSubstrings(slug);
+ const truncatedSlug = truncateSlug(slugWithoutReservedSubstrings, ORGANIZATION_SLUG_MAX_LENGTH);
+
+ return truncatedSlug || randomFallbackSlug();
}
export function appendOrganizationSlugCollisionSuffix(slug: string, suffix: string): string {
diff --git a/apps/web/src/lib/organizations/organizations.test.ts b/apps/web/src/lib/organizations/organizations.test.ts
index 546712cf0a..bd035268ee 100644
--- a/apps/web/src/lib/organizations/organizations.test.ts
+++ b/apps/web/src/lib/organizations/organizations.test.ts
@@ -43,6 +43,12 @@ describe('Organizations', () => {
expect(normalizeOrganizationSlug("Evan's Test Org")).toBe('evans-test-org');
expect(normalizeOrganizationSlug('Money.7R33$')).toBe('money-7ree');
expect(normalizeOrganizationSlug('Team_Alpha Beta.Gamma!')).toBe('teamalpha-beta-gamma');
+ expect(normalizeOrganizationSlug('Kilo Test Org')).toBe('test-org');
+ expect(normalizeOrganizationSlug('Kilocode Team')).toBe('code-team');
+ expect(normalizeOrganizationSlug('mykiloorg')).toBe('myorg');
+ expect(normalizeOrganizationSlug('Kilo')).toMatch(/^[a-z]+-[a-z]+$/);
+ expect(normalizeOrganizationSlug('')).toMatch(/^[a-z]+-[a-z]+$/);
+ expect(normalizeOrganizationSlug('!!!')).toMatch(/^[a-z]+-[a-z]+$/);
});
test('stores the normalized organization slug when creating an organization', async () => {
diff --git a/apps/web/src/routers/organizations/organization-router.test.ts b/apps/web/src/routers/organizations/organization-router.test.ts
index 76f5be62a7..c65769774a 100644
--- a/apps/web/src/routers/organizations/organization-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-router.test.ts
@@ -10,6 +10,7 @@ import type { User, Organization } from '@kilocode/db/schema';
let regularUser: User;
let adminUser: User;
let creditManagerUser: User;
+let staffCreditManagerUser: User;
let adminWithoutCreditAccessUser: User;
let memberUser: User;
let nonMemberUser: User;
@@ -37,6 +38,13 @@ describe('organizations trpc router', () => {
can_manage_credits: true,
});
+ staffCreditManagerUser = await insertTestUser({
+ google_user_email: 'staff-credit-manager-org@kilocode.ai',
+ google_user_name: 'Staff Credit Manager Org User',
+ is_admin: true,
+ can_manage_credits: true,
+ });
+
adminWithoutCreditAccessUser = await insertTestUser({
google_user_email: 'admin-without-credit-org@admin.example.com',
google_user_name: 'Admin Without Credit Org User',
@@ -622,6 +630,23 @@ describe('organizations trpc router', () => {
expect(result.organization.slug).toBe('support-slug');
});
+ it('allows Kilo staff to edit slugs containing reserved terms', async () => {
+ const caller = await createCallerForUser(staffCreditManagerUser.id);
+
+ const result = await caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'kilocode-org',
+ });
+
+ expect(result.organization.slug).toBe('kilocode-org');
+
+ const [updatedOrg] = await db
+ .select({ slug: organizations.slug })
+ .from(organizations)
+ .where(eq(organizations.id, testOrganization.id));
+ expect(updatedOrg.slug).toBe('kilocode-org');
+ });
+
it('rejects admins without credit management access when they are not org members', async () => {
const caller = await createCallerForUser(adminWithoutCreditAccessUser.id);
@@ -676,6 +701,24 @@ describe('organizations trpc router', () => {
})
).rejects.toThrow('Organization slug must use lowercase letters, numbers, and hyphens');
});
+
+ it('rejects slugs containing reserved terms', async () => {
+ const caller = await createCallerForUser(regularUser.id);
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'my-kilo-org',
+ })
+ ).rejects.toThrow('Organization slug cannot contain reserved terms');
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'kilocode-org',
+ })
+ ).rejects.toThrow('Organization slug cannot contain reserved terms');
+ });
});
describe('createOrganization with company_domain', () => {
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index abcdccc7cf..b3c51e12dd 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -66,6 +66,7 @@ import { organizationAutoTopUpRouter } from '@/routers/organizations/organizatio
import { organizationKiloclawRouter } from '@/routers/organizations/organization-kiloclaw-router';
import { organizationBitbucketRouter } from '@/routers/organizations/organization-bitbucket-router';
import { ORGANIZATION_SLUG_MAX_LENGTH } from '@/lib/organizations/organization-route-utils';
+import { organizationSlugContainsReservedSubstring } from '@/lib/organizations/organization-slug';
const OrganizationUpdateSchema = OrganizationIdInputSchema.extend({
name: OrganizationNameSchema,
@@ -116,6 +117,10 @@ async function ensureOrganizationSlugUpdateAccess(ctx: TRPCContext, organization
});
}
+function isKiloStaffUser(user: TRPCContext['user']): boolean {
+ return user.google_user_email.toLowerCase().endsWith('@kilocode.ai');
+}
+
const OrganizationInvoicesInputSchema = OrganizationIdInputSchema.extend({
period: TimePeriodSchema.optional().default('month'),
});
@@ -456,6 +461,16 @@ export const organizationsRouter = createTRPCRouter({
updateSlug: baseProcedure.input(OrganizationSlugUpdateSchema).mutation(async opts => {
await ensureOrganizationSlugUpdateAccess(opts.ctx, opts.input.organizationId);
if (opts.input.slug) {
+ if (
+ organizationSlugContainsReservedSubstring(opts.input.slug) &&
+ !isKiloStaffUser(opts.ctx.user)
+ ) {
+ throw new TRPCError({
+ code: 'BAD_REQUEST',
+ message: 'Organization slug cannot contain reserved terms',
+ });
+ }
+
await assertActiveSlugAvailable(opts.input.slug, opts.input.organizationId);
}
From 2aa4c7d1ea7b11279e5a940d0049af2b450111a6 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 15:58:52 -0500
Subject: [PATCH 17/33] fix(web): resolve organization routes canonically
---
.../[id]/app-builder/[projectId]/page.tsx | 32 +++----
.../organizations/[id]/app-builder/page.tsx | 30 +++---
.../organizations/[id]/auto-fix/page.tsx | 40 ++++----
.../organizations/[id]/auto-triage/page.tsx | 40 ++++----
.../components/OrgInstancePresenceMount.tsx | 5 +-
.../kilo-chat/OrgKiloChatRootLayoutClient.tsx | 43 +++++++++
.../[id]/claw/kilo-chat/layout.tsx | 44 ++++-----
.../(app)/organizations/[id]/claw/layout.tsx | 13 ++-
.../[id]/cloud/(agent)/chat/page.tsx | 21 +----
.../[id]/cloud/(agent)/layout.tsx | 8 +-
.../organizations/[id]/cloud/(agent)/page.tsx | 29 +++---
.../[id]/gastown/[townId]/page.tsx | 11 ++-
.../[townId]/rigs/[rigId]/settings/page.tsx | 6 +-
.../[id]/gastown/[townId]/settings/page.tsx | 6 +-
.../integrations/linear/reinstall/route.ts | 10 +-
.../integrations/slack/reinstall/route.ts | 8 +-
.../src/app/(app)/organizations/[id]/page.tsx | 21 +++--
.../[id]/payment-details/page.tsx | 20 ++--
.../welcome/OrganizationWelcomePageClient.tsx | 63 +++++++++++++
.../organizations/[id]/welcome/layout.tsx | 21 +----
.../(app)/organizations/[id]/welcome/page.tsx | 70 ++------------
.../components/app-builder/AppBuilderPage.tsx | 14 ++-
.../OrganizationByPageLayout.tsx | 45 +++------
.../organization-page-context.server.ts | 93 +++++++++++++++++++
.../organization-route-utils.server.ts | 7 ++
25 files changed, 398 insertions(+), 302 deletions(-)
create mode 100644 apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/OrgKiloChatRootLayoutClient.tsx
create mode 100644 apps/web/src/app/(app)/organizations/[id]/welcome/OrganizationWelcomePageClient.tsx
create mode 100644 apps/web/src/lib/organizations/organization-page-context.server.ts
diff --git a/apps/web/src/app/(app)/organizations/[id]/app-builder/[projectId]/page.tsx b/apps/web/src/app/(app)/organizations/[id]/app-builder/[projectId]/page.tsx
index bd5e7e5e5f..0b02b200aa 100644
--- a/apps/web/src/app/(app)/organizations/[id]/app-builder/[projectId]/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/app-builder/[projectId]/page.tsx
@@ -1,34 +1,30 @@
-import { notFound, redirect } from 'next/navigation';
+import { notFound } from 'next/navigation';
import { AppBuilderPage } from '@/components/app-builder/AppBuilderPage';
-import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
import { isFeatureFlagEnabled } from '@/lib/posthog-feature-flags';
-import { signInUrlWithCallbackPath } from '@/lib/user/server';
type Props = {
params: Promise<{ id: string; projectId: string }>;
};
export default async function OrgAppBuilderProjectPage({ params }: Props) {
- const { id, projectId } = await params;
- const organizationId = decodeURIComponent(id);
+ const [{ projectId }, { user, organization, canonicalRouteIdentifier }] = await Promise.all([
+ params,
+ requireCanonicalOrganizationRouteContext(params),
+ ]);
- const result = await getAuthorizedOrgContext(organizationId);
- if (!result.success) {
- if (result.nextResponse.status === 401) {
- redirect(await signInUrlWithCallbackPath());
- }
- redirect('/profile');
- }
-
- const isAppBuilderEnabled = await isFeatureFlagEnabled(
- 'app-builder-feature',
- result.data.user.id
- );
+ const isAppBuilderEnabled = await isFeatureFlagEnabled('app-builder-feature', user.id);
const isDevelopment = process.env.NODE_ENV === 'development';
if (!isAppBuilderEnabled && !isDevelopment) {
return notFound();
}
- return ;
+ return (
+
+ );
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/app-builder/page.tsx b/apps/web/src/app/(app)/organizations/[id]/app-builder/page.tsx
index 929215f2ea..aec1c5eddc 100644
--- a/apps/web/src/app/(app)/organizations/[id]/app-builder/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/app-builder/page.tsx
@@ -1,34 +1,28 @@
-import { notFound, redirect } from 'next/navigation';
+import { notFound } from 'next/navigation';
import { AppBuilderPage } from '@/components/app-builder/AppBuilderPage';
-import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
import { isFeatureFlagEnabled } from '@/lib/posthog-feature-flags';
-import { signInUrlWithCallbackPath } from '@/lib/user/server';
type Props = {
params: Promise<{ id: string }>;
};
export default async function OrgAppBuilderPage({ params }: Props) {
- const { id } = await params;
- const organizationId = decodeURIComponent(id);
+ const { user, organization, canonicalRouteIdentifier } =
+ await requireCanonicalOrganizationRouteContext(params);
- const result = await getAuthorizedOrgContext(organizationId);
- if (!result.success) {
- if (result.nextResponse.status === 401) {
- redirect(await signInUrlWithCallbackPath());
- }
- redirect('/profile');
- }
-
- const isAppBuilderEnabled = await isFeatureFlagEnabled(
- 'app-builder-feature',
- result.data.user.id
- );
+ const isAppBuilderEnabled = await isFeatureFlagEnabled('app-builder-feature', user.id);
const isDevelopment = process.env.NODE_ENV === 'development';
if (!isAppBuilderEnabled && !isDevelopment) {
return notFound();
}
- return ;
+ return (
+
+ );
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx b/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx
index d2c5596cdd..9abbd94805 100644
--- a/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx
@@ -9,31 +9,31 @@ type AutoFixPageProps = {
};
export default async function AutoFixPage({ params, searchParams }: AutoFixPageProps) {
- const { id: organizationId } = await params;
const search = await searchParams;
- // Feature flags - use server-side check with organization ID as distinct ID
- const isAutoTriageFeatureEnabled = await isFeatureFlagEnabled(
- 'auto-triage-feature',
- organizationId
- );
- const isDevelopment = process.env.NODE_ENV === 'development';
-
- if (!isAutoTriageFeatureEnabled && !isDevelopment) {
- return notFound();
- }
-
return (
(
-
- )}
+ render={async ({ organization }) => {
+ const isAutoTriageFeatureEnabled = await isFeatureFlagEnabled(
+ 'auto-triage-feature',
+ organization.id
+ );
+ const isDevelopment = process.env.NODE_ENV === 'development';
+
+ if (!isAutoTriageFeatureEnabled && !isDevelopment) {
+ return notFound();
+ }
+
+ return (
+
+ );
+ }}
/>
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx b/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx
index 63e0cab3d3..733907197f 100644
--- a/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx
@@ -9,31 +9,31 @@ type AutoTriagePageProps = {
};
export default async function AutoTriagePage({ params, searchParams }: AutoTriagePageProps) {
- const { id: organizationId } = await params;
const search = await searchParams;
- // Feature flags - use server-side check with organization ID as distinct ID
- const isAutoTriageFeatureEnabled = await isFeatureFlagEnabled(
- 'auto-triage-feature',
- organizationId
- );
- const isDevelopment = process.env.NODE_ENV === 'development';
-
- if (!isAutoTriageFeatureEnabled && !isDevelopment) {
- return notFound();
- }
-
return (
(
-
- )}
+ render={async ({ organization }) => {
+ const isAutoTriageFeatureEnabled = await isFeatureFlagEnabled(
+ 'auto-triage-feature',
+ organization.id
+ );
+ const isDevelopment = process.env.NODE_ENV === 'development';
+
+ if (!isAutoTriageFeatureEnabled && !isDevelopment) {
+ return notFound();
+ }
+
+ return (
+
+ );
+ }}
/>
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/components/OrgInstancePresenceMount.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/components/OrgInstancePresenceMount.tsx
index 23c300b371..d79d40c109 100644
--- a/apps/web/src/app/(app)/organizations/[id]/claw/components/OrgInstancePresenceMount.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/components/OrgInstancePresenceMount.tsx
@@ -1,12 +1,9 @@
'use client';
-import { useParams } from 'next/navigation';
import { useInstancePresence } from '@/hooks/useInstancePresence';
import { useOrgKiloClawStatus } from '@/hooks/useOrgKiloClaw';
-export function OrgInstancePresenceMount() {
- const params = useParams<{ id: string }>();
- const organizationId = params?.id;
+export function OrgInstancePresenceMount({ organizationId }: { organizationId: string }) {
const { data: status } = useOrgKiloClawStatus(organizationId);
useInstancePresence(status?.sandboxId ?? undefined);
return null;
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/OrgKiloChatRootLayoutClient.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/OrgKiloChatRootLayoutClient.tsx
new file mode 100644
index 0000000000..87fae95cc2
--- /dev/null
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/OrgKiloChatRootLayoutClient.tsx
@@ -0,0 +1,43 @@
+'use client';
+
+import { useUser } from '@/hooks/useUser';
+import { useOrgKiloClawStatus } from '@/hooks/useOrgKiloClaw';
+import { KiloChatLayout } from '@/app/(app)/claw/kilo-chat/components/KiloChatLayout';
+
+type OrgKiloChatRootLayoutClientProps = {
+ children: React.ReactNode;
+ organizationId: string;
+ organizationRouteIdentifier: string;
+};
+
+export function OrgKiloChatRootLayoutClient({
+ children,
+ organizationId,
+ organizationRouteIdentifier,
+}: OrgKiloChatRootLayoutClientProps) {
+ const { data: user } = useUser();
+ const { data: status, error, isError, isLoading, refetch } = useOrgKiloClawStatus(organizationId);
+ const instanceErrorMessage =
+ error instanceof Error ? error.message : error ? 'Unknown error' : null;
+
+ const basePath = `/organizations/${organizationRouteIdentifier}/claw/kilo-chat`;
+ const noInstanceRedirect = `/organizations/${organizationRouteIdentifier}/claw/new`;
+
+ return (
+ void refetch()}
+ assistantName={status?.botName ?? null}
+ assistantEmoji={status?.botEmoji ?? null}
+ >
+ {children}
+
+ );
+}
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/layout.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/layout.tsx
index 97b03a9158..71760abec1 100644
--- a/apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/layout.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/kilo-chat/layout.tsx
@@ -1,36 +1,24 @@
-'use client';
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
+import { OrgKiloChatRootLayoutClient } from './OrgKiloChatRootLayoutClient';
-import { useParams } from 'next/navigation';
-import { useUser } from '@/hooks/useUser';
-import { useOrgKiloClawStatus } from '@/hooks/useOrgKiloClaw';
-import { KiloChatLayout } from '@/app/(app)/claw/kilo-chat/components/KiloChatLayout';
+type OrgKiloChatRootLayoutProps = {
+ children: React.ReactNode;
+ params: Promise<{ id: string }>;
+};
-export default function OrgKiloChatRootLayout({ children }: { children: React.ReactNode }) {
- const params = useParams<{ id: string }>();
- const organizationId = params.id;
- const { data: user } = useUser();
- const { data: status, error, isError, isLoading, refetch } = useOrgKiloClawStatus(organizationId);
- const instanceErrorMessage =
- error instanceof Error ? error.message : error ? 'Unknown error' : null;
-
- const basePath = `/organizations/${organizationId}/claw/kilo-chat`;
- const noInstanceRedirect = `/organizations/${organizationId}/claw/new`;
+export default async function OrgKiloChatRootLayout({
+ children,
+ params,
+}: OrgKiloChatRootLayoutProps) {
+ const { organization, canonicalRouteIdentifier } =
+ await requireCanonicalOrganizationRouteContext(params);
return (
- void refetch()}
- assistantName={status?.botName ?? null}
- assistantEmoji={status?.botEmoji ?? null}
+
{children}
-
+
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/layout.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/layout.tsx
index 81e90f5079..f6116c0349 100644
--- a/apps/web/src/app/(app)/organizations/[id]/claw/layout.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/layout.tsx
@@ -1,11 +1,20 @@
import { PylonSupportButton } from '@/components/pylon-support-button';
import { PylonWidget } from '@/components/pylon-widget';
import { OrgInstancePresenceMount } from './components/OrgInstancePresenceMount';
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
+
+export default async function OrgClawLayout({
+ children,
+ params,
+}: {
+ children: React.ReactNode;
+ params: Promise<{ id: string }>;
+}) {
+ const { organization } = await requireCanonicalOrganizationRouteContext(params);
-export default function OrgClawLayout({ children }: { children: React.ReactNode }) {
return (
<>
-
+
{children}
diff --git a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/chat/page.tsx b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/chat/page.tsx
index 1c55cc22d4..b8378bfb7b 100644
--- a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/chat/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/chat/page.tsx
@@ -1,9 +1,7 @@
-import { redirect } from 'next/navigation';
import { isNewSession } from '@/lib/cloud-agent/session-type';
import { LegacySessionViewer } from '@/components/cloud-agent-next/LegacySessionViewer';
import { CloudChatPageWrapperNext } from './CloudChatPageWrapperNext';
-import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
-import { signInUrlWithCallbackPath } from '@/lib/user/server';
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
type PageProps = {
params: Promise<{ id: string }>;
@@ -11,22 +9,13 @@ type PageProps = {
};
export default async function OrganizationCloudChatPage({ params, searchParams }: PageProps) {
- const { id } = await params;
- const organizationId = decodeURIComponent(id);
-
- const result = await getAuthorizedOrgContext(organizationId);
- if (!result.success) {
- if (result.nextResponse.status === 401) {
- redirect(await signInUrlWithCallbackPath());
- }
- redirect('/profile');
- }
-
+ const { organization, canonicalRouteIdentifier } =
+ await requireCanonicalOrganizationRouteContext(params);
const { sessionId } = await searchParams;
if (!sessionId || isNewSession(sessionId)) {
- return ;
+ return ;
}
- return ;
+ return ;
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx
index f7f605f547..901b1bf92e 100644
--- a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx
@@ -1,6 +1,7 @@
import { Suspense } from 'react';
import { CloudAgentProvider } from '@/components/cloud-agent-next/CloudAgentProvider';
import { CloudSidebarLayout } from '@/components/cloud-agent-next/CloudSidebarLayout';
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
export default async function OrgCloudAgentLayout({
children,
@@ -9,13 +10,12 @@ export default async function OrgCloudAgentLayout({
children: React.ReactNode;
params: Promise<{ id: string }>;
}) {
- const { id } = await params;
- const organizationId = decodeURIComponent(id);
+ const { organization } = await requireCanonicalOrganizationRouteContext(params);
return (
-
+
Loading... }>
- {children}
+ {children}
);
diff --git a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx
index a370830a4b..ce6c2c447f 100644
--- a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx
@@ -1,5 +1,4 @@
import { OrganizationByPageLayout } from '@/components/organizations/OrganizationByPageLayout';
-import { getUserFromAuthOrRedirect } from '@/lib/user/server';
import { isFeatureFlagEnabledOrDevelopment } from '@/lib/posthog-feature-flags';
import { NewSessionPanel } from '@/components/cloud-agent-next/NewSessionPanel';
@@ -8,25 +7,21 @@ export default async function OrganizationCloudPage({
}: {
params: Promise<{ id: string }>;
}) {
- const { id } = await params;
- const organizationId = decodeURIComponent(id);
- await getUserFromAuthOrRedirect(
- `/users/sign_in?callbackPath=${encodeURIComponent(`/organizations/${organizationId}/cloud`)}`
- );
- const isDevcontainerAvailable = await isFeatureFlagEnabledOrDevelopment(
- 'cloud-agent-devcontainer',
- organizationId
- );
-
return (
(
-
- )}
+ render={async ({ organization }) => {
+ const isDevcontainerAvailable = await isFeatureFlagEnabledOrDevelopment(
+ 'cloud-agent-devcontainer',
+ organization.id
+ );
+ return (
+
+ );
+ }}
/>
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/page.tsx b/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/page.tsx
index e1aef4452b..1052c9ac16 100644
--- a/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/page.tsx
@@ -6,14 +6,17 @@ export default async function OrgTownOverviewPage({
}: {
params: Promise<{ id: string; townId: string }>;
}) {
- const { id, townId } = await params;
- const basePath = `/organizations/${id}/gastown/${townId}`;
+ const { townId } = await params;
return (
(
-
+ render={({ organization, organizationRouteIdentifier }) => (
+
)}
/>
);
diff --git a/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/rigs/[rigId]/settings/page.tsx b/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/rigs/[rigId]/settings/page.tsx
index 72ab31603d..a6e91f6624 100644
--- a/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/rigs/[rigId]/settings/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/rigs/[rigId]/settings/page.tsx
@@ -6,13 +6,13 @@ export default async function OrgRigSettingsPage({
}: {
params: Promise<{ id: string; townId: string; rigId: string }>;
}) {
- const { id: organizationId, townId, rigId } = await params;
+ const { townId, rigId } = await params;
return (
(
-
+ render={({ organization }) => (
+
)}
/>
);
diff --git a/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/settings/page.tsx b/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/settings/page.tsx
index 2dbe200b98..b92effc009 100644
--- a/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/settings/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/gastown/[townId]/settings/page.tsx
@@ -6,16 +6,16 @@ export default async function OrgTownSettingsPage({
}: {
params: Promise<{ id: string; townId: string }>;
}) {
- const { id: organizationId, townId } = await params;
+ const { townId } = await params;
return (
(
+ render={({ role, organization }) => (
)}
/>
diff --git a/apps/web/src/app/(app)/organizations/[id]/integrations/linear/reinstall/route.ts b/apps/web/src/app/(app)/organizations/[id]/integrations/linear/reinstall/route.ts
index 0227b57cc4..ed74269f14 100644
--- a/apps/web/src/app/(app)/organizations/[id]/integrations/linear/reinstall/route.ts
+++ b/apps/web/src/app/(app)/organizations/[id]/integrations/linear/reinstall/route.ts
@@ -5,13 +5,14 @@ import { ensureOrganizationAccess } from '@/routers/organizations/utils';
import { requireActiveSubscriptionOrTrial } from '@/lib/organizations/trial-middleware';
import { PLATFORM } from '@/lib/integrations/core/constants';
import { getPlatformOAuthConnectPath } from '@/lib/integrations/oauth/paths';
+import { resolveOrganizationRouteParams } from '@/lib/organizations/organization-route-utils.server';
type RouteContext = {
params: Promise<{ id: string }>;
};
export async function GET(request: NextRequest, context: RouteContext) {
- const { id } = await context.params;
+ const organizationId = await resolveOrganizationRouteParams(context.params);
const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false });
if (authFailedResponse || !user) {
const signInUrl = new URL('/users/sign_in', request.url);
@@ -20,13 +21,14 @@ export async function GET(request: NextRequest, context: RouteContext) {
}
try {
- await ensureOrganizationAccess({ user }, id, ['owner', 'billing_manager']);
- await requireActiveSubscriptionOrTrial(id);
+ if (!organizationId) throw new Error('Organization not found');
+ await ensureOrganizationAccess({ user }, organizationId, ['owner', 'billing_manager']);
+ await requireActiveSubscriptionOrTrial(organizationId);
} catch {
return NextResponse.redirect(new URL('/integrations?error=unauthorized', request.url));
}
return NextResponse.redirect(
- new URL(getPlatformOAuthConnectPath(PLATFORM.LINEAR, id), request.url)
+ new URL(getPlatformOAuthConnectPath(PLATFORM.LINEAR, organizationId), request.url)
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/integrations/slack/reinstall/route.ts b/apps/web/src/app/(app)/organizations/[id]/integrations/slack/reinstall/route.ts
index c95439f971..a9ee7df850 100644
--- a/apps/web/src/app/(app)/organizations/[id]/integrations/slack/reinstall/route.ts
+++ b/apps/web/src/app/(app)/organizations/[id]/integrations/slack/reinstall/route.ts
@@ -4,13 +4,14 @@ import { getUserFromAuth } from '@/lib/user/server';
import { ensureOrganizationAccess } from '@/routers/organizations/utils';
import { PLATFORM } from '@/lib/integrations/core/constants';
import { getPlatformOAuthConnectPath } from '@/lib/integrations/oauth/paths';
+import { resolveOrganizationRouteParams } from '@/lib/organizations/organization-route-utils.server';
type RouteContext = {
params: Promise<{ id: string }>;
};
export async function GET(request: NextRequest, context: RouteContext) {
- const { id } = await context.params;
+ const organizationId = await resolveOrganizationRouteParams(context.params);
const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false });
if (authFailedResponse || !user) {
const signInUrl = new URL('/users/sign_in', request.url);
@@ -19,12 +20,13 @@ export async function GET(request: NextRequest, context: RouteContext) {
}
try {
- await ensureOrganizationAccess({ user }, id);
+ if (!organizationId) throw new Error('Organization not found');
+ await ensureOrganizationAccess({ user }, organizationId);
} catch {
return NextResponse.redirect(new URL('/integrations?error=unauthorized', request.url));
}
return NextResponse.redirect(
- new URL(getPlatformOAuthConnectPath(PLATFORM.SLACK, id), request.url)
+ new URL(getPlatformOAuthConnectPath(PLATFORM.SLACK, organizationId), request.url)
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/page.tsx b/apps/web/src/app/(app)/organizations/[id]/page.tsx
index b17a6421c9..0f14b26cf1 100644
--- a/apps/web/src/app/(app)/organizations/[id]/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/page.tsx
@@ -10,22 +10,23 @@ export default async function OrganizationByIdPage({
params: Promise<{ id: string }>;
searchParams: Promise>;
}) {
- const { id: organizationId } = await params;
const search = new URLSearchParams(await searchParams);
const topupAmount = Number.parseFloat(search.get(TOPUP_AMOUNT_QUERY_STRING_KEY) || '0') || 0;
- const isAutoTopUpEnabled = await isOrgAutoTopUpFeatureEnabled(organizationId);
return (
(
-
- )}
+ render={async ({ role, organization }) => {
+ const isAutoTopUpEnabled = await isOrgAutoTopUpFeatureEnabled(organization.id);
+ return (
+
+ );
+ }}
/>
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/payment-details/page.tsx b/apps/web/src/app/(app)/organizations/[id]/payment-details/page.tsx
index 659b9490e8..3497465fc3 100644
--- a/apps/web/src/app/(app)/organizations/[id]/payment-details/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/payment-details/page.tsx
@@ -7,19 +7,19 @@ export default async function OrganizationPaymentDetailsPage({
}: {
params: Promise<{ id: string }>;
}) {
- const { id: organizationId } = await params;
- const isAutoTopUpEnabled = await isOrgAutoTopUpFeatureEnabled(organizationId);
-
return (
(
-
- )}
+ render={async ({ role, organization }) => {
+ const isAutoTopUpEnabled = await isOrgAutoTopUpFeatureEnabled(organization.id);
+ return (
+
+ );
+ }}
/>
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/welcome/OrganizationWelcomePageClient.tsx b/apps/web/src/app/(app)/organizations/[id]/welcome/OrganizationWelcomePageClient.tsx
new file mode 100644
index 0000000000..57c887e1a6
--- /dev/null
+++ b/apps/web/src/app/(app)/organizations/[id]/welcome/OrganizationWelcomePageClient.tsx
@@ -0,0 +1,63 @@
+'use client';
+
+import { useEffect, useState } from 'react';
+import { PageLayout } from '@/components/PageLayout';
+import { InviteMemberDialog } from '@/components/organizations/members/InviteMemberDialog';
+import CreditPurchaseOptions from '@/components/payment/CreditPurchaseOptions';
+import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
+import { OrganizationAdminContextProvider } from '@/components/organizations/OrganizationContextWrapper';
+import { OrganizationWelcomeCards } from '@/components/organizations/welcome/OrganizationWelcomeCards';
+
+type OrganizationWelcomePageClientProps = {
+ organizationId: string;
+};
+
+export function OrganizationWelcomePageClient({
+ organizationId,
+}: OrganizationWelcomePageClientProps) {
+ const [blockClose, setBlockClose] = useState(false);
+ const [isInviteDialogOpen, setIsInviteDialogOpen] = useState(false);
+ const [isCreditDialogOpen, setIsCreditDialogOpen] = useState(false);
+
+ useEffect(() => {
+ const urlParams = new URLSearchParams(window.location.search);
+ if (urlParams.get('firstTime') !== '1') return;
+
+ setBlockClose(true);
+ setIsInviteDialogOpen(true);
+
+ const url = new URL(window.location.href);
+ url.searchParams.delete('firstTime');
+ window.history.replaceState({}, '', url.pathname + url.search);
+ }, []);
+
+ return (
+
+
+ setIsInviteDialogOpen(true)}
+ onBuyCreditsClick={() => setIsCreditDialogOpen(true)}
+ />
+
+ {
+ setBlockClose(false);
+ }}
+ blockClose={blockClose}
+ />
+
+
+
+
+ Purchase Credits
+
+
+
+
+
+
+ );
+}
diff --git a/apps/web/src/app/(app)/organizations/[id]/welcome/layout.tsx b/apps/web/src/app/(app)/organizations/[id]/welcome/layout.tsx
index 5a1a681d75..cda1610afb 100644
--- a/apps/web/src/app/(app)/organizations/[id]/welcome/layout.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/welcome/layout.tsx
@@ -1,22 +1,3 @@
-import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
-import { signInUrlWithCallbackPath } from '@/lib/user/server';
-import { redirect } from 'next/navigation';
-
-export default async function WelcomeLayout({
- children,
- params,
-}: {
- children: React.ReactNode;
- params: Promise<{ id: string }>;
-}) {
- const { id } = await params;
- const organizationId = decodeURIComponent(id);
- const result = await getAuthorizedOrgContext(organizationId);
- if (!result.success) {
- if (result.nextResponse.status === 401) {
- redirect(await signInUrlWithCallbackPath());
- }
- redirect('/profile');
- }
+export default function WelcomeLayout({ children }: { children: React.ReactNode }) {
return <>{children}>;
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/welcome/page.tsx b/apps/web/src/app/(app)/organizations/[id]/welcome/page.tsx
index 5bc27e9210..6f6ea9d453 100644
--- a/apps/web/src/app/(app)/organizations/[id]/welcome/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/welcome/page.tsx
@@ -1,65 +1,11 @@
-'use client';
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
+import { OrganizationWelcomePageClient } from './OrganizationWelcomePageClient';
-import { useState, useEffect } from 'react';
-import { PageLayout } from '@/components/PageLayout';
-import { InviteMemberDialog } from '@/components/organizations/members/InviteMemberDialog';
-import CreditPurchaseOptions from '@/components/payment/CreditPurchaseOptions';
-import { useParams } from 'next/navigation';
-import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
-import { OrganizationAdminContextProvider } from '@/components/organizations/OrganizationContextWrapper';
-import { OrganizationWelcomeCards } from '@/components/organizations/welcome/OrganizationWelcomeCards';
+type OrganizationStartPageProps = {
+ params: Promise<{ id: string }>;
+};
-export default function OrganizationStartPage() {
- const params = useParams();
- const orgId = params.id as string;
- const [blockClose, setBlockClose] = useState(false);
- const [isInviteDialogOpen, setIsInviteDialogOpen] = useState(false);
- const [isCreditDialogOpen, setIsCreditDialogOpen] = useState(false);
-
- // Check for firstTime query param on mount and remove from URL
- useEffect(() => {
- if (typeof window !== 'undefined') {
- const urlParams = new URLSearchParams(window.location.search);
- if (urlParams.get('firstTime') === '1') {
- setBlockClose(true);
- setIsInviteDialogOpen(true);
-
- // Remove query param from URL without adding to history
- const url = new URL(window.location.href);
- url.searchParams.delete('firstTime');
- window.history.replaceState({}, '', url.pathname + url.search);
- }
- }
- }, []);
-
- return (
-
-
- setIsInviteDialogOpen(true)}
- onBuyCreditsClick={() => setIsCreditDialogOpen(true)}
- />
-
- {
- setBlockClose(false);
- }}
- blockClose={blockClose}
- />
-
- {/* Credit Purchase Dialog */}
-
-
-
- Purchase Credits
-
-
-
-
-
-
- );
+export default async function OrganizationStartPage({ params }: OrganizationStartPageProps) {
+ const { organization } = await requireCanonicalOrganizationRouteContext(params);
+ return ;
}
diff --git a/apps/web/src/components/app-builder/AppBuilderPage.tsx b/apps/web/src/components/app-builder/AppBuilderPage.tsx
index e9a826218f..6187305fe9 100644
--- a/apps/web/src/components/app-builder/AppBuilderPage.tsx
+++ b/apps/web/src/components/app-builder/AppBuilderPage.tsx
@@ -23,6 +23,7 @@ import { AppBuilderLanding } from './AppBuilderLanding';
type AppBuilderPageProps = {
organizationId?: string; // undefined for personal context
+ organizationRouteIdentifier?: string; // undefined for personal context
projectId?: string; // undefined for new project
};
@@ -46,19 +47,24 @@ function AppBuilderProjectView({ organizationId }: { organizationId?: string })
);
}
-export function AppBuilderPage({ organizationId, projectId }: AppBuilderPageProps) {
+export function AppBuilderPage({
+ organizationId,
+ organizationRouteIdentifier,
+ projectId,
+}: AppBuilderPageProps) {
const router = useRouter();
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
// Handle project creation from landing page
const handleProjectCreated = useCallback(
(createdProjectId: string, _prompt: string) => {
// Navigate to the project page - ProjectLoader will handle loading
- const newPath = organizationId
- ? `/organizations/${organizationId}/app-builder/${createdProjectId}`
+ const newPath = organizationPathIdentifier
+ ? `/organizations/${organizationPathIdentifier}/app-builder/${createdProjectId}`
: `/app-builder/${createdProjectId}`;
router.replace(newPath);
},
- [organizationId, router]
+ [organizationPathIdentifier, router]
);
// Show landing if no projectId
diff --git a/apps/web/src/components/organizations/OrganizationByPageLayout.tsx b/apps/web/src/components/organizations/OrganizationByPageLayout.tsx
index 9866380599..516c5feaa8 100644
--- a/apps/web/src/components/organizations/OrganizationByPageLayout.tsx
+++ b/apps/web/src/components/organizations/OrganizationByPageLayout.tsx
@@ -1,16 +1,9 @@
'use server';
-import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
-import { signInUrlWithCallbackPath } from '@/lib/user/server';
import type { OrganizationRole } from '@/lib/organizations/organization-types';
import type { Organization } from '@kilocode/db/schema';
-import { redirect } from 'next/navigation';
-import { headers } from 'next/headers';
import type { JSX } from 'react';
import { OrganizationTrialWrapper } from './OrganizationTrialWrapper';
-import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
-
-const UUID_ROUTE_IDENTIFIER_PATTERN =
- /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
+import { requireCanonicalOrganizationRouteContext } from '@/lib/organizations/organization-page-context.server';
export async function OrganizationByPageLayout({
params,
@@ -22,41 +15,29 @@ export async function OrganizationByPageLayout({
render: ({
role,
organization,
+ organizationRouteIdentifier,
isGlobalAdmin,
}: {
role: OrganizationRole;
organization: Organization;
+ organizationRouteIdentifier: string;
isGlobalAdmin: boolean;
- }) => JSX.Element;
+ }) => JSX.Element | Promise;
roles?: OrganizationRole[];
/** When true, skip the PageContainer wrapper (used by gastown fullscreen pages). */
fullBleed?: boolean;
}) {
- const { id } = await params;
- const organizationId = decodeURIComponent(id);
- const result = await getAuthorizedOrgContext(organizationId, roles);
- if (!result.success) {
- if (result.nextResponse.status === 401) {
- redirect(await signInUrlWithCallbackPath());
- }
- redirect('/profile');
- }
- const { user, organization } = result.data;
- const organizationRouteIdentifier = getOrganizationRouteIdentifier(organization);
- if (
- UUID_ROUTE_IDENTIFIER_PATTERN.test(organizationId) &&
- organizationRouteIdentifier !== organizationId
- ) {
- const pathname = (await headers()).get('x-pathname') ?? `/organizations/${id}`;
- redirect(
- pathname.replace(`/organizations/${id}`, `/organizations/${organizationRouteIdentifier}`)
- );
- }
+ const context = await requireCanonicalOrganizationRouteContext(params, roles);
- const role = user.is_admin ? 'owner' : user.role;
+ const role = context.user.is_admin ? 'owner' : context.user.role;
return (
-
- {render({ role, organization, isGlobalAdmin: user.is_admin })}
+
+ {await render({
+ role,
+ organization: context.organization,
+ organizationRouteIdentifier: context.canonicalRouteIdentifier,
+ isGlobalAdmin: context.user.is_admin,
+ })}
);
}
diff --git a/apps/web/src/lib/organizations/organization-page-context.server.ts b/apps/web/src/lib/organizations/organization-page-context.server.ts
new file mode 100644
index 0000000000..034c607141
--- /dev/null
+++ b/apps/web/src/lib/organizations/organization-page-context.server.ts
@@ -0,0 +1,93 @@
+import 'server-only';
+
+import { headers } from 'next/headers';
+import { redirect } from 'next/navigation';
+import type { Organization, User } from '@kilocode/db/schema';
+import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
+import type { OrganizationRole } from '@/lib/organizations/organization-types';
+import {
+ getOrganizationRouteIdentifier,
+ isUuidOrganizationRouteIdentifier,
+} from '@/lib/organizations/organization-route-utils';
+import { signInUrlWithCallbackPath } from '@/lib/user/server';
+
+export type OrganizationRouteParams = Promise<{ id: string }>;
+
+export type AuthorizedOrganizationRouteContext = {
+ rawRouteIdentifier: string;
+ routeIdentifier: string;
+ canonicalRouteIdentifier: string;
+ user: User & { readonly role: OrganizationRole };
+ organization: Organization;
+};
+
+export async function getAuthorizedOrganizationRouteContext(
+ params: OrganizationRouteParams,
+ roles?: OrganizationRole[]
+) {
+ const { id } = await params;
+ const routeIdentifier = decodeURIComponent(id);
+ const result = await getAuthorizedOrgContext(routeIdentifier, roles);
+
+ return {
+ rawRouteIdentifier: id,
+ routeIdentifier,
+ result,
+ };
+}
+
+export async function requireAuthorizedOrganizationRouteContext(
+ params: OrganizationRouteParams,
+ roles?: OrganizationRole[]
+): Promise {
+ const { rawRouteIdentifier, routeIdentifier, result } =
+ await getAuthorizedOrganizationRouteContext(params, roles);
+
+ if (!result.success) {
+ if (result.nextResponse.status === 401) {
+ redirect(await signInUrlWithCallbackPath());
+ }
+ redirect('/profile');
+ }
+
+ return {
+ rawRouteIdentifier,
+ routeIdentifier,
+ canonicalRouteIdentifier: getOrganizationRouteIdentifier(result.data.organization),
+ user: result.data.user,
+ organization: result.data.organization,
+ };
+}
+
+export async function requireCanonicalOrganizationRouteContext(
+ params: OrganizationRouteParams,
+ roles?: OrganizationRole[]
+): Promise {
+ const context = await requireAuthorizedOrganizationRouteContext(params, roles);
+ await redirectCanonicalOrganizationRouteIfNeeded(context);
+ return context;
+}
+
+export async function redirectCanonicalOrganizationRouteIfNeeded({
+ rawRouteIdentifier,
+ routeIdentifier,
+ canonicalRouteIdentifier,
+}: Pick<
+ AuthorizedOrganizationRouteContext,
+ 'rawRouteIdentifier' | 'routeIdentifier' | 'canonicalRouteIdentifier'
+>) {
+ if (
+ !isUuidOrganizationRouteIdentifier(routeIdentifier) ||
+ canonicalRouteIdentifier === routeIdentifier
+ ) {
+ return;
+ }
+
+ const pathname = (await headers()).get('x-pathname') ?? `/organizations/${rawRouteIdentifier}`;
+ redirect(
+ pathname.replace(
+ `/organizations/${rawRouteIdentifier}`,
+ `/organizations/${canonicalRouteIdentifier}`
+ )
+ );
+}
diff --git a/apps/web/src/lib/organizations/organization-route-utils.server.ts b/apps/web/src/lib/organizations/organization-route-utils.server.ts
index e7fc431be8..d0964b09d3 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.server.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.server.ts
@@ -45,3 +45,10 @@ export async function resolveOrganizationRouteIdentifier(
const organization = await resolveOrganizationRouteIdentifierDetails(identifier);
return organization?.id ?? null;
}
+
+export async function resolveOrganizationRouteParams(
+ params: Promise<{ id: string }>
+): Promise {
+ const { id } = await params;
+ return resolveOrganizationRouteIdentifier(decodeURIComponent(id));
+}
From fce35f3919e3dd3fb8106f60a35d46616b555f30 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 16:41:05 -0500
Subject: [PATCH 18/33] fix(admin): manage organization slugs
---
apps/web/src/app/admin/backfills/page.tsx | 5 +
.../components/OrganizationSlugBackfill.tsx | 97 +++++++++++++++++++
.../useAdminCreditManagementPermission.ts | 3 +-
.../organizations/OrganizationInfoCard.tsx | 9 +-
.../organizations/organization-router.test.ts | 65 +++++++++++++
.../organizations/organization-router.ts | 24 ++---
6 files changed, 189 insertions(+), 14 deletions(-)
create mode 100644 apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
diff --git a/apps/web/src/app/admin/backfills/page.tsx b/apps/web/src/app/admin/backfills/page.tsx
index 50a3755844..33e06e2ab3 100644
--- a/apps/web/src/app/admin/backfills/page.tsx
+++ b/apps/web/src/app/admin/backfills/page.tsx
@@ -3,6 +3,7 @@ import { NormalizedEmailBackfill } from '../components/NormalizedEmailBackfill';
import { EmailDomainBackfill } from '../components/EmailDomainBackfill';
import { BlockBlacklistedDomainsBackfill } from '../components/BlockBlacklistedDomainsBackfill';
import { BlockedAtBackfill } from '../components/BlockedAtBackfill';
+import { OrganizationSlugBackfill } from '../components/OrganizationSlugBackfill';
import { SafetyIdentifierHashGenerator } from '../components/SafetyIdentifierHashGenerator';
import AdminPage from '../components/AdminPage';
import { BreadcrumbItem, BreadcrumbPage } from '@/components/ui/breadcrumb';
@@ -35,6 +36,10 @@ export default function BackfillsPage() {
Blocked At Backfill
+
+
Organization Slug Backfill
+
+
Safety Identifier Backfill
diff --git a/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx b/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
new file mode 100644
index 0000000000..57413e2b23
--- /dev/null
+++ b/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
@@ -0,0 +1,97 @@
+'use client';
+
+import { useState } from 'react';
+import { useMutation, useQueryClient } from '@tanstack/react-query';
+import { Button } from '@/components/ui/button';
+import { Alert, AlertDescription } from '@/components/ui/alert';
+import { Badge } from '@/components/ui/badge';
+import { useTRPC } from '@/lib/trpc/utils';
+
+type BatchLog = {
+ updatedCount: number;
+ timestamp: Date;
+};
+
+export function OrganizationSlugBackfill() {
+ const trpc = useTRPC();
+ const queryClient = useQueryClient();
+ const [logs, setLogs] = useState([]);
+
+ const mutation = useMutation(
+ trpc.organizations.admin.backfillMissingSlugs.mutationOptions({
+ onSuccess: data => {
+ setLogs(prev => [{ updatedCount: data.updatedCount, timestamp: new Date() }, ...prev]);
+ void queryClient.invalidateQueries({ queryKey: ['admin-organizations'] });
+ },
+ })
+ );
+
+ const lastResult = mutation.data;
+ const isDone = lastResult?.updatedCount === 0;
+
+ return (
+
+
+ Backfill organization slugs for legacy organizations missing the field. This scans all
+ missing rows in one transaction and allocates unique slugs from organization names.
+
+
+
+
+ Organizations missing slugs
+ {lastResult ? (
+ isDone ? (
+
+ None updated
+
+ ) : (
+ {lastResult.updatedCount.toLocaleString()} updated
+ )
+ ) : (
+ Not checked
+ )}
+
+
+ {mutation.isError && (
+
+ {mutation.error.message}
+
+ )}
+
+ {lastResult && lastResult.organizations.length > 0 ? (
+
+
+ {lastResult.organizations.map(organization => (
+
+ {organization.name}
+ {organization.slug}
+
+ ))}
+
+
+ ) : null}
+
+
mutation.mutate()} disabled={mutation.isPending}>
+ {mutation.isPending ? 'Backfilling...' : 'Backfill missing slugs'}
+
+
+
+ {logs.length > 0 && (
+
+
Batch log
+
+ {logs.map((log, i) => (
+
+ {log.timestamp.toLocaleTimeString()}
+ backfilled {log.updatedCount.toLocaleString()} organizations
+
+ ))}
+
+
+ )}
+
+ );
+}
diff --git a/apps/web/src/app/admin/useAdminCreditManagementPermission.ts b/apps/web/src/app/admin/useAdminCreditManagementPermission.ts
index e64fa0883f..ef3bfe27e6 100644
--- a/apps/web/src/app/admin/useAdminCreditManagementPermission.ts
+++ b/apps/web/src/app/admin/useAdminCreditManagementPermission.ts
@@ -3,10 +3,11 @@
import { useQuery } from '@tanstack/react-query';
import { useTRPC } from '@/lib/trpc/utils';
-export function useAdminCreditManagementPermission() {
+export function useAdminCreditManagementPermission(options?: { enabled?: boolean }) {
const trpc = useTRPC();
const query = useQuery(
trpc.admin.getPermissions.queryOptions(undefined, {
+ enabled: options?.enabled ?? true,
staleTime: 0,
refetchOnWindowFocus: true,
})
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index af2d0f7b07..0b34ce7c0f 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -47,6 +47,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/comp
import { useExpiringCredits } from './useExpiringCredits';
import { useAdminOrganizationHierarchy } from '@/app/admin/api/organizations/hooks';
import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
+import { useAdminCreditManagementPermission } from '@/app/admin/useAdminCreditManagementPermission';
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString('en-US', {
@@ -334,10 +335,16 @@ function Inner(props: InnerProps) {
};
const isKiloAdmin = useIsKiloAdmin();
+ const orgRole = useUserOrganizationRole();
const isAutoTopUpEnabled = useIsAutoTopUpEnabled();
const isInAdminDashboard = isKiloAdmin && showAdminControls;
const isOrgOwner = useCanManagePaymentInfo();
- const canEditSlug = isOrgOwner || isKiloAdmin;
+ const adminCreditManagementPermission = useAdminCreditManagementPermission({
+ enabled: isKiloAdmin,
+ });
+ const canEditSlug =
+ (orgRole === 'owner' && !showAdminControls) ||
+ (isKiloAdmin && adminCreditManagementPermission.canManageCredits);
const hierarchyQuery = useAdminOrganizationHierarchy(id, isInAdminDashboard);
const handleSeatsRequirementEdit = () => {
diff --git a/apps/web/src/routers/organizations/organization-router.test.ts b/apps/web/src/routers/organizations/organization-router.test.ts
index c65769774a..1b34fdc827 100644
--- a/apps/web/src/routers/organizations/organization-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-router.test.ts
@@ -572,6 +572,71 @@ describe('organizations trpc router', () => {
});
});
+ describe('slugAvailability procedure', () => {
+ let slugAvailabilityConflictOrganization: Organization;
+
+ beforeAll(async () => {
+ slugAvailabilityConflictOrganization = await createOrganization(
+ 'Slug Availability Conflict Organization',
+ memberUser.id
+ );
+ await db
+ .update(organizations)
+ .set({ slug: 'availability-existing-slug' })
+ .where(eq(organizations.id, slugAvailabilityConflictOrganization.id));
+ });
+
+ afterAll(async () => {
+ await db
+ .delete(organizations)
+ .where(eq(organizations.id, slugAvailabilityConflictOrganization.id));
+ });
+
+ it('checks organization slug availability for organization owners', async () => {
+ const caller = await createCallerForUser(regularUser.id);
+
+ await expect(
+ caller.organizations.slugAvailability({
+ organizationId: testOrganization.id,
+ slug: 'owner-available-slug',
+ })
+ ).resolves.toEqual({ available: true });
+ });
+
+ it('checks organization slug availability for credit managers without org membership', async () => {
+ const caller = await createCallerForUser(creditManagerUser.id);
+
+ await expect(
+ caller.organizations.slugAvailability({
+ organizationId: testOrganization.id,
+ slug: 'support-available-slug',
+ })
+ ).resolves.toEqual({ available: true });
+ });
+
+ it('returns unavailable slugs for credit managers without org membership', async () => {
+ const caller = await createCallerForUser(creditManagerUser.id);
+
+ await expect(
+ caller.organizations.slugAvailability({
+ organizationId: testOrganization.id,
+ slug: 'availability-existing-slug',
+ })
+ ).resolves.toEqual({ available: false });
+ });
+
+ it('rejects availability checks for admins without credit management access', async () => {
+ const caller = await createCallerForUser(adminWithoutCreditAccessUser.id);
+
+ await expect(
+ caller.organizations.slugAvailability({
+ organizationId: testOrganization.id,
+ slug: 'admin-no-credit-slug',
+ })
+ ).rejects.toThrow('You do not have access to this organization');
+ });
+ });
+
describe('updateSlug procedure', () => {
let slugConflictOrganization: Organization;
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index b3c51e12dd..3a0f0066c0 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -260,20 +260,20 @@ export const organizationsRouter = createTRPCRouter({
return successResult();
}),
- slugAvailability: organizationMemberProcedure
- .input(OrganizationSlugUpdateSchema)
- .query(async opts => {
- if (!opts.input.slug) {
- return { available: true };
- }
+ slugAvailability: baseProcedure.input(OrganizationSlugUpdateSchema).query(async opts => {
+ await ensureOrganizationSlugUpdateAccess(opts.ctx, opts.input.organizationId);
- const existingOrganization = await getOrganizationByActiveSlug(
- opts.input.slug,
- opts.input.organizationId
- );
+ if (!opts.input.slug) {
+ return { available: true };
+ }
- return { available: !existingOrganization };
- }),
+ const existingOrganization = await getOrganizationByActiveSlug(
+ opts.input.slug,
+ opts.input.organizationId
+ );
+
+ return { available: !existingOrganization };
+ }),
withMembers: organizationMemberProcedure.query(async opts => {
const organizationId = opts.input.organizationId;
From 4c0ca0a923c091012419df950fcf4b93327f56d6 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 16:43:34 -0500
Subject: [PATCH 19/33] feat(organizations): resolve route identifiers
---
.../cloud/sessions/SessionsPageContent.tsx | 19 ++++++++++++-----
.../src/app/(app)/components/AppSidebar.tsx | 14 +++++++++++++
.../[id]/auto-fix/AutoFixPageClient.tsx | 4 +++-
.../organizations/[id]/auto-fix/page.tsx | 3 ++-
.../[id]/auto-triage/AutoTriagePageClient.tsx | 4 +++-
.../organizations/[id]/auto-triage/page.tsx | 3 ++-
.../[id]/claw/OrgClawRedirectClient.tsx | 10 +++++++--
.../claw/chat/OrgChatRootLayoutClient.tsx | 6 ++++--
.../organizations/[id]/claw/chat/layout.tsx | 5 ++++-
.../[id]/claw/new/OrgClawNewClient.tsx | 4 +++-
.../organizations/[id]/claw/new/page.tsx | 1 +
.../(app)/organizations/[id]/claw/page.tsx | 7 ++++++-
.../[id]/cloud/sessions/page.tsx | 7 +++++--
.../code-reviews/ReviewAgentPageClient.tsx | 8 ++++---
.../organizations/[id]/code-reviews/page.tsx | 3 ++-
.../[id]/deploy/DeployPageClient.tsx | 9 ++++++--
.../[id]/deploy/[deploymentId]/page.tsx | 8 +++++--
.../(app)/organizations/[id]/deploy/page.tsx | 7 ++++++-
.../[id]/gastown/OrgTownListPageClient.tsx | 9 ++++++--
.../(app)/organizations/[id]/gastown/page.tsx | 8 +++++--
.../[id]/security-agent/page.tsx | 4 +++-
.../wasteland/OrgWastelandListPageClient.tsx | 16 +++++++++-----
.../organizations/[id]/wasteland/page.tsx | 7 ++++++-
.../components/admin-omnibox/AdminOmnibox.tsx | 12 ++++++++++-
.../integrations/IntegrationDetailPage.tsx | 6 ++++--
.../organization-page-context.server.ts | 8 ++++---
apps/web/src/lib/user/server.ts | 3 ++-
apps/web/src/proxy.ts | 1 +
.../organizations/organization-router.ts | 21 +++++++++++++++++++
29 files changed, 172 insertions(+), 45 deletions(-)
diff --git a/apps/web/src/app/(app)/cloud/sessions/SessionsPageContent.tsx b/apps/web/src/app/(app)/cloud/sessions/SessionsPageContent.tsx
index 672deb8961..48d99acbd4 100644
--- a/apps/web/src/app/(app)/cloud/sessions/SessionsPageContent.tsx
+++ b/apps/web/src/app/(app)/cloud/sessions/SessionsPageContent.tsx
@@ -46,7 +46,15 @@ const PLATFORM_OPTIONS: readonly {
type PlatformFilterValue = 'all' | 'cloud-agent' | 'cli' | 'agent-manager' | 'gastown' | 'other';
-export function SessionsPageContent() {
+type SessionsPageContentProps = {
+ organizationId?: string;
+ organizationRouteIdentifier?: string;
+};
+
+export function SessionsPageContent({
+ organizationId,
+ organizationRouteIdentifier,
+}: SessionsPageContentProps = {}) {
const trpc = useTRPC();
const pathname = usePathname();
const [searchQuery, setSearchQuery] = useState('');
@@ -65,11 +73,12 @@ export function SessionsPageContent() {
return () => clearTimeout(timer);
}, [searchQuery]);
- // Determine if we're in an organization context
- const organizationId = pathname.match(/^\/organizations\/([^/]+)/)?.[1];
-
// When in organization context, OrganizationTrialWrapper already provides PageContainer
const shouldUsePageContainer = !organizationId;
+ const organizationPathIdentifier =
+ organizationRouteIdentifier ??
+ organizationId ??
+ pathname.match(/^\/organizations\/([^/]+)/)?.[1];
const isSearching = debouncedSearchQuery.trim().length > 0;
@@ -242,7 +251,7 @@ export function SessionsPageContent() {
setIsDialogOpen(false)}
diff --git a/apps/web/src/app/(app)/components/AppSidebar.tsx b/apps/web/src/app/(app)/components/AppSidebar.tsx
index 2d90a5bed5..9f66d63659 100644
--- a/apps/web/src/app/(app)/components/AppSidebar.tsx
+++ b/apps/web/src/app/(app)/components/AppSidebar.tsx
@@ -82,8 +82,22 @@ export default function AppSidebar(props: React.ComponentProps)
})),
currentOrgIdentifier
);
+ const { data: resolvedCurrentOrg } = useQuery(
+ trpc.organizations.resolveRouteIdentifier.queryOptions(
+ { routeIdentifier: currentOrgIdentifier ?? '' },
+ {
+ enabled: Boolean(currentOrgIdentifier && !currentOrgFromList),
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ }
+ )
+ );
const currentOrgId =
currentOrgFromList?.id ??
+ resolvedCurrentOrg?.id ??
(currentOrgIdentifier && isUuidOrganizationRouteIdentifier(currentOrgIdentifier)
? currentOrgIdentifier
: null);
diff --git a/apps/web/src/app/(app)/organizations/[id]/auto-fix/AutoFixPageClient.tsx b/apps/web/src/app/(app)/organizations/[id]/auto-fix/AutoFixPageClient.tsx
index ca26cdd6fa..2a513b3cb8 100644
--- a/apps/web/src/app/(app)/organizations/[id]/auto-fix/AutoFixPageClient.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/auto-fix/AutoFixPageClient.tsx
@@ -16,6 +16,7 @@ import Link from 'next/link';
type AutoFixPageClientProps = {
organizationId: string;
+ organizationRouteIdentifier: string;
organizationName: string;
successMessage?: string;
errorMessage?: string;
@@ -23,6 +24,7 @@ type AutoFixPageClientProps = {
export function AutoFixPageClient({
organizationId,
+ organizationRouteIdentifier,
organizationName,
successMessage,
errorMessage,
@@ -82,7 +84,7 @@ export function AutoFixPageClient({
The Kilo GitHub App must be installed to use Auto Fix. The app automatically manages
workflows and triggers fixes on labeled issues.
-
+
Install GitHub App
diff --git a/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx b/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx
index 9abbd94805..636b244db8 100644
--- a/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/auto-fix/page.tsx
@@ -14,7 +14,7 @@ export default async function AutoFixPage({ params, searchParams }: AutoFixPageP
return (
{
+ render={async ({ organization, organizationRouteIdentifier }) => {
const isAutoTriageFeatureEnabled = await isFeatureFlagEnabled(
'auto-triage-feature',
organization.id
@@ -28,6 +28,7 @@ export default async function AutoFixPage({ params, searchParams }: AutoFixPageP
return (
-
+
Install GitHub App
diff --git a/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx b/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx
index 733907197f..40c9e36b5b 100644
--- a/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/auto-triage/page.tsx
@@ -14,7 +14,7 @@ export default async function AutoTriagePage({ params, searchParams }: AutoTriag
return (
{
+ render={async ({ organization, organizationRouteIdentifier }) => {
const isAutoTriageFeatureEnabled = await isFeatureFlagEnabled(
'auto-triage-feature',
organization.id
@@ -28,6 +28,7 @@ export default async function AutoTriagePage({ params, searchParams }: AutoTriag
return (
{
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/chat/OrgChatRootLayoutClient.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/chat/OrgChatRootLayoutClient.tsx
index 812603e43b..9a7b236e5b 100644
--- a/apps/web/src/app/(app)/organizations/[id]/claw/chat/OrgChatRootLayoutClient.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/chat/OrgChatRootLayoutClient.tsx
@@ -7,9 +7,11 @@ import { KiloChatLayout } from '@/app/(app)/claw/kilo-chat/components/KiloChatLa
export function OrgChatRootLayoutClient({
children,
organizationId,
+ organizationRouteIdentifier,
}: {
children: React.ReactNode;
organizationId: string;
+ organizationRouteIdentifier: string;
}) {
const { data: user } = useUser();
const { data: status, error, isError, isLoading, refetch } = useOrgKiloClawStatus(organizationId);
@@ -20,8 +22,8 @@ export function OrgChatRootLayoutClient({
(
-
+
{children}
)}
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/new/OrgClawNewClient.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/new/OrgClawNewClient.tsx
index 19ff205499..9fab3c11c8 100644
--- a/apps/web/src/app/(app)/organizations/[id]/claw/new/OrgClawNewClient.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/new/OrgClawNewClient.tsx
@@ -14,16 +14,18 @@ const ClawOnboardingWithBoundary = withStatusQueryBoundary(ClawOnboardingFlow);
export function OrgClawNewClient({
organizationId,
+ organizationRouteIdentifier,
fakeOnboardingStep,
}: {
organizationId: string;
+ organizationRouteIdentifier: string;
fakeOnboardingStep: ClawOnboardingRenderStep | null;
}) {
if (fakeOnboardingStep) {
return (
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/new/page.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/new/page.tsx
index 391dd49086..0b1882873f 100644
--- a/apps/web/src/app/(app)/organizations/[id]/claw/new/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/new/page.tsx
@@ -25,6 +25,7 @@ export default async function OrgClawNewPage({ params, searchParams }: OrgClawNe
render={org => (
)}
diff --git a/apps/web/src/app/(app)/organizations/[id]/claw/page.tsx b/apps/web/src/app/(app)/organizations/[id]/claw/page.tsx
index 85be03037d..968edfa18c 100644
--- a/apps/web/src/app/(app)/organizations/[id]/claw/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/claw/page.tsx
@@ -9,7 +9,12 @@ export default async function OrgClawPage({ params }: OrgClawPageProps) {
return (
}
+ render={org => (
+
+ )}
/>
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/cloud/sessions/page.tsx b/apps/web/src/app/(app)/organizations/[id]/cloud/sessions/page.tsx
index 2c2473aeaa..50d32a9255 100644
--- a/apps/web/src/app/(app)/organizations/[id]/cloud/sessions/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/cloud/sessions/page.tsx
@@ -10,11 +10,14 @@ export default async function OrganizationSessionsPage({
return (
(
+ render={({ organization, organizationRouteIdentifier }) => (
Loading...}
>
-
+
)}
/>
diff --git a/apps/web/src/app/(app)/organizations/[id]/code-reviews/ReviewAgentPageClient.tsx b/apps/web/src/app/(app)/organizations/[id]/code-reviews/ReviewAgentPageClient.tsx
index 3acabb7a23..9da45f8d98 100644
--- a/apps/web/src/app/(app)/organizations/[id]/code-reviews/ReviewAgentPageClient.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/code-reviews/ReviewAgentPageClient.tsx
@@ -31,6 +31,7 @@ type Platform = 'github' | 'gitlab';
type ReviewAgentPageClientProps = {
organizationId: string;
+ organizationRouteIdentifier: string;
organizationName: string;
successMessage?: string;
errorMessage?: string;
@@ -39,6 +40,7 @@ type ReviewAgentPageClientProps = {
export function ReviewAgentPageClient({
organizationId,
+ organizationRouteIdentifier,
organizationName,
successMessage,
errorMessage,
@@ -55,7 +57,7 @@ export function ReviewAgentPageClient({
}
const queryString = params.toString();
router.push(
- `/organizations/${organizationId}/code-reviews${queryString ? `?${queryString}` : ''}`
+ `/organizations/${organizationRouteIdentifier}/code-reviews${queryString ? `?${queryString}` : ''}`
);
};
@@ -166,7 +168,7 @@ export function ReviewAgentPageClient({
The Kilo GitHub App must be installed to use Code Reviewer. The app automatically
manages workflows and triggers reviews on your pull requests.
-
+
Install GitHub App
@@ -263,7 +265,7 @@ export function ReviewAgentPageClient({
Connect your GitLab account to use Code Reviews for GitLab. You'll also need to
configure a webhook in your GitLab project settings.
-
+
Connect GitLab
diff --git a/apps/web/src/app/(app)/organizations/[id]/code-reviews/page.tsx b/apps/web/src/app/(app)/organizations/[id]/code-reviews/page.tsx
index 01b2b82ee4..8af223731a 100644
--- a/apps/web/src/app/(app)/organizations/[id]/code-reviews/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/code-reviews/page.tsx
@@ -13,9 +13,10 @@ export default async function ReviewAgentPage({ params, searchParams }: ReviewAg
return (
(
+ render={({ organization, organizationRouteIdentifier }) => (
{
router.push(`${basePath}/${deploymentId}`);
diff --git a/apps/web/src/app/(app)/organizations/[id]/deploy/[deploymentId]/page.tsx b/apps/web/src/app/(app)/organizations/[id]/deploy/[deploymentId]/page.tsx
index 0010996925..641dbeb48c 100644
--- a/apps/web/src/app/(app)/organizations/[id]/deploy/[deploymentId]/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/deploy/[deploymentId]/page.tsx
@@ -20,8 +20,12 @@ export default async function OrgDeploymentDetailPage({
return (
(
-
+ render={({ organization, organizationRouteIdentifier }) => (
+
)}
/>
);
diff --git a/apps/web/src/app/(app)/organizations/[id]/deploy/page.tsx b/apps/web/src/app/(app)/organizations/[id]/deploy/page.tsx
index fcfdb8a5c4..ac456e8a5e 100644
--- a/apps/web/src/app/(app)/organizations/[id]/deploy/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/deploy/page.tsx
@@ -18,7 +18,12 @@ export default async function OrganizationDeployPage({
return (
}
+ render={({ organization, organizationRouteIdentifier }) => (
+
+ )}
/>
);
}
diff --git a/apps/web/src/app/(app)/organizations/[id]/gastown/OrgTownListPageClient.tsx b/apps/web/src/app/(app)/organizations/[id]/gastown/OrgTownListPageClient.tsx
index 71fe8ac207..f0ad283630 100644
--- a/apps/web/src/app/(app)/organizations/[id]/gastown/OrgTownListPageClient.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/gastown/OrgTownListPageClient.tsx
@@ -15,10 +15,15 @@ import { formatDistanceToNow } from 'date-fns';
type OrgTownListPageClientProps = {
organizationId: string;
+ organizationRouteIdentifier: string;
role: string;
};
-export function OrgTownListPageClient({ organizationId, role }: OrgTownListPageClientProps) {
+export function OrgTownListPageClient({
+ organizationId,
+ organizationRouteIdentifier,
+ role,
+}: OrgTownListPageClientProps) {
const isOwner = role === 'owner';
const router = useRouter();
const trpc = useGastownTRPC();
@@ -120,7 +125,7 @@ export function OrgTownListPageClient({ organizationId, role }: OrgTownListPageC
key={town.id}
className="cursor-pointer border-white/10 bg-white/[0.03] transition-[border-color,background-color,transform] hover:bg-white/[0.05]"
onClick={() =>
- void router.push(`/organizations/${organizationId}/gastown/${town.id}`)
+ void router.push(`/organizations/${organizationRouteIdentifier}/gastown/${town.id}`)
}
>
diff --git a/apps/web/src/app/(app)/organizations/[id]/gastown/page.tsx b/apps/web/src/app/(app)/organizations/[id]/gastown/page.tsx
index dc02f5edf4..e4c2aadb6d 100644
--- a/apps/web/src/app/(app)/organizations/[id]/gastown/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/gastown/page.tsx
@@ -5,8 +5,12 @@ export default async function OrgGastownPage({ params }: { params: Promise<{ id:
return (
(
-
+ render={({ organization, organizationRouteIdentifier, role }) => (
+
)}
/>
);
diff --git a/apps/web/src/app/(app)/organizations/[id]/security-agent/page.tsx b/apps/web/src/app/(app)/organizations/[id]/security-agent/page.tsx
index ceb08de0f9..fb2e35a383 100644
--- a/apps/web/src/app/(app)/organizations/[id]/security-agent/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/security-agent/page.tsx
@@ -4,17 +4,19 @@ import { redirect } from 'next/navigation';
import { Loader2 } from 'lucide-react';
import { useSecurityAgent } from '@/components/security-agent/SecurityAgentContext';
import { SecurityDashboard } from '@/components/security-agent/SecurityDashboard';
+import { useUrlOrganizationIdentifier } from '@/hooks/useUrlOrganizationId';
export default function OrgSecurityAgentDashboardPage() {
const { hasIntegration, isEnabled, isLoadingConfig, isLoadingPermission, organizationId } =
useSecurityAgent();
+ const organizationRouteIdentifier = useUrlOrganizationIdentifier() ?? organizationId;
const shouldRedirectToConfig =
!!organizationId &&
((!isLoadingPermission && !hasIntegration) || (hasIntegration && isEnabled === false));
if (shouldRedirectToConfig) {
- redirect(`/organizations/${organizationId}/security-agent/config`);
+ redirect(`/organizations/${organizationRouteIdentifier}/security-agent/config`);
}
if (isLoadingPermission || (hasIntegration && isLoadingConfig)) {
diff --git a/apps/web/src/app/(app)/organizations/[id]/wasteland/OrgWastelandListPageClient.tsx b/apps/web/src/app/(app)/organizations/[id]/wasteland/OrgWastelandListPageClient.tsx
index 82c3f2c72a..b32b80fe31 100644
--- a/apps/web/src/app/(app)/organizations/[id]/wasteland/OrgWastelandListPageClient.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/wasteland/OrgWastelandListPageClient.tsx
@@ -21,21 +21,25 @@ import { parseDolthubUpstream } from '@/lib/wasteland/upstream';
// legacy page renders the configure-upstream UI in that case.
function linkForOrgWasteland(
wasteland: { wasteland_id: string; dolthub_upstream: string | null },
- organizationId: string
+ organizationRouteIdentifier: string
) {
const upstream = parseDolthubUpstream(wasteland.dolthub_upstream);
if (upstream) return `/wasteland/${upstream.owner}/${upstream.repo}`;
- return `/organizations/${organizationId}/wasteland/${wasteland.wasteland_id}`;
+ return `/organizations/${organizationRouteIdentifier}/wasteland/${wasteland.wasteland_id}`;
}
type OrgWastelandListPageClientProps = {
organizationId: string;
+ organizationRouteIdentifier: string;
};
-export function OrgWastelandListPageClient({ organizationId }: OrgWastelandListPageClientProps) {
+export function OrgWastelandListPageClient({
+ organizationId,
+ organizationRouteIdentifier,
+}: OrgWastelandListPageClientProps) {
const router = useRouter();
const trpc = useWastelandTRPC();
- const newUrl = `/organizations/${organizationId}/wasteland/new`;
+ const newUrl = `/organizations/${organizationRouteIdentifier}/wasteland/new`;
const wastelandsQuery = useQuery({
...trpc.wasteland.listWastelands.queryOptions({ organizationId }),
@@ -126,7 +130,9 @@ export function OrgWastelandListPageClient({ organizationId }: OrgWastelandListP
router.push(linkForOrgWasteland(wasteland, organizationId))}
+ onClick={() =>
+ router.push(linkForOrgWasteland(wasteland, organizationRouteIdentifier))
+ }
/>
))}
diff --git a/apps/web/src/app/(app)/organizations/[id]/wasteland/page.tsx b/apps/web/src/app/(app)/organizations/[id]/wasteland/page.tsx
index 156ddc748d..7521e64462 100644
--- a/apps/web/src/app/(app)/organizations/[id]/wasteland/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/wasteland/page.tsx
@@ -5,7 +5,12 @@ export default async function OrgWastelandPage({ params }: { params: Promise<{ i
return (
}
+ render={({ organization, organizationRouteIdentifier }) => (
+
+ )}
/>
);
}
diff --git a/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx b/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx
index 6b23c34599..dad6ea27ef 100644
--- a/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx
+++ b/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx
@@ -21,6 +21,8 @@ import { createActionRegistry, filterRegistry } from './action-registry';
import type { OmniboxContext, OmniboxActionGroup } from './types';
import { Shield, User, MapPin, ExternalLink, Info, Zap, Building2 } from 'lucide-react';
import type { OrganizationRole } from '@/lib/organizations/organization-types';
+import { useTRPC } from '@/lib/trpc/utils';
+import { useQuery } from '@tanstack/react-query';
// Build version - using a constant for now, could be injected at build time
const BUILD_VERSION = 'dev';
@@ -68,10 +70,18 @@ type AdminOmniboxInnerProps = {
function AdminOmniboxInner({ open, setOpen }: AdminOmniboxInnerProps) {
const pathname = usePathname();
+ const trpc = useTRPC();
const { data: user } = useUser();
const { setAssumedRole, assumedRole, originalRole } = useRoleTesting();
- const organizationId = extractOrganizationId(pathname);
+ const organizationRouteIdentifier = extractOrganizationId(pathname);
+ const { data: resolvedOrganization } = useQuery(
+ trpc.organizations.resolveRouteIdentifier.queryOptions(
+ { routeIdentifier: organizationRouteIdentifier ?? '' },
+ { enabled: Boolean(organizationRouteIdentifier) }
+ )
+ );
+ const organizationId = resolvedOrganization?.id ?? null;
// Handle role change
const handleRoleChange = useCallback(
diff --git a/apps/web/src/components/integrations/IntegrationDetailPage.tsx b/apps/web/src/components/integrations/IntegrationDetailPage.tsx
index 8aa136590b..ae3fa3eebe 100644
--- a/apps/web/src/components/integrations/IntegrationDetailPage.tsx
+++ b/apps/web/src/components/integrations/IntegrationDetailPage.tsx
@@ -253,10 +253,12 @@ export async function OrganizationIntegrationDetailPage({
return (
(
+ render={({ organization, organizationRouteIdentifier }) => (
<>
-
+
{entry.organizationSubtitle(organization.name)}
diff --git a/apps/web/src/lib/organizations/organization-page-context.server.ts b/apps/web/src/lib/organizations/organization-page-context.server.ts
index 034c607141..40bd740d54 100644
--- a/apps/web/src/lib/organizations/organization-page-context.server.ts
+++ b/apps/web/src/lib/organizations/organization-page-context.server.ts
@@ -83,11 +83,13 @@ export async function redirectCanonicalOrganizationRouteIfNeeded({
return;
}
- const pathname = (await headers()).get('x-pathname') ?? `/organizations/${rawRouteIdentifier}`;
+ const headersList = await headers();
+ const pathname = headersList.get('x-pathname') ?? `/organizations/${rawRouteIdentifier}`;
+ const search = headersList.get('x-search') ?? '';
redirect(
- pathname.replace(
+ `${pathname.replace(
`/organizations/${rawRouteIdentifier}`,
`/organizations/${canonicalRouteIdentifier}`
- )
+ )}${search}`
);
}
diff --git a/apps/web/src/lib/user/server.ts b/apps/web/src/lib/user/server.ts
index d5253c8946..2fd5dad2cd 100644
--- a/apps/web/src/lib/user/server.ts
+++ b/apps/web/src/lib/user/server.ts
@@ -1066,9 +1066,10 @@ async function appendCallbackPath(url: string): Promise {
if (url.includes('callbackPath')) return url;
const headersList = await headers();
const pathname = headersList.get('x-pathname');
+ const search = headersList.get('x-search') ?? '';
if (pathname && pathname !== '/') {
const separator = url.includes('?') ? '&' : '?';
- return `${url}${separator}callbackPath=${encodeURIComponent(pathname)}`;
+ return `${url}${separator}callbackPath=${encodeURIComponent(`${pathname}${search}`)}`;
}
return url;
}
diff --git a/apps/web/src/proxy.ts b/apps/web/src/proxy.ts
index 4d761db9d0..9e13a93e29 100644
--- a/apps/web/src/proxy.ts
+++ b/apps/web/src/proxy.ts
@@ -13,6 +13,7 @@ import {
function baseProxy(request: NextRequestWithAuth) {
const requestHeaders = new Headers(request.headers);
requestHeaders.set('x-pathname', request.nextUrl.pathname);
+ requestHeaders.set('x-search', request.nextUrl.search);
const response = NextResponse.next({
request: {
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index 3a0f0066c0..0421d24bf9 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -67,6 +67,8 @@ import { organizationKiloclawRouter } from '@/routers/organizations/organization
import { organizationBitbucketRouter } from '@/routers/organizations/organization-bitbucket-router';
import { ORGANIZATION_SLUG_MAX_LENGTH } from '@/lib/organizations/organization-route-utils';
import { organizationSlugContainsReservedSubstring } from '@/lib/organizations/organization-slug';
+import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
const OrganizationUpdateSchema = OrganizationIdInputSchema.extend({
name: OrganizationNameSchema,
@@ -189,6 +191,25 @@ export const organizationsRouter = createTRPCRouter({
kiloclaw: organizationKiloclawRouter,
bitbucket: organizationBitbucketRouter,
+ resolveRouteIdentifier: baseProcedure
+ .input(z.object({ routeIdentifier: z.string().min(1) }))
+ .query(async ({ input }) => {
+ const result = await getAuthorizedOrgContext(input.routeIdentifier);
+
+ if (!result.success) {
+ throw new TRPCError({
+ code: result.nextResponse.status === 401 ? 'UNAUTHORIZED' : 'NOT_FOUND',
+ message: 'Organization not found',
+ });
+ }
+
+ return {
+ id: result.data.organization.id,
+ slug: result.data.organization.slug,
+ routeIdentifier: getOrganizationRouteIdentifier(result.data.organization),
+ };
+ }),
+
list: baseProcedure.query(async opts => {
const { user } = opts.ctx;
return await getUserOrganizationsWithSeats(user.id);
From aa94ac613ce5773afd328f51b1807036aa9671c9 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 17:15:53 -0500
Subject: [PATCH 20/33] fix(organizations): enforce slug route boundaries
---
.../app/api/auto-routing/mode/route.test.ts | 17 +++++-
.../src/app/api/auto-routing/mode/route.ts | 13 ++++-
.../app/api/code-indexing/enabled/route.ts | 10 +++-
.../app/api/code-indexing/manifest/route.ts | 17 +++++-
.../api/code-indexing/upsert-by-file/route.ts | 2 +-
.../token/route.test.ts | 9 ++-
.../auto-routing-benchmark/token/route.ts | 2 +-
.../integrations/dolthub/token/route.ts | 2 +-
.../billing-side-effects/route.test.ts | 15 ++---
.../kiloclaw/billing-side-effects/route.ts | 2 +-
.../[id]/models/validate/route.test.ts | 33 +++++++++--
apps/web/src/app/payments/topup/route.ts | 25 ++++++--
.../app/payments/topup/success/actions.tsx | 12 +++-
.../src/app/payments/topup/success/page.tsx | 10 +++-
.../web/src/lib/bot/linear-link-state.test.ts | 2 +-
apps/web/src/lib/bot/linear-link-state.ts | 2 +-
apps/web/src/lib/cloud-agent-sdk/schemas.ts | 4 +-
apps/web/src/lib/integrations/oauth/common.ts | 22 ++++++-
.../oauth/platforms/bitbucket-connect.ts | 6 +-
.../oauth/platforms/gitlab-connect.ts | 6 +-
.../lib/organizations/organization-seats.ts | 2 +-
.../routers/auto-triage/auto-triage-router.ts | 2 +-
.../web/src/routers/usage-analytics-router.ts | 4 +-
docs/organization-slug-url-api-audit.md | 57 +++++++++++++++++++
24 files changed, 229 insertions(+), 47 deletions(-)
create mode 100644 docs/organization-slug-url-api-audit.md
diff --git a/apps/web/src/app/api/auto-routing/mode/route.test.ts b/apps/web/src/app/api/auto-routing/mode/route.test.ts
index 861c54598f..9d4f464686 100644
--- a/apps/web/src/app/api/auto-routing/mode/route.test.ts
+++ b/apps/web/src/app/api/auto-routing/mode/route.test.ts
@@ -22,7 +22,7 @@ const mockedGetUserFromAuth = jest.mocked(getUserFromAuth);
const mockedEnsureOrganizationAccess = jest.mocked(ensureOrganizationAccess);
const USER_ID = 'user-1';
-const ORGANIZATION_ID = 'org-1';
+const ORGANIZATION_ID = '550e8400-e29b-41d4-a716-446655440000';
function makeRequest(path: string, body?: unknown) {
return new NextRequest(`http://localhost:3000${path}`, {
@@ -148,6 +148,21 @@ describe('/api/auto-routing/mode', () => {
expect(mockedUpdateAutoRoutingMode).not.toHaveBeenCalled();
});
+ test('rejects a slug passed as organizationId before organization access checks', async () => {
+ const response = await PUT(
+ makeRequest('/api/auto-routing/mode?organizationId=acme', {
+ mode: 'best_accuracy',
+ })
+ );
+
+ expect(response.status).toBe(400);
+ await expect(response.json()).resolves.toEqual({
+ error: 'Invalid organizationId',
+ });
+ expect(mockedEnsureOrganizationAccess).not.toHaveBeenCalled();
+ expect(mockedUpdateAutoRoutingMode).not.toHaveBeenCalled();
+ });
+
test('maps missing organization entitlements to HTTP 404', async () => {
mockedRequireActiveSubscriptionOrTrial.mockRejectedValue(
new TRPCError({
diff --git a/apps/web/src/app/api/auto-routing/mode/route.ts b/apps/web/src/app/api/auto-routing/mode/route.ts
index ef3baf512c..3ee2b16dea 100644
--- a/apps/web/src/app/api/auto-routing/mode/route.ts
+++ b/apps/web/src/app/api/auto-routing/mode/route.ts
@@ -5,6 +5,7 @@ import {
} from '@kilocode/auto-routing-contracts';
import { TRPCError } from '@trpc/server';
import { NextResponse, type NextRequest } from 'next/server';
+import { z } from 'zod';
import {
getAutoRoutingMode,
updateAutoRoutingMode,
@@ -13,6 +14,8 @@ import { getUserFromAuth } from '@/lib/user/server';
import { ensureOrganizationAccess } from '@/routers/organizations/utils';
import { requireActiveSubscriptionOrTrial } from '@/lib/organizations/trial-middleware';
+const OrganizationIdSchema = z.uuid();
+
function workerResultResponse(result: { status: number; body: unknown }): NextResponse {
if (result.status >= 400) {
return NextResponse.json(result.body, { status: result.status });
@@ -47,11 +50,17 @@ async function resolveOwner(
return { response: NextResponse.json({ error: 'Authentication required' }, { status: 401 }) };
}
- const organizationId = request.nextUrl.searchParams.get('organizationId');
- if (!organizationId) {
+ const organizationIdParam = request.nextUrl.searchParams.get('organizationId');
+ if (!organizationIdParam) {
return { ownerType: 'user', ownerId: user.id };
}
+ const parsedOrganizationId = OrganizationIdSchema.safeParse(organizationIdParam);
+ if (!parsedOrganizationId.success) {
+ return { response: NextResponse.json({ error: 'Invalid organizationId' }, { status: 400 }) };
+ }
+ const organizationId = parsedOrganizationId.data;
+
try {
await ensureOrganizationAccess({ user }, organizationId, roles);
} catch (error) {
diff --git a/apps/web/src/app/api/code-indexing/enabled/route.ts b/apps/web/src/app/api/code-indexing/enabled/route.ts
index 4f53e568c7..0a69c64c1f 100644
--- a/apps/web/src/app/api/code-indexing/enabled/route.ts
+++ b/apps/web/src/app/api/code-indexing/enabled/route.ts
@@ -1,10 +1,13 @@
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
+import { z } from 'zod';
import { createTRPCContext } from '@/lib/trpc/init';
import { ensureOrganizationAccessAndFetchOrg } from '@/routers/organizations/utils';
import { getUserFromAuth } from '@/lib/user/server';
import { isEnabledForUser } from '@/lib/code-indexing/util';
+const OrganizationIdSchema = z.uuid();
+
type EnabledResponse = { enabled: boolean };
type ErrorResponse = { error: string; message?: string };
@@ -36,11 +39,16 @@ export async function GET(
return NextResponse.json({ enabled: isEnabledForUser(res.user) });
}
+ const parsedOrganizationId = OrganizationIdSchema.safeParse(organizationId);
+ if (!parsedOrganizationId.success) {
+ return NextResponse.json({ error: 'Invalid organizationId' }, { status: 400 });
+ }
+
// Check if user has access to the organization and fetch it
try {
// Create tRPC context for authentication
const ctx = await createTRPCContext();
- const org = await ensureOrganizationAccessAndFetchOrg(ctx, organizationId);
+ const org = await ensureOrganizationAccessAndFetchOrg(ctx, parsedOrganizationId.data);
// Check if code indexing is enabled in organization settings
const enabled = org.settings?.code_indexing_enabled === true;
diff --git a/apps/web/src/app/api/code-indexing/manifest/route.ts b/apps/web/src/app/api/code-indexing/manifest/route.ts
index 31e62af0d1..31f9e864ab 100644
--- a/apps/web/src/app/api/code-indexing/manifest/route.ts
+++ b/apps/web/src/app/api/code-indexing/manifest/route.ts
@@ -1,9 +1,12 @@
import type { NextRequest } from 'next/server';
+import { z } from 'zod';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
+const OrganizationIdSchema = z.uuid();
+
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
- const organizationId = searchParams.get('organizationId') || undefined;
+ const organizationIdParam = searchParams.get('organizationId');
const projectId = searchParams.get('projectId');
const gitBranch = searchParams.get('gitBranch');
@@ -16,6 +19,18 @@ export async function GET(request: NextRequest) {
);
}
+ let organizationId: string | undefined;
+ if (organizationIdParam) {
+ const parsedOrganizationId = OrganizationIdSchema.safeParse(organizationIdParam);
+ if (!parsedOrganizationId.success) {
+ return new Response(JSON.stringify({ error: 'Invalid organizationId' }), {
+ status: 400,
+ headers: { 'Content-Type': 'application/json' },
+ });
+ }
+ organizationId = parsedOrganizationId.data;
+ }
+
return handleTRPCRequest(request, async caller => {
return caller.codeIndexing.getManifest({
organizationId,
diff --git a/apps/web/src/app/api/code-indexing/upsert-by-file/route.ts b/apps/web/src/app/api/code-indexing/upsert-by-file/route.ts
index 1165398a0b..cdce08d44a 100644
--- a/apps/web/src/app/api/code-indexing/upsert-by-file/route.ts
+++ b/apps/web/src/app/api/code-indexing/upsert-by-file/route.ts
@@ -23,7 +23,7 @@ const BATCH_SIZE = 4;
// Zod schema for form data validation
const FormDataSchema = z.object({
file: z.instanceof(File, { message: 'file must be a File object' }),
- organizationId: z.string().optional().nullable(),
+ organizationId: z.uuid().optional().nullable(),
projectId: z.string().min(1, { message: 'projectId is required' }),
filePath: z.string().min(1, { message: 'filePath is required' }),
fileHash: z.string().min(1, { message: 'fileHash is required' }),
diff --git a/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.test.ts b/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.test.ts
index 11ff95ea77..e0f6700201 100644
--- a/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.test.ts
+++ b/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.test.ts
@@ -30,6 +30,7 @@ jest.mock('@/lib/tokens', () => ({
import { POST } from './route';
const mockGenerateApiToken = jest.mocked(generateApiToken);
+const ORGANIZATION_ID = '550e8400-e29b-41d4-a716-446655440000';
function createRequest(body: unknown, headers: Record = {}) {
return new NextRequest('http://localhost:3000/api/internal/auto-routing-benchmark/token', {
@@ -98,7 +99,7 @@ describe('POST /api/internal/auto-routing-benchmark/token', () => {
const res = await POST(
createRequest(
- { userId: 'user-1', organizationId: 'org-1' },
+ { userId: 'user-1', organizationId: ORGANIZATION_ID },
{ authorization: 'Bearer internal-secret' }
)
);
@@ -106,7 +107,11 @@ describe('POST /api/internal/auto-routing-benchmark/token', () => {
expect(res.status).toBe(200);
expect(mockGenerateApiToken).toHaveBeenCalledWith(
user,
- { tokenSource: 'auto-routing-benchmark', organizationId: 'org-1', organizationRole: 'owner' },
+ {
+ tokenSource: 'auto-routing-benchmark',
+ organizationId: ORGANIZATION_ID,
+ organizationRole: 'owner',
+ },
{ expiresIn: 6 * 60 * 60 }
);
});
diff --git a/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.ts b/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.ts
index 71c7f94d37..367a99c164 100644
--- a/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.ts
+++ b/apps/web/src/app/api/internal/auto-routing-benchmark/token/route.ts
@@ -33,7 +33,7 @@ import { INTERNAL_API_SECRET } from '@/lib/config.server';
const RequestSchema = z.object({
userId: z.string().min(1),
- organizationId: z.string().min(1).optional(),
+ organizationId: z.uuid().optional(),
});
const SIX_HOURS_IN_SECONDS = 6 * 60 * 60;
diff --git a/apps/web/src/app/api/internal/integrations/dolthub/token/route.ts b/apps/web/src/app/api/internal/integrations/dolthub/token/route.ts
index 273040d02d..fac56c7806 100644
--- a/apps/web/src/app/api/internal/integrations/dolthub/token/route.ts
+++ b/apps/web/src/app/api/internal/integrations/dolthub/token/route.ts
@@ -26,7 +26,7 @@ import { INTEGRATION_STATUS } from '@/lib/integrations/core/constants';
const RequestSchema = z
.object({
userId: z.string().min(1).optional(),
- organizationId: z.string().min(1).optional(),
+ organizationId: z.uuid().optional(),
})
.refine(v => Boolean(v.userId) !== Boolean(v.organizationId), {
message: 'Provide exactly one of userId or organizationId',
diff --git a/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.test.ts b/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.test.ts
index d02753cfad..178b12b96a 100644
--- a/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.test.ts
+++ b/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.test.ts
@@ -62,6 +62,7 @@ const mockProcessPersonalKiloClawPaidConversion = jest.mocked(
processPersonalKiloClawPaidConversion
);
const mockEnforceKiloClawCommitRetirementGuard = jest.mocked(enforceKiloClawCommitRetirementGuard);
+const ORGANIZATION_ID = '550e8400-e29b-41d4-a716-446655440000';
type ConsoleSpy = jest.SpiedFunction | jest.SpiedFunction;
@@ -174,11 +175,11 @@ describe('POST /api/internal/kiloclaw/billing-side-effects', () => {
organization_name: 'Acme Corp',
instance_label: 'Research Claw',
destruction_date: 'May 25, 2026',
- organization_billing_url: 'https://app.kilo.ai/organizations/org-123/payment-details',
+ organization_billing_url: `https://app.kilo.ai/organizations/${ORGANIZATION_ID}/payment-details`,
},
userId: 'owner-123',
instanceId: 'instance-456',
- organizationId: 'org-123',
+ organizationId: ORGANIZATION_ID,
},
})
);
@@ -189,14 +190,14 @@ describe('POST /api/internal/kiloclaw/billing-side-effects', () => {
templateName: 'clawOrganizationTrialSuspendedBillingAuthority',
userId: 'owner-123',
instanceId: 'instance-456',
- organizationId: 'org-123',
+ organizationId: ORGANIZATION_ID,
})
);
expect(findJsonLog(consoleLogSpy, 'Starting billing side effect request')).toEqual(
expect.objectContaining({
userId: 'owner-123',
instanceId: 'instance-456',
- organizationId: 'org-123',
+ organizationId: ORGANIZATION_ID,
templateName: 'clawOrganizationTrialSuspendedBillingAuthority',
})
);
@@ -218,7 +219,7 @@ describe('POST /api/internal/kiloclaw/billing-side-effects', () => {
},
userId: 'member-123',
instanceId: 'instance-456',
- organizationId: 'org-123',
+ organizationId: ORGANIZATION_ID,
},
})
);
@@ -238,9 +239,9 @@ describe('POST /api/internal/kiloclaw/billing-side-effects', () => {
templateVars: {
organization_name: 'Acme Corp',
instance_label: 'Research Claw',
- organization_billing_url: 'https://app.kilo.ai/organizations/org-123/payment-details',
+ organization_billing_url: `https://app.kilo.ai/organizations/${ORGANIZATION_ID}/payment-details`,
},
- organizationId: 'org-123',
+ organizationId: ORGANIZATION_ID,
},
})
);
diff --git a/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.ts b/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.ts
index c4bdc58012..f0443da0a5 100644
--- a/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.ts
+++ b/apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.ts
@@ -114,7 +114,7 @@ const OrganizationLifecycleIdentitySchema = {
to: z.email(),
userId: z.string().min(1),
instanceId: z.string().min(1),
- organizationId: z.string().min(1),
+ organizationId: z.uuid(),
};
const OrganizationLifecycleBillingAuthorityVarsSchema = z.object({
diff --git a/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts b/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts
index 209e8747c9..33a10c869e 100644
--- a/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts
+++ b/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts
@@ -2,12 +2,18 @@ import { beforeEach, describe, expect, test } from '@jest/globals';
import { NextRequest, NextResponse } from 'next/server';
import type { OpenRouterModel } from '@/lib/organizations/organization-types';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
+import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
import { POST } from './route';
jest.mock('@/lib/trpc-route-handler', () => ({ handleTRPCRequest: jest.fn() }));
+jest.mock('@/lib/organizations/organization-route-utils.server', () => ({
+ resolveOrganizationRouteIdentifier: jest.fn(),
+}));
const mockedHandleTRPCRequest = jest.mocked(handleTRPCRequest);
+const mockedResolveOrganizationRouteIdentifier = jest.mocked(resolveOrganizationRouteIdentifier);
const listAvailableModels = jest.fn();
+const ORGANIZATION_ID = '550e8400-e29b-41d4-a716-446655440000';
function makeModel(id: string): OpenRouterModel {
return {
@@ -28,7 +34,7 @@ function makeModel(id: string): OpenRouterModel {
}
function request(modelId: string) {
- return new NextRequest('http://localhost:3000/api/organizations/org-1/models/validate', {
+ return new NextRequest('http://localhost:3000/api/organizations/acme/models/validate', {
method: 'POST',
body: JSON.stringify({ modelId }),
});
@@ -37,6 +43,7 @@ function request(modelId: string) {
describe('POST /api/organizations/[id]/models/validate', () => {
beforeEach(() => {
jest.resetAllMocks();
+ mockedResolveOrganizationRouteIdentifier.mockResolvedValue(ORGANIZATION_ID);
listAvailableModels.mockResolvedValue({ data: [makeModel('available/model')] });
mockedHandleTRPCRequest.mockImplementation(async (request, handler) => {
const result = await handler({
@@ -48,31 +55,45 @@ describe('POST /api/organizations/[id]/models/validate', () => {
test('validates against the authorized organization catalog', async () => {
const response = await POST(request('available/model'), {
- params: Promise.resolve({ id: 'org-1' }),
+ params: Promise.resolve({ id: 'acme' }),
});
- expect(listAvailableModels).toHaveBeenCalledWith({ organizationId: 'org-1' });
+ expect(mockedResolveOrganizationRouteIdentifier).toHaveBeenCalledWith('acme');
+ expect(listAvailableModels).toHaveBeenCalledWith({ organizationId: ORGANIZATION_ID });
await expect(response.json()).resolves.toEqual({ valid: true });
});
test('reports an organization-unavailable model without policy details', async () => {
const response = await POST(request('missing/model'), {
- params: Promise.resolve({ id: 'org-1' }),
+ params: Promise.resolve({ id: 'acme' }),
});
await expect(response.json()).resolves.toEqual({ valid: false, reason: 'unavailable' });
});
+ test('returns 404 when the route identifier cannot be resolved', async () => {
+ mockedResolveOrganizationRouteIdentifier.mockResolvedValue(null);
+
+ const response = await POST(request('available/model'), {
+ params: Promise.resolve({ id: 'missing-org' }),
+ });
+
+ expect(response.status).toBe(404);
+ await expect(response.json()).resolves.toEqual({ error: 'Organization not found' });
+ expect(mockedHandleTRPCRequest).not.toHaveBeenCalled();
+ });
+
test('rejects an invalid body before invoking organization authorization', async () => {
const response = await POST(
- new NextRequest('http://localhost:3000/api/organizations/org-1/models/validate', {
+ new NextRequest('http://localhost:3000/api/organizations/acme/models/validate', {
method: 'POST',
body: JSON.stringify({ modelId: '' }),
}),
- { params: Promise.resolve({ id: 'org-1' }) }
+ { params: Promise.resolve({ id: 'acme' }) }
);
expect(response.status).toBe(400);
+ expect(mockedResolveOrganizationRouteIdentifier).not.toHaveBeenCalled();
expect(mockedHandleTRPCRequest).not.toHaveBeenCalled();
});
});
diff --git a/apps/web/src/app/payments/topup/route.ts b/apps/web/src/app/payments/topup/route.ts
index 6540150b70..c9431253ec 100644
--- a/apps/web/src/app/payments/topup/route.ts
+++ b/apps/web/src/app/payments/topup/route.ts
@@ -7,6 +7,8 @@ import { isValidReturnUrl } from '@/lib/payment-return-url';
import { captureException } from '@sentry/nextjs';
import { getOrCreateStripeCustomerIdForOrganization } from '@/lib/organizations/organization-billing';
import { getAuthorizedOrgContext } from '@/lib/organizations/organization-auth';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
+import { TOPUP_CANCELED_QUERY_STRING_KEY } from '@/lib/organizations/constants';
/**
* NOTE: Crypto payment support (Coinbase Commerce) was removed in January 2026.
@@ -58,25 +60,36 @@ export async function POST(request: NextRequest): Promise>
return NextResponse.json({ error: validationResult.error }, { status: 400 });
}
- // validate org id
- const organizationId = searchParams.get('organization-id');
- if (organizationId && typeof organizationId !== 'string') {
+ // Accept a route identifier at the URL boundary, then immediately normalize to
+ // the database UUID before calling billing or writing Stripe metadata.
+ const organizationRouteIdentifier = searchParams.get('organization-id');
+ if (organizationRouteIdentifier && typeof organizationRouteIdentifier !== 'string') {
return NextResponse.json({ error: 'Invalid org id' }, { status: 400 });
}
let stripeCustomerId: string | null | undefined;
- if (organizationId) {
- const orgContext = await getAuthorizedOrgContext(organizationId, ['owner', 'billing_manager']);
+ let organizationId: string | null = null;
+ let organizationCancelPath: string | null = null;
+ if (organizationRouteIdentifier) {
+ const orgContext = await getAuthorizedOrgContext(organizationRouteIdentifier, [
+ 'owner',
+ 'billing_manager',
+ ]);
if (!orgContext.success) {
return orgContext.nextResponse;
}
+ organizationId = orgContext.data.organization.id;
+ const canonicalRouteIdentifier = getOrganizationRouteIdentifier(orgContext.data.organization);
+ organizationCancelPath = `/organizations/${canonicalRouteIdentifier}?${TOPUP_CANCELED_QUERY_STRING_KEY}=true`;
stripeCustomerId = await getOrCreateStripeCustomerIdForOrganization(organizationId);
} else {
stripeCustomerId = currentUser.stripe_customer_id;
}
const cancelPathRaw = searchParams.get('cancel-path');
- const cancelPath = cancelPathRaw && isValidReturnUrl(cancelPathRaw) ? cancelPathRaw : null;
+ const cancelPath =
+ (cancelPathRaw && isValidReturnUrl(cancelPathRaw) ? cancelPathRaw : null) ??
+ organizationCancelPath;
const url = await getStripeTopUpCheckoutUrl(
currentUser.id,
diff --git a/apps/web/src/app/payments/topup/success/actions.tsx b/apps/web/src/app/payments/topup/success/actions.tsx
index 7952ea643c..f1e23ecca1 100644
--- a/apps/web/src/app/payments/topup/success/actions.tsx
+++ b/apps/web/src/app/payments/topup/success/actions.tsx
@@ -8,6 +8,8 @@ import { captureMessage } from '@sentry/nextjs';
import { inArray } from 'drizzle-orm';
import type Stripe from 'stripe';
import { getAndClearPaymentReturnUrl } from '@/lib/payment-return-url';
+import { getOrganizationById } from '@/lib/organizations/organizations';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
export async function fetchCreditTransactionIdForStripeSession(sessionId: string) {
console.info(
@@ -47,7 +49,15 @@ export async function fetchCreditTransactionIdForStripeSession(sessionId: string
console.info(`No credit transaction found for session ${sessionId}`);
}
- return creditTransaction;
+ if (!creditTransaction?.organization_id) {
+ return creditTransaction;
+ }
+
+ const organization = await getOrganizationById(creditTransaction.organization_id);
+ return {
+ ...creditTransaction,
+ organizationRouteIdentifier: organization ? getOrganizationRouteIdentifier(organization) : null,
+ };
}
export async function getPaymentReturnUrl(): Promise {
diff --git a/apps/web/src/app/payments/topup/success/page.tsx b/apps/web/src/app/payments/topup/success/page.tsx
index 15e4c14bce..88b959fbc3 100644
--- a/apps/web/src/app/payments/topup/success/page.tsx
+++ b/apps/web/src/app/payments/topup/success/page.tsx
@@ -9,7 +9,11 @@ import { fromMicrodollars } from '@/lib/utils';
import { TOPUP_AMOUNT_QUERY_STRING_KEY } from '@/lib/organizations/constants';
import { PageContainer } from '@/components/layouts/PageContainer';
-function getRedirectUrl(txn: CreditTransaction | undefined, returnUrl: string | null) {
+type TopUpCreditTransaction = CreditTransaction & {
+ organizationRouteIdentifier?: string | null;
+};
+
+function getRedirectUrl(txn: TopUpCreditTransaction | undefined, returnUrl: string | null) {
// If there's a valid return URL from the cookie, use it
if (returnUrl) {
return returnUrl;
@@ -21,11 +25,11 @@ function getRedirectUrl(txn: CreditTransaction | undefined, returnUrl: string |
}
const params = new URLSearchParams();
params.set(TOPUP_AMOUNT_QUERY_STRING_KEY, fromMicrodollars(txn.amount_microdollars).toString());
- return `/organizations/${txn.organization_id}?${params.toString()}`;
+ return `/organizations/${txn.organizationRouteIdentifier ?? txn.organization_id}?${params.toString()}`;
}
export default function TopUpSuccessPage() {
- const [creditTransaction, setCreditTransaction] = useState();
+ const [creditTransaction, setCreditTransaction] = useState();
const [tries, setTries] = useState(0);
const [hasExceededMaxTries, setHasExceededMaxTries] = useState(false);
const [returnUrl, setReturnUrl] = useState(null);
diff --git a/apps/web/src/lib/bot/linear-link-state.test.ts b/apps/web/src/lib/bot/linear-link-state.test.ts
index 377be7765e..b9b045c32b 100644
--- a/apps/web/src/lib/bot/linear-link-state.test.ts
+++ b/apps/web/src/lib/bot/linear-link-state.test.ts
@@ -5,7 +5,7 @@ import { createLinearBotLinkState, verifyLinearBotLinkState } from './linear-lin
const USER_ID = 'kilo-user-1';
const PLATFORM_INTEGRATION_ID = 'pi_linear_1';
-const ORGANIZATION_ID = 'org-linear-123';
+const ORGANIZATION_ID = '550e8400-e29b-41d4-a716-446655440000';
function signPayload(payload: object): string {
const encoded = Buffer.from(JSON.stringify(payload)).toString('base64url');
diff --git a/apps/web/src/lib/bot/linear-link-state.ts b/apps/web/src/lib/bot/linear-link-state.ts
index e39e85b95c..dbbacfad08 100644
--- a/apps/web/src/lib/bot/linear-link-state.ts
+++ b/apps/web/src/lib/bot/linear-link-state.ts
@@ -22,7 +22,7 @@ const linearBotLinkStatePayloadSchema = z.object({
kind: z.literal(KIND),
userId: z.string().min(1),
platformIntegrationId: z.string().min(1),
- organizationId: z.string().min(1),
+ organizationId: z.uuid(),
callbackPath: z.string().startsWith('/'),
iat: z.number(),
nonce: z.string().min(1),
diff --git a/apps/web/src/lib/cloud-agent-sdk/schemas.ts b/apps/web/src/lib/cloud-agent-sdk/schemas.ts
index fd9aa0b958..ec79fcd813 100644
--- a/apps/web/src/lib/cloud-agent-sdk/schemas.ts
+++ b/apps/web/src/lib/cloud-agent-sdk/schemas.ts
@@ -158,7 +158,7 @@ export const sessionEventV2RowSchema = z.object({
updatedAt: z.string(),
title: z.string().nullable(),
createdOnPlatform: z.string().nullable(),
- organizationId: z.string().nullable(),
+ organizationId: z.uuid().nullable(),
gitUrl: z.string().nullable(),
gitBranch: z.string().nullable(),
parentSessionId: z.string().nullable(),
@@ -199,7 +199,7 @@ export const sessionDeletedPayloadSchema = z.object({
source: z.literal('v2'),
sessionId: z.string(),
parentSessionId: z.string().nullable(),
- organizationId: z.string().nullable(),
+ organizationId: z.uuid().nullable(),
gitUrl: z.string().nullable(),
gitBranch: z.string().nullable(),
createdOnPlatform: z.string().nullable(),
diff --git a/apps/web/src/lib/integrations/oauth/common.ts b/apps/web/src/lib/integrations/oauth/common.ts
index 003ed94dd8..bbfad415df 100644
--- a/apps/web/src/lib/integrations/oauth/common.ts
+++ b/apps/web/src/lib/integrations/oauth/common.ts
@@ -2,6 +2,7 @@ import 'server-only';
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { captureException } from '@sentry/nextjs';
+import { z } from 'zod';
import { APP_URL } from '@/lib/constants';
import { getUserFromAuth } from '@/lib/user/server';
import { ensureOrganizationAccess } from '@/routers/organizations/utils';
@@ -12,6 +13,7 @@ import type { Owner } from '@/lib/integrations/core/types';
import type { RetainedOAuthPlatform, StandardOAuthPlatform } from '@/lib/integrations/oauth/paths';
type AuthenticatedOAuthUser = Parameters[0]['user'];
+const OrganizationIdSchema = z.uuid();
export type ResolveConnectOwnerOptions = {
organizationRoles?: Parameters[2];
@@ -48,6 +50,17 @@ export function parseOAuthStateOwner(owner: string): Owner | null {
return null;
}
+export function parseOptionalOrganizationId(value: string | null | undefined): string | null {
+ if (!value) return null;
+
+ const parsed = OrganizationIdSchema.safeParse(value);
+ if (!parsed.success) {
+ throw new Error('Invalid organizationId');
+ }
+
+ return parsed.data;
+}
+
export function buildIntegrationOAuthRedirectPath(
platform: StandardOAuthPlatform,
owner: Owner | null | undefined,
@@ -126,7 +139,9 @@ export async function resolveOAuthConnectOwner(
user: AuthenticatedOAuthUser,
options: ResolveConnectOwnerOptions = {}
): Promise<{ owner: Owner; organizationId: string | null }> {
- const organizationId = request.nextUrl.searchParams.get('organizationId');
+ const organizationId = parseOptionalOrganizationId(
+ request.nextUrl.searchParams.get('organizationId')
+ );
if (!organizationId) {
return {
@@ -157,9 +172,12 @@ export async function handleStatefulPlatformOAuthConnect(
requireActiveOrganizationSubscription,
}: HandleStatefulOAuthConnectOptions
): Promise {
- const organizationId = request.nextUrl.searchParams.get('organizationId');
+ let organizationId: string | null = null;
try {
+ organizationId = parseOptionalOrganizationId(
+ request.nextUrl.searchParams.get('organizationId')
+ );
const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false });
if (authFailedResponse) {
return redirectToSignInForOAuthConnect(request);
diff --git a/apps/web/src/lib/integrations/oauth/platforms/bitbucket-connect.ts b/apps/web/src/lib/integrations/oauth/platforms/bitbucket-connect.ts
index 13ed91f066..a11d79d12c 100644
--- a/apps/web/src/lib/integrations/oauth/platforms/bitbucket-connect.ts
+++ b/apps/web/src/lib/integrations/oauth/platforms/bitbucket-connect.ts
@@ -8,6 +8,7 @@ import { buildBitbucketOAuthUrl } from '@/lib/integrations/platforms/bitbucket/a
import { createOAuthState } from '@/lib/integrations/oauth-state';
import {
buildIntegrationOAuthConnectErrorPath,
+ parseOptionalOrganizationId,
redirectToSignInForOAuthConnect,
} from '@/lib/integrations/oauth/common';
import { validateReturnPath } from '@/lib/integrations/validate-return-path';
@@ -21,9 +22,12 @@ function detailPath(organizationId: string | null): string {
}
export async function handleBitbucketOAuthConnect(request: NextRequest): Promise {
- const organizationId = request.nextUrl.searchParams.get('organizationId');
+ let organizationId: string | null = null;
try {
+ organizationId = parseOptionalOrganizationId(
+ request.nextUrl.searchParams.get('organizationId')
+ );
const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false });
if (authFailedResponse) {
return redirectToSignInForOAuthConnect(request, detailPath(organizationId));
diff --git a/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts b/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
index cb957bb8a1..514776e52c 100644
--- a/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
+++ b/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
@@ -15,6 +15,7 @@ import { PLATFORM } from '@/lib/integrations/core/constants';
import { validateReturnPath } from '@/lib/integrations/validate-return-path';
import {
buildIntegrationOAuthConnectErrorPath,
+ parseOptionalOrganizationId,
redirectToSignInForOAuthConnect,
} from '@/lib/integrations/oauth/common';
import type { Owner } from '@/lib/integrations/core/types';
@@ -22,7 +23,7 @@ import type { Owner } from '@/lib/integrations/core/types';
type AuthenticatedOAuthUser = Parameters[0]['user'];
const GitLabOAuthConnectPostBodySchema = z.object({
- organizationId: z.string().optional(),
+ organizationId: z.uuid().optional(),
instanceUrl: z.string().optional(),
clientId: z.string().optional(),
clientSecret: z.string().optional(),
@@ -50,9 +51,10 @@ type GitLabOAuthConnectOptions = {
*/
export async function handleGitLabOAuthConnect(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
- const organizationId = searchParams.get('organizationId');
+ let organizationId: string | null = null;
try {
+ organizationId = parseOptionalOrganizationId(searchParams.get('organizationId'));
const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false });
if (authFailedResponse) {
const hasLegacyQueryCredentials =
diff --git a/apps/web/src/lib/organizations/organization-seats.ts b/apps/web/src/lib/organizations/organization-seats.ts
index bce2cad84c..eab5b4f0de 100644
--- a/apps/web/src/lib/organizations/organization-seats.ts
+++ b/apps/web/src/lib/organizations/organization-seats.ts
@@ -40,7 +40,7 @@ const sentryError = sentryLogger('organization_seats', 'error');
const SubscriptionMetadataSchema = z.object({
type: z.string(),
kiloUserId: z.string(),
- organizationId: z.string(),
+ organizationId: z.uuid(),
seats: z
.string()
.transform((val, ctx) => {
diff --git a/apps/web/src/routers/auto-triage/auto-triage-router.ts b/apps/web/src/routers/auto-triage/auto-triage-router.ts
index 9fb89d75ed..dcc0572485 100644
--- a/apps/web/src/routers/auto-triage/auto-triage-router.ts
+++ b/apps/web/src/routers/auto-triage/auto-triage-router.ts
@@ -334,7 +334,7 @@ export const autoTriageRouter = createTRPCRouter({
z.object({
issueUrl: z.string().min(1),
owner: z.discriminatedUnion('type', [
- z.object({ type: z.literal('org'), organizationId: z.string() }),
+ z.object({ type: z.literal('org'), organizationId: z.uuid() }),
z.object({ type: z.literal('user') }),
]),
})
diff --git a/apps/web/src/routers/usage-analytics-router.ts b/apps/web/src/routers/usage-analytics-router.ts
index 6022d086f6..87bd4c345d 100644
--- a/apps/web/src/routers/usage-analytics-router.ts
+++ b/apps/web/src/routers/usage-analytics-router.ts
@@ -600,12 +600,12 @@ const ScopeOrganizationsInputSchema = z.object({
});
const ScopeOrganizationSchema = z.object({
- organizationId: z.string(),
+ organizationId: z.uuid(),
organizationName: z.string(),
});
const ScopeOrganizationsOutputSchema = z.object({
- organizationId: z.string(),
+ organizationId: z.uuid(),
organizationName: z.string(),
/** Direct child organizations, sorted by name. Empty when not a parent org. */
children: z.array(ScopeOrganizationSchema),
diff --git a/docs/organization-slug-url-api-audit.md b/docs/organization-slug-url-api-audit.md
new file mode 100644
index 0000000000..cd9008b03d
--- /dev/null
+++ b/docs/organization-slug-url-api-audit.md
@@ -0,0 +1,57 @@
+# Organization Slug URL/API Audit
+
+## Invariant
+
+Slugs are route aliases only. A slug may appear in `/organizations/:identifier` URLs, but data/backend operations must receive a resolved organization UUID. Fields named `organizationId` or `organization_id` are UUID contracts and must reject slug values rather than treating them as first-class identifiers. URL generation should prefer `slug ?? id`.
+
+## Route-Boundary Slug Support
+
+| Surface | Files | Status |
+|---|---|---|
+| Canonical route identifier helpers | `apps/web/src/lib/organizations/organization-route-utils.ts`, `apps/web/src/lib/organizations/organization-route-utils.server.ts` | Verified. `getOrganizationRouteIdentifier` emits `slug ?? id`; server resolver accepts UUID or slug and returns UUID details. |
+| Authorized organization page context | `apps/web/src/lib/organizations/organization-auth.ts`, `apps/web/src/lib/organizations/organization-page-context.server.ts`, `apps/web/src/components/organizations/OrganizationByPageLayout.tsx` | Verified. Slug route params are resolved to UUID before authorization; UUID URLs redirect to slug when a slug exists. |
+| App Router organization pages | `apps/web/src/app/(app)/organizations/[id]/**` | Verified by shared layout/context pattern. Existing `[id]` segment now means route identifier, not backend ID. Major covered subtrees: dashboard, welcome, payment details, subscriptions, usage details, providers/models, custom modes, audit logs, integrations, cloud, KiloClaw, app-builder, deploy, security-agent, auto-fix, auto-triage, code-indexing, code-reviews, Gastown, Wasteland. |
+| Organization API route params | `apps/web/src/app/api/organizations/[id]/route.ts`, `defaults/route.ts`, `modes/route.ts`, `models/route.ts`, `models/validate/route.ts`, `user-tokens/route.ts` | Verified/fixed tests. Route param accepts slug or UUID; handler resolves before tRPC/backend calls. |
+| Reinstall routes under org pages | `apps/web/src/app/(app)/organizations/[id]/integrations/slack/reinstall/route.ts`, `linear/reinstall/route.ts` | Verified. Route params resolve through `resolveOrganizationRouteParams` before access checks. |
+
+## Backend/API Organization ID Contracts
+
+| Surface | Files | Status |
+|---|---|---|
+| Organization tRPC routers | `apps/web/src/routers/organizations/**`, especially `utils.ts` | Verified. `OrganizationIdInputSchema` is `z.uuid()` and backend procedures remain UUID-only. |
+| Cross-feature tRPC org inputs | `agent-profiles`, `app-builder`, `byok`, `cli/unified sessions`, `code-indexing`, `code-reviews`, `deployments`, `discord`, `dolthub`, `github-apps`, `gitlab`, `linear`, `mcp-gateway`, `slack`, `usage-analytics`, `webhook-triggers` routers | Verified by schema scan. Inputs named `organizationId` are UUID schemas. |
+| OAuth connect query/body contracts | `apps/web/src/lib/integrations/oauth/common.ts`, `platforms/gitlab-connect.ts`, `platforms/bitbucket-connect.ts` | Fixed. Optional `organizationId` is parsed as UUID before access checks and before OAuth state owner creation. |
+| Auto-routing API | `apps/web/src/app/api/auto-routing/mode/route.ts` | Fixed. Query `organizationId` rejects slugs before org access, entitlement, or worker calls. |
+| Code indexing APIs | `apps/web/src/app/api/code-indexing/enabled/route.ts`, `manifest/route.ts`, `upsert-by-file/route.ts` | Fixed. Query/form `organizationId` rejects slugs before tRPC/storage/backend calls. |
+| Internal APIs | `apps/web/src/app/api/internal/auto-routing-benchmark/token/route.ts`, `apps/web/src/app/api/internal/integrations/dolthub/token/route.ts`, `apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.ts` | Fixed. Internal `organizationId` payloads are UUID contracts. |
+| Signed/state payloads and event schemas | `apps/web/src/lib/bot/linear-link-state.ts`, `apps/web/src/lib/cloud-agent-sdk/schemas.ts` | Fixed. Organization IDs inside state/events are UUID-or-null contracts. |
+| Stripe seat metadata | `apps/web/src/lib/organizations/organization-seats.ts` | Fixed. Subscription metadata `organizationId` parses as UUID. |
+| Admin/analytics owner schemas | `apps/web/src/routers/auto-triage/auto-triage-router.ts`, `apps/web/src/routers/usage-analytics-router.ts` | Fixed. Organization owner/output IDs are UUID schemas. |
+
+## URL Generation Findings
+
+| Pattern | Files | Status |
+|---|---|---|
+| Slug-aware generated organization links | `OrganizationSwitcher.tsx`, `OrganizationAppSidebar.tsx`, `OrganizationMembersCard.tsx`, `OrganizationChildOrganizationsCard.tsx`, `OrganizationInfoCard.tsx`, payment top-up success and cancel paths | Verified/fixed. These use `getOrganizationRouteIdentifier` or resolved route identifier. |
+| Existing UUID-based but compatible organization links | App-builder, cloud-agent, deploy, integrations, security-agent, usage detail links, feature adoption links, webhook routes, MCP gateway routes, bot reinstall links, code-review action links | Documented. These continue to work because UUID URLs are accepted and canonicalized on page routes, but they do not yet prefer slug at generation time. |
+| Email/service generated organization links | `services/kiloclaw-billing/src/lifecycle.ts`, `apps/web/src/lib/organizations/organization-auto-top-up.ts`, some email/admin test helpers | Documented. These still build UUID organization URLs because the generating context only has organization UUID. They are compatible via canonical redirect, but should be upgraded when slug data is available at generation time. |
+| External provider URLs containing `organizations` | GitHub organization repository creation URLs | Not applicable. These are provider URLs, not Kilo organization route identifiers. |
+| Admin organization URLs | `apps/web/src/app/admin/**`, admin components/hooks | Not part of slug migration. Admin routes intentionally remain UUID-keyed. |
+
+## Fixes Applied In This Pass
+
+| Area | Change |
+|---|---|
+| Payment top-up | Slug/UUID query route identifier is resolved with `getAuthorizedOrgContext`; Stripe customer lookup, metadata, and checkout use UUID; cancel/success returns prefer slug route identifier. |
+| Organization models validate API test | Added slug-to-UUID resolver mocking and 404 resolver coverage. |
+| API/query hardening | Query/form/body fields named `organizationId` now reject slugs in OAuth connect, auto-routing, code-indexing, selected internal APIs, bot-link state, Cloud Agent events, Stripe metadata, admin triage, and usage analytics. |
+
+## Verification
+
+| Check | Result |
+|---|---|
+| Slug route helper/router tests | Passed: `organization-route-utils`, `useUrlOrganizationId`, organization router/admin router, organization lib tests. |
+| Organization API `[id]` tests | Passed: defaults, modes, models validate. |
+| Auto-routing/internal/bot/billing focused tests | Passed: 7 suites, 43 tests. |
+| Typecheck | Passed: `scripts/typecheck-all.sh --changes-only` and `pnpm --filter web typecheck`. |
+
From 8ab5889b45f41cdb17dfa826d693c3344616826f Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 18:18:10 -0500
Subject: [PATCH 21/33] fix(organizations): harden slug route handling
---
.../components/OrganizationSlugBackfill.tsx | 6 +-
.../organizations/[id]/models/route.test.ts | 76 +++++++++++++++
.../api/organizations/[id]/models/route.ts | 11 ++-
.../[id]/models/validate/route.test.ts | 41 ++++++--
.../[id]/models/validate/route.ts | 10 +-
.../app/api/organizations/[id]/route.test.ts | 67 +++++++++++++
.../src/app/api/organizations/[id]/route.ts | 12 +--
apps/web/src/app/api/organizations/hooks.ts | 2 +-
.../organizations/OrganizationInfoCard.tsx | 9 +-
.../organization-page-context.server.ts | 8 +-
.../organization-route-utils.server.ts | 7 +-
.../organizations/organization-slug.server.ts | 19 ++++
.../lib/organizations/organization-slug.ts | 2 +-
.../lib/organizations/organizations.test.ts | 48 +++++++++
.../src/lib/organizations/organizations.ts | 34 ++++++-
.../organization-admin-router.test.ts | 83 ++++++++++++++++
.../organization-admin-router.ts | 32 +++++-
.../organizations/organization-router.test.ts | 97 ++++++++++++++++++-
.../organizations/organization-router.ts | 52 ++++++----
19 files changed, 556 insertions(+), 60 deletions(-)
create mode 100644 apps/web/src/app/api/organizations/[id]/models/route.test.ts
create mode 100644 apps/web/src/app/api/organizations/[id]/route.test.ts
diff --git a/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx b/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
index 57413e2b23..a996b24c1a 100644
--- a/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
+++ b/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
@@ -32,8 +32,8 @@ export function OrganizationSlugBackfill() {
return (
- Backfill organization slugs for legacy organizations missing the field. This scans all
- missing rows in one transaction and allocates unique slugs from organization names.
+ Backfill organization slugs for legacy organizations missing the field. Each click processes
+ up to 50 organizations. Click repeatedly until no rows are updated.
@@ -75,7 +75,7 @@ export function OrganizationSlugBackfill() {
) : null}
mutation.mutate()} disabled={mutation.isPending}>
- {mutation.isPending ? 'Backfilling...' : 'Backfill missing slugs'}
+ {mutation.isPending ? 'Backfilling...' : 'Backfill next 50'}
diff --git a/apps/web/src/app/api/organizations/[id]/models/route.test.ts b/apps/web/src/app/api/organizations/[id]/models/route.test.ts
new file mode 100644
index 0000000000..259e052ef2
--- /dev/null
+++ b/apps/web/src/app/api/organizations/[id]/models/route.test.ts
@@ -0,0 +1,76 @@
+import { beforeEach, describe, expect, test } from '@jest/globals';
+import { NextRequest, NextResponse } from 'next/server';
+import type { OpenRouterModel } from '@/lib/organizations/organization-types';
+import { handleTRPCRequest } from '@/lib/trpc-route-handler';
+import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
+import { GET } from './route';
+
+jest.mock('@/lib/trpc-route-handler', () => ({ handleTRPCRequest: jest.fn() }));
+jest.mock('@/lib/organizations/organization-route-utils.server', () => ({
+ resolveOrganizationRouteIdentifier: jest.fn(),
+}));
+
+const mockedHandleTRPCRequest = jest.mocked(handleTRPCRequest);
+const mockedResolveOrganizationRouteIdentifier = jest.mocked(resolveOrganizationRouteIdentifier);
+const listAvailableModels = jest.fn();
+
+function makeModel(id: string): OpenRouterModel {
+ return {
+ id,
+ name: id,
+ created: 0,
+ description: '',
+ architecture: {
+ input_modalities: ['text'],
+ output_modalities: ['text'],
+ tokenizer: 'test',
+ },
+ top_provider: { is_moderated: false },
+ pricing: { prompt: '0', completion: '0' },
+ context_length: 0,
+ supported_parameters: ['tools'],
+ };
+}
+
+describe('GET /api/organizations/[id]/models', () => {
+ beforeEach(() => {
+ jest.resetAllMocks();
+ mockedResolveOrganizationRouteIdentifier.mockResolvedValue(
+ '550e8400-e29b-41d4-a716-446655440000'
+ );
+ listAvailableModels.mockResolvedValue({ data: [makeModel('available/model')] });
+ mockedHandleTRPCRequest.mockImplementation(async (_request, handler) => {
+ const result = await handler({
+ organizations: { settings: { listAvailableModels } },
+ } as never);
+ return NextResponse.json(result);
+ });
+ });
+
+ test('resolves the organization route identifier after authentication', async () => {
+ const response = await GET(
+ new NextRequest('http://localhost:3000/api/organizations/acme/models'),
+ { params: Promise.resolve({ id: 'acme' }) }
+ );
+
+ expect(response.status).toBe(200);
+ expect(mockedResolveOrganizationRouteIdentifier).toHaveBeenCalledWith('acme');
+ expect(listAvailableModels).toHaveBeenCalledWith({
+ organizationId: '550e8400-e29b-41d4-a716-446655440000',
+ });
+ });
+
+ test('does not resolve organization slugs when authentication fails', async () => {
+ mockedHandleTRPCRequest.mockResolvedValue(
+ NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
+ );
+
+ const response = await GET(
+ new NextRequest('http://localhost:3000/api/organizations/acme/models'),
+ { params: Promise.resolve({ id: 'acme' }) }
+ );
+
+ expect(response.status).toBe(401);
+ expect(mockedResolveOrganizationRouteIdentifier).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/web/src/app/api/organizations/[id]/models/route.ts b/apps/web/src/app/api/organizations/[id]/models/route.ts
index c4c50a95fd..3687f768a2 100644
--- a/apps/web/src/app/api/organizations/[id]/models/route.ts
+++ b/apps/web/src/app/api/organizations/[id]/models/route.ts
@@ -1,20 +1,21 @@
import type { NextRequest } from 'next/server';
-import { NextResponse } from 'next/server';
import type { OpenRouterModelsResponse } from '@/lib/organizations/organization-types';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
import { FEATURE_HEADER, validateFeatureHeader } from '@/lib/feature-detection';
import { filterByFeature } from '@/lib/ai-gateway/models';
import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
+import { TRPCError } from '@trpc/server';
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const routeIdentifier = (await params).id;
- const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
- if (!organizationId) {
- return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
- }
const feature = validateFeatureHeader(request.headers.get(FEATURE_HEADER));
return handleTRPCRequest
(request, async caller => {
+ const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
+ if (!organizationId) {
+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Organization not found' });
+ }
+
const result = await caller.organizations.settings.listAvailableModels({ organizationId });
return { ...result, data: filterByFeature(result.data, feature) };
});
diff --git a/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts b/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts
index 33a10c869e..4d59c458a2 100644
--- a/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts
+++ b/apps/web/src/app/api/organizations/[id]/models/validate/route.test.ts
@@ -4,6 +4,7 @@ import type { OpenRouterModel } from '@/lib/organizations/organization-types';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
import { POST } from './route';
+import { TRPCError } from '@trpc/server';
jest.mock('@/lib/trpc-route-handler', () => ({ handleTRPCRequest: jest.fn() }));
jest.mock('@/lib/organizations/organization-route-utils.server', () => ({
@@ -45,11 +46,21 @@ describe('POST /api/organizations/[id]/models/validate', () => {
jest.resetAllMocks();
mockedResolveOrganizationRouteIdentifier.mockResolvedValue(ORGANIZATION_ID);
listAvailableModels.mockResolvedValue({ data: [makeModel('available/model')] });
- mockedHandleTRPCRequest.mockImplementation(async (request, handler) => {
- const result = await handler({
- organizations: { settings: { listAvailableModels } },
- } as never);
- return NextResponse.json(result);
+ mockedHandleTRPCRequest.mockImplementation(async (_request, handler) => {
+ try {
+ const result = await handler({
+ organizations: { settings: { listAvailableModels } },
+ } as never);
+ return NextResponse.json(result);
+ } catch (error) {
+ if (error instanceof TRPCError) {
+ return NextResponse.json(
+ { error: error.message, message: error.message },
+ { status: 404 }
+ );
+ }
+ throw error;
+ }
});
});
@@ -79,8 +90,24 @@ describe('POST /api/organizations/[id]/models/validate', () => {
});
expect(response.status).toBe(404);
- await expect(response.json()).resolves.toEqual({ error: 'Organization not found' });
- expect(mockedHandleTRPCRequest).not.toHaveBeenCalled();
+ await expect(response.json()).resolves.toEqual({
+ error: 'Organization not found',
+ message: 'Organization not found',
+ });
+ expect(mockedHandleTRPCRequest).toHaveBeenCalled();
+ });
+
+ test('does not resolve organization slugs when authentication fails', async () => {
+ mockedHandleTRPCRequest.mockResolvedValue(
+ NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
+ );
+
+ const response = await POST(request('available/model'), {
+ params: Promise.resolve({ id: 'acme' }),
+ });
+
+ expect(response.status).toBe(401);
+ expect(mockedResolveOrganizationRouteIdentifier).not.toHaveBeenCalled();
});
test('rejects an invalid body before invoking organization authorization', async () => {
diff --git a/apps/web/src/app/api/organizations/[id]/models/validate/route.ts b/apps/web/src/app/api/organizations/[id]/models/validate/route.ts
index 1668a302b7..2eeafae53a 100644
--- a/apps/web/src/app/api/organizations/[id]/models/validate/route.ts
+++ b/apps/web/src/app/api/organizations/[id]/models/validate/route.ts
@@ -5,6 +5,7 @@ import { handleTRPCRequest } from '@/lib/trpc-route-handler';
import { FEATURE_HEADER, validateFeatureHeader } from '@/lib/feature-detection';
import { filterByFeature } from '@/lib/ai-gateway/models';
import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
+import { TRPCError } from '@trpc/server';
const BodySchema = z.object({ modelId: z.string().trim().min(1) });
@@ -30,13 +31,14 @@ export async function POST(
}
const routeIdentifier = (await params).id;
- const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
- if (!organizationId) {
- return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
- }
const feature = validateFeatureHeader(request.headers.get(FEATURE_HEADER));
return handleTRPCRequest(request, async caller => {
+ const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
+ if (!organizationId) {
+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Organization not found' });
+ }
+
const result = await caller.organizations.settings.listAvailableModels({ organizationId });
const available = filterByFeature(result.data, feature).some(
model => model.id === bodyResult.data.modelId
diff --git a/apps/web/src/app/api/organizations/[id]/route.test.ts b/apps/web/src/app/api/organizations/[id]/route.test.ts
new file mode 100644
index 0000000000..6fc34fe66c
--- /dev/null
+++ b/apps/web/src/app/api/organizations/[id]/route.test.ts
@@ -0,0 +1,67 @@
+import { beforeEach, describe, expect, test } from '@jest/globals';
+import { NextRequest, NextResponse } from 'next/server';
+import { TRPCError } from '@trpc/server';
+import { handleTRPCRequest } from '@/lib/trpc-route-handler';
+import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
+import { GET } from './route';
+
+jest.mock('@/lib/trpc-route-handler', () => ({ handleTRPCRequest: jest.fn() }));
+jest.mock('@/lib/organizations/organization-route-utils.server', () => ({
+ resolveOrganizationRouteIdentifier: jest.fn(),
+}));
+
+const mockedHandleTRPCRequest = jest.mocked(handleTRPCRequest);
+const mockedResolveOrganizationRouteIdentifier = jest.mocked(resolveOrganizationRouteIdentifier);
+
+describe('GET /api/organizations/[id]', () => {
+ beforeEach(() => {
+ jest.resetAllMocks();
+ mockedResolveOrganizationRouteIdentifier.mockResolvedValue(
+ '550e8400-e29b-41d4-a716-446655440000'
+ );
+ mockedHandleTRPCRequest.mockImplementation(async (_request, handler) => {
+ try {
+ const result = await handler({
+ organizations: {
+ withMembers: jest.fn().mockResolvedValue({
+ id: '550e8400-e29b-41d4-a716-446655440000',
+ name: 'Acme',
+ settings: {},
+ }),
+ },
+ } as never);
+ return NextResponse.json(result);
+ } catch (error) {
+ if (error instanceof TRPCError) {
+ return NextResponse.json(
+ { error: error.message, message: error.message },
+ { status: 404 }
+ );
+ }
+ throw error;
+ }
+ });
+ });
+
+ test('resolves the organization route identifier after authentication', async () => {
+ const response = await GET(new NextRequest('http://localhost:3000/api/organizations/acme'), {
+ params: Promise.resolve({ id: 'acme' }),
+ });
+
+ expect(response.status).toBe(200);
+ expect(mockedResolveOrganizationRouteIdentifier).toHaveBeenCalledWith('acme');
+ });
+
+ test('does not resolve organization slugs when authentication fails', async () => {
+ mockedHandleTRPCRequest.mockResolvedValue(
+ NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
+ );
+
+ const response = await GET(new NextRequest('http://localhost:3000/api/organizations/acme'), {
+ params: Promise.resolve({ id: 'acme' }),
+ });
+
+ expect(response.status).toBe(401);
+ expect(mockedResolveOrganizationRouteIdentifier).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/web/src/app/api/organizations/[id]/route.ts b/apps/web/src/app/api/organizations/[id]/route.ts
index 6cd0dcc39e..8eccddf63b 100644
--- a/apps/web/src/app/api/organizations/[id]/route.ts
+++ b/apps/web/src/app/api/organizations/[id]/route.ts
@@ -1,17 +1,17 @@
import type { NextRequest } from 'next/server';
-import { NextResponse } from 'next/server';
import { handleTRPCRequest } from '@/lib/trpc-route-handler';
import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
+import { TRPCError } from '@trpc/server';
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const routeIdentifier = (await params).id;
- const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
-
- if (!organizationId) {
- return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
- }
return handleTRPCRequest(request, async caller => {
+ const organizationId = await resolveOrganizationRouteIdentifier(routeIdentifier);
+ if (!organizationId) {
+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Organization not found' });
+ }
+
const org = await caller.organizations.withMembers({ organizationId });
const res = {
id: org.id,
diff --git a/apps/web/src/app/api/organizations/hooks.ts b/apps/web/src/app/api/organizations/hooks.ts
index bd25d67e99..ae1f8fd747 100644
--- a/apps/web/src/app/api/organizations/hooks.ts
+++ b/apps/web/src/app/api/organizations/hooks.ts
@@ -107,7 +107,7 @@ export function useOrganizationUsageStats(organizationId: string) {
export function useSlugAvailability(
organizationId: string,
- slug: string | null,
+ slug: string,
options?: { enabled?: boolean }
) {
const trpc = useTRPC();
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index 0b34ce7c0f..7294a9edc4 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -209,7 +209,7 @@ function Inner(props: InnerProps) {
const updateSuppressTrialMessaging = useUpdateSuppressTrialMessaging();
const { expiringBlocks, expiring_mUsd, earliestExpiry } = useExpiringCredits(id);
- const editedSlugAvailability = useSlugAvailability(id, editedSlug.trim() || null, {
+ const editedSlugAvailability = useSlugAvailability(id, editedSlug.trim(), {
enabled: isEditingSlug && Boolean(editedSlug.trim()) && editedSlug.trim() !== info.slug,
});
const isEditedSlugAvailable = editedSlugAvailability.data?.available ?? true;
@@ -254,7 +254,12 @@ function Inner(props: InnerProps) {
const handleSlugSave = async () => {
setSlugError(null);
- const nextSlug = editedSlug.trim() || null;
+ const nextSlug = editedSlug.trim();
+ if (!nextSlug) {
+ setSlugError('Organization slug is required');
+ return;
+ }
+
if (nextSlug === info.slug) {
setEditedSlug(info.slug ?? '');
setIsEditingSlug(false);
diff --git a/apps/web/src/lib/organizations/organization-page-context.server.ts b/apps/web/src/lib/organizations/organization-page-context.server.ts
index 40bd740d54..e642e6fe36 100644
--- a/apps/web/src/lib/organizations/organization-page-context.server.ts
+++ b/apps/web/src/lib/organizations/organization-page-context.server.ts
@@ -1,5 +1,6 @@
import 'server-only';
+import { cache } from 'react';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';
import type { Organization, User } from '@kilocode/db/schema';
@@ -21,13 +22,18 @@ export type AuthorizedOrganizationRouteContext = {
organization: Organization;
};
+const getAuthorizedOrganizationRouteContextForIdentifier = cache(
+ async (routeIdentifier: string, roles?: OrganizationRole[]) =>
+ getAuthorizedOrgContext(routeIdentifier, roles)
+);
+
export async function getAuthorizedOrganizationRouteContext(
params: OrganizationRouteParams,
roles?: OrganizationRole[]
) {
const { id } = await params;
const routeIdentifier = decodeURIComponent(id);
- const result = await getAuthorizedOrgContext(routeIdentifier, roles);
+ const result = await getAuthorizedOrganizationRouteContextForIdentifier(routeIdentifier, roles);
return {
rawRouteIdentifier: id,
diff --git a/apps/web/src/lib/organizations/organization-route-utils.server.ts b/apps/web/src/lib/organizations/organization-route-utils.server.ts
index d0964b09d3..a0a901f5e9 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.server.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.server.ts
@@ -1,5 +1,6 @@
import 'server-only';
+import { cache } from 'react';
import { organizations } from '@kilocode/db/schema';
import { and, eq, isNull } from 'drizzle-orm';
import { db } from '@/lib/drizzle';
@@ -13,7 +14,7 @@ export type ResolvedOrganizationRouteIdentifier = OrganizationRouteIdentifierInp
routeIdentifier: string;
};
-export async function resolveOrganizationRouteIdentifierDetails(
+async function resolveOrganizationRouteIdentifierDetailsUncached(
identifier: string
): Promise {
const [organization] = await db
@@ -39,6 +40,10 @@ export async function resolveOrganizationRouteIdentifierDetails(
};
}
+export const resolveOrganizationRouteIdentifierDetails = cache(
+ resolveOrganizationRouteIdentifierDetailsUncached
+);
+
export async function resolveOrganizationRouteIdentifier(
identifier: string
): Promise {
diff --git a/apps/web/src/lib/organizations/organization-slug.server.ts b/apps/web/src/lib/organizations/organization-slug.server.ts
index b73be5f9ab..6729b021f5 100644
--- a/apps/web/src/lib/organizations/organization-slug.server.ts
+++ b/apps/web/src/lib/organizations/organization-slug.server.ts
@@ -13,6 +13,9 @@ import {
const ORGANIZATION_SLUG_ALLOCATION_LOCK_KEY_1 = 20260625;
const ORGANIZATION_SLUG_ALLOCATION_LOCK_KEY_2 = 1;
const MAX_ORGANIZATION_SLUG_ALLOCATION_ATTEMPTS = 32;
+const DELETED_ORGANIZATION_SLUG_PREFIX = 'deleted-';
+const DELETED_ORGANIZATION_SLUG_RANDOM_BYTES = 12;
+export const MAX_DELETED_ORGANIZATION_SLUG_ATTEMPTS = 5;
async function organizationSlugExists(slug: string, tx: DrizzleTransaction): Promise {
const [existingOrganization] = await tx
@@ -28,6 +31,10 @@ function generateOrganizationSlugCollisionSuffix(): string {
return randomBytes(2).toString('hex').slice(0, ORGANIZATION_SLUG_COLLISION_SUFFIX_LENGTH);
}
+function generateDeletedOrganizationSlug(): string {
+ return `${DELETED_ORGANIZATION_SLUG_PREFIX}${randomBytes(DELETED_ORGANIZATION_SLUG_RANDOM_BYTES).toString('hex')}`;
+}
+
export async function allocateOrganizationSlug(
name: string,
tx: DrizzleTransaction
@@ -54,3 +61,15 @@ export async function allocateOrganizationSlug(
throw new Error(`Failed to allocate organization slug for "${name}"`);
}
+
+export async function allocateDeletedOrganizationSlug(tx: DrizzleTransaction): Promise {
+ for (let attempt = 0; attempt < MAX_DELETED_ORGANIZATION_SLUG_ATTEMPTS; attempt += 1) {
+ const candidateSlug = generateDeletedOrganizationSlug();
+
+ if (!(await organizationSlugExists(candidateSlug, tx))) {
+ return candidateSlug;
+ }
+ }
+
+ throw new Error('Failed to allocate deleted organization slug');
+}
diff --git a/apps/web/src/lib/organizations/organization-slug.ts b/apps/web/src/lib/organizations/organization-slug.ts
index 585148e432..e2ad4cc6af 100644
--- a/apps/web/src/lib/organizations/organization-slug.ts
+++ b/apps/web/src/lib/organizations/organization-slug.ts
@@ -3,7 +3,7 @@ import { ORGANIZATION_SLUG_MAX_LENGTH } from '@/lib/organizations/organization-r
export const ORGANIZATION_SLUG_COLLISION_SUFFIX_LENGTH = 3;
const ORGANIZATION_SLUG_SUFFIX_SEPARATOR_LENGTH = 1;
-const ORGANIZATION_SLUG_RESERVED_SUBSTRINGS = ['kilo'];
+const ORGANIZATION_SLUG_RESERVED_SUBSTRINGS = ['kilo', 'deleted'];
const ORGANIZATION_SLUG_FALLBACK_ADJECTIVES = [
'bright',
'calm',
diff --git a/apps/web/src/lib/organizations/organizations.test.ts b/apps/web/src/lib/organizations/organizations.test.ts
index bd035268ee..7e8f68e8ca 100644
--- a/apps/web/src/lib/organizations/organizations.test.ts
+++ b/apps/web/src/lib/organizations/organizations.test.ts
@@ -19,6 +19,7 @@ import {
inviteUserToOrganization,
getOrganizationMembers,
acceptOrganizationInvite,
+ markOrganizationAsDeleted,
} from './organizations';
import { fromMicrodollars } from '@/lib/utils';
import { DEFAULT_MEMBER_DAILY_LIMIT_USD } from '@/lib/organizations/constants';
@@ -45,6 +46,7 @@ describe('Organizations', () => {
expect(normalizeOrganizationSlug('Team_Alpha Beta.Gamma!')).toBe('teamalpha-beta-gamma');
expect(normalizeOrganizationSlug('Kilo Test Org')).toBe('test-org');
expect(normalizeOrganizationSlug('Kilocode Team')).toBe('code-team');
+ expect(normalizeOrganizationSlug('Deleted Team')).toBe('team');
expect(normalizeOrganizationSlug('mykiloorg')).toBe('myorg');
expect(normalizeOrganizationSlug('Kilo')).toMatch(/^[a-z]+-[a-z]+$/);
expect(normalizeOrganizationSlug('')).toMatch(/^[a-z]+-[a-z]+$/);
@@ -69,6 +71,52 @@ describe('Organizations', () => {
expect(firstOrganization.slug).toBe('demo-example-org');
expect(secondOrganization.slug).toMatch(/^demo-example-org-[0-9a-f]{3}$/);
});
+
+ test('randomizes deleted organization slugs and releases the original slug', async () => {
+ const user = await insertTestUser();
+ const organization = await createOrganization('Reusable Org', user.id);
+ const secondOrganization = await createOrganization('Second Reusable Org', user.id);
+
+ await markOrganizationAsDeleted(organization.id);
+ await markOrganizationAsDeleted(secondOrganization.id);
+
+ const deletedOrganization = await db.query.organizations.findFirst({
+ where: eq(organizations.id, organization.id),
+ });
+ const secondDeletedOrganization = await db.query.organizations.findFirst({
+ where: eq(organizations.id, secondOrganization.id),
+ });
+ expect(deletedOrganization).toBeDefined();
+ expect(deletedOrganization?.deleted_at).not.toBeNull();
+ expect(deletedOrganization?.slug).toMatch(/^deleted-[0-9a-f]{24}$/);
+ expect(deletedOrganization?.slug).toHaveLength(32);
+ expect(deletedOrganization?.slug).not.toBe(
+ `deleted-${organization.id.replaceAll('-', '').slice(0, 24)}`
+ );
+ expect(secondDeletedOrganization?.slug).toMatch(/^deleted-[0-9a-f]{24}$/);
+ expect(secondDeletedOrganization?.slug).not.toBe(deletedOrganization?.slug);
+
+ const replacementOrganization = await createOrganization('Reusable Org', user.id);
+ expect(replacementOrganization.slug).toBe('reusable-org');
+ });
+
+ test('sets a deleted marker slug when the existing organization slug is null', async () => {
+ const user = await insertTestUser();
+ const organization = await createOrganization('Null Slug Org', user.id);
+ await db
+ .update(organizations)
+ .set({ slug: null })
+ .where(eq(organizations.id, organization.id));
+
+ await markOrganizationAsDeleted(organization.id);
+
+ const deletedOrganization = await db.query.organizations.findFirst({
+ where: eq(organizations.id, organization.id),
+ });
+ expect(deletedOrganization?.deleted_at).not.toBeNull();
+ expect(deletedOrganization?.slug).toMatch(/^deleted-[0-9a-f]{24}$/);
+ expect(deletedOrganization?.slug).toHaveLength(32);
+ });
});
describe('getUserOrganizationsWithSeats', () => {
diff --git a/apps/web/src/lib/organizations/organizations.ts b/apps/web/src/lib/organizations/organizations.ts
index 76e0ede14c..08efdf02c0 100644
--- a/apps/web/src/lib/organizations/organizations.ts
+++ b/apps/web/src/lib/organizations/organizations.ts
@@ -27,7 +27,11 @@ import { APP_URL } from '@/lib/constants';
import { createAuditLog } from '@/lib/organizations/organization-audit-logs';
import { failureResult, successResult } from '@/lib/maybe-result';
import { reportEvents } from '@/lib/ai-gateway/abuse-service';
-import { allocateOrganizationSlug } from '@/lib/organizations/organization-slug.server';
+import {
+ allocateDeletedOrganizationSlug,
+ allocateOrganizationSlug,
+ MAX_DELETED_ORGANIZATION_SLUG_ATTEMPTS,
+} from '@/lib/organizations/organization-slug.server';
export async function getOrganizationById(
id: Organization['id'],
@@ -847,11 +851,31 @@ export async function setOrganizationRecommendationsDigestEnabled(
return row?.settings ?? {};
}
+function isUniqueConstraintViolation(error: unknown): boolean {
+ if (error === null || typeof error !== 'object') return false;
+ const err = error as { code?: string; cause?: { code?: string } };
+ return (err.code ?? err.cause?.code) === '23505';
+}
+
export async function markOrganizationAsDeleted(organizationId: Organization['id']): Promise {
- await db
- .update(organizations)
- .set({ ...auto_deleted_at })
- .where(eq(organizations.id, organizationId));
+ for (let attempt = 0; attempt < MAX_DELETED_ORGANIZATION_SLUG_ATTEMPTS; attempt += 1) {
+ try {
+ await db.transaction(async tx => {
+ const deletedSlug = await allocateDeletedOrganizationSlug(tx);
+
+ await tx
+ .update(organizations)
+ .set({ ...auto_deleted_at, slug: deletedSlug })
+ .where(eq(organizations.id, organizationId));
+ });
+ return;
+ } catch (error) {
+ if (isUniqueConstraintViolation(error)) continue;
+ throw error;
+ }
+ }
+
+ throw new Error(`Failed to allocate deleted organization slug for ${organizationId}`);
}
export async function getOrganizationMemberByEmail(
diff --git a/apps/web/src/routers/organizations/organization-admin-router.test.ts b/apps/web/src/routers/organizations/organization-admin-router.test.ts
index 3331c422dd..1d9b671d2b 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.test.ts
@@ -110,6 +110,7 @@ describe('organization admin router', () => {
organizationIds.includes(organization.id)
);
+ expect(result.updatedCount).toBeLessThanOrEqual(50);
expect(backfilledRows).toHaveLength(2);
expect(backfilledRows.map(organization => organization.id)).toEqual([
otherMissingOrganization.id,
@@ -142,6 +143,88 @@ describe('organization admin router', () => {
await db.delete(organizations).where(inArray(organizations.id, organizationIds));
}
});
+
+ it('backfills legacy deleted organizations with deleted slugs that do not block name reuse', async () => {
+ const organizationName = `Backfill Deleted Legacy ${crypto.randomUUID()}`;
+ const deletedOrganization = await createOrganization(organizationName, null);
+ const nullSlugDeletedOrganization = await createOrganization(
+ `Backfill Null Deleted Legacy ${crypto.randomUUID()}`,
+ null
+ );
+ const alreadyBackfilledDeletedOrganization = await createOrganization(
+ `Backfill Already Deleted Legacy ${crypto.randomUUID()}`,
+ null
+ );
+ const alreadyBackfilledDeletedSlug = `deleted-${crypto.randomUUID().replaceAll('-', '').slice(0, 24)}`;
+ const organizationIds = [
+ deletedOrganization.id,
+ nullSlugDeletedOrganization.id,
+ alreadyBackfilledDeletedOrganization.id,
+ ];
+
+ try {
+ await db
+ .update(organizations)
+ .set({ slug: null, deleted_at: sql`NOW()` })
+ .where(eq(organizations.id, nullSlugDeletedOrganization.id));
+
+ await db
+ .update(organizations)
+ .set({ deleted_at: sql`NOW()` })
+ .where(eq(organizations.id, deletedOrganization.id));
+
+ await db
+ .update(organizations)
+ .set({ slug: alreadyBackfilledDeletedSlug, deleted_at: sql`NOW()` })
+ .where(eq(organizations.id, alreadyBackfilledDeletedOrganization.id));
+
+ const caller = await createCallerForUser(adminUser.id);
+ const result = await caller.organizations.admin.backfillMissingSlugs();
+ const backfilledDeletedOrganization = result.organizations.find(
+ organization => organization.id === deletedOrganization.id
+ );
+ const backfilledNullSlugDeletedOrganization = result.organizations.find(
+ organization => organization.id === nullSlugDeletedOrganization.id
+ );
+
+ expect(backfilledDeletedOrganization?.slug).toMatch(/^deleted-[0-9a-f]{24}$/);
+ expect(backfilledNullSlugDeletedOrganization?.slug).toMatch(/^deleted-[0-9a-f]{24}$/);
+ expect(
+ result.organizations.some(
+ organization => organization.id === alreadyBackfilledDeletedOrganization.id
+ )
+ ).toBe(false);
+
+ const reusedNameOrganization = await createOrganization(organizationName, null);
+ organizationIds.push(reusedNameOrganization.id);
+
+ const updatedOrganizations = await db
+ .select({ id: organizations.id, slug: organizations.slug })
+ .from(organizations)
+ .where(inArray(organizations.id, organizationIds));
+ const updatedSlugByOrganizationId = new Map(
+ updatedOrganizations.map(organization => [organization.id, organization.slug])
+ );
+
+ expect(updatedSlugByOrganizationId.get(deletedOrganization.id)).toMatch(
+ /^deleted-[0-9a-f]{24}$/
+ );
+ expect(updatedSlugByOrganizationId.get(deletedOrganization.id)).not.toBe(
+ normalizeOrganizationSlug(organizationName)
+ );
+ expect(updatedSlugByOrganizationId.get(nullSlugDeletedOrganization.id)).toMatch(
+ /^deleted-[0-9a-f]{24}$/
+ );
+ expect(updatedSlugByOrganizationId.get(alreadyBackfilledDeletedOrganization.id)).toBe(
+ alreadyBackfilledDeletedSlug
+ );
+ expect(updatedSlugByOrganizationId.get(reusedNameOrganization.id)).toBe(
+ normalizeOrganizationSlug(organizationName)
+ );
+ } finally {
+ await db.delete(organizations).where(inArray(organizations.id, organizationIds));
+ }
+ });
});
describe('nullifyCredits', () => {
diff --git a/apps/web/src/routers/organizations/organization-admin-router.ts b/apps/web/src/routers/organizations/organization-admin-router.ts
index 10789acf21..4236a2acb5 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.ts
@@ -21,7 +21,9 @@ import {
gt,
and,
isNull,
+ isNotNull,
inArray,
+ notLike,
sql,
type SQL,
} from 'drizzle-orm';
@@ -51,7 +53,10 @@ import {
ORGANIZATION_TRIAL_ACTIVE_MIN_DAYS_REMAINING,
ORGANIZATION_TRIAL_DURATION_DAYS,
} from '@kilocode/organization-entitlement';
-import { allocateOrganizationSlug } from '@/lib/organizations/organization-slug.server';
+import {
+ allocateDeletedOrganizationSlug,
+ allocateOrganizationSlug,
+} from '@/lib/organizations/organization-slug.server';
const OrganizationListInputSchema = z.object({
page: z.number().int().min(1).default(1),
@@ -201,6 +206,8 @@ const BackfillMissingSlugsOutputSchema = z.object({
),
});
+const BACKFILL_MISSING_SLUGS_BATCH_SIZE = 50;
+
const AddMemberInputSchema = z.object({
organizationId: z.uuid(),
userId: z.string(),
@@ -311,14 +318,21 @@ export const organizationAdminRouter = createTRPCRouter({
.select({
id: organizations.id,
name: organizations.name,
+ deleted_at: organizations.deleted_at,
})
.from(organizations)
- .where(isNull(organizations.slug))
+ .where(
+ or(
+ isNull(organizations.slug),
+ and(isNotNull(organizations.deleted_at), notLike(organizations.slug, 'deleted-%'))
+ )
+ )
.orderBy(
desc(organizations.total_microdollars_acquired),
asc(organizations.created_at),
asc(organizations.id)
)
+ .limit(BACKFILL_MISSING_SLUGS_BATCH_SIZE)
.for('update');
const updatedOrganizations: Array<{
@@ -328,11 +342,21 @@ export const organizationAdminRouter = createTRPCRouter({
}> = [];
for (const organization of organizationsWithoutSlugs) {
- const slug = await allocateOrganizationSlug(organization.name, tx);
+ const slug = organization.deleted_at
+ ? await allocateDeletedOrganizationSlug(tx)
+ : await allocateOrganizationSlug(organization.name, tx);
const [updatedOrganization] = await tx
.update(organizations)
.set({ slug })
- .where(and(eq(organizations.id, organization.id), isNull(organizations.slug)))
+ .where(
+ and(
+ eq(organizations.id, organization.id),
+ or(
+ isNull(organizations.slug),
+ and(isNotNull(organizations.deleted_at), notLike(organizations.slug, 'deleted-%'))
+ )
+ )
+ )
.returning({
id: organizations.id,
name: organizations.name,
diff --git a/apps/web/src/routers/organizations/organization-router.test.ts b/apps/web/src/routers/organizations/organization-router.test.ts
index 1b34fdc827..83bff080b4 100644
--- a/apps/web/src/routers/organizations/organization-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-router.test.ts
@@ -3,7 +3,11 @@ import { db } from '@/lib/drizzle';
import { credit_transactions, organizations } from '@kilocode/db/schema';
import { eq } from 'drizzle-orm';
import { insertTestUser } from '@/tests/helpers/user.helper';
-import { createOrganization, addUserToOrganization } from '@/lib/organizations/organizations';
+import {
+ createOrganization,
+ addUserToOrganization,
+ markOrganizationAsDeleted,
+} from '@/lib/organizations/organizations';
import type { User, Organization } from '@kilocode/db/schema';
// Test users and organization will be created dynamically
@@ -635,6 +639,42 @@ describe('organizations trpc router', () => {
})
).rejects.toThrow('You do not have access to this organization');
});
+
+ it('rejects availability checks for deleted organizations', async () => {
+ const deletedOrganization = await createOrganization(
+ 'Deleted Slug Availability Organization',
+ regularUser.id
+ );
+ await db
+ .update(organizations)
+ .set({ slug: 'deleted-availability-before' })
+ .where(eq(organizations.id, deletedOrganization.id));
+ await markOrganizationAsDeleted(deletedOrganization.id);
+
+ try {
+ const [deletedRow] = await db
+ .select({ slug: organizations.slug })
+ .from(organizations)
+ .where(eq(organizations.id, deletedOrganization.id));
+ if (!deletedRow) throw new Error('Expected deleted organization row to exist');
+
+ const caller = await createCallerForUser(regularUser.id);
+ await expect(
+ caller.organizations.slugAvailability({
+ organizationId: deletedOrganization.id,
+ slug: 'deleted-availability-after',
+ })
+ ).rejects.toThrow('Organization not found');
+
+ const [unchangedRow] = await db
+ .select({ slug: organizations.slug })
+ .from(organizations)
+ .where(eq(organizations.id, deletedOrganization.id));
+ expect(unchangedRow?.slug).toBe(deletedRow.slug);
+ } finally {
+ await db.delete(organizations).where(eq(organizations.id, deletedOrganization.id));
+ }
+ });
});
describe('updateSlug procedure', () => {
@@ -767,6 +807,17 @@ describe('organizations trpc router', () => {
).rejects.toThrow('Organization slug must use lowercase letters, numbers, and hyphens');
});
+ it('rejects null slug updates', async () => {
+ const caller = await createCallerForUser(regularUser.id);
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: null as never,
+ })
+ ).rejects.toThrow();
+ });
+
it('rejects slugs containing reserved terms', async () => {
const caller = await createCallerForUser(regularUser.id);
@@ -783,6 +834,50 @@ describe('organizations trpc router', () => {
slug: 'kilocode-org',
})
).rejects.toThrow('Organization slug cannot contain reserved terms');
+
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: testOrganization.id,
+ slug: 'deleted-team',
+ })
+ ).rejects.toThrow('Organization slug cannot contain reserved terms');
+ });
+
+ it('rejects deleted organizations without changing the deleted marker slug', async () => {
+ const deletedOrganization = await createOrganization(
+ 'Deleted Slug Update Organization',
+ regularUser.id
+ );
+ await db
+ .update(organizations)
+ .set({ slug: 'deleted-update-before' })
+ .where(eq(organizations.id, deletedOrganization.id));
+ await markOrganizationAsDeleted(deletedOrganization.id);
+
+ try {
+ const [deletedRow] = await db
+ .select({ slug: organizations.slug })
+ .from(organizations)
+ .where(eq(organizations.id, deletedOrganization.id));
+ if (!deletedRow) throw new Error('Expected deleted organization row to exist');
+ expect(deletedRow.slug).toMatch(/^deleted-/);
+
+ const caller = await createCallerForUser(regularUser.id);
+ await expect(
+ caller.organizations.updateSlug({
+ organizationId: deletedOrganization.id,
+ slug: 'active-looking-slug',
+ })
+ ).rejects.toThrow('Organization not found');
+
+ const [unchangedRow] = await db
+ .select({ slug: organizations.slug })
+ .from(organizations)
+ .where(eq(organizations.id, deletedOrganization.id));
+ expect(unchangedRow?.slug).toBe(deletedRow.slug);
+ } finally {
+ await db.delete(organizations).where(eq(organizations.id, deletedOrganization.id));
+ }
});
});
diff --git a/apps/web/src/routers/organizations/organization-router.ts b/apps/web/src/routers/organizations/organization-router.ts
index 0421d24bf9..d3c6b95499 100644
--- a/apps/web/src/routers/organizations/organization-router.ts
+++ b/apps/web/src/routers/organizations/organization-router.ts
@@ -88,7 +88,7 @@ const OrganizationSlugSchema = z
);
const OrganizationSlugUpdateSchema = OrganizationIdInputSchema.extend({
- slug: OrganizationSlugSchema.nullable(),
+ slug: OrganizationSlugSchema,
});
const OrganizationSeatsUpdateSchema = OrganizationIdInputSchema.extend({
@@ -119,6 +119,16 @@ async function ensureOrganizationSlugUpdateAccess(ctx: TRPCContext, organization
});
}
+async function assertOrganizationSlugUpdateTargetIsActive(organizationId: string) {
+ const organization = await getOrganizationById(organizationId);
+ if (organization) return;
+
+ throw new TRPCError({
+ code: 'NOT_FOUND',
+ message: 'Organization not found',
+ });
+}
+
function isKiloStaffUser(user: TRPCContext['user']): boolean {
return user.google_user_email.toLowerCase().endsWith('@kilocode.ai');
}
@@ -283,10 +293,7 @@ export const organizationsRouter = createTRPCRouter({
slugAvailability: baseProcedure.input(OrganizationSlugUpdateSchema).query(async opts => {
await ensureOrganizationSlugUpdateAccess(opts.ctx, opts.input.organizationId);
-
- if (!opts.input.slug) {
- return { available: true };
- }
+ await assertOrganizationSlugUpdateTargetIsActive(opts.input.organizationId);
const existingOrganization = await getOrganizationByActiveSlug(
opts.input.slug,
@@ -481,24 +488,31 @@ export const organizationsRouter = createTRPCRouter({
updateSlug: baseProcedure.input(OrganizationSlugUpdateSchema).mutation(async opts => {
await ensureOrganizationSlugUpdateAccess(opts.ctx, opts.input.organizationId);
- if (opts.input.slug) {
- if (
- organizationSlugContainsReservedSubstring(opts.input.slug) &&
- !isKiloStaffUser(opts.ctx.user)
- ) {
- throw new TRPCError({
- code: 'BAD_REQUEST',
- message: 'Organization slug cannot contain reserved terms',
- });
- }
-
- await assertActiveSlugAvailable(opts.input.slug, opts.input.organizationId);
+ await assertOrganizationSlugUpdateTargetIsActive(opts.input.organizationId);
+ if (
+ organizationSlugContainsReservedSubstring(opts.input.slug) &&
+ !isKiloStaffUser(opts.ctx.user)
+ ) {
+ throw new TRPCError({
+ code: 'BAD_REQUEST',
+ message: 'Organization slug cannot contain reserved terms',
+ });
}
- await db
+ await assertActiveSlugAvailable(opts.input.slug, opts.input.organizationId);
+
+ const [updatedOrganization] = await db
.update(organizations)
.set({ slug: opts.input.slug })
- .where(eq(organizations.id, opts.input.organizationId));
+ .where(and(eq(organizations.id, opts.input.organizationId), isNull(organizations.deleted_at)))
+ .returning({ id: organizations.id });
+
+ if (!updatedOrganization) {
+ throw new TRPCError({
+ code: 'NOT_FOUND',
+ message: 'Organization not found',
+ });
+ }
return {
organization: {
From 697bc035c2d1a5bd5a42638f5bdb50ff24a847fc Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 18:57:53 -0500
Subject: [PATCH 22/33] fix(organizations): use slugs in org URLs
---
.../[id]/cloud/(agent)/layout.tsx | 10 +-
.../organizations/[id]/cloud/(agent)/page.tsx | 3 +-
.../[id]/code-reviews/review-md/page.tsx | 4 +-
.../src/app/(app)/organizations/[id]/page.tsx | 3 +-
.../[id]/security-agent/layout.tsx | 7 +-
.../OrganizationAdminDashboard.tsx | 16 ++-
.../components/OrganizationTableBody.tsx | 3 +-
.../security-agent/notifications/route.ts | 28 ++++--
apps/web/src/app/api/profile/usage/route.ts | 16 ++-
.../payments/subscriptions/success/page.tsx | 5 +-
.../app/users/accept-invite/[token]/page.tsx | 6 +-
.../app-builder/AppBuilderLanding.tsx | 25 ++++-
.../components/app-builder/AppBuilderPage.tsx | 30 +++++-
.../app-builder/AppBuilderPreview.tsx | 26 +++--
.../app-builder/MigrateToGitHubDialog.tsx | 11 ++-
.../cloud-agent-next/ChatSidebar.tsx | 8 +-
.../cloud-agent-next/CloudSidebarLayout.tsx | 17 +++-
.../cloud-agent-next/NewSessionPanel.tsx | 25 +++--
.../organizations/NoOrganizationsState.tsx | 2 +
.../organizations/OrganizationCard.tsx | 4 +-
.../organizations/OrganizationDashboard.tsx | 8 +-
.../organizations/OrganizationInfoCard.tsx | 4 +
...ionProvidersAndModelsConfigurationCard.tsx | 8 +-
.../OrganizationUsageSummaryCard.tsx | 29 +++---
.../organizations/SeatUsageCard.tsx | 9 +-
.../new/CreateOrganizationPage.tsx | 15 ++-
.../subscription/SubscriptionQuickActions.tsx | 24 +++--
.../components/MetricDetailDrawer.tsx | 19 ++--
.../payment/StripeSessionStatusChecker.tsx | 7 +-
.../profile/ProfileOrganizationsSection.tsx | 6 +-
.../security-agent/FindingDetailDialog.tsx | 8 +-
.../security-agent/SecurityAgentContext.tsx | 15 ++-
.../security-agent/SecurityAgentLayout.tsx | 8 +-
.../security-agent/SecurityConfigPage.tsx | 7 +-
.../security-agent/SecurityDashboard.tsx | 15 ++-
.../security-agent/SecurityFindingsPage.tsx | 25 ++++-
apps/web/src/lib/bot/agent-runner.ts | 23 +++--
.../src/lib/cloud-agent-next/session-url.ts | 9 +-
apps/web/src/lib/email.ts | 98 +++++++++++++++----
.../src/lib/organizations/feature-adoption.ts | 5 +-
.../organizations/organization-auto-top-up.ts | 8 +-
.../organization-billing.test.ts | 4 +-
.../organization-route-utils.server.ts | 9 ++
.../organization-route-utils.test.ts | 20 ++++
.../organizations/organization-route-utils.ts | 18 ++++
.../lib/organizations/organization-types.ts | 1 +
.../src/lib/organizations/organizations.ts | 2 +
.../organizations/recommendations-digest.ts | 12 ++-
.../src/lib/organizations/recommendations.ts | 15 +--
apps/web/src/lib/stripe/index.ts | 7 +-
apps/web/src/lib/user/server.ts | 3 +-
51 files changed, 532 insertions(+), 158 deletions(-)
diff --git a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx
index 901b1bf92e..4eb198fafe 100644
--- a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/layout.tsx
@@ -10,12 +10,18 @@ export default async function OrgCloudAgentLayout({
children: React.ReactNode;
params: Promise<{ id: string }>;
}) {
- const { organization } = await requireCanonicalOrganizationRouteContext(params);
+ const { organization, canonicalRouteIdentifier } =
+ await requireCanonicalOrganizationRouteContext(params);
return (
Loading... }>
- {children}
+
+ {children}
+
);
diff --git a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx
index ce6c2c447f..a262175470 100644
--- a/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/cloud/(agent)/page.tsx
@@ -10,7 +10,7 @@ export default async function OrganizationCloudPage({
return (
{
+ render={async ({ organization, organizationRouteIdentifier }) => {
const isDevcontainerAvailable = await isFeatureFlagEnabledOrDevelopment(
'cloud-agent-devcontainer',
organization.id
@@ -18,6 +18,7 @@ export default async function OrganizationCloudPage({
return (
);
diff --git a/apps/web/src/app/(app)/organizations/[id]/code-reviews/review-md/page.tsx b/apps/web/src/app/(app)/organizations/[id]/code-reviews/review-md/page.tsx
index c1aafb3ff3..71df6941ef 100644
--- a/apps/web/src/app/(app)/organizations/[id]/code-reviews/review-md/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/code-reviews/review-md/page.tsx
@@ -11,9 +11,9 @@ export default async function OrganizationReviewMdGuidePage({
return (
(
+ render={({ organizationRouteIdentifier }) => (
)}
diff --git a/apps/web/src/app/(app)/organizations/[id]/page.tsx b/apps/web/src/app/(app)/organizations/[id]/page.tsx
index 0f14b26cf1..41c72c12a7 100644
--- a/apps/web/src/app/(app)/organizations/[id]/page.tsx
+++ b/apps/web/src/app/(app)/organizations/[id]/page.tsx
@@ -16,11 +16,12 @@ export default async function OrganizationByIdPage({
return (
{
+ render={async ({ role, organization, organizationRouteIdentifier }) => {
const isAutoTopUpEnabled = await isOrgAutoTopUpFeatureEnabled(organization.id);
return (
(
-
+ render={({ organization, organizationRouteIdentifier }) => (
+
{children}
)}
diff --git a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx
index f64611066d..da391581a6 100644
--- a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx
+++ b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx
@@ -21,6 +21,7 @@ import {
BreadcrumbSeparator,
} from '@/components/ui/breadcrumb';
import { useOrganizationWithMembers } from '@/app/api/organizations/hooks';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
function OrganizationDetailAdminPage({
children,
@@ -47,6 +48,11 @@ function OrganizationDetailAdminPage({
}
export function OrganizationAdminDashboard({ organizationId }: { organizationId: string }) {
+ const { data: organization } = useOrganizationWithMembers(organizationId);
+ const organizationRouteIdentifier = organization
+ ? getOrganizationRouteIdentifier(organization)
+ : undefined;
+
return (
// in admin, admins are always owners of every organization
@@ -59,14 +65,20 @@ export function OrganizationAdminDashboard({ organizationId }: { organizationId:
-
+
-
+
diff --git a/apps/web/src/app/admin/components/OrganizationTableBody.tsx b/apps/web/src/app/admin/components/OrganizationTableBody.tsx
index 93068b9f80..574cec0b86 100644
--- a/apps/web/src/app/admin/components/OrganizationTableBody.tsx
+++ b/apps/web/src/app/admin/components/OrganizationTableBody.tsx
@@ -13,6 +13,7 @@ import {
getStripeStatusLabel,
getStripeStatusStyle,
} from '@/lib/admin/stripe-subscription-statuses';
+import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
type AdminOrganization = z.infer
;
@@ -77,7 +78,7 @@ function LinksCell({ organization }: { organization: AdminOrganization }) {
{
if (finding.ownedByOrganizationId) {
- return `${NEXTAUTH_URL}/organizations/${finding.ownedByOrganizationId}/security-agent/${path}`;
+ const organizationPath =
+ (await getOrganizationAppPathById(
+ finding.ownedByOrganizationId,
+ `/security-agent/${path}`
+ )) ?? `/organizations/${finding.ownedByOrganizationId}/security-agent/${path}`;
+ return `${NEXTAUTH_URL}${organizationPath}`;
}
return `${NEXTAUTH_URL}/security-agent/${path}`;
}
-function actionUrl(finding: {
+async function actionUrl(finding: {
ownedByOrganizationId: string | null;
ownedByUserId: string | null;
-}): string {
+}): Promise {
return securityAgentUrl(finding, 'findings');
}
-function manageNotificationsUrl(finding: {
+async function manageNotificationsUrl(finding: {
kind: 'new_finding' | 'sla_warning' | 'sla_breach';
ownedByOrganizationId: string | null;
ownedByUserId: string | null;
-}): string {
+}): Promise {
const tab = finding.kind === 'new_finding' ? 'notifications' : 'sla';
return securityAgentUrl(finding, `config?tab=${tab}`);
}
@@ -258,6 +264,10 @@ export async function POST(req: NextRequest) {
}
const templateName = notificationKindToTemplate[row.kind];
+ const [findingActionUrl, findingManageNotificationsUrl] = await Promise.all([
+ actionUrl(row),
+ manageNotificationsUrl(row),
+ ]);
const result = await sendEmail({
to: row.recipientEmail,
templateName,
@@ -270,8 +280,8 @@ export async function POST(req: NextRequest) {
ghsaId: row.ghsaId,
cvssScore: row.cvssScore,
slaDeadline: formatDeadline(row.slaDueAt),
- actionUrl: actionUrl(row),
- manageNotificationsUrl: manageNotificationsUrl(row),
+ actionUrl: findingActionUrl,
+ manageNotificationsUrl: findingManageNotificationsUrl,
}),
}).catch(() => null);
diff --git a/apps/web/src/app/api/profile/usage/route.ts b/apps/web/src/app/api/profile/usage/route.ts
index 748ae18c0c..d9808d9e3e 100644
--- a/apps/web/src/app/api/profile/usage/route.ts
+++ b/apps/web/src/app/api/profile/usage/route.ts
@@ -6,8 +6,11 @@ import { timedUsageQuery } from '@/lib/usage-query';
import { microdollar_usage } from '@kilocode/db/schema';
import { eq, sql, desc, isNull, and, gte } from 'drizzle-orm';
import { getDateThreshold, type Period } from '@/routers/user-router';
+import * as z from 'zod';
+import { isOrganizationMember } from '@/lib/organizations/organizations';
const VALID_PERIODS = new Set(['week', 'month', 'year', 'all']);
+const ViewTypeSchema = z.union([z.literal('personal'), z.literal('all'), z.uuid()]);
export async function GET(request: NextRequest) {
const { user, authFailedResponse } = await getUserFromAuth({
@@ -18,12 +21,23 @@ export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const groupByModel = searchParams.get('groupByModel') === 'true';
- const viewType = searchParams.get('viewType') || 'personal'; // 'personal', 'all', or organization ID
+ const viewTypeResult = ViewTypeSchema.safeParse(searchParams.get('viewType') || 'personal');
+ if (!viewTypeResult.success) {
+ return NextResponse.json({ error: 'Invalid viewType' }, { status: 400 });
+ }
+ const viewType = viewTypeResult.data;
const periodParam = searchParams.get('period') || 'week';
const period: Period = VALID_PERIODS.has(periodParam) ? (periodParam as Period) : 'week';
const userId = user.id;
+ if (viewType !== 'personal' && viewType !== 'all') {
+ const hasAccess = await isOrganizationMember(viewType, userId);
+ if (!hasAccess) {
+ return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
+ }
+ }
+
// Build the select object conditionally
const selectFields = {
date: sql`DATE(${microdollar_usage.created_at})`,
diff --git a/apps/web/src/app/payments/subscriptions/success/page.tsx b/apps/web/src/app/payments/subscriptions/success/page.tsx
index fb6d0f7efc..7c3cfd341d 100644
--- a/apps/web/src/app/payments/subscriptions/success/page.tsx
+++ b/apps/web/src/app/payments/subscriptions/success/page.tsx
@@ -1,5 +1,6 @@
import { StripeSessionStatusChecker } from '@/components/payment/StripeSessionStatusChecker';
import { STRIPE_SUB_QUERY_STRING_KEY } from '@/lib/organizations/constants';
+import { getOrganizationAppPathById } from '@/lib/organizations/organization-route-utils.server';
import { getUserFromAuthOrRedirect } from '@/lib/user/server';
import assert from 'assert';
@@ -14,5 +15,7 @@ export default async function Page({
const organizationId = params['organizationId'];
assert(sessionId && typeof sessionId === 'string');
assert(organizationId && typeof organizationId === 'string');
- return ;
+ const organizationPath = await getOrganizationAppPathById(organizationId);
+ assert(organizationPath);
+ return ;
}
diff --git a/apps/web/src/app/users/accept-invite/[token]/page.tsx b/apps/web/src/app/users/accept-invite/[token]/page.tsx
index 2ea714ba11..14badabb6a 100644
--- a/apps/web/src/app/users/accept-invite/[token]/page.tsx
+++ b/apps/web/src/app/users/accept-invite/[token]/page.tsx
@@ -4,6 +4,7 @@ import { headers } from 'next/headers';
import { redirect } from 'next/navigation';
import { acceptOrganizationInvite } from '@/lib/organizations/organizations';
import { ensureHasValidStytch } from '@/lib/user';
+import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
type AcceptInvitePageProps = {
params: Promise<{ token: string }>;
@@ -29,7 +30,10 @@ export default async function AcceptInvitePage({ params }: AcceptInvitePageProps
await ensureHasValidStytch(user.id);
// now that the user has signed up (or in) redirect to the standard after sign up page
// for possible stitch validation etc
- const redirectTo = `/organizations/${result.organizationId}`;
+ const redirectTo = getOrganizationAppPath({
+ id: result.organizationId,
+ slug: result.organizationSlug,
+ });
redirect(redirectTo);
}
diff --git a/apps/web/src/components/app-builder/AppBuilderLanding.tsx b/apps/web/src/components/app-builder/AppBuilderLanding.tsx
index 7e34547f75..391c169bd3 100644
--- a/apps/web/src/components/app-builder/AppBuilderLanding.tsx
+++ b/apps/web/src/components/app-builder/AppBuilderLanding.tsx
@@ -48,6 +48,7 @@ import { InsufficientBalanceBanner } from '@/components/shared/InsufficientBalan
import { PromptInput } from '@/components/app-builder/PromptInput';
import { TemplateGallery } from '@/components/app-builder/TemplateGallery';
import type { Images } from '@/lib/images-schema';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import {
type AppBuilderGalleryTemplate,
APP_BUILDER_TEMPLATE_ASK_PROMPT,
@@ -78,6 +79,7 @@ function sanitizeProjectTitle(title: string): string {
type AppBuilderLandingProps = {
organizationId?: string;
+ organizationRouteIdentifier?: string;
onProjectCreated: (projectId: string, prompt: string) => void;
};
@@ -248,17 +250,22 @@ function AllProjectsSheet({
userProjects,
allProjects,
organizationId,
+ organizationRouteIdentifier,
children,
}: {
userProjects: Project[];
allProjects: Project[];
organizationId?: string;
+ organizationRouteIdentifier?: string;
children: React.ReactNode;
}) {
const [search, setSearch] = useState('');
const [viewMode, setViewMode] = useState('user');
const [deletingProjectId, setDeletingProjectId] = useState(null);
- const basePath = organizationId ? `/organizations/${organizationId}/app-builder` : '/app-builder';
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
+ const basePath = organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/app-builder')
+ : '/app-builder';
const trpc = useTRPC();
const queryClient = useQueryClient();
@@ -383,14 +390,19 @@ function ProjectsSection({
allProjects,
isLoading,
organizationId,
+ organizationRouteIdentifier,
}: {
userProjects: Project[] | undefined;
allProjects: Project[] | undefined;
isLoading: boolean;
organizationId?: string;
+ organizationRouteIdentifier?: string;
}) {
const [deletingProjectId, setDeletingProjectId] = useState(null);
- const basePath = organizationId ? `/organizations/${organizationId}/app-builder` : '/app-builder';
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
+ const basePath = organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/app-builder')
+ : '/app-builder';
// For landing page, always show user's projects (or all projects for personal context)
const displayProjects = userProjects;
const recentProjects = displayProjects?.slice(0, MAX_RECENT_PROJECTS);
@@ -478,6 +490,7 @@ function ProjectsSection({
userProjects={userProjects || []}
allProjects={allProjects || []}
organizationId={organizationId}
+ organizationRouteIdentifier={organizationRouteIdentifier}
>
View all {displayProjects.length} projects
@@ -521,7 +535,11 @@ function ProjectsSection({
/**
* Main landing component
*/
-export function AppBuilderLanding({ organizationId, onProjectCreated }: AppBuilderLandingProps) {
+export function AppBuilderLanding({
+ organizationId,
+ organizationRouteIdentifier,
+ onProjectCreated,
+}: AppBuilderLandingProps) {
const [model, setModel] = useState('');
const [isModelUserSelected, setIsModelUserSelected] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -845,6 +863,7 @@ export function AppBuilderLanding({ organizationId, onProjectCreated }: AppBuild
allProjects={allProjects}
isLoading={projectsLoading}
organizationId={organizationId}
+ organizationRouteIdentifier={organizationRouteIdentifier}
/>
diff --git a/apps/web/src/components/app-builder/AppBuilderPage.tsx b/apps/web/src/components/app-builder/AppBuilderPage.tsx
index 6187305fe9..49938010d7 100644
--- a/apps/web/src/components/app-builder/AppBuilderPage.tsx
+++ b/apps/web/src/components/app-builder/AppBuilderPage.tsx
@@ -19,6 +19,7 @@ import { ProjectLoader } from './ProjectLoader';
import { ProjectSession } from './ProjectSession';
import { AppBuilderChat } from './AppBuilderChat';
import { AppBuilderPreview } from './AppBuilderPreview';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import { AppBuilderLanding } from './AppBuilderLanding';
type AppBuilderPageProps = {
@@ -31,7 +32,13 @@ type AppBuilderPageProps = {
* Inner component that contains the chat and preview layout.
* Rendered inside ProjectSession, so it has access to useProject hooks.
*/
-function AppBuilderProjectView({ organizationId }: { organizationId?: string }) {
+function AppBuilderProjectView({
+ organizationId,
+ organizationRouteIdentifier,
+}: {
+ organizationId?: string;
+ organizationRouteIdentifier?: string;
+}) {
return (
{/* Chat Pane - 1/3 width on desktop, full width on mobile */}
@@ -41,7 +48,10 @@ function AppBuilderProjectView({ organizationId }: { organizationId?: string })
{/* Preview Pane - 2/3 width on desktop, full width on mobile */}
);
@@ -60,7 +70,10 @@ export function AppBuilderPage({
(createdProjectId: string, _prompt: string) => {
// Navigate to the project page - ProjectLoader will handle loading
const newPath = organizationPathIdentifier
- ? `/organizations/${organizationPathIdentifier}/app-builder/${createdProjectId}`
+ ? getOrganizationAppPathForRouteIdentifier(
+ organizationPathIdentifier,
+ `/app-builder/${createdProjectId}`
+ )
: `/app-builder/${createdProjectId}`;
router.replace(newPath);
},
@@ -70,7 +83,11 @@ export function AppBuilderPage({
// Show landing if no projectId
if (!projectId) {
return (
-
+
);
}
@@ -79,7 +96,10 @@ export function AppBuilderPage({
{projectWithMessages => (
-
+
)}
diff --git a/apps/web/src/components/app-builder/AppBuilderPreview.tsx b/apps/web/src/components/app-builder/AppBuilderPreview.tsx
index 3567a446e5..87251cdaa0 100644
--- a/apps/web/src/components/app-builder/AppBuilderPreview.tsx
+++ b/apps/web/src/components/app-builder/AppBuilderPreview.tsx
@@ -29,6 +29,7 @@ import { useTRPC } from '@/lib/trpc/utils';
import { useQuery } from '@tanstack/react-query';
import { DEPLOYMENT_POLL_INTERVAL_MS } from '@/lib/user-deployments/constants';
import { isDeploymentInProgress, type BuildStatus } from '@/lib/user-deployments/types';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import { CloneDialog } from './CloneDialog';
import { MigrateToGitHubDialog } from './MigrateToGitHubDialog';
import { useProject } from './ProjectSession';
@@ -36,6 +37,7 @@ import { toast } from 'sonner';
type AppBuilderPreviewProps = {
organizationId?: string;
+ organizationRouteIdentifier?: string;
};
function IdleState() {
@@ -303,19 +305,21 @@ const statusLabels: Record = {
cancelled: 'Cancelled',
};
-function deploymentPageUrl(organizationId: string | undefined, deploymentId: string) {
- const base = organizationId ? `/organizations/${organizationId}/deploy` : '/deploy';
+function deploymentPageUrl(organizationRouteIdentifier: string | undefined, deploymentId: string) {
+ const base = organizationRouteIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationRouteIdentifier, '/deploy')
+ : '/deploy';
return `${base}/${deploymentId}`;
}
function DeploymentControls({
state,
onDeploy,
- organizationId,
+ organizationRouteIdentifier,
}: {
state: DeploymentState;
onDeploy: () => void;
- organizationId?: string;
+ organizationRouteIdentifier?: string;
}) {
switch (state.kind) {
case 'creating':
@@ -328,7 +332,10 @@ function DeploymentControls({
case 'in-progress':
return (
-
+
{statusLabels[state.buildStatus]}...
@@ -346,7 +353,10 @@ function DeploymentControls({
case 'failed':
return (
-
+
Failed - View Logs
@@ -383,6 +393,7 @@ function getPathFromUrl(url: string): string {
*/
export const AppBuilderPreview = memo(function AppBuilderPreview({
organizationId,
+ organizationRouteIdentifier,
}: AppBuilderPreviewProps) {
// Get state and manager from ProjectSession context
const { manager, state } = useProject();
@@ -582,6 +593,7 @@ export const AppBuilderPreview = memo(function AppBuilderPreview({
manager.setGitRepoFullName(repoFullName)}
/>
@@ -604,7 +616,7 @@ export const AppBuilderPreview = memo(function AppBuilderPreview({
diff --git a/apps/web/src/components/app-builder/MigrateToGitHubDialog.tsx b/apps/web/src/components/app-builder/MigrateToGitHubDialog.tsx
index 7069a58451..bbf6533215 100644
--- a/apps/web/src/components/app-builder/MigrateToGitHubDialog.tsx
+++ b/apps/web/src/components/app-builder/MigrateToGitHubDialog.tsx
@@ -38,10 +38,12 @@ import {
} from '@/components/ui/dialog';
import { RepositoryCombobox, type RepositoryOption } from '@/components/shared/RepositoryCombobox';
import type { CanMigrateToGitHubResult, MigrateToGitHubErrorCode } from '@/lib/app-builder/types';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
type MigrateToGitHubDialogProps = {
projectId: string;
organizationId?: string;
+ organizationRouteIdentifier?: string;
disabled?: boolean;
/** Called after migration completes successfully, with the GitHub repo full name */
onMigrationComplete?: (repoFullName: string) => void;
@@ -64,6 +66,7 @@ const errorMessages: Record = {
export function MigrateToGitHubDialog({
projectId,
organizationId,
+ organizationRouteIdentifier,
disabled,
onMigrationComplete,
}: MigrateToGitHubDialogProps) {
@@ -79,6 +82,7 @@ export function MigrateToGitHubDialog({
const trpc = useTRPC();
const queryClient = useQueryClient();
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
// Pre-flight check queries for personal/org context
const personalCanMigrateQuery = useQuery({
@@ -280,8 +284,11 @@ export function MigrateToGitHubDialog({
diff --git a/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx b/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
index 96f377d05a..20f82a7dc8 100644
--- a/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
+++ b/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
@@ -22,6 +22,7 @@ import type { StoredSession } from './types';
import { SessionPrIndicator } from './SessionPrIndicator';
import { isNewSession } from '@/lib/cloud-agent/session-type';
import { cn } from '@/lib/utils';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import {
DropdownMenu,
DropdownMenuCheckboxItem,
@@ -106,6 +107,7 @@ type ChatSidebarProps = {
sessions: StoredSession[];
currentSessionId?: string;
organizationId?: string;
+ organizationRouteIdentifier?: string;
onDeleteSession?: (sessionId: string) => void;
onRenameSession?: (sessionId: string, title: string) => Promise;
isInSheet?: boolean;
@@ -310,6 +312,7 @@ export function ChatSidebar({
sessions,
currentSessionId,
organizationId,
+ organizationRouteIdentifier,
onDeleteSession,
onRenameSession,
isInSheet = false,
@@ -353,7 +356,10 @@ export function ChatSidebar({
setEditingSessionId(null);
}, []);
- const basePath = organizationId ? `/organizations/${organizationId}/cloud` : '/cloud';
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
+ const basePath = organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/cloud')
+ : '/cloud';
const chatPath = `${basePath}/chat`;
const handleNewSession = useCallback(() => {
diff --git a/apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx b/apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx
index 35557d5323..6c8037c4af 100644
--- a/apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx
+++ b/apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx
@@ -6,6 +6,7 @@ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
import { useSetAtom } from 'jotai';
import { toast } from 'sonner';
import { useTRPC } from '@/lib/trpc/utils';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import { startOfDay, subDays } from 'date-fns';
import { extractRepoFromGitUrl } from './utils/git-utils';
import { ChatSidebar } from './ChatSidebar';
@@ -30,10 +31,15 @@ export function useSidebarToggle() {
type CloudSidebarLayoutProps = {
organizationId?: string;
+ organizationRouteIdentifier?: string;
children: ReactNode;
};
-export function CloudSidebarLayout({ organizationId, children }: CloudSidebarLayoutProps) {
+export function CloudSidebarLayout({
+ organizationId,
+ organizationRouteIdentifier,
+ children,
+}: CloudSidebarLayoutProps) {
const router = useRouter();
const searchParams = useSearchParams();
const currentSessionId = searchParams.get('sessionId') ?? undefined;
@@ -50,6 +56,10 @@ export function CloudSidebarLayout({ organizationId, children }: CloudSidebarLay
});
const [mobileSheetOpen, setMobileSheetOpen] = useState(false);
const repoUpdatedSince = useMemo(() => startOfDay(subDays(new Date(), 30)).toISOString(), []);
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
+ const basePath = organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/cloud')
+ : '/cloud';
const createdOnPlatform = useMemo(() => {
if (platformFilter.length === 0) return undefined;
@@ -109,7 +119,6 @@ export function CloudSidebarLayout({ organizationId, children }: CloudSidebarLay
async (sessionId: string) => {
// Navigate away if deleting the current session
if (sessionId === currentSessionId) {
- const basePath = organizationId ? `/organizations/${organizationId}/cloud` : '/cloud';
router.push(basePath);
}
@@ -134,7 +143,7 @@ export function CloudSidebarLayout({ organizationId, children }: CloudSidebarLay
},
[
currentSessionId,
- organizationId,
+ basePath,
router,
deleteSessionFromStore,
deleteCliSessionV2,
@@ -170,6 +179,7 @@ export function CloudSidebarLayout({ organizationId, children }: CloudSidebarLay
sessions={sessions}
currentSessionId={currentSessionId}
organizationId={organizationId}
+ organizationRouteIdentifier={organizationRouteIdentifier}
onDeleteSession={handleDeleteSession}
onRenameSession={handleRenameSession}
isInSheet
@@ -192,6 +202,7 @@ export function CloudSidebarLayout({ organizationId, children }: CloudSidebarLay
sessions={sessions}
currentSessionId={currentSessionId}
organizationId={organizationId}
+ organizationRouteIdentifier={organizationRouteIdentifier}
onDeleteSession={handleDeleteSession}
onRenameSession={handleRenameSession}
activeSessions={activeSessions}
diff --git a/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx b/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
index fa293c5296..bab4c01251 100644
--- a/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
+++ b/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
@@ -35,6 +35,7 @@ import { useSlashCommandAutocomplete } from '@/hooks/useSlashCommandAutocomplete
import { commandsOrDefault } from '@cloud-agent-shared';
import { useOrganizationDefaults } from '@/app/api/organizations/hooks';
import { useModelSelectorList } from '@/app/api/openrouter/hooks';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import {
selectedProfileIdAtom,
resetSessionFormAtom,
@@ -108,6 +109,7 @@ type Repository = {
type NewSessionPanelProps = {
organizationId?: string;
+ organizationRouteIdentifier?: string;
isDevcontainerAvailable: boolean;
};
@@ -118,7 +120,11 @@ type ContextualTipProps = {
onDismiss: () => void;
};
-export function NewSessionPanel({ organizationId, isDevcontainerAvailable }: NewSessionPanelProps) {
+export function NewSessionPanel({
+ organizationId,
+ organizationRouteIdentifier,
+ isDevcontainerAvailable,
+}: NewSessionPanelProps) {
const router = useRouter();
const trpc = useTRPC();
const trpcClient = useRawTRPCClient();
@@ -229,6 +235,7 @@ export function NewSessionPanel({ organizationId, isDevcontainerAvailable }: New
// ---------------------------------------------------------------------------
const [selectedProfileId, setSelectedProfileId] = useAtom(selectedProfileIdAtom);
const resetSessionForm = useSetAtom(resetSessionFormAtom);
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
// Clear any lingering manual overrides whenever the page loads
useEffect(() => {
@@ -673,8 +680,11 @@ export function NewSessionPanel({ organizationId, isDevcontainerAvailable }: New
!organizationId || (!isLoadingBitbucketRepos && bitbucketRepoData?.status !== 'available');
const isIntegrationMissing =
githubIntegrationMissing && gitlabIntegrationMissing && bitbucketIntegrationMissing;
- const bitbucketIntegrationHref = organizationId
- ? `/organizations/${organizationId}/integrations/bitbucket`
+ const bitbucketIntegrationHref = organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(
+ organizationPathIdentifier,
+ '/integrations/bitbucket'
+ )
: null;
// ---------------------------------------------------------------------------
@@ -898,7 +908,9 @@ export function NewSessionPanel({ organizationId, isDevcontainerAvailable }: New
attachmentUpload.clearAttachments();
setAttachmentMessageUuid(uuidv4());
- const basePath = organizationId ? `/organizations/${organizationId}/cloud` : '/cloud';
+ const basePath = organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/cloud')
+ : '/cloud';
router.push(`${basePath}/chat?sessionId=${result.kiloSessionId}`);
} catch (error) {
console.error('Failed to prepare session:', error);
@@ -923,6 +935,7 @@ export function NewSessionPanel({ organizationId, isDevcontainerAvailable }: New
model,
mode,
organizationId,
+ organizationPathIdentifier,
prompt,
queryClient,
router,
@@ -1003,8 +1016,8 @@ export function NewSessionPanel({ organizationId, isDevcontainerAvailable }: New
// Integration missing view
// ---------------------------------------------------------------------------
if (isIntegrationMissing) {
- const integrationsPath = organizationId
- ? `/organizations/${organizationId}/integrations`
+ const integrationsPath = organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/integrations')
: '/integrations';
const integrationMessage =
githubRepoData?.errorMessage ||
diff --git a/apps/web/src/components/organizations/NoOrganizationsState.tsx b/apps/web/src/components/organizations/NoOrganizationsState.tsx
index 8e9fe07f18..c009d0ff3e 100644
--- a/apps/web/src/components/organizations/NoOrganizationsState.tsx
+++ b/apps/web/src/components/organizations/NoOrganizationsState.tsx
@@ -10,6 +10,7 @@ export function NoOrganizationsState() {
const fakeOrganizations: OrganizationCardOrg[] = [
{
organizationId: 'fake-org-1',
+ organizationSlug: 'acme-corporation',
organizationName: 'Acme Corporation',
role: 'owner',
memberCount: 8,
@@ -22,6 +23,7 @@ export function NoOrganizationsState() {
},
{
organizationId: 'fake-org-2',
+ organizationSlug: 'tech-innovators-inc',
organizationName: 'Tech Innovators Inc',
role: 'member',
memberCount: 15,
diff --git a/apps/web/src/components/organizations/OrganizationCard.tsx b/apps/web/src/components/organizations/OrganizationCard.tsx
index 519e7a1831..1efc4421ba 100644
--- a/apps/web/src/components/organizations/OrganizationCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationCard.tsx
@@ -8,9 +8,11 @@ import {
getRoleLabel,
} from '@/lib/organizations/organization-shared-utils';
import { formatMicrodollars } from '@/lib/admin-utils';
+import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
export type OrganizationCardOrg = {
organizationId: string;
+ organizationSlug: string | null;
organizationName: string;
role: string;
memberCount: number;
@@ -31,7 +33,7 @@ export function OrganizationCard({ org }: OrganizationCardProps) {
diff --git a/apps/web/src/components/organizations/OrganizationDashboard.tsx b/apps/web/src/components/organizations/OrganizationDashboard.tsx
index 6eeed6d0a2..dd85c97115 100644
--- a/apps/web/src/components/organizations/OrganizationDashboard.tsx
+++ b/apps/web/src/components/organizations/OrganizationDashboard.tsx
@@ -51,6 +51,7 @@ const addDismissedOrganization = (organizationId: string): void => {
type Props = {
organizationId: string;
+ organizationRouteIdentifier: string;
role: OrganizationRole;
topupAmount: number;
isAutoTopUpEnabled: boolean;
@@ -58,6 +59,7 @@ type Props = {
export function OrganizationDashboard({
organizationId,
+ organizationRouteIdentifier,
role,
topupAmount,
isAutoTopUpEnabled,
@@ -154,6 +156,7 @@ export function OrganizationDashboard({
) : (
)}
@@ -164,7 +167,10 @@ export function OrganizationDashboard({
-
+
{(currentRole === 'owner' || currentRole === 'billing_manager') && (
)}
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index 7294a9edc4..a0770773a7 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -506,6 +506,10 @@ function Inner(props: InnerProps) {
)}
+
+
Organization ID
+
{id}
+
Company Domain
{isEditingDomain ? (
diff --git a/apps/web/src/components/organizations/OrganizationProvidersAndModelsConfigurationCard.tsx b/apps/web/src/components/organizations/OrganizationProvidersAndModelsConfigurationCard.tsx
index 4c9863ca4b..fdf498473b 100644
--- a/apps/web/src/components/organizations/OrganizationProvidersAndModelsConfigurationCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationProvidersAndModelsConfigurationCard.tsx
@@ -14,9 +14,11 @@ import { useOrganizationConfiguration } from './providers-and-models/useOrganiza
import { useOpenRouterModelsAndProviders } from '@/app/api/openrouter/hooks';
import type { ProviderSelection } from '@/components/models/util';
import { normalizeModelId } from '@/lib/ai-gateway/model-utils';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
type OrganizationProvidersAndModelsConfigurationCardProps = {
organizationId: string;
+ organizationRouteIdentifier?: string;
readonly: boolean;
};
@@ -64,6 +66,7 @@ export function computeProviderSelectionsForSummaryCard(params: {
export function OrganizationProvidersAndModelsConfigurationCard({
organizationId,
+ organizationRouteIdentifier,
readonly,
}: OrganizationProvidersAndModelsConfigurationCardProps) {
const [isDefaultModelDialogOpen, setIsDefaultModelDialogOpen] = useState(false);
@@ -114,6 +117,9 @@ export function OrganizationProvidersAndModelsConfigurationCard({
);
}
+ const routeIdentifier =
+ organizationRouteIdentifier ?? getOrganizationRouteIdentifier(organizationData);
+
return (
@@ -159,7 +165,7 @@ export function OrganizationProvidersAndModelsConfigurationCard({
/>
{readonly ? 'View ' : 'Configure '} providers and models
diff --git a/apps/web/src/components/organizations/OrganizationUsageSummaryCard.tsx b/apps/web/src/components/organizations/OrganizationUsageSummaryCard.tsx
index dd5969c0bb..cba12530af 100644
--- a/apps/web/src/components/organizations/OrganizationUsageSummaryCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationUsageSummaryCard.tsx
@@ -62,7 +62,13 @@ function MetricWithTooltip({
);
}
-export function OrganizationUsageSummaryCard({ organizationId }: { organizationId: string }) {
+export function OrganizationUsageSummaryCard({
+ organizationId,
+ organizationRouteIdentifier,
+}: {
+ organizationId: string;
+ organizationRouteIdentifier?: string;
+}) {
const {
error,
data: usage_stats,
@@ -108,7 +114,6 @@ export function OrganizationUsageSummaryCard({ organizationId }: { organizationI
const averageRequestsPerDay = Math.round((usage_stats.totalRequestCount / 30) * 10) / 10;
const averageInputTokensPerDay = Math.round((usage_stats.totalInputTokens / 30) * 10) / 10;
const averageOutputTokensPerDay = Math.round((usage_stats.totalOutputTokens / 30) * 10) / 10;
-
return (
@@ -190,15 +195,17 @@ export function OrganizationUsageSummaryCard({ organizationId }: { organizationI
/>
-
-
-
- View Detailed Usage
-
-
+ {organizationRouteIdentifier ? (
+
+
+
+ View Detailed Usage
+
+
+ ) : null}
diff --git a/apps/web/src/components/organizations/SeatUsageCard.tsx b/apps/web/src/components/organizations/SeatUsageCard.tsx
index d8d3a66c49..4a825c972d 100644
--- a/apps/web/src/components/organizations/SeatUsageCard.tsx
+++ b/apps/web/src/components/organizations/SeatUsageCard.tsx
@@ -13,12 +13,14 @@ import {
useOrganizationTrialStatus,
useOrganizationWithMembers,
} from '@/app/api/organizations/hooks';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
type Props = {
organizationId: string;
+ organizationRouteIdentifier?: string;
};
-export function SeatUsageCard({ organizationId }: Props) {
+export function SeatUsageCard({ organizationId, organizationRouteIdentifier }: Props) {
const currentUserRole = useUserOrganizationRole();
const {
@@ -64,6 +66,7 @@ export function SeatUsageCard({ organizationId }: Props) {
const { usedSeats, totalSeats } = seatUsage;
const isTrial = status !== 'subscribed';
+ const routeIdentifier = organizationRouteIdentifier ?? getOrganizationRouteIdentifier(org);
// Hide seat usage card when trial messaging is suppressed (e.g., OSS program participants)
if (org.settings.suppress_trial_messaging) {
@@ -85,7 +88,9 @@ export function SeatUsageCard({ organizationId }: Props) {
{(currentUserRole === 'owner' || currentUserRole === 'billing_manager') && (
-
+
Manage Subscription
diff --git a/apps/web/src/components/organizations/new/CreateOrganizationPage.tsx b/apps/web/src/components/organizations/new/CreateOrganizationPage.tsx
index a7f60ac6ee..281e278912 100644
--- a/apps/web/src/components/organizations/new/CreateOrganizationPage.tsx
+++ b/apps/web/src/components/organizations/new/CreateOrganizationPage.tsx
@@ -26,6 +26,7 @@ import { motion, AnimatePresence } from 'motion/react';
import { useCreateOrganization } from '@/app/api/organizations/hooks';
import { SubscriptionsSeatQuantitySchema } from '@/app/payments/subscriptions/types';
import Link from 'next/link';
+import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
const CreateOrganizationSchema = z.object({
organizationName: OrganizationNameSchema,
@@ -116,16 +117,14 @@ export function CreateOrganizationPage({ mockSelectedOrgName }: CreateOrganizati
}
try {
- const orgId = (
- await createOrganizationMutation.mutateAsync({
- name: validationResult.data.organizationName,
- autoAddCreator: true,
- company_domain: companyDomain.trim() || undefined,
- })
- ).organization.id;
+ const { organization } = await createOrganizationMutation.mutateAsync({
+ name: validationResult.data.organizationName,
+ autoAddCreator: true,
+ company_domain: companyDomain.trim() || undefined,
+ });
// Redirect with query param that will force users to invite a single user.
- window.location.href = `/organizations/${orgId}/welcome?firstTime=1`;
+ window.location.href = `${getOrganizationAppPath(organization, '/welcome')}?firstTime=1`;
} catch (error) {
console.error('Failed to create organization:', error);
setErrors({
diff --git a/apps/web/src/components/organizations/subscription/SubscriptionQuickActions.tsx b/apps/web/src/components/organizations/subscription/SubscriptionQuickActions.tsx
index d7f7f4c034..cd6d8e497b 100644
--- a/apps/web/src/components/organizations/subscription/SubscriptionQuickActions.tsx
+++ b/apps/web/src/components/organizations/subscription/SubscriptionQuickActions.tsx
@@ -18,6 +18,7 @@ import { seatPrice } from '@/lib/organizations/constants';
import { useOrganizationReadOnly } from '@/lib/organizations/use-organization-read-only';
import { formatDate, canManageBilling, findPaidSeatItem } from './utils';
import type { SubscriptionWithPeriod } from './types';
+import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
export function SubscriptionQuickActions({
subscription,
@@ -95,6 +96,7 @@ export function SubscriptionQuickActions({
const canChangeBillingCycle = canCancelSubscription && !hasPendingSchedule;
const periodEnd = (subscription as SubscriptionWithPeriod).current_period_end;
const effectiveDateLabel = periodEnd ? formatDate(periodEnd) : null;
+ const paymentHistoryPath = org.data ? getOrganizationAppPath(org.data, '/payment-details') : null;
return (
<>
@@ -141,16 +143,18 @@ export function SubscriptionQuickActions({
Update Payment Method
-
-
-
- View Payment History
-
-
+ {paymentHistoryPath ? (
+
+
+
+ View Payment History
+
+
+ ) : null}
{canCancelSubscription && (
=> ({
frequency: {
title: 'Frequency Score',
@@ -90,7 +91,7 @@ const getMetricInfo = (
Depth increases when AI touches multiple stages of the same task. A common pattern: use
Architect mode to plan a feature, the Code mode to build it, and{' '}
Code Reviewer
@@ -110,7 +111,7 @@ const getMetricInfo = (
If acceptance rates are low, the issue is often context—the AI is making suggestions
without understanding your codebase.{' '}
Managed Indexing
@@ -128,7 +129,7 @@ const getMetricInfo = (
<>
Generated code that never runs is hard to trust.{' '}
Kilo Deploy
@@ -165,7 +166,7 @@ const getMetricInfo = (
Coverage is partly a numbers game. If you have team members who haven't logged in or
aren't using the tool, your score will reflect that. Check your{' '}
Organization Dashboard
@@ -184,7 +185,7 @@ const getMetricInfo = (
Spiky usage—heavy on Mondays, quiet the rest of the week—limits your Coverage score. One
way to smooth this out: make{' '}
Code Reviewer
@@ -206,7 +207,11 @@ export function MetricDetailDrawer({
organizationId,
chartData,
}: MetricDetailDrawerProps) {
- const metricInfo = useMemo(() => getMetricInfo(organizationId), [organizationId]);
+ const organizationRouteIdentifier = useUrlOrganizationIdentifier() ?? organizationId;
+ const metricInfo = useMemo(
+ () => getMetricInfo(organizationRouteIdentifier),
+ [organizationRouteIdentifier]
+ );
// Filter chart data to only show the selected metric
const metricChartData = useMemo(() => {
diff --git a/apps/web/src/components/payment/StripeSessionStatusChecker.tsx b/apps/web/src/components/payment/StripeSessionStatusChecker.tsx
index 39bf8d9961..6b94f5c2fc 100644
--- a/apps/web/src/components/payment/StripeSessionStatusChecker.tsx
+++ b/apps/web/src/components/payment/StripeSessionStatusChecker.tsx
@@ -1,14 +1,13 @@
'use client';
import BigLoader from '@/components/BigLoader';
-import type { Organization } from '@kilocode/db/schema';
import { useStripeSessionStatus } from '@/app/payments/hooks';
import { redirect } from 'next/navigation';
type Props = {
- organizationId: Organization['id'];
+ organizationPath: string;
sessionId: string;
};
-export function StripeSessionStatusChecker({ organizationId, sessionId }: Props) {
+export function StripeSessionStatusChecker({ organizationPath, sessionId }: Props) {
const result = useStripeSessionStatus({ sessionId });
if (result.status === 'pending' && result.isFetching) {
@@ -18,5 +17,5 @@ export function StripeSessionStatusChecker({ organizationId, sessionId }: Props)
);
}
- return redirect(`/organizations/${organizationId}`);
+ return redirect(organizationPath);
}
diff --git a/apps/web/src/components/profile/ProfileOrganizationsSection.tsx b/apps/web/src/components/profile/ProfileOrganizationsSection.tsx
index 64b10e5234..ca7b7b44de 100644
--- a/apps/web/src/components/profile/ProfileOrganizationsSection.tsx
+++ b/apps/web/src/components/profile/ProfileOrganizationsSection.tsx
@@ -9,6 +9,7 @@ import {
import { formatMicrodollars } from '@/lib/admin-utils';
import Link from 'next/link';
import type { UserOrganizationWithSeats } from '@/lib/organizations/organization-types';
+import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
type ProfileOrganizationsSectionProps = {
orgs: UserOrganizationWithSeats[];
@@ -29,7 +30,10 @@ export function ProfileOrganizationsSection({ orgs }: ProfileOrganizationsSectio
{orgs.map(org => (
diff --git a/apps/web/src/components/security-agent/FindingDetailDialog.tsx b/apps/web/src/components/security-agent/FindingDetailDialog.tsx
index 9ffc15af39..7e9ac8c63e 100644
--- a/apps/web/src/components/security-agent/FindingDetailDialog.tsx
+++ b/apps/web/src/components/security-agent/FindingDetailDialog.tsx
@@ -30,6 +30,7 @@ import {
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { cn } from '@/lib/utils';
import { useTRPC } from '@/lib/trpc/utils';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import { useQuery } from '@tanstack/react-query';
import type { SecurityFinding } from '@kilocode/db/schema';
import { formatDistanceToNow, isPast } from 'date-fns';
@@ -973,6 +974,7 @@ type FindingAnalysisProps = {
analysisError: string | null;
cliSessionId: string | null;
organizationId?: string;
+ organizationRouteIdentifier?: string;
interactionState: AnalysisInteractionState;
onStartAnalysis: StartAnalysis;
onRestartAnalysis: () => void;
@@ -1548,6 +1550,7 @@ function FindingAnalysisPanel({
analysisError,
cliSessionId,
organizationId,
+ organizationRouteIdentifier,
interactionState: {
isAwaitingAnalysisAdmission,
isAnalyzing,
@@ -1576,7 +1579,7 @@ function FindingAnalysisPanel({
});
const sessionHref = cliSessionId
? organizationId
- ? `/organizations/${organizationId}/cloud/chat?sessionId=${cliSessionId}`
+ ? `${getOrganizationAppPathForRouteIdentifier(organizationRouteIdentifier ?? organizationId, '/cloud/chat')}?sessionId=${cliSessionId}`
: `/cloud/chat?sessionId=${cliSessionId}`
: null;
const sandbox = analysis?.sandboxAnalysis;
@@ -2910,6 +2913,7 @@ type FindingDetailDialogProps = {
onStartAnalysis: StartFindingAnalysis;
analysisAtCapacity: boolean;
organizationId?: string;
+ organizationRouteIdentifier?: string;
showSla?: boolean;
};
@@ -2923,6 +2927,7 @@ export function FindingDetailDialog({
onStartAnalysis,
analysisAtCapacity,
organizationId,
+ organizationRouteIdentifier,
showSla = true,
}: FindingDetailDialogProps) {
const trpc = useTRPC();
@@ -3350,6 +3355,7 @@ export function FindingDetailDialog({
analysisError={analysisError}
cliSessionId={cliSessionId}
organizationId={organizationId}
+ organizationRouteIdentifier={organizationRouteIdentifier}
interactionState={{
isAwaitingAnalysisAdmission,
isAnalyzing,
diff --git a/apps/web/src/components/security-agent/SecurityAgentContext.tsx b/apps/web/src/components/security-agent/SecurityAgentContext.tsx
index ee38207570..a054cddbc2 100644
--- a/apps/web/src/components/security-agent/SecurityAgentContext.tsx
+++ b/apps/web/src/components/security-agent/SecurityAgentContext.tsx
@@ -30,6 +30,7 @@ import {
type SecurityAgentContextValue = {
organizationId: string | undefined;
+ organizationRouteIdentifier: string | undefined;
isOrg: boolean;
// Permission & config state
@@ -383,6 +384,7 @@ function commandFailureDescription(command: SecurityAgentCommand): string {
type SecurityAgentProviderProps = {
organizationId?: string;
+ organizationRouteIdentifier?: string;
children: React.ReactNode;
};
@@ -551,7 +553,8 @@ function invalidateSecurityAgentQueryScopesForOwner(
}
function useSecurityAgentProviderValue(
- organizationId: string | undefined
+ organizationId: string | undefined,
+ organizationRouteIdentifier: string | undefined
): SecurityAgentContextValue {
const trpc = useTRPC();
const queryClient = useQueryClient();
@@ -1398,6 +1401,7 @@ function useSecurityAgentProviderValue(
const value = useMemo(
() => ({
organizationId,
+ organizationRouteIdentifier,
isOrg,
hasIntegration,
hasPermission,
@@ -1460,6 +1464,7 @@ function useSecurityAgentProviderValue(
}),
[
organizationId,
+ organizationRouteIdentifier,
isOrg,
hasIntegration,
hasPermission,
@@ -1509,7 +1514,11 @@ function useSecurityAgentProviderValue(
return value;
}
-export function SecurityAgentProvider({ organizationId, children }: SecurityAgentProviderProps) {
- const value = useSecurityAgentProviderValue(organizationId);
+export function SecurityAgentProvider({
+ organizationId,
+ organizationRouteIdentifier,
+ children,
+}: SecurityAgentProviderProps) {
+ const value = useSecurityAgentProviderValue(organizationId, organizationRouteIdentifier);
return {children} ;
}
diff --git a/apps/web/src/components/security-agent/SecurityAgentLayout.tsx b/apps/web/src/components/security-agent/SecurityAgentLayout.tsx
index a9ea839bd8..a00da1bfca 100644
--- a/apps/web/src/components/security-agent/SecurityAgentLayout.tsx
+++ b/apps/web/src/components/security-agent/SecurityAgentLayout.tsx
@@ -28,6 +28,7 @@ import {
} from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTRPC } from '@/lib/trpc/utils';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from 'sonner';
import { useSecurityAgent } from './SecurityAgentContext';
@@ -298,6 +299,7 @@ export function SecurityAgentLayout({ children }: SecurityAgentLayoutProps) {
const queryClient = useQueryClient();
const {
organizationId,
+ organizationRouteIdentifier,
isOrg,
hasIntegration,
hasPermission,
@@ -308,7 +310,11 @@ export function SecurityAgentLayout({ children }: SecurityAgentLayoutProps) {
reauthorizeUrl,
} = useSecurityAgent();
- const basePath = isOrg ? `/organizations/${organizationId}/security-agent` : '/security-agent';
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
+ const basePath =
+ isOrg && organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/security-agent')
+ : '/security-agent';
const showSetupOnly =
(!isLoadingPermission && !hasIntegration) || (!isLoadingConfig && !hasConfig);
diff --git a/apps/web/src/components/security-agent/SecurityConfigPage.tsx b/apps/web/src/components/security-agent/SecurityConfigPage.tsx
index f88489265d..655253fb49 100644
--- a/apps/web/src/components/security-agent/SecurityConfigPage.tsx
+++ b/apps/web/src/components/security-agent/SecurityConfigPage.tsx
@@ -5,6 +5,7 @@ import { ClearFindingsCard } from './ClearFindingsCard';
import { SecurityConfigForm } from './SecurityConfigForm';
import { useSecurityAgent } from './SecurityAgentContext';
import { SecurityAgentGitHubInstallCta } from './SecurityAgentGitHubInstallCta';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import {
DEFAULT_SECURITY_AGENT_ANALYSIS_MODEL,
DEFAULT_SECURITY_AGENT_REMEDIATION_MODEL,
@@ -15,6 +16,7 @@ import type { SecurityConfigFormState } from './security-config-types';
export function SecurityConfigPage() {
const {
organizationId,
+ organizationRouteIdentifier,
isOrg,
hasIntegration,
isLoadingPermission,
@@ -41,9 +43,10 @@ export function SecurityConfigPage() {
}
if (!hasIntegration) {
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
const installUrl =
- isOrg && organizationId
- ? `/organizations/${organizationId}/integrations`
+ isOrg && organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/integrations')
: '/integrations/github';
return ;
}
diff --git a/apps/web/src/components/security-agent/SecurityDashboard.tsx b/apps/web/src/components/security-agent/SecurityDashboard.tsx
index 95fda36509..bddb44b351 100644
--- a/apps/web/src/components/security-agent/SecurityDashboard.tsx
+++ b/apps/web/src/components/security-agent/SecurityDashboard.tsx
@@ -28,6 +28,7 @@ import { Skeleton } from '@/components/ui/skeleton';
import { cn } from '@/lib/utils';
import type { DashboardStats } from '@/lib/security-agent/db/dashboard-stats';
import { useTRPC } from '@/lib/trpc/utils';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import { RepositoryFilter } from './RepositoryFilter';
import { SecurityAgentActionBar, SecurityAgentActionBarField } from './SecurityAgentActionBar';
import { SecurityAgentGitHubInstallCta } from './SecurityAgentGitHubInstallCta';
@@ -143,6 +144,7 @@ export function SecurityDashboard() {
isLoadingPermission,
isOrg,
organizationId,
+ organizationRouteIdentifier,
configData,
filteredRepositories,
handleSync,
@@ -150,7 +152,11 @@ export function SecurityDashboard() {
} = useSecurityAgent();
const trpc = useTRPC();
const [repoFullName, setRepoFullName] = useState(undefined);
- const basePath = isOrg ? `/organizations/${organizationId}/security-agent` : '/security-agent';
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
+ const basePath =
+ isOrg && organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/security-agent')
+ : '/security-agent';
const slaEnabled = configData?.slaEnabled ?? true;
const {
@@ -189,9 +195,10 @@ export function SecurityDashboard() {
}
if (!hasIntegration) {
- const installUrl = isOrg
- ? `/organizations/${organizationId}/integrations`
- : '/integrations/github';
+ const installUrl =
+ isOrg && organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/integrations')
+ : '/integrations/github';
return ;
}
diff --git a/apps/web/src/components/security-agent/SecurityFindingsPage.tsx b/apps/web/src/components/security-agent/SecurityFindingsPage.tsx
index e7f736a79c..f0c131fe63 100644
--- a/apps/web/src/components/security-agent/SecurityFindingsPage.tsx
+++ b/apps/web/src/components/security-agent/SecurityFindingsPage.tsx
@@ -8,6 +8,7 @@ import { AlertTriangle, ExternalLink } from 'lucide-react';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
import { useTRPC } from '@/lib/trpc/utils';
+import { getOrganizationAppPathForRouteIdentifier } from '@/lib/organizations/organization-route-utils';
import {
OutcomeFilterSchema,
SecurityFindingStatusSchema,
@@ -133,6 +134,7 @@ function pageReducer(state: PageState, action: PageAction): PageState {
export function SecurityFindingsPage() {
const {
organizationId,
+ organizationRouteIdentifier,
isOrg,
configData,
hasIntegration,
@@ -301,16 +303,21 @@ export function SecurityFindingsPage() {
dispatch({ type: 'set-sort', sortBy });
};
- const basePath = isOrg ? `/organizations/${organizationId}/security-agent` : '/security-agent';
+ const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
+ const basePath =
+ isOrg && organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/security-agent')
+ : '/security-agent';
const handleOpenFinding = (findingId: string) => {
const params = new URLSearchParams(searchParams.toString());
params.set('findingId', findingId);
dispatch({ type: 'open-deep-link' });
router.replace(`${basePath}/findings?${params.toString()}`);
};
- const installUrl = isOrg
- ? `/organizations/${organizationId}/integrations`
- : '/integrations/github';
+ const installUrl =
+ isOrg && organizationPathIdentifier
+ ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/integrations')
+ : '/integrations/github';
if (isEnabled === false) {
return (
@@ -351,7 +358,14 @@ export function SecurityFindingsPage() {
View integrations
@@ -410,6 +424,7 @@ export function SecurityFindingsPage() {
canDismiss={activeFinding?.status === 'open'}
onOpenFinding={handleOpenFinding}
organizationId={organizationId}
+ organizationRouteIdentifier={organizationPathIdentifier}
showSla={slaEnabled}
/>
diff --git a/apps/web/src/lib/bot/agent-runner.ts b/apps/web/src/lib/bot/agent-runner.ts
index 75f317fdab..586dac78d1 100644
--- a/apps/web/src/lib/bot/agent-runner.ts
+++ b/apps/web/src/lib/bot/agent-runner.ts
@@ -285,14 +285,21 @@ This tool returns an acknowledgement immediately. The final Cloud Agent result w
resolvedCloudAgentSessionId = cloudAgentSessionId;
resolvedKiloSessionId = kiloSessionId;
params.onSessionReady?.({ kiloSessionId, cloudAgentSessionId, prompt: args.prompt });
- const sessionUrl = buildSessionUrl(kiloSessionId, owner);
- void postSessionLinkEphemeral({
- thread: params.thread,
- message: params.message,
- sessionUrl,
- prompt: args.prompt,
- provider,
- modelSlug,
+ void (async () => {
+ const sessionUrl = await buildSessionUrl(kiloSessionId, owner);
+ await postSessionLinkEphemeral({
+ thread: params.thread,
+ message: params.message,
+ sessionUrl,
+ prompt: args.prompt,
+ provider,
+ modelSlug,
+ });
+ })().catch(error => {
+ captureException(error, {
+ tags: { source: 'bot_cloud_agent_session_link' },
+ extra: { kiloSessionId, owner },
+ });
});
},
{
diff --git a/apps/web/src/lib/cloud-agent-next/session-url.ts b/apps/web/src/lib/cloud-agent-next/session-url.ts
index 8db11d6a9d..35d536b49a 100644
--- a/apps/web/src/lib/cloud-agent-next/session-url.ts
+++ b/apps/web/src/lib/cloud-agent-next/session-url.ts
@@ -1,6 +1,7 @@
import { APP_URL } from '@/lib/constants';
import { db } from '@/lib/drizzle';
import type { Owner } from '@/lib/integrations/core/types';
+import { getOrganizationAppPathById } from '@/lib/organizations/organization-route-utils.server';
import { cli_sessions_v2 } from '@kilocode/db/schema';
import { eq } from 'drizzle-orm';
@@ -9,8 +10,12 @@ import { eq } from 'drizzle-orm';
* @param dbSessionId - The database UUID (session_id from cli_sessions table)
* @param owner - The owner of the installation (user or org)
*/
-export function buildSessionUrl(dbSessionId: string, owner: Owner): string {
- const basePath = owner.type === 'org' ? `/organizations/${owner.id}/cloud` : '/cloud';
+export async function buildSessionUrl(dbSessionId: string, owner: Owner): Promise {
+ const basePath =
+ owner.type === 'org'
+ ? ((await getOrganizationAppPathById(owner.id, '/cloud')) ??
+ `/organizations/${owner.id}/cloud`)
+ : '/cloud';
return `${APP_URL}${basePath}/chat?sessionId=${dbSessionId}`;
}
diff --git a/apps/web/src/lib/email.ts b/apps/web/src/lib/email.ts
index 505020486d..714944749c 100644
--- a/apps/web/src/lib/email.ts
+++ b/apps/web/src/lib/email.ts
@@ -1,11 +1,17 @@
import fs from 'fs';
import path from 'path';
-import type { Organization } from '@kilocode/db/schema';
+import { organizations, type Organization } from '@kilocode/db/schema';
import { getMagicLinkUrl, type MagicLinkTokenWithPlaintext } from '@/lib/auth/magic-link-tokens';
import { NEXTAUTH_URL } from '@/lib/config.server';
import { getEmailVerificationRecipient, sendViaMailgun } from '@/lib/email-mailgun';
import { verifyEmail } from '@/lib/email-neverbounce';
+import { db } from '@/lib/drizzle';
+import {
+ getOrganizationAppPathForRouteIdentifier,
+ getOrganizationRouteIdentifier,
+} from '@/lib/organizations/organization-route-utils';
import { logExceptInTest, warnExceptInTest } from '@/lib/utils.server';
+import { and, eq, isNull } from 'drizzle-orm';
// Subject lines for each template — also serves as the canonical list of template names
export const subjects = {
@@ -156,10 +162,25 @@ type Props = {
organizationId: string;
};
+async function getOrganizationEmailPath(organizationId: string, suffix = ''): Promise {
+ const [organization] = await db
+ .select({ id: organizations.id, slug: organizations.slug })
+ .from(organizations)
+ .where(and(eq(organizations.id, organizationId), isNull(organizations.deleted_at)))
+ .limit(1);
+ const routeIdentifier = organization
+ ? getOrganizationRouteIdentifier(organization)
+ : organizationId;
+ return getOrganizationAppPathForRouteIdentifier(routeIdentifier, suffix);
+}
+
export async function sendOrgSubscriptionEmail(to: string, props: Props): Promise {
const seats = `${props.seatCount} seat${props.seatCount === 1 ? '' : 's'}`;
- const organization_url = `${NEXTAUTH_URL}/organizations/${props.organizationId}`;
- const invoices_url = `${NEXTAUTH_URL}/organizations/${props.organizationId}/payment-details`;
+ const organization_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(props.organizationId)}`;
+ const invoices_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ props.organizationId,
+ '/payment-details'
+ )}`;
return send({
to,
templateName: 'orgSubscription',
@@ -169,7 +190,10 @@ export async function sendOrgSubscriptionEmail(to: string, props: Props): Promis
export async function sendOrgRenewedEmail(to: string, props: Props): Promise {
const seats = `${props.seatCount} seat${props.seatCount === 1 ? '' : 's'}`;
- const invoices_url = `${NEXTAUTH_URL}/organizations/${props.organizationId}/payment-details`;
+ const invoices_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ props.organizationId,
+ '/payment-details'
+ )}`;
return send({
to,
templateName: 'orgRenewed',
@@ -181,7 +205,10 @@ export async function sendOrgCancelledEmail(
to: string,
props: Omit
): Promise {
- const invoices_url = `${NEXTAUTH_URL}/organizations/${props.organizationId}/payment-details`;
+ const invoices_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ props.organizationId,
+ '/payment-details'
+ )}`;
return send({
to,
templateName: 'orgCancelled',
@@ -193,7 +220,7 @@ export async function sendOrgSSOUserJoinedEmail(
to: string,
props: Omit & { new_user_email: string }
): Promise {
- const organization_url = `${NEXTAUTH_URL}/organizations/${props.organizationId}`;
+ const organization_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(props.organizationId)}`;
return send({
to,
templateName: 'orgSSOUserJoined',
@@ -237,7 +264,7 @@ export async function sendAutoTopUpFailedEmail(
props: { reason: string; organizationId?: string }
): Promise {
const credits_url = props.organizationId
- ? `${NEXTAUTH_URL}/organizations/${props.organizationId}/payment-details`
+ ? `${NEXTAUTH_URL}${await getOrganizationEmailPath(props.organizationId, '/payment-details')}`
: `${NEXTAUTH_URL}/credits?show-auto-top-up`;
return send({
to,
@@ -298,7 +325,7 @@ export async function sendBalanceAlertEmail(props: SendBalanceAlertEmailProps):
return;
}
- const organization_url = `${NEXTAUTH_URL}/organizations/${organizationId}`;
+ const organization_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(organizationId)}`;
const sendToRecipient = async (email: string) => {
const result = await send({
@@ -345,8 +372,14 @@ type OssInviteEmailData = {
};
export async function sendOssInviteNewUserEmail(data: OssInviteEmailData): Promise {
- const integrations_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}/integrations`;
- const code_reviews_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}/code-reviews`;
+ const integrations_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ data.organizationId,
+ '/integrations'
+ )}`;
+ const code_reviews_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ data.organizationId,
+ '/code-reviews'
+ )}`;
const tierConfig = ossTierConfig[data.tier];
return send({
to: data.to,
@@ -367,9 +400,15 @@ export async function sendOssInviteNewUserEmail(data: OssInviteEmailData): Promi
export async function sendOssInviteExistingUserEmail(
data: Omit
): Promise {
- const organization_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}`;
- const integrations_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}/integrations`;
- const code_reviews_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}/code-reviews`;
+ const organization_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(data.organizationId)}`;
+ const integrations_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ data.organizationId,
+ '/integrations'
+ )}`;
+ const code_reviews_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ data.organizationId,
+ '/code-reviews'
+ )}`;
const tierConfig = ossTierConfig[data.tier];
return send({
to: data.to,
@@ -398,9 +437,15 @@ type OssProvisionEmailData = {
export async function sendOssExistingOrgProvisionedEmail(
data: OssProvisionEmailData
): Promise {
- const organization_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}`;
- const integrations_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}/integrations`;
- const code_reviews_url = `${NEXTAUTH_URL}/organizations/${data.organizationId}/code-reviews`;
+ const organization_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(data.organizationId)}`;
+ const integrations_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ data.organizationId,
+ '/integrations'
+ )}`;
+ const code_reviews_url = `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ data.organizationId,
+ '/code-reviews'
+ )}`;
const tierConfig = ossTierConfig[data.tier];
const templateVars = {
organization_name: data.organizationName,
@@ -519,6 +564,19 @@ function formatDate(date: Date): string {
});
}
+async function getOrganizationCreditsUrl(
+ props: OrganizationCreditsTopUpEmailProps
+): Promise {
+ if (props.creditsUrl) return props.creditsUrl;
+ if (props.organizationId) {
+ return `${NEXTAUTH_URL}${await getOrganizationEmailPath(
+ props.organizationId,
+ '/payment-details'
+ )}`;
+ }
+ throw new Error('Organization top-up emails require creditsUrl or organizationId');
+}
+
export async function sendCreditsTopUpEmail(
props: SendCreditsTopUpEmailProps
): Promise {
@@ -531,7 +589,7 @@ export async function sendCreditsTopUpEmail(
const organizationName = isOrgVariant ? (props.organizationName ?? 'your organization') : '';
const credits_url = isOrgVariant
- ? props.creditsUrl || `${NEXTAUTH_URL}/organizations/${props.organizationId}/payment-details`
+ ? await getOrganizationCreditsUrl(props)
: `${NEXTAUTH_URL}/credits`;
return send({
to: props.to,
@@ -596,6 +654,7 @@ type RecommendationsDigestRecommendation = {
type SendRecommendationsDigestEmailProps = {
organizationId: string;
+ organizationRouteIdentifier: string;
organizationName: string;
adoptedCount: number;
totalCount: number;
@@ -635,7 +694,10 @@ export async function sendRecommendationsDigestEmail(
to: string,
props: SendRecommendationsDigestEmailProps
): Promise {
- const dashboard_url = `${NEXTAUTH_URL}/organizations/${props.organizationId}/usage-details?view=feature-adoption`;
+ const dashboard_url = `${NEXTAUTH_URL}${getOrganizationAppPathForRouteIdentifier(
+ props.organizationRouteIdentifier,
+ '/usage-details'
+ )}?view=feature-adoption`;
return send({
to,
templateName: 'recommendationsDigest',
diff --git a/apps/web/src/lib/organizations/feature-adoption.ts b/apps/web/src/lib/organizations/feature-adoption.ts
index 9ed7278a54..f1a9831568 100644
--- a/apps/web/src/lib/organizations/feature-adoption.ts
+++ b/apps/web/src/lib/organizations/feature-adoption.ts
@@ -2,6 +2,7 @@ import { organizations } from '@kilocode/db/schema';
import { and, eq, isNull, sql } from 'drizzle-orm';
import { readDb } from '@/lib/drizzle';
import { INTEGRATION_STATUS } from '@/lib/integrations/core/constants';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
export const FEATURE_ADOPTION_KEYS = [
'source-control-integration',
@@ -186,7 +187,7 @@ export async function getOrganizationFeatureAdoption(organizationId: string): Pr
checks: FeatureAdoptionCheck[];
}> {
const organizationRows = await readDb
- .select({ plan: organizations.plan })
+ .select({ id: organizations.id, plan: organizations.plan, slug: organizations.slug })
.from(organizations)
.where(and(eq(organizations.id, organizationId), isNull(organizations.deleted_at)))
.limit(1);
@@ -202,6 +203,6 @@ export async function getOrganizationFeatureAdoption(organizationId: string): Pr
return {
plan: organization.plan,
- checks: buildFeatureAdoptionChecks(organizationId, state),
+ checks: buildFeatureAdoptionChecks(getOrganizationRouteIdentifier(organization), state),
};
}
diff --git a/apps/web/src/lib/organizations/organization-auto-top-up.ts b/apps/web/src/lib/organizations/organization-auto-top-up.ts
index e5cd90a6c3..fdfd5289a5 100644
--- a/apps/web/src/lib/organizations/organization-auto-top-up.ts
+++ b/apps/web/src/lib/organizations/organization-auto-top-up.ts
@@ -6,6 +6,7 @@ import {
DEFAULT_ORG_AUTO_TOP_UP_AMOUNT_CENTS,
} from '@/lib/autoTopUpConstants';
import { isFeatureFlagEnabled } from '@/lib/posthog-feature-flags';
+import { getOrganizationAppPathById } from '@/lib/organizations/organization-route-utils.server';
export async function isOrgAutoTopUpFeatureEnabled(organizationId: string): Promise {
return (
@@ -25,6 +26,9 @@ export async function createOrgAutoTopUpSetupCheckoutSession(
amountCents: number = DEFAULT_ORG_AUTO_TOP_UP_AMOUNT_CENTS
): Promise {
const amountDollars = amountCents / 100;
+ const organizationPath =
+ (await getOrganizationAppPathById(organizationId, '/payment-details')) ??
+ `/organizations/${organizationId}/payment-details`;
const checkoutSession = await client.checkout.sessions.create({
mode: 'payment',
@@ -54,8 +58,8 @@ export async function createOrgAutoTopUpSetupCheckoutSession(
enabled: true,
required: 'never',
},
- success_url: `${APP_URL}/organizations/${organizationId}/payment-details?auto_topup_setup=success`,
- cancel_url: `${APP_URL}/organizations/${organizationId}/payment-details?auto_topup_setup=cancelled`,
+ success_url: `${APP_URL}${organizationPath}?auto_topup_setup=success`,
+ cancel_url: `${APP_URL}${organizationPath}?auto_topup_setup=cancelled`,
payment_intent_data: {
metadata: {
type: 'org-auto-topup-setup',
diff --git a/apps/web/src/lib/organizations/organization-billing.test.ts b/apps/web/src/lib/organizations/organization-billing.test.ts
index 64daf92bd9..5602b3ba60 100644
--- a/apps/web/src/lib/organizations/organization-billing.test.ts
+++ b/apps/web/src/lib/organizations/organization-billing.test.ts
@@ -597,7 +597,7 @@ describe('processTopupForOrganization', () => {
expect(topUpEmail.html).toContain(
'A Kilo credit top-up has been processed for Test Organization. The credits are now available to the organization.'
);
- expect(topUpEmail.html).toContain(`/organizations/${testOrganization.id}/payment-details`);
+ expect(topUpEmail.html).toContain(`/organizations/${testOrganization.slug}/payment-details`);
expect(topUpEmail.html).toContain('https://pay.stripe.test/receipts/pi');
const emailMarkers = await getOrganizationTopUpEmailMarkers(stripePaymentId);
@@ -636,7 +636,7 @@ describe('processTopupForOrganization', () => {
expect(topUpEmail.html).toContain(
'Test Organization was automatically topped up so your team can keep using Kilo without interruption. The new credits are available now.'
);
- expect(topUpEmail.html).toContain(`/organizations/${testOrganization.id}/payment-details`);
+ expect(topUpEmail.html).toContain(`/organizations/${testOrganization.slug}/payment-details`);
expect(topUpEmail.html).toContain('https://pay.stripe.test/receipts/ch');
const emailMarkers = await getOrganizationTopUpEmailMarkers(stripePaymentId);
diff --git a/apps/web/src/lib/organizations/organization-route-utils.server.ts b/apps/web/src/lib/organizations/organization-route-utils.server.ts
index a0a901f5e9..39057e36f4 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.server.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.server.ts
@@ -5,6 +5,7 @@ import { organizations } from '@kilocode/db/schema';
import { and, eq, isNull } from 'drizzle-orm';
import { db } from '@/lib/drizzle';
import {
+ getOrganizationAppPath,
getOrganizationRouteIdentifier,
isUuidOrganizationRouteIdentifier,
type OrganizationRouteIdentifierInput,
@@ -57,3 +58,11 @@ export async function resolveOrganizationRouteParams(
const { id } = await params;
return resolveOrganizationRouteIdentifier(decodeURIComponent(id));
}
+
+export async function getOrganizationAppPathById(
+ organizationId: string,
+ suffix = ''
+): Promise {
+ const organization = await resolveOrganizationRouteIdentifierDetails(organizationId);
+ return organization ? getOrganizationAppPath(organization, suffix) : null;
+}
diff --git a/apps/web/src/lib/organizations/organization-route-utils.test.ts b/apps/web/src/lib/organizations/organization-route-utils.test.ts
index c45e1fd0a3..b9752f8321 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.test.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.test.ts
@@ -4,6 +4,8 @@ import { organizations } from '@kilocode/db/schema';
import { inArray } from 'drizzle-orm';
import {
findOrganizationByRouteIdentifier,
+ getOrganizationAppPath,
+ getOrganizationAppPathForRouteIdentifier,
getOrganizationRouteIdentifier,
isOrganizationRouteIdentifierMatch,
isUuidOrganizationRouteIdentifier,
@@ -28,6 +30,24 @@ describe('getOrganizationRouteIdentifier', () => {
});
});
+describe('organization app paths', () => {
+ it('uses the slug in organization app paths when one exists', () => {
+ expect(getOrganizationAppPath({ id: 'org-id', slug: 'acme' }, '/payment-details')).toBe(
+ '/organizations/acme/payment-details'
+ );
+ });
+
+ it('falls back to the organization id in app paths when no slug exists', () => {
+ expect(getOrganizationAppPath({ id: 'org-id', slug: null })).toBe('/organizations/org-id');
+ });
+
+ it('encodes explicit route identifiers', () => {
+ expect(getOrganizationAppPathForRouteIdentifier('acme inc', 'code-reviews')).toBe(
+ '/organizations/acme%20inc/code-reviews'
+ );
+ });
+});
+
describe('organization route identifier matching', () => {
const organizationsForRouteMatching = [
{ id: '550e8400-e29b-41d4-a716-446655440000', slug: 'acme' },
diff --git a/apps/web/src/lib/organizations/organization-route-utils.ts b/apps/web/src/lib/organizations/organization-route-utils.ts
index 80613e88ab..776111e2f2 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.ts
@@ -14,6 +14,24 @@ export function getOrganizationRouteIdentifier(
return organization.slug ?? organization.id;
}
+export function getOrganizationAppPath(
+ organization: OrganizationRouteIdentifierInput,
+ suffix = ''
+): string {
+ return getOrganizationAppPathForRouteIdentifier(
+ getOrganizationRouteIdentifier(organization),
+ suffix
+ );
+}
+
+export function getOrganizationAppPathForRouteIdentifier(
+ routeIdentifier: string,
+ suffix = ''
+): string {
+ const normalizedSuffix = suffix ? (suffix.startsWith('/') ? suffix : `/${suffix}`) : '';
+ return `/organizations/${encodeURIComponent(routeIdentifier)}${normalizedSuffix}`;
+}
+
export function isUuidOrganizationRouteIdentifier(identifier: string): boolean {
return UUID_ROUTE_IDENTIFIER_PATTERN.test(identifier);
}
diff --git a/apps/web/src/lib/organizations/organization-types.ts b/apps/web/src/lib/organizations/organization-types.ts
index e68da116bf..aae52d54b0 100644
--- a/apps/web/src/lib/organizations/organization-types.ts
+++ b/apps/web/src/lib/organizations/organization-types.ts
@@ -145,6 +145,7 @@ export type AcceptInviteResult = Result<
{
invitation: typeof organization_invitations.$inferSelect;
organizationId: string;
+ organizationSlug: Organization['slug'];
role: OrganizationRole;
},
string
diff --git a/apps/web/src/lib/organizations/organizations.ts b/apps/web/src/lib/organizations/organizations.ts
index 08efdf02c0..4e5ebb6588 100644
--- a/apps/web/src/lib/organizations/organizations.ts
+++ b/apps/web/src/lib/organizations/organizations.ts
@@ -721,6 +721,7 @@ export async function acceptOrganizationInvite(
return successResult({
invitation: updatedInvitation,
organizationId: invitation.organization_id,
+ organizationSlug: organization.slug,
role: invitation.role,
membershipInserted: false,
});
@@ -766,6 +767,7 @@ export async function acceptOrganizationInvite(
return successResult({
invitation: updatedInvitation,
organizationId: invitation.organization_id,
+ organizationSlug: organization.slug,
role: invitation.role,
membershipInserted: true,
});
diff --git a/apps/web/src/lib/organizations/recommendations-digest.ts b/apps/web/src/lib/organizations/recommendations-digest.ts
index 870e1462b9..d009a47dca 100644
--- a/apps/web/src/lib/organizations/recommendations-digest.ts
+++ b/apps/web/src/lib/organizations/recommendations-digest.ts
@@ -10,6 +10,7 @@ import {
import { getOrganizationRecommendations } from './recommendations';
import { sendRecommendationsDigestEmail } from '@/lib/email';
import { errorExceptInTest, logExceptInTest } from '@/lib/utils.server';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
// Cap the number of recommendations listed in the email; the rest live on the
// dashboard the email links to.
@@ -38,6 +39,7 @@ function digestIdempotencyKey(
export type RecommendationsDigestData = {
organizationId: string;
+ organizationRouteIdentifier: string;
organizationName: string;
adoptedCount: number;
totalCount: number;
@@ -55,7 +57,8 @@ export type RecommendationsDigestData = {
// that says "all good" every week trains owners to ignore it).
export async function buildOrganizationRecommendationsDigest(
organizationId: string,
- organizationName: string
+ organizationName: string,
+ organizationSlug: string | null = null
): Promise {
const { plan, checks, recommendations } = await getOrganizationRecommendations(organizationId);
if (plan !== 'enterprise') {
@@ -69,6 +72,10 @@ export async function buildOrganizationRecommendationsDigest(
return {
organizationId,
+ organizationRouteIdentifier: getOrganizationRouteIdentifier({
+ id: organizationId,
+ slug: organizationSlug,
+ }),
organizationName,
adoptedCount: checks.filter(check => check.adopted).length,
totalCount: checks.length,
@@ -188,6 +195,7 @@ export async function dispatchEnterpriseRecommendationsDigests(): Promise
limit(async () => {
try {
- const digest = await buildOrganizationRecommendationsDigest(org.id, org.name);
+ const digest = await buildOrganizationRecommendationsDigest(org.id, org.name, org.slug);
if (!digest) {
summary.orgsSkippedEmpty++;
return;
diff --git a/apps/web/src/lib/organizations/recommendations.ts b/apps/web/src/lib/organizations/recommendations.ts
index 0edfb28901..f245c6e031 100644
--- a/apps/web/src/lib/organizations/recommendations.ts
+++ b/apps/web/src/lib/organizations/recommendations.ts
@@ -16,6 +16,7 @@ import {
} from '@/lib/organizations/feature-adoption';
import { getOrganizationSeatUsage } from '@/lib/organizations/organization-seats';
import { resolveEffectiveOrganizationSsoPolicy } from '@/lib/organizations/organization-sso-policy';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
// Which surface a recommendation ties back to. Per-feature recommendations reuse
// the feature adoption key so the UI can show the same icon; organization-level
@@ -504,7 +505,7 @@ export async function getOrganizationRecommendations(organizationId: string): Pr
recommendations: Recommendation[];
}> {
const orgRows = await readDb
- .select({ plan: organizations.plan })
+ .select({ id: organizations.id, plan: organizations.plan, slug: organizations.slug })
.from(organizations)
.where(and(eq(organizations.id, organizationId), isNull(organizations.deleted_at)))
.limit(1);
@@ -525,12 +526,14 @@ export async function getOrganizationRecommendations(organizationId: string): Pr
]);
const dismissed = new Set(dismissedRows.map(row => row.key));
- const recommendations = buildRecommendations(organizationId, state).map(recommendation =>
- dismissed.has(recommendation.key)
- ? { ...recommendation, status: 'dismissed' as const }
- : recommendation
+ const organizationRouteIdentifier = getOrganizationRouteIdentifier(organization);
+ const recommendations = buildRecommendations(organizationRouteIdentifier, state).map(
+ recommendation =>
+ dismissed.has(recommendation.key)
+ ? { ...recommendation, status: 'dismissed' as const }
+ : recommendation
);
- const checks = buildFeatureAdoptionChecks(organizationId, state);
+ const checks = buildFeatureAdoptionChecks(organizationRouteIdentifier, state);
return { plan: organization.plan, checks, recommendations };
}
diff --git a/apps/web/src/lib/stripe/index.ts b/apps/web/src/lib/stripe/index.ts
index 4c4d0533d8..08ab3461a6 100644
--- a/apps/web/src/lib/stripe/index.ts
+++ b/apps/web/src/lib/stripe/index.ts
@@ -29,6 +29,7 @@ import type { UnifiedInvoice } from '@/types/billing';
import type { StripeConfig } from '@/lib/credits';
import { processTopUp } from '@/lib/credits';
import { processTopupForOrganization } from '@/lib/organizations/organization-billing';
+import { getOrganizationAppPathById } from '@/lib/organizations/organization-route-utils.server';
import {
STRIPE_SUB_QUERY_STRING_KEY,
TOPUP_CANCELED_QUERY_STRING_KEY,
@@ -1455,12 +1456,12 @@ export async function getStripeTopUpCheckoutUrl(
},
];
- const isOrganizationTopUp = Boolean(organizationId);
let cancelUrl: string;
if (cancelPath) {
cancelUrl = `${APP_URL}${cancelPath}`;
- } else if (isOrganizationTopUp) {
- cancelUrl = `${APP_URL}/organizations/${organizationId}?${TOPUP_CANCELED_QUERY_STRING_KEY}=true`;
+ } else if (organizationId) {
+ const organizationPath = await getOrganizationAppPathById(organizationId);
+ cancelUrl = `${APP_URL}${organizationPath ?? `/organizations/${organizationId}`}?${TOPUP_CANCELED_QUERY_STRING_KEY}=true`;
} else {
cancelUrl = `${APP_URL}/profile?payment_status=topup_cancelled&origin=${origin}`;
}
diff --git a/apps/web/src/lib/user/server.ts b/apps/web/src/lib/user/server.ts
index 2fd5dad2cd..e55110b869 100644
--- a/apps/web/src/lib/user/server.ts
+++ b/apps/web/src/lib/user/server.ts
@@ -46,6 +46,7 @@ import type { AuthProviderId } from '@kilocode/db/schema-types';
import PostHogClient from '@/lib/posthog';
import { captureException } from '@sentry/nextjs';
import { getSingleUserOrganization, isOrganizationMember } from '@/lib/organizations/organizations';
+import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
import { resolveSsoAuthorityForDomain } from '@/lib/organizations/organization-sso-policy';
import type { AccountLinkingSession } from '@/lib/account-linking-session';
import { getAccountLinkingSession } from '@/lib/account-linking-session';
@@ -1181,7 +1182,7 @@ export async function getProfileRedirectPath(user: User) {
if (classification.isTrialExpiredForEnforcement) {
return '/profile';
}
- return `/organizations/${singleOrg.id}`;
+ return getOrganizationAppPath(singleOrg);
}
return '/profile';
From eb59d9483158a6876da827d2250cfc6d29f3dad4 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Thu, 25 Jun 2026 19:55:39 -0500
Subject: [PATCH 23/33] fix(organizations): use slugs in admin org URLs
---
.../OrganizationAdminDashboard.tsx | 5 +++-
.../OrganizationAdminHierarchyManagement.tsx | 5 +++-
.../OrganizationAdminWebhooks.tsx | 10 +++++--
.../components/OrganizationTableBody.tsx | 13 ++++++---
.../src/app/admin/organizations/[id]/page.tsx | 13 +++++++--
.../[id]/webhooks/[triggerId]/page.tsx | 26 ++++++++++++++---
.../organizations/[id]/webhooks/page.tsx | 24 ++++++++++++---
.../webhooks/AdminWebhookTriggerDetails.tsx | 12 ++++++--
.../components/admin-omnibox/AdminOmnibox.tsx | 5 ++--
.../organizations/OrganizationInfoCard.tsx | 5 ++--
.../organization-admin-router.test.ts | 29 +++++++++++++++----
.../organization-admin-router.ts | 9 +++++-
12 files changed, 125 insertions(+), 31 deletions(-)
diff --git a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx
index da391581a6..261d810759 100644
--- a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx
+++ b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx
@@ -82,7 +82,10 @@ export function OrganizationAdminDashboard({ organizationId }: { organizationId:
-
+
diff --git a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminHierarchyManagement.tsx b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminHierarchyManagement.tsx
index a963791c16..9ccab01c46 100644
--- a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminHierarchyManagement.tsx
+++ b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminHierarchyManagement.tsx
@@ -33,15 +33,18 @@ import {
} from '@/components/ui/dialog';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
type OrganizationSearchResult = {
id: string;
name: string;
+ slug: string | null;
};
type OrganizationSummary = {
id: string;
name: string;
+ slug: string | null;
};
type OrganizationAdminHierarchyManagementProps = {
@@ -189,7 +192,7 @@ export function OrganizationAdminHierarchyManagement({
className="border-border bg-surface-raised flex items-center justify-between gap-3 rounded-md border px-3 py-2"
>
{childOrganization.name}
diff --git a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminWebhooks.tsx b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminWebhooks.tsx
index fb04204046..df87b7642c 100644
--- a/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminWebhooks.tsx
+++ b/apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminWebhooks.tsx
@@ -7,9 +7,15 @@ import { Webhook } from 'lucide-react';
type OrganizationAdminWebhooksProps = {
organizationId: string;
+ organizationRouteIdentifier?: string;
};
-export function OrganizationAdminWebhooks({ organizationId }: OrganizationAdminWebhooksProps) {
+export function OrganizationAdminWebhooks({
+ organizationId,
+ organizationRouteIdentifier,
+}: OrganizationAdminWebhooksProps) {
+ const routeIdentifier = organizationRouteIdentifier ?? organizationId;
+
return (
@@ -20,7 +26,7 @@ export function OrganizationAdminWebhooks({ organizationId }: OrganizationAdminW
Read-only view of webhook triggers and request history for this organization.
-
+
View webhooks
diff --git a/apps/web/src/app/admin/components/OrganizationTableBody.tsx b/apps/web/src/app/admin/components/OrganizationTableBody.tsx
index 574cec0b86..730a94cbe1 100644
--- a/apps/web/src/app/admin/components/OrganizationTableBody.tsx
+++ b/apps/web/src/app/admin/components/OrganizationTableBody.tsx
@@ -13,7 +13,10 @@ import {
getStripeStatusLabel,
getStripeStatusStyle,
} from '@/lib/admin/stripe-subscription-statuses';
-import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
+import {
+ getOrganizationAppPath,
+ getOrganizationRouteIdentifier,
+} from '@/lib/organizations/organization-route-utils';
type AdminOrganization = z.infer;
@@ -290,8 +293,10 @@ export function OrganizationTableBody({
const router = useRouter();
const colSpan = getColumnCount(variant, showDeleted, showStripeStatus, showTrialEndDate);
- const handleRowClick = (organizationId: string) => {
- router.push(`/admin/organizations/${encodeURIComponent(organizationId)}`);
+ const handleRowClick = (organization: AdminOrganization) => {
+ router.push(
+ `/admin/organizations/${encodeURIComponent(getOrganizationRouteIdentifier(organization))}`
+ );
};
if (isLoading) {
@@ -339,7 +344,7 @@ export function OrganizationTableBody({
handleRowClick(organization.id)}
+ onClick={() => handleRowClick(organization)}
>
{variant === 'entitlements' ? (
;
+ return ;
}
diff --git a/apps/web/src/app/admin/organizations/[id]/webhooks/[triggerId]/page.tsx b/apps/web/src/app/admin/organizations/[id]/webhooks/[triggerId]/page.tsx
index 682275ec81..b50d8c9017 100644
--- a/apps/web/src/app/admin/organizations/[id]/webhooks/[triggerId]/page.tsx
+++ b/apps/web/src/app/admin/organizations/[id]/webhooks/[triggerId]/page.tsx
@@ -1,20 +1,38 @@
-'use client';
-
import { Suspense } from 'react';
import { AdminWebhookTriggerDetails } from '@/app/admin/webhooks/AdminWebhookTriggerDetails';
+import { resolveOrganizationRouteIdentifierDetails } from '@/lib/organizations/organization-route-utils.server';
+import { redirect } from 'next/navigation';
type AdminOrganizationWebhookDetailPageProps = {
params: Promise<{ id: string; triggerId: string }>;
};
-export default function AdminOrganizationWebhookDetailPage({
+export default async function AdminOrganizationWebhookDetailPage({
params,
}: AdminOrganizationWebhookDetailPageProps) {
+ const { id, triggerId } = await params;
+ const organization = await resolveOrganizationRouteIdentifierDetails(decodeURIComponent(id));
+ if (!organization) {
+ redirect('/admin/organizations');
+ }
+
+ if (decodeURIComponent(id) !== organization.routeIdentifier) {
+ redirect(
+ `/admin/organizations/${encodeURIComponent(organization.routeIdentifier)}/webhooks/${encodeURIComponent(triggerId)}`
+ );
+ }
+
+ const resolvedParams = Promise.resolve({ id: organization.id, triggerId });
+
return (
Loading... }
>
-
+
);
}
diff --git a/apps/web/src/app/admin/organizations/[id]/webhooks/page.tsx b/apps/web/src/app/admin/organizations/[id]/webhooks/page.tsx
index 795ec6fbbd..aed78c60c4 100644
--- a/apps/web/src/app/admin/organizations/[id]/webhooks/page.tsx
+++ b/apps/web/src/app/admin/organizations/[id]/webhooks/page.tsx
@@ -4,6 +4,8 @@ import { AdminWebhookTriggersList } from '@/app/admin/webhooks/AdminWebhookTrigg
import { db } from '@/lib/drizzle';
import { organizations } from '@kilocode/db/schema';
import { eq } from 'drizzle-orm';
+import { getOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
+import { resolveOrganizationRouteIdentifierDetails } from '@/lib/organizations/organization-route-utils.server';
export default async function AdminOrganizationWebhooksPage({
params,
@@ -16,26 +18,40 @@ export default async function AdminOrganizationWebhooksPage({
}
const { id } = await params;
- const organizationId = decodeURIComponent(id);
+ const resolvedOrganization = await resolveOrganizationRouteIdentifierDetails(
+ decodeURIComponent(id)
+ );
+ if (!resolvedOrganization) {
+ redirect('/admin/organizations');
+ }
+
+ if (decodeURIComponent(id) !== resolvedOrganization.routeIdentifier) {
+ redirect(
+ `/admin/organizations/${encodeURIComponent(resolvedOrganization.routeIdentifier)}/webhooks`
+ );
+ }
const organization = await db.query.organizations.findFirst({
columns: {
id: true,
name: true,
+ slug: true,
},
- where: eq(organizations.id, organizationId),
+ where: eq(organizations.id, resolvedOrganization.id),
});
if (!organization) {
redirect('/admin/organizations');
}
+ const routeIdentifier = getOrganizationRouteIdentifier(organization);
+
return (
);
}
diff --git a/apps/web/src/app/admin/webhooks/AdminWebhookTriggerDetails.tsx b/apps/web/src/app/admin/webhooks/AdminWebhookTriggerDetails.tsx
index 7466b4b8df..d568675ba2 100644
--- a/apps/web/src/app/admin/webhooks/AdminWebhookTriggerDetails.tsx
+++ b/apps/web/src/app/admin/webhooks/AdminWebhookTriggerDetails.tsx
@@ -21,23 +21,29 @@ import { WebhookRequestsContent } from '@/app/(app)/cloud/webhooks/[triggerId]/r
type AdminWebhookTriggerDetailsProps = {
params: Promise<{ id: string; triggerId: string }>;
scope: 'user' | 'organization';
+ ownerRouteIdentifier?: string;
};
function formatTimestamp(value: string) {
return new Date(value).toLocaleString();
}
-export function AdminWebhookTriggerDetails({ params, scope }: AdminWebhookTriggerDetailsProps) {
+export function AdminWebhookTriggerDetails({
+ params,
+ scope,
+ ownerRouteIdentifier,
+}: AdminWebhookTriggerDetailsProps) {
const { id, triggerId } = use(params);
const trpc = useTRPC();
const ownerId = decodeURIComponent(id);
+ const ownerPathIdentifier = ownerRouteIdentifier ?? ownerId;
const isOrg = scope === 'organization';
const listPath = isOrg
- ? `/admin/organizations/${encodeURIComponent(ownerId)}/webhooks`
+ ? `/admin/organizations/${encodeURIComponent(ownerPathIdentifier)}/webhooks`
: `/admin/users/${encodeURIComponent(ownerId)}/webhooks`;
const parentPath = isOrg
- ? `/admin/organizations/${encodeURIComponent(ownerId)}`
+ ? `/admin/organizations/${encodeURIComponent(ownerPathIdentifier)}`
: `/admin/users/${encodeURIComponent(ownerId)}`;
const triggerInput = isOrg
diff --git a/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx b/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx
index dad6ea27ef..a0b7a4c705 100644
--- a/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx
+++ b/apps/web/src/components/admin-omnibox/AdminOmnibox.tsx
@@ -82,6 +82,7 @@ function AdminOmniboxInner({ open, setOpen }: AdminOmniboxInnerProps) {
)
);
const organizationId = resolvedOrganization?.id ?? null;
+ const organizationAdminRouteIdentifier = resolvedOrganization?.routeIdentifier ?? null;
// Handle role change
const handleRoleChange = useCallback(
@@ -192,9 +193,9 @@ function AdminOmniboxInner({ open, setOpen }: AdminOmniboxInnerProps) {
Admin Panel
- {organizationId && (
+ {organizationAdminRouteIdentifier && (
setOpen(false)}
>
diff --git a/apps/web/src/components/organizations/OrganizationInfoCard.tsx b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
index a0770773a7..cdf0e22961 100644
--- a/apps/web/src/components/organizations/OrganizationInfoCard.tsx
+++ b/apps/web/src/components/organizations/OrganizationInfoCard.tsx
@@ -81,6 +81,7 @@ type InnerProps = {
type OrganizationHierarchySummary = {
id: string;
name: string;
+ slug: string | null;
};
type OrganizationHierarchySectionProps = {
@@ -122,7 +123,7 @@ function OrganizationHierarchySection({ parent }: OrganizationHierarchySectionPr
Parent organization:{' '}
{parent.name}
@@ -161,7 +162,7 @@ export function ChildOrganizationsCard({ organizationId }: { organizationId: str
{childOrganizations.map(childOrganization => (
{childOrganization.name}
diff --git a/apps/web/src/routers/organizations/organization-admin-router.test.ts b/apps/web/src/routers/organizations/organization-admin-router.test.ts
index 1d9b671d2b..0fdf72bd84 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.test.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.test.ts
@@ -958,22 +958,40 @@ describe('organization admin router', () => {
expect(childHierarchy.parent).toEqual({
id: parentOrganization.id,
name: parentOrganization.name,
+ slug: parentOrganization.slug,
});
expect(childHierarchy.ancestors).toEqual([
- { id: parentOrganization.id, name: parentOrganization.name },
- { id: grandparentOrganization.id, name: grandparentOrganization.name },
+ {
+ id: parentOrganization.id,
+ name: parentOrganization.name,
+ slug: parentOrganization.slug,
+ },
+ {
+ id: grandparentOrganization.id,
+ name: grandparentOrganization.name,
+ slug: grandparentOrganization.slug,
+ },
]);
expect(childHierarchy.children).toEqual([]);
expect(parentHierarchy.parent).toEqual({
id: grandparentOrganization.id,
name: grandparentOrganization.name,
+ slug: grandparentOrganization.slug,
});
expect(parentHierarchy.ancestors).toEqual([
- { id: grandparentOrganization.id, name: grandparentOrganization.name },
+ {
+ id: grandparentOrganization.id,
+ name: grandparentOrganization.name,
+ slug: grandparentOrganization.slug,
+ },
]);
expect(parentHierarchy.children).toEqual([
- { id: childOrganization.id, name: childOrganization.name },
- { id: siblingOrganization.id, name: siblingOrganization.name },
+ { id: childOrganization.id, name: childOrganization.name, slug: childOrganization.slug },
+ {
+ id: siblingOrganization.id,
+ name: siblingOrganization.name,
+ slug: siblingOrganization.slug,
+ },
]);
} finally {
await db
@@ -1084,6 +1102,7 @@ describe('organization admin router', () => {
expect(hierarchy.children).toContainEqual({
id: childOrganization.id,
name: childOrganization.name,
+ slug: childOrganization.slug,
});
expect(updatedChildOrganization.require_seats).toBe(false);
expect(updatedChildOrganization.free_trial_end_at).toBeNull();
diff --git a/apps/web/src/routers/organizations/organization-admin-router.ts b/apps/web/src/routers/organizations/organization-admin-router.ts
index 4236a2acb5..21d924008b 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.ts
@@ -101,6 +101,7 @@ const OrganizationSearchInputSchema = z.object({
const OrganizationSearchResultSchema = z.object({
id: z.string(),
name: z.string(),
+ slug: z.string().nullable(),
});
const OrganizationCreateInputSchema = z.object({
@@ -147,6 +148,7 @@ const AdminOrganizationDetailsSchema = z.object({
const OrganizationHierarchySummarySchema = z.object({
id: z.string(),
name: z.string(),
+ slug: z.string().nullable(),
});
const AdminOrganizationHierarchySchema = z.object({
@@ -570,6 +572,7 @@ export const organizationAdminRouter = createTRPCRouter({
.select({
parent_id: parentOrganizations.id,
parent_name: parentOrganizations.name,
+ parent_slug: parentOrganizations.slug,
})
.from(organizations)
.leftJoin(
@@ -600,6 +603,7 @@ export const organizationAdminRouter = createTRPCRouter({
.select({
id: organizations.id,
name: organizations.name,
+ slug: organizations.slug,
parent_organization_id: organizations.parent_organization_id,
})
.from(organizations)
@@ -610,7 +614,7 @@ export const organizationAdminRouter = createTRPCRouter({
break;
}
- ancestors.push({ id: ancestor.id, name: ancestor.name });
+ ancestors.push({ id: ancestor.id, name: ancestor.name, slug: ancestor.slug });
currentParentId = ancestor.parent_organization_id;
}
@@ -618,6 +622,7 @@ export const organizationAdminRouter = createTRPCRouter({
.select({
id: organizations.id,
name: organizations.name,
+ slug: organizations.slug,
})
.from(organizations)
.where(eq(organizations.parent_organization_id, organizationId))
@@ -628,6 +633,7 @@ export const organizationAdminRouter = createTRPCRouter({
? {
id: organizationHierarchy.parent_id,
name: organizationHierarchy.parent_name ?? 'Unknown organization',
+ slug: organizationHierarchy.parent_slug,
}
: null,
ancestors,
@@ -1382,6 +1388,7 @@ export const organizationAdminRouter = createTRPCRouter({
.select({
id: organizations.id,
name: organizations.name,
+ slug: organizations.slug,
})
.from(organizations)
.where(and(...conditions))
From f51f59539aeb80e2a1f81b5ab5e8325e59ea0708 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 08:54:22 -0500
Subject: [PATCH 24/33] NewSessionPanel used organizationRouteIdentifier ??
organizationId for the post-create router.push, so an open tab could redirect
to a stale slug after organization slug changes. Fixed
apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx:911 to build the
post-create redirect from stable organizationId.
---
apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx | 5 ++---
.../src/routers/organizations/organization-admin-router.ts | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx b/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
index bab4c01251..979c680c5b 100644
--- a/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
+++ b/apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
@@ -908,8 +908,8 @@ export function NewSessionPanel({
attachmentUpload.clearAttachments();
setAttachmentMessageUuid(uuidv4());
- const basePath = organizationPathIdentifier
- ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/cloud')
+ const basePath = organizationId
+ ? getOrganizationAppPathForRouteIdentifier(organizationId, '/cloud')
: '/cloud';
router.push(`${basePath}/chat?sessionId=${result.kiloSessionId}`);
} catch (error) {
@@ -935,7 +935,6 @@ export function NewSessionPanel({
model,
mode,
organizationId,
- organizationPathIdentifier,
prompt,
queryClient,
router,
diff --git a/apps/web/src/routers/organizations/organization-admin-router.ts b/apps/web/src/routers/organizations/organization-admin-router.ts
index 21d924008b..1a85d3609d 100644
--- a/apps/web/src/routers/organizations/organization-admin-router.ts
+++ b/apps/web/src/routers/organizations/organization-admin-router.ts
@@ -208,7 +208,7 @@ const BackfillMissingSlugsOutputSchema = z.object({
),
});
-const BACKFILL_MISSING_SLUGS_BATCH_SIZE = 50;
+const BACKFILL_MISSING_SLUGS_BATCH_SIZE = 1000;
const AddMemberInputSchema = z.object({
organizationId: z.uuid(),
From cdaae4174d57c26ba78dd3ad732a3e28dc8bf856 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 08:59:18 -0500
Subject: [PATCH 25/33] fix(organizations): use stable ID for chat sidebar
routes
---
apps/web/src/components/cloud-agent-next/ChatSidebar.tsx | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx b/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
index 20f82a7dc8..6878dd3aca 100644
--- a/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
+++ b/apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
@@ -312,7 +312,6 @@ export function ChatSidebar({
sessions,
currentSessionId,
organizationId,
- organizationRouteIdentifier,
onDeleteSession,
onRenameSession,
isInSheet = false,
@@ -356,9 +355,8 @@ export function ChatSidebar({
setEditingSessionId(null);
}, []);
- const organizationPathIdentifier = organizationRouteIdentifier ?? organizationId;
- const basePath = organizationPathIdentifier
- ? getOrganizationAppPathForRouteIdentifier(organizationPathIdentifier, '/cloud')
+ const basePath = organizationId
+ ? getOrganizationAppPathForRouteIdentifier(organizationId, '/cloud')
: '/cloud';
const chatPath = `${basePath}/chat`;
From 65535690d7e72db19f625d9cd13524e4bb99a596 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 10:24:19 -0500
Subject: [PATCH 26/33] Confirmed the review feedback: producer schema still
allows organizationId: z.string().nullable(), while web had narrowed it to
UUID and skips failed parses. Changed: -
apps/web/src/lib/cloud-agent-sdk/schemas.ts:161 restores
sessionEventV2RowSchema.organizationId to z.string().nullable(). -
apps/web/src/lib/cloud-agent-sdk/schemas.ts:202 restores
sessionDeletedPayloadSchema.organizationId to z.string().nullable(). -
apps/web/src/lib/cloud-agent-sdk/schemas.test.ts:21 adds regression coverage
for non-UUID org IDs in session.created. -
apps/web/src/lib/cloud-agent-sdk/schemas.test.ts:30 adds regression coverage
for non-UUID org IDs in session.deleted.
---
.../src/lib/cloud-agent-sdk/schemas.test.ts | 47 +++++++++++++++++++
apps/web/src/lib/cloud-agent-sdk/schemas.ts | 4 +-
2 files changed, 49 insertions(+), 2 deletions(-)
create mode 100644 apps/web/src/lib/cloud-agent-sdk/schemas.test.ts
diff --git a/apps/web/src/lib/cloud-agent-sdk/schemas.test.ts b/apps/web/src/lib/cloud-agent-sdk/schemas.test.ts
new file mode 100644
index 0000000000..d25d454ef5
--- /dev/null
+++ b/apps/web/src/lib/cloud-agent-sdk/schemas.test.ts
@@ -0,0 +1,47 @@
+import { describe, expect, it } from '@jest/globals';
+
+import { sessionEventPayloadSchema } from './schemas';
+
+describe('sessionEventPayloadSchema', () => {
+ const session = {
+ source: 'v2',
+ sessionId: 'ses_1',
+ createdAt: '2026-01-01T00:00:00.000Z',
+ updatedAt: '2026-01-01T00:00:01.000Z',
+ title: 'Test',
+ createdOnPlatform: 'web',
+ organizationId: 'org_external_1',
+ gitUrl: null,
+ gitBranch: null,
+ parentSessionId: null,
+ status: 'idle',
+ statusUpdatedAt: null,
+ };
+
+ it('accepts non-UUID organization IDs in session row events', () => {
+ const result = sessionEventPayloadSchema.safeParse({
+ type: 'session.created',
+ data: { source: 'v2', session, changedAt: session.updatedAt },
+ });
+
+ expect(result.success).toBe(true);
+ });
+
+ it('accepts non-UUID organization IDs in deleted events', () => {
+ const result = sessionEventPayloadSchema.safeParse({
+ type: 'session.deleted',
+ data: {
+ source: 'v2',
+ sessionId: session.sessionId,
+ parentSessionId: null,
+ organizationId: session.organizationId,
+ gitUrl: null,
+ gitBranch: null,
+ createdOnPlatform: 'web',
+ deletedAt: '2026-01-01T00:00:02.000Z',
+ },
+ });
+
+ expect(result.success).toBe(true);
+ });
+});
diff --git a/apps/web/src/lib/cloud-agent-sdk/schemas.ts b/apps/web/src/lib/cloud-agent-sdk/schemas.ts
index ec79fcd813..fd9aa0b958 100644
--- a/apps/web/src/lib/cloud-agent-sdk/schemas.ts
+++ b/apps/web/src/lib/cloud-agent-sdk/schemas.ts
@@ -158,7 +158,7 @@ export const sessionEventV2RowSchema = z.object({
updatedAt: z.string(),
title: z.string().nullable(),
createdOnPlatform: z.string().nullable(),
- organizationId: z.uuid().nullable(),
+ organizationId: z.string().nullable(),
gitUrl: z.string().nullable(),
gitBranch: z.string().nullable(),
parentSessionId: z.string().nullable(),
@@ -199,7 +199,7 @@ export const sessionDeletedPayloadSchema = z.object({
source: z.literal('v2'),
sessionId: z.string(),
parentSessionId: z.string().nullable(),
- organizationId: z.uuid().nullable(),
+ organizationId: z.string().nullable(),
gitUrl: z.string().nullable(),
gitBranch: z.string().nullable(),
createdOnPlatform: z.string().nullable(),
From 389f44e039374d013df2336a49fc8f2d0c03a3c9 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 10:44:36 -0500
Subject: [PATCH 27/33] Update org slug backfill button label to reflect the
1000 batch size
---
.../web/src/app/admin/components/OrganizationSlugBackfill.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx b/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
index a996b24c1a..ad7e741ab0 100644
--- a/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
+++ b/apps/web/src/app/admin/components/OrganizationSlugBackfill.tsx
@@ -33,7 +33,7 @@ export function OrganizationSlugBackfill() {
Backfill organization slugs for legacy organizations missing the field. Each click processes
- up to 50 organizations. Click repeatedly until no rows are updated.
+ up to 1,000 organizations. Click repeatedly until no rows are updated.
@@ -75,7 +75,7 @@ export function OrganizationSlugBackfill() {
) : null}
mutation.mutate()} disabled={mutation.isPending}>
- {mutation.isPending ? 'Backfilling...' : 'Backfill next 50'}
+ {mutation.isPending ? 'Backfilling...' : 'Backfill next 1,000'}
From dbca7b2f47ad9e482c03660a73abee4aac3c9a6f Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 11:24:27 -0500
Subject: [PATCH 28/33] fix typecheck
---
apps/storybook/src/mockData/organizations.ts | 5 +++--
apps/storybook/stories/OrganizationSwitcher.stories.tsx | 9 ++++++++-
apps/storybook/stories/Sidebar.stories.tsx | 2 ++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/apps/storybook/src/mockData/organizations.ts b/apps/storybook/src/mockData/organizations.ts
index 6b4de19477..2555b67a99 100644
--- a/apps/storybook/src/mockData/organizations.ts
+++ b/apps/storybook/src/mockData/organizations.ts
@@ -28,6 +28,7 @@ function generateMember(): OrganizationMember {
{
id: randomId(rng, 'org'),
name: `Team ${randomInt(rng, 1, 9)}`,
+ slug: `team-${randomInt(rng, 1, 9)}`,
role: 'member',
},
]
@@ -56,8 +57,8 @@ export function generateOrganization(): OrganizationWithMembers {
...base,
name: `Company ${randomInt(rng, 0, 999)} ${companyType}`,
childOrganizations: [
- { id: randomId(rng, 'org'), name: 'Platform Team' },
- { id: randomId(rng, 'org'), name: 'Product Team' },
+ { id: randomId(rng, 'org'), name: 'Platform Team', slug: 'platform-team' },
+ { id: randomId(rng, 'org'), name: 'Product Team', slug: 'product-team' },
],
members: Array.from({ length: randomInt(rng, 2, 7) }, generateMember),
effectiveSsoPolicy: {
diff --git a/apps/storybook/stories/OrganizationSwitcher.stories.tsx b/apps/storybook/stories/OrganizationSwitcher.stories.tsx
index b43fa485a4..de9b827d06 100644
--- a/apps/storybook/stories/OrganizationSwitcher.stories.tsx
+++ b/apps/storybook/stories/OrganizationSwitcher.stories.tsx
@@ -13,16 +13,19 @@ type OrganizationSwitcherStoryProps = {
const organizations: OrganizationSwitcherOrganization[] = [
{
organizationId: 'org-kilo',
+ organizationSlug: 'kilo-code',
organizationName: 'Kilo Code',
role: 'owner',
},
{
organizationId: 'org-design',
+ organizationSlug: 'design-systems',
organizationName: 'Design Systems',
role: 'member',
},
{
organizationId: 'org-cloud',
+ organizationSlug: 'cloud-platform',
organizationName: 'Cloud Platform',
role: 'member',
},
@@ -34,6 +37,10 @@ function OrganizationSwitcherStory({
}: OrganizationSwitcherStoryProps) {
const [organizationId, setOrganizationId] = useState(initialOrganizationId);
+ const handleOrganizationSwitch = (organization: OrganizationSwitcherOrganization | null) => {
+ setOrganizationId(organization?.organizationId ?? null);
+ };
+
return (
@@ -41,7 +48,7 @@ function OrganizationSwitcherStory({
organizationId={organizationId}
organizations={organizations}
isPending={isPending}
- onOrganizationSwitch={setOrganizationId}
+ onOrganizationSwitch={handleOrganizationSwitch}
/>
diff --git a/apps/storybook/stories/Sidebar.stories.tsx b/apps/storybook/stories/Sidebar.stories.tsx
index cd8d2c5a91..476a8b89f0 100644
--- a/apps/storybook/stories/Sidebar.stories.tsx
+++ b/apps/storybook/stories/Sidebar.stories.tsx
@@ -82,11 +82,13 @@ const mockUser = {
const mockOrganizations = [
{
organizationId: 'org-kilo',
+ organizationSlug: 'kilo-code',
organizationName: 'Kilo Code',
role: 'owner',
},
{
organizationId: 'org-design',
+ organizationSlug: 'design-systems',
organizationName: 'Design Systems',
role: 'member',
},
From 1b57afebfc474e729d49a63227cc6508c5de825b Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 11:39:33 -0500
Subject: [PATCH 29/33] fix tests
---
.../integrations/linear/connect/route.test.ts | 21 ++++++++++---------
apps/web/src/lib/email.ts | 5 +++++
apps/web/src/lib/integrations/oauth/common.ts | 11 ++++++----
3 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/apps/web/src/app/api/integrations/linear/connect/route.test.ts b/apps/web/src/app/api/integrations/linear/connect/route.test.ts
index 0ea2c4f6a0..7f3bc28755 100644
--- a/apps/web/src/app/api/integrations/linear/connect/route.test.ts
+++ b/apps/web/src/app/api/integrations/linear/connect/route.test.ts
@@ -25,6 +25,7 @@ const mockedGetLinearOAuthUrl = jest.mocked(getLinearOAuthUrl);
const mockedEnsureOrganizationAccess = jest.mocked(ensureOrganizationAccess);
const mockedRequireActiveSubscriptionOrTrial = jest.mocked(requireActiveSubscriptionOrTrial);
const USER_ID = '034489e8-19e0-4479-9d69-2edad719e847';
+const ORGANIZATION_ID = '7e3011af-e99d-444f-8171-54c2225b87dc';
function makeRequest(pathWithQuery: string) {
return new NextRequest(`http://localhost:3000${pathWithQuery}`);
@@ -57,7 +58,7 @@ describe('GET /api/integrations/linear/connect', () => {
} as never);
const response = await callLinearConnect(
- makeRequest('/api/integrations/linear/connect?organizationId=org-linear-123')
+ makeRequest(`/api/integrations/linear/connect?organizationId=${ORGANIZATION_ID}`)
);
const location = response.headers.get('location');
@@ -65,7 +66,7 @@ describe('GET /api/integrations/linear/connect', () => {
const url = new URL(location ?? '');
expect(url.pathname).toBe('/users/sign_in');
expect(url.searchParams.get('callbackPath')).toBe(
- '/api/integrations/linear/connect?organizationId=org-linear-123'
+ `/api/integrations/linear/connect?organizationId=${ORGANIZATION_ID}`
);
expect(mockedGetLinearOAuthUrl).not.toHaveBeenCalled();
});
@@ -87,19 +88,19 @@ describe('GET /api/integrations/linear/connect', () => {
test('authorizes org-scoped installs for owners and billing managers with an active subscription', async () => {
await callLinearConnect(
- makeRequest('/api/integrations/linear/connect?organizationId=org-linear-123')
+ makeRequest(`/api/integrations/linear/connect?organizationId=${ORGANIZATION_ID}`)
);
expect(mockedEnsureOrganizationAccess).toHaveBeenCalledWith(
{ user: expect.objectContaining({ id: USER_ID }) },
- 'org-linear-123',
+ ORGANIZATION_ID,
['owner', 'billing_manager']
);
- expect(mockedRequireActiveSubscriptionOrTrial).toHaveBeenCalledWith('org-linear-123');
+ expect(mockedRequireActiveSubscriptionOrTrial).toHaveBeenCalledWith(ORGANIZATION_ID);
const state = mockedGetLinearOAuthUrl.mock.calls[0]?.[0];
expect(verifyOAuthState(state ?? null)).toEqual(
expect.objectContaining({
- owner: 'org_org-linear-123',
+ owner: `org_${ORGANIZATION_ID}`,
userId: USER_ID,
})
);
@@ -109,14 +110,14 @@ describe('GET /api/integrations/linear/connect', () => {
mockedEnsureOrganizationAccess.mockRejectedValue(new Error('unauthorized'));
const response = await callLinearConnect(
- makeRequest('/api/integrations/linear/connect?organizationId=org-linear-123')
+ makeRequest(`/api/integrations/linear/connect?organizationId=${ORGANIZATION_ID}`)
);
const location = response.headers.get('location');
expect(location).toBeTruthy();
const url = new URL(location ?? '');
expect(`${url.pathname}${url.search}`).toBe(
- '/organizations/org-linear-123/integrations/linear?error=oauth_init_failed'
+ `/organizations/${ORGANIZATION_ID}/integrations/linear?error=oauth_init_failed`
);
expect(mockedRequireActiveSubscriptionOrTrial).not.toHaveBeenCalled();
expect(mockedGetLinearOAuthUrl).not.toHaveBeenCalled();
@@ -126,14 +127,14 @@ describe('GET /api/integrations/linear/connect', () => {
mockedRequireActiveSubscriptionOrTrial.mockRejectedValue(new Error('inactive subscription'));
const response = await callLinearConnect(
- makeRequest('/api/integrations/linear/connect?organizationId=org-linear-123')
+ makeRequest(`/api/integrations/linear/connect?organizationId=${ORGANIZATION_ID}`)
);
const location = response.headers.get('location');
expect(location).toBeTruthy();
const url = new URL(location ?? '');
expect(`${url.pathname}${url.search}`).toBe(
- '/organizations/org-linear-123/integrations/linear?error=oauth_init_failed'
+ `/organizations/${ORGANIZATION_ID}/integrations/linear?error=oauth_init_failed`
);
expect(mockedGetLinearOAuthUrl).not.toHaveBeenCalled();
});
diff --git a/apps/web/src/lib/email.ts b/apps/web/src/lib/email.ts
index 714944749c..d2d19f20fb 100644
--- a/apps/web/src/lib/email.ts
+++ b/apps/web/src/lib/email.ts
@@ -9,6 +9,7 @@ import { db } from '@/lib/drizzle';
import {
getOrganizationAppPathForRouteIdentifier,
getOrganizationRouteIdentifier,
+ isUuidOrganizationRouteIdentifier,
} from '@/lib/organizations/organization-route-utils';
import { logExceptInTest, warnExceptInTest } from '@/lib/utils.server';
import { and, eq, isNull } from 'drizzle-orm';
@@ -163,6 +164,10 @@ type Props = {
};
async function getOrganizationEmailPath(organizationId: string, suffix = ''): Promise {
+ if (!isUuidOrganizationRouteIdentifier(organizationId)) {
+ return getOrganizationAppPathForRouteIdentifier(organizationId, suffix);
+ }
+
const [organization] = await db
.select({ id: organizations.id, slug: organizations.slug })
.from(organizations)
diff --git a/apps/web/src/lib/integrations/oauth/common.ts b/apps/web/src/lib/integrations/oauth/common.ts
index bbfad415df..7659116ef9 100644
--- a/apps/web/src/lib/integrations/oauth/common.ts
+++ b/apps/web/src/lib/integrations/oauth/common.ts
@@ -172,17 +172,16 @@ export async function handleStatefulPlatformOAuthConnect(
requireActiveOrganizationSubscription,
}: HandleStatefulOAuthConnectOptions
): Promise {
+ const requestedOrganizationId = request.nextUrl.searchParams.get('organizationId');
let organizationId: string | null = null;
try {
- organizationId = parseOptionalOrganizationId(
- request.nextUrl.searchParams.get('organizationId')
- );
const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false });
if (authFailedResponse) {
return redirectToSignInForOAuthConnect(request);
}
+ organizationId = parseOptionalOrganizationId(requestedOrganizationId);
const { owner } = await resolveOAuthConnectOwner(request, user, {
organizationRoles,
requireActiveOrganizationSubscription,
@@ -205,7 +204,11 @@ export async function handleStatefulPlatformOAuthConnect(
return NextResponse.redirect(
new URL(
- buildIntegrationOAuthConnectErrorPath(platform, organizationId, 'oauth_init_failed'),
+ buildIntegrationOAuthConnectErrorPath(
+ platform,
+ organizationId ?? requestedOrganizationId,
+ 'oauth_init_failed'
+ ),
APP_URL
)
);
From c4d933a1bea47cdaa284121f6a07a8d4e109fda2 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 11:48:03 -0500
Subject: [PATCH 30/33] Fix oauth error routing
---
.../api/integrations/linear/connect/route.test.ts | 14 ++++++++++++++
apps/web/src/lib/integrations/oauth/common.ts | 2 +-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/apps/web/src/app/api/integrations/linear/connect/route.test.ts b/apps/web/src/app/api/integrations/linear/connect/route.test.ts
index 7f3bc28755..61dd30ba92 100644
--- a/apps/web/src/app/api/integrations/linear/connect/route.test.ts
+++ b/apps/web/src/app/api/integrations/linear/connect/route.test.ts
@@ -123,6 +123,20 @@ describe('GET /api/integrations/linear/connect', () => {
expect(mockedGetLinearOAuthUrl).not.toHaveBeenCalled();
});
+ test('redirects malformed organization IDs to the generic integration error path', async () => {
+ const response = await callLinearConnect(
+ makeRequest('/api/integrations/linear/connect?organizationId=not-a-uuid')
+ );
+
+ const location = response.headers.get('location');
+ expect(location).toBeTruthy();
+ const url = new URL(location ?? '');
+ expect(`${url.pathname}${url.search}`).toBe('/integrations/linear?error=oauth_init_failed');
+ expect(mockedEnsureOrganizationAccess).not.toHaveBeenCalled();
+ expect(mockedRequireActiveSubscriptionOrTrial).not.toHaveBeenCalled();
+ expect(mockedGetLinearOAuthUrl).not.toHaveBeenCalled();
+ });
+
test('redirects inactive org subscription failures without creating an OAuth URL', async () => {
mockedRequireActiveSubscriptionOrTrial.mockRejectedValue(new Error('inactive subscription'));
diff --git a/apps/web/src/lib/integrations/oauth/common.ts b/apps/web/src/lib/integrations/oauth/common.ts
index 7659116ef9..6128896cf2 100644
--- a/apps/web/src/lib/integrations/oauth/common.ts
+++ b/apps/web/src/lib/integrations/oauth/common.ts
@@ -206,7 +206,7 @@ export async function handleStatefulPlatformOAuthConnect(
new URL(
buildIntegrationOAuthConnectErrorPath(
platform,
- organizationId ?? requestedOrganizationId,
+ organizationId,
'oauth_init_failed'
),
APP_URL
From 0b19c0f0be1c50e5f5e042d7be8dc814b68d5ec2 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 11:50:15 -0500
Subject: [PATCH 31/33] format file
---
apps/web/src/lib/integrations/oauth/common.ts | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/apps/web/src/lib/integrations/oauth/common.ts b/apps/web/src/lib/integrations/oauth/common.ts
index 6128896cf2..f472121c33 100644
--- a/apps/web/src/lib/integrations/oauth/common.ts
+++ b/apps/web/src/lib/integrations/oauth/common.ts
@@ -204,11 +204,7 @@ export async function handleStatefulPlatformOAuthConnect(
return NextResponse.redirect(
new URL(
- buildIntegrationOAuthConnectErrorPath(
- platform,
- organizationId,
- 'oauth_init_failed'
- ),
+ buildIntegrationOAuthConnectErrorPath(platform, organizationId, 'oauth_init_failed'),
APP_URL
)
);
From 8b1e34c2df4a2348297cf1d0756f7181553d8c3e Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 12:07:24 -0500
Subject: [PATCH 32/33] Fix org slug redirect regressions
---
.../lib/integrations/oauth/platforms/gitlab-connect.ts | 7 +++++--
apps/web/src/lib/organizations/organization-auth.test.ts | 2 +-
apps/web/src/lib/organizations/organization-auth.ts | 8 ++++++++
.../web/src/lib/organizations/organization-route-utils.ts | 7 +++++++
apps/web/src/lib/user/server.ts | 3 +--
5 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts b/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
index 514776e52c..131b137a24 100644
--- a/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
+++ b/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
@@ -51,10 +51,10 @@ type GitLabOAuthConnectOptions = {
*/
export async function handleGitLabOAuthConnect(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
+ const requestedOrganizationId = searchParams.get('organizationId');
let organizationId: string | null = null;
try {
- organizationId = parseOptionalOrganizationId(searchParams.get('organizationId'));
const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false });
if (authFailedResponse) {
const hasLegacyQueryCredentials =
@@ -62,10 +62,13 @@ export async function handleGitLabOAuthConnect(request: NextRequest) {
return redirectToSignInForOAuthConnect(
request,
- hasLegacyQueryCredentials ? buildGitLabDetailCallbackPath(organizationId) : undefined
+ hasLegacyQueryCredentials
+ ? buildGitLabDetailCallbackPath(requestedOrganizationId)
+ : undefined
);
}
+ organizationId = parseOptionalOrganizationId(requestedOrganizationId);
const instanceUrl = searchParams.get('instanceUrl') || undefined;
const returnToParam = searchParams.get('returnTo') || undefined;
const returnTo = returnToParam ? validateReturnPath(returnToParam) : null;
diff --git a/apps/web/src/lib/organizations/organization-auth.test.ts b/apps/web/src/lib/organizations/organization-auth.test.ts
index ee2a943d2c..f3b73783fa 100644
--- a/apps/web/src/lib/organizations/organization-auth.test.ts
+++ b/apps/web/src/lib/organizations/organization-auth.test.ts
@@ -394,7 +394,7 @@ describe('getAuthorizedOrgContext', () => {
authFailedResponse: null,
});
- const result = await getAuthorizedOrgContext('invalid-uuid', undefined, mockGetUserFromAuth);
+ const result = await getAuthorizedOrgContext('invalid uuid', undefined, mockGetUserFromAuth);
expect(result.success).toBe(false);
if (!result.success) {
diff --git a/apps/web/src/lib/organizations/organization-auth.ts b/apps/web/src/lib/organizations/organization-auth.ts
index 4fe76bb9e2..d883fce441 100644
--- a/apps/web/src/lib/organizations/organization-auth.ts
+++ b/apps/web/src/lib/organizations/organization-auth.ts
@@ -12,6 +12,7 @@ import { successResult } from '@/lib/maybe-result';
import { getOrganizationById } from '@/lib/organizations/organizations';
import z from 'zod';
import { resolveOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils.server';
+import { isValidOrganizationRouteIdentifier } from '@/lib/organizations/organization-route-utils';
const warnInSentry = sentryLogger('org_auth', 'warning');
@@ -55,6 +56,13 @@ export async function getAuthorizedOrgContext(
if (authFailedResponse) {
return { success: false, nextResponse: authFailedResponse };
}
+ if (!isValidOrganizationRouteIdentifier(id)) {
+ const res = NextResponse.json({ error: 'Invalid organization ID' }, { status: 400 });
+ return {
+ success: false,
+ nextResponse: res,
+ };
+ }
const { success, data } = UUIDSchema.safeParse(id);
if (!success) {
const organizationIdForSlug = await resolveOrganizationRouteIdentifier(id);
diff --git a/apps/web/src/lib/organizations/organization-route-utils.ts b/apps/web/src/lib/organizations/organization-route-utils.ts
index 776111e2f2..489b304c45 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.ts
@@ -7,6 +7,7 @@ export type OrganizationRouteIdentifierInput = {
const UUID_ROUTE_IDENTIFIER_PATTERN =
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
+const SLUG_ROUTE_IDENTIFIER_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
export function getOrganizationRouteIdentifier(
organization: OrganizationRouteIdentifierInput
@@ -36,6 +37,12 @@ export function isUuidOrganizationRouteIdentifier(identifier: string): boolean {
return UUID_ROUTE_IDENTIFIER_PATTERN.test(identifier);
}
+export function isValidOrganizationRouteIdentifier(identifier: string): boolean {
+ return (
+ isUuidOrganizationRouteIdentifier(identifier) || SLUG_ROUTE_IDENTIFIER_PATTERN.test(identifier)
+ );
+}
+
export function isOrganizationRouteIdentifierMatch(
organization: OrganizationRouteIdentifierInput,
routeIdentifier: string
diff --git a/apps/web/src/lib/user/server.ts b/apps/web/src/lib/user/server.ts
index e55110b869..2fd5dad2cd 100644
--- a/apps/web/src/lib/user/server.ts
+++ b/apps/web/src/lib/user/server.ts
@@ -46,7 +46,6 @@ import type { AuthProviderId } from '@kilocode/db/schema-types';
import PostHogClient from '@/lib/posthog';
import { captureException } from '@sentry/nextjs';
import { getSingleUserOrganization, isOrganizationMember } from '@/lib/organizations/organizations';
-import { getOrganizationAppPath } from '@/lib/organizations/organization-route-utils';
import { resolveSsoAuthorityForDomain } from '@/lib/organizations/organization-sso-policy';
import type { AccountLinkingSession } from '@/lib/account-linking-session';
import { getAccountLinkingSession } from '@/lib/account-linking-session';
@@ -1182,7 +1181,7 @@ export async function getProfileRedirectPath(user: User) {
if (classification.isTrialExpiredForEnforcement) {
return '/profile';
}
- return getOrganizationAppPath(singleOrg);
+ return `/organizations/${singleOrg.id}`;
}
return '/profile';
From 471efa3847b44cf43c811d1afc3250fa56376ad8 Mon Sep 17 00:00:00 2001
From: Evan Jacobson
Date: Fri, 26 Jun 2026 12:16:27 -0500
Subject: [PATCH 33/33] Fix org slug review regressions
---
.../integrations/gitlab/connect/route.test.ts | 30 +++++++++++++++++--
.../oauth/platforms/gitlab-connect.ts | 12 +++++++-
.../organization-route-utils.test.ts | 21 +++++++++++++
.../organizations/organization-route-utils.ts | 2 +-
4 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/apps/web/src/app/api/integrations/gitlab/connect/route.test.ts b/apps/web/src/app/api/integrations/gitlab/connect/route.test.ts
index c96b536ddc..5681ac5142 100644
--- a/apps/web/src/app/api/integrations/gitlab/connect/route.test.ts
+++ b/apps/web/src/app/api/integrations/gitlab/connect/route.test.ts
@@ -29,6 +29,7 @@ const mockedCreateGitLabOAuthState = jest.mocked(createGitLabOAuthState);
const mockedStoreGitLabOAuthCredentials = jest.mocked(storeGitLabOAuthCredentials);
const USER_ID = '034489e8-19e0-4479-9d69-2edad719e847';
+const ORGANIZATION_ID = 'b41fc61e-827a-4bd4-a94f-16ae8ebf19e2';
function makeRequest(pathWithQuery: string) {
return new NextRequest(`http://localhost:3000${pathWithQuery}`);
@@ -120,7 +121,7 @@ describe('GET /api/integrations/gitlab/connect', () => {
const response = await callGitLabConnect(
makeRequest(
- '/api/integrations/gitlab/connect?organizationId=org-gitlab-123&instanceUrl=https%3A%2F%2Fgitlab.example.com&clientId=client-id&clientSecret=client-secret'
+ `/api/integrations/gitlab/connect?organizationId=${ORGANIZATION_ID}&instanceUrl=https%3A%2F%2Fgitlab.example.com&clientId=client-id&clientSecret=client-secret`
)
);
@@ -129,7 +130,7 @@ describe('GET /api/integrations/gitlab/connect', () => {
const url = new URL(location ?? '');
expect(url.pathname).toBe('/users/sign_in');
expect(url.searchParams.get('callbackPath')).toBe(
- '/organizations/org-gitlab-123/integrations/gitlab'
+ `/organizations/${ORGANIZATION_ID}/integrations/gitlab`
);
expect(location).not.toContain('clientSecret');
expect(location).not.toContain('client-secret');
@@ -138,6 +139,31 @@ describe('GET /api/integrations/gitlab/connect', () => {
expect(mockedBuildGitLabOAuthUrl).not.toHaveBeenCalled();
});
+ test('does not preserve malformed organization IDs in self-hosted sign-in callbacks', async () => {
+ mockedGetUserFromAuth.mockResolvedValue({
+ user: null,
+ authFailedResponse: new Response(null, { status: 401 }),
+ } as never);
+
+ const response = await callGitLabConnect(
+ makeRequest(
+ '/api/integrations/gitlab/connect?organizationId=not-a-uuid&instanceUrl=https%3A%2F%2Fgitlab.example.com&clientId=client-id&clientSecret=client-secret'
+ )
+ );
+
+ const location = response.headers.get('location');
+ expect(location).toBeTruthy();
+ const url = new URL(location ?? '');
+ expect(url.pathname).toBe('/users/sign_in');
+ expect(url.searchParams.get('callbackPath')).toBe('/integrations/gitlab');
+ expect(location).not.toContain('clientSecret');
+ expect(location).not.toContain('client-secret');
+ expect(location).not.toContain('not-a-uuid');
+ expect(mockedCreateGitLabOAuthState).not.toHaveBeenCalled();
+ expect(mockedStoreGitLabOAuthCredentials).not.toHaveBeenCalled();
+ expect(mockedBuildGitLabOAuthUrl).not.toHaveBeenCalled();
+ });
+
test('does not initialize a self-hosted flow without custom OAuth credentials', async () => {
const response = await callGitLabConnect(
makeRequest('/api/integrations/gitlab/connect?instanceUrl=https%3A%2F%2Fattacker.example')
diff --git a/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts b/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
index 131b137a24..67cc5ebedf 100644
--- a/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
+++ b/apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
@@ -63,7 +63,7 @@ export async function handleGitLabOAuthConnect(request: NextRequest) {
return redirectToSignInForOAuthConnect(
request,
hasLegacyQueryCredentials
- ? buildGitLabDetailCallbackPath(requestedOrganizationId)
+ ? buildGitLabDetailCallbackPathForRequestedOrganization(requestedOrganizationId)
: undefined
);
}
@@ -157,6 +157,16 @@ function buildGitLabDetailCallbackPath(organizationId: string | null): string {
return '/integrations/gitlab';
}
+function buildGitLabDetailCallbackPathForRequestedOrganization(
+ requestedOrganizationId: string | null
+): string {
+ try {
+ return buildGitLabDetailCallbackPath(parseOptionalOrganizationId(requestedOrganizationId));
+ } catch {
+ return buildGitLabDetailCallbackPath(null);
+ }
+}
+
async function buildGitLabConnectOAuthUrl(
user: AuthenticatedOAuthUser,
{ organizationId, instanceUrl, clientId, clientSecret, returnTo }: GitLabOAuthConnectOptions
diff --git a/apps/web/src/lib/organizations/organization-route-utils.test.ts b/apps/web/src/lib/organizations/organization-route-utils.test.ts
index b9752f8321..adc2c319c8 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.test.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.test.ts
@@ -8,6 +8,7 @@ import {
getOrganizationAppPathForRouteIdentifier,
getOrganizationRouteIdentifier,
isOrganizationRouteIdentifierMatch,
+ isValidOrganizationRouteIdentifier,
isUuidOrganizationRouteIdentifier,
ORGANIZATION_SLUG_MAX_LENGTH,
} from './organization-route-utils';
@@ -87,6 +88,14 @@ describe('organization route identifier matching', () => {
expect(isUuidOrganizationRouteIdentifier('550e8400-e29b-41d4-a716-446655440000')).toBe(true);
expect(isUuidOrganizationRouteIdentifier('acme')).toBe(false);
});
+
+ it('validates slug route identifiers using the persisted slug format', () => {
+ expect(isValidOrganizationRouteIdentifier('acme')).toBe(true);
+ expect(isValidOrganizationRouteIdentifier('acme-')).toBe(true);
+ expect(isValidOrganizationRouteIdentifier('a'.repeat(32))).toBe(true);
+ expect(isValidOrganizationRouteIdentifier('a'.repeat(33))).toBe(false);
+ expect(isValidOrganizationRouteIdentifier('acme_inc')).toBe(false);
+ });
});
describe('resolveOrganizationRouteIdentifier', () => {
@@ -97,6 +106,7 @@ describe('resolveOrganizationRouteIdentifier', () => {
inArray(organizations.slug, [
'route-id-org',
'route-slug-org',
+ 'route-slug-ending-hyphen-',
'deleted-route-org',
'persisted-kilocode-org',
])
@@ -125,6 +135,17 @@ describe('resolveOrganizationRouteIdentifier', () => {
);
});
+ it('resolves persisted slugs ending with hyphen', async () => {
+ const [organization] = await db
+ .insert(organizations)
+ .values({ name: 'Route Slug Ending Hyphen Org', slug: 'route-slug-ending-hyphen-' })
+ .returning();
+
+ await expect(resolveOrganizationRouteIdentifier('route-slug-ending-hyphen-')).resolves.toBe(
+ organization.id
+ );
+ });
+
it('resolves already persisted slugs containing reserved terms', async () => {
const [organization] = await db
.insert(organizations)
diff --git a/apps/web/src/lib/organizations/organization-route-utils.ts b/apps/web/src/lib/organizations/organization-route-utils.ts
index 489b304c45..3d467aff60 100644
--- a/apps/web/src/lib/organizations/organization-route-utils.ts
+++ b/apps/web/src/lib/organizations/organization-route-utils.ts
@@ -7,7 +7,7 @@ export type OrganizationRouteIdentifierInput = {
const UUID_ROUTE_IDENTIFIER_PATTERN =
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
-const SLUG_ROUTE_IDENTIFIER_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
+const SLUG_ROUTE_IDENTIFIER_PATTERN = /^[a-z0-9][a-z0-9-]{0,31}$/;
export function getOrganizationRouteIdentifier(
organization: OrganizationRouteIdentifierInput