diff --git a/.env.local.example b/.env.local.example
index 67fa499fc6..3dc26a141e 100644
--- a/.env.local.example
+++ b/.env.local.example
@@ -96,6 +96,7 @@ INTERNAL_API_SECRET=changeme
# Worker URLs (defaults shown, workers are optional)
CLOUD_AGENT_API_URL=http://localhost:8788
WEBHOOK_AGENT_URL=http://localhost:8793
+MODEL_EVAL_INGEST_URL=http://localhost:8798
SESSION_INGEST_WORKER_URL=
CODE_REVIEW_WORKER_URL=mock-url
CODE_REVIEW_WORKER_AUTH_TOKEN=mock-token
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
index 2cc88cd1aa..395d99aaf8 100644
--- a/DEVELOPMENT.md
+++ b/DEVELOPMENT.md
@@ -140,7 +140,7 @@ Copy `.env.local.example` to `.env.local`, then update the following variables i
- `INTERNAL_API_SECRET`: Generate a random secret with `openssl rand -base64 32`
- `STRIPE_SECRET_KEY` and `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`: These must be set to create a fake account. You can use an existing Stripe account or create a new one, and use the keys from Sandbox Mode (formerly Test Mode) here.
-Then copy `.env.development.local.example` to `.env.development.local`.
+Then run `pnpm dev:env`. It derives `apps/web/.env.development.local` and Worker `.dev.vars` files from `.env.local` plus each `.example` template. Re-run it after pulling changes that add local service URLs or Worker env vars.
These changes will allow you to do local testing with a fake account.
diff --git a/apps/web/.env.development.local.example b/apps/web/.env.development.local.example
index c5f4d2c32d..5696f52e65 100644
--- a/apps/web/.env.development.local.example
+++ b/apps/web/.env.development.local.example
@@ -31,6 +31,9 @@ USER_DEPLOYMENTS_DISPATCHER_URL=http://localhost:8799
# @url cloudflare-webhook-agent-ingest
WEBHOOK_AGENT_URL=http://localhost:8793
+# @url cloudflare-model-eval-ingest
+MODEL_EVAL_INGEST_URL=http://localhost:8798
+
# @url cloudflare-o11y
O11Y_SERVICE_URL=http://localhost:8801
diff --git a/apps/web/src/app/admin/components/AppSidebar.tsx b/apps/web/src/app/admin/components/AppSidebar.tsx
index 20e15b1193..8152865666 100644
--- a/apps/web/src/app/admin/components/AppSidebar.tsx
+++ b/apps/web/src/app/admin/components/AppSidebar.tsx
@@ -180,6 +180,11 @@ const analyticsObservabilityItems: MenuItem[] = [
url: '/admin/model-stats',
icon: () => ,
},
+ {
+ title: () => 'Model Benchmarks',
+ url: '/admin/model-eval-ingest',
+ icon: () => ,
+ },
{
title: () => 'Session Traces',
url: '/admin/session-traces',
diff --git a/apps/web/src/app/admin/model-eval-ingest/ModelEvalIngestContent.tsx b/apps/web/src/app/admin/model-eval-ingest/ModelEvalIngestContent.tsx
new file mode 100644
index 0000000000..bde616a118
--- /dev/null
+++ b/apps/web/src/app/admin/model-eval-ingest/ModelEvalIngestContent.tsx
@@ -0,0 +1,217 @@
+'use client';
+
+import { useState } from 'react';
+import { useMutation, useQuery } from '@tanstack/react-query';
+import { ExternalLink, RefreshCw } from 'lucide-react';
+import { toast } from 'sonner';
+import { useTRPC } from '@/lib/trpc/utils';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/ui/table';
+
+const PAGE_SIZE = 50;
+
+export function ModelEvalIngestContent() {
+ const trpc = useTRPC();
+ const [page, setPage] = useState(1);
+ const historyQuery = useQuery(
+ trpc.admin.modelEvalIngest.list.queryOptions({ page, limit: PAGE_SIZE })
+ );
+ const syncMutation = useMutation(
+ trpc.admin.modelEvalIngest.syncNow.mutationOptions({
+ onSuccess: result => {
+ toast.success(formatSyncToast(result));
+ void historyQuery.refetch();
+ },
+ onError: error => toast.error(error.message || 'Model eval sync failed'),
+ })
+ );
+ const repullMutation = useMutation(
+ trpc.admin.modelEvalIngest.repullPromotion.mutationOptions({
+ onSuccess: result => {
+ toast.success(
+ `Promotion re-pull fetched ${result.fetched} records and refreshed ${result.cacheRecomputes} caches`
+ );
+ void historyQuery.refetch();
+ },
+ onError: error => toast.error(error.message || 'Promotion re-pull failed'),
+ })
+ );
+
+ const rows = historyQuery.data?.rows ?? [];
+ const pagination = historyQuery.data?.pagination;
+
+ return (
+
+
+
+
Model Benchmarks
+
+ Audit promoted kilo-bench evals that cloud has pulled, then refresh the public Kilo
+ Bench cache on demand. Bench remains the aggregate source; this table is the cloud-side
+ ingest history.
+
+
+
syncMutation.mutate()} disabled={syncMutation.isPending}>
+
+ {syncMutation.isPending ? 'Syncing...' : 'Sync now'}
+
+
+
+
+
+ Promotion history
+
+ Rows are append-only and deduplicated by bench eval name. Promoter email and bench links
+ stay admin-only here, never in the public model-stats cache.
+
+
+
+
+
+
+
+ Bench eval
+ Model
+ Task
+ Score
+ Trials
+ Promoted
+ Promoter
+ Ingested
+ Action
+
+
+
+ {rows.length === 0 ? (
+
+
+ {historyQuery.isLoading
+ ? 'Loading ingest history...'
+ : 'No ingested promotions yet.'}
+
+
+ ) : (
+ rows.map(row => (
+
+
+
+ {row.benchEvalName}
+
+
+
+
+ {row.model}
+
+ {row.provider}
+ {row.variant ? ` / ${row.variant}` : ''}
+
+
+ {row.taskSource}
+
+ {formatScore(row.overallScore)}
+
+ total {formatScore(row.totalScore)}
+
+
+
+ {row.nTotalTrials}
+ {row.nErrored} errored
+
+
+ {formatTimestamp(row.promotedAt)}
+
+
+ {row.promotedByEmail}
+
+
+ {formatTimestamp(row.createdAt)}
+
+
+
+ repullMutation.mutate({ promotionName: row.benchEvalName })
+ }
+ disabled={repullMutation.isPending}
+ >
+ Repull
+
+
+
+ ))
+ )}
+
+
+
+
+
+
+ {pagination ? `${pagination.total} ingested promotion rows` : 'Loading row count...'}
+
+
+ setPage(current => Math.max(1, current - 1))}
+ disabled={page <= 1 || historyQuery.isFetching}
+ >
+ Previous
+
+ setPage(current => current + 1)}
+ disabled={!pagination || page >= pagination.totalPages || historyQuery.isFetching}
+ >
+ Next
+
+
+
+
+
+
+ );
+}
+
+function formatTimestamp(value: string): string {
+ return new Date(value).toLocaleString();
+}
+
+function formatScore(value: number): string {
+ return value.toFixed(4);
+}
+
+function formatSyncToast(result: {
+ inserted: number;
+ alreadyHad: number;
+ fetched: number;
+}): string {
+ if (result.inserted > 0) {
+ const inserted = `Bench sync inserted ${formatCount(result.inserted, 'new promotion')}.`;
+ return result.alreadyHad > 0
+ ? `${inserted} ${formatCount(result.alreadyHad, 'existing promotion')} rechecked.`
+ : inserted;
+ }
+
+ if (result.alreadyHad > 0) {
+ return `Bench sync is up to date; ${formatCount(result.alreadyHad, 'existing promotion')} rechecked.`;
+ }
+
+ return `Bench sync is up to date; ${formatCount(result.fetched, 'promotion')} returned.`;
+}
+
+function formatCount(count: number, label: string): string {
+ return `${count} ${label}${count === 1 ? '' : 's'}`;
+}
diff --git a/apps/web/src/app/admin/model-eval-ingest/page.tsx b/apps/web/src/app/admin/model-eval-ingest/page.tsx
new file mode 100644
index 0000000000..c9891bfe41
--- /dev/null
+++ b/apps/web/src/app/admin/model-eval-ingest/page.tsx
@@ -0,0 +1,17 @@
+import { BreadcrumbItem, BreadcrumbPage } from '@/components/ui/breadcrumb';
+import AdminPage from '@/app/admin/components/AdminPage';
+import { ModelEvalIngestContent } from './ModelEvalIngestContent';
+
+const breadcrumbs = (
+
+ Model Benchmarks
+
+);
+
+export default function ModelEvalIngestPage() {
+ return (
+
+
+
+ );
+}
diff --git a/apps/web/src/lib/config.server.ts b/apps/web/src/lib/config.server.ts
index 4619863c0a..b2bc5e9a75 100644
--- a/apps/web/src/lib/config.server.ts
+++ b/apps/web/src/lib/config.server.ts
@@ -334,6 +334,9 @@ export const STRIPE_KILOCLAW_EARLYBIRD_COUPON_ID = getEnvVariable(
export const WEBHOOK_AGENT_URL =
getEnvVariable('WEBHOOK_AGENT_URL') || 'https://hooks.kilosessions.ai';
+// Model eval ingest Worker
+export const MODEL_EVAL_INGEST_URL = getEnvVariable('MODEL_EVAL_INGEST_URL') || '';
+
// Session ingest worker (public share proxy)
export const SESSION_INGEST_WORKER_URL = getEnvVariable('SESSION_INGEST_WORKER_URL') || '';
diff --git a/apps/web/src/lib/model-eval-ingest-client.ts b/apps/web/src/lib/model-eval-ingest-client.ts
new file mode 100644
index 0000000000..81e53f2f0a
--- /dev/null
+++ b/apps/web/src/lib/model-eval-ingest-client.ts
@@ -0,0 +1,45 @@
+import 'server-only';
+import * as z from 'zod';
+import { INTERNAL_API_SECRET, MODEL_EVAL_INGEST_URL } from '@/lib/config.server';
+
+const ModelEvalSyncResultSchema = z.object({
+ success: z.literal(true),
+ inserted: z.number().int().nonnegative(),
+ alreadyHad: z.number().int().nonnegative(),
+ cacheRecomputes: z.number().int().nonnegative(),
+ fetched: z.number().int().nonnegative(),
+});
+const ModelEvalSyncErrorSchema = z.object({ error: z.string().optional() });
+
+export type ModelEvalSyncResult = z.infer;
+
+type ModelEvalSyncRequest = {
+ promotionName?: string;
+};
+
+export async function syncModelEvalPromotions(
+ request: ModelEvalSyncRequest = {}
+): Promise {
+ if (!MODEL_EVAL_INGEST_URL) {
+ throw new Error('MODEL_EVAL_INGEST_URL is not configured');
+ }
+
+ const response = await fetch(`${MODEL_EVAL_INGEST_URL}/internal/sync`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'x-internal-api-key': INTERNAL_API_SECRET,
+ },
+ body: JSON.stringify(request),
+ });
+
+ const body: unknown = await response.json();
+ if (!response.ok) {
+ const errorBody = ModelEvalSyncErrorSchema.safeParse(body);
+ throw new Error(
+ errorBody.success && errorBody.data.error ? errorBody.data.error : `HTTP ${response.status}`
+ );
+ }
+
+ return ModelEvalSyncResultSchema.parse(body);
+}
diff --git a/apps/web/src/lib/user.test.ts b/apps/web/src/lib/user.test.ts
index c94a50bd49..9a8e142719 100644
--- a/apps/web/src/lib/user.test.ts
+++ b/apps/web/src/lib/user.test.ts
@@ -66,6 +66,7 @@ import {
impact_advocate_reward_redemptions,
impact_conversion_reports,
github_branch_pull_requests,
+ model_eval_ingestions,
} from '@kilocode/db/schema';
import { eq, count } from 'drizzle-orm';
import {
@@ -126,6 +127,7 @@ describe('User', () => {
await db.delete(organization_audit_logs);
await db.delete(security_audit_log);
await db.delete(kiloclaw_admin_audit_logs);
+ await db.delete(model_eval_ingestions);
await db.delete(kiloclaw_scheduled_action_targets);
await db.delete(kiloclaw_scheduled_action_stages);
await db.delete(kiloclaw_scheduled_actions);
@@ -1126,6 +1128,58 @@ describe('User', () => {
expect(logs[0].target_user_id).toBe('some-other-user'); // not anonymized (different user)
});
+ it('should anonymize model eval ingest promoter email', async () => {
+ const promoter = await insertTestUser();
+ const otherPromoter = await insertTestUser();
+
+ await db.insert(model_eval_ingestions).values([
+ {
+ bench_eval_name: 'soft-delete-promoter-eval',
+ bench_eval_url: 'https://bench.example.com/jobs/soft-delete-promoter-eval',
+ provider: 'kilo',
+ model: 'kilo/openai/gpt-5.5',
+ variant: null,
+ task_source: 'terminal-bench',
+ n_total_trials: 4,
+ total_score: 1.5,
+ overall_score: 0.375,
+ n_errored: 0,
+ promoted_at: new Date('2026-05-14T10:00:00.000Z').toISOString(),
+ promoted_by_email: promoter.google_user_email,
+ promotion_note: null,
+ },
+ {
+ bench_eval_name: 'retained-promoter-eval',
+ bench_eval_url: 'https://bench.example.com/jobs/retained-promoter-eval',
+ provider: 'kilo',
+ model: 'kilo/openai/gpt-5.5',
+ variant: null,
+ task_source: 'swebench-verified',
+ n_total_trials: 4,
+ total_score: 2,
+ overall_score: 0.5,
+ n_errored: 0,
+ promoted_at: new Date('2026-05-14T11:00:00.000Z').toISOString(),
+ promoted_by_email: otherPromoter.google_user_email,
+ promotion_note: null,
+ },
+ ]);
+
+ await softDeleteUser(promoter.id);
+
+ const rows = await db
+ .select({
+ benchEvalName: model_eval_ingestions.bench_eval_name,
+ promoterEmail: model_eval_ingestions.promoted_by_email,
+ })
+ .from(model_eval_ingestions);
+ const anonymized = rows.find(row => row.benchEvalName === 'soft-delete-promoter-eval');
+ const retained = rows.find(row => row.benchEvalName === 'retained-promoter-eval');
+
+ expect(anonymized?.promoterEmail).toBe(`deleted+${promoter.id}@deleted.invalid`);
+ expect(retained?.promoterEmail).toBe(otherPromoter.google_user_email);
+ });
+
it('should anonymize kiloclaw admin audit logs where user is target', async () => {
const targetUser = await insertTestUser();
const adminUser = await insertTestUser();
diff --git a/apps/web/src/lib/user.ts b/apps/web/src/lib/user.ts
index d78338c7d5..b7a9a1a261 100644
--- a/apps/web/src/lib/user.ts
+++ b/apps/web/src/lib/user.ts
@@ -75,6 +75,7 @@ import {
impact_advocate_reward_redemptions,
impact_conversion_reports,
github_branch_pull_requests,
+ model_eval_ingestions,
} from '@kilocode/db/schema';
import { eq, and, inArray, isNotNull, isNull, sql, or, gte, count } from 'drizzle-orm';
import { allow_fake_login, IS_DEVELOPMENT } from './constants';
@@ -724,6 +725,7 @@ export class SoftDeletePreconditionError extends Error {
* - organization_user_limits/usage
* - organization_audit_logs (actor PII nulled)
* - kiloclaw_admin_audit_logs (actor PII nulled, target_user_id anonymized)
+ * - model_eval_ingestions (promoter email anonymized)
* - credit_campaigns (created_by_kilo_user_id anonymized)
* - payment_methods (soft-deleted, address/name/IP fields nulled)
* - App Store account token and retained Kilo Pass store purchase/event token fields
@@ -1081,6 +1083,11 @@ export async function softDeleteUser(userId: string) {
.set({ target_user_id: 'deleted-user' })
.where(eq(kiloclaw_admin_audit_logs.target_user_id, userId));
+ await tx
+ .update(model_eval_ingestions)
+ .set({ promoted_by_email: `deleted+${userId}@deleted.invalid` })
+ .where(sql`lower(${model_eval_ingestions.promoted_by_email}) = lower(${originalEmail})`);
+
// Credit campaigns: strip the creator-admin reference. The campaigns
// themselves are retained (they represent ongoing marketing relationships
// and audit of granted credits), but the link back to the deleted user
diff --git a/apps/web/src/routers/admin-model-eval-ingest-router.ts b/apps/web/src/routers/admin-model-eval-ingest-router.ts
new file mode 100644
index 0000000000..2b2e0ce531
--- /dev/null
+++ b/apps/web/src/routers/admin-model-eval-ingest-router.ts
@@ -0,0 +1,72 @@
+import { adminProcedure, createTRPCRouter } from '@/lib/trpc/init';
+import { db } from '@/lib/drizzle';
+import { model_eval_ingestions } from '@kilocode/db/schema';
+import { desc, sql } from 'drizzle-orm';
+import { revalidatePath } from 'next/cache';
+import * as z from 'zod';
+import { syncModelEvalPromotions } from '@/lib/model-eval-ingest-client';
+
+const ModelEvalIngestListSchema = z.object({
+ page: z.number().int().positive().default(1),
+ limit: z.number().int().min(1).max(100).default(50),
+});
+
+export const adminModelEvalIngestRouter = createTRPCRouter({
+ list: adminProcedure.input(ModelEvalIngestListSchema).query(async ({ input }) => {
+ const offset = (input.page - 1) * input.limit;
+ const rows = await db
+ .select({
+ id: model_eval_ingestions.id,
+ benchEvalName: model_eval_ingestions.bench_eval_name,
+ benchEvalUrl: model_eval_ingestions.bench_eval_url,
+ provider: model_eval_ingestions.provider,
+ model: model_eval_ingestions.model,
+ variant: model_eval_ingestions.variant,
+ taskSource: model_eval_ingestions.task_source,
+ nTotalTrials: model_eval_ingestions.n_total_trials,
+ totalScore: model_eval_ingestions.total_score,
+ overallScore: model_eval_ingestions.overall_score,
+ nErrored: model_eval_ingestions.n_errored,
+ promotedAt: model_eval_ingestions.promoted_at,
+ promotedByEmail: model_eval_ingestions.promoted_by_email,
+ promotionNote: model_eval_ingestions.promotion_note,
+ createdAt: model_eval_ingestions.created_at,
+ modelStatsId: model_eval_ingestions.model_stats_id,
+ total: sql`count(*) OVER()::int`.as('total'),
+ })
+ .from(model_eval_ingestions)
+ .orderBy(desc(model_eval_ingestions.promoted_at), desc(model_eval_ingestions.bench_eval_name))
+ .limit(input.limit)
+ .offset(offset);
+
+ const total = rows[0]?.total ?? 0;
+ return {
+ rows: rows.map(({ total: _total, ...row }) => row),
+ pagination: {
+ page: input.page,
+ limit: input.limit,
+ total,
+ totalPages: Math.ceil(total / input.limit),
+ },
+ };
+ }),
+
+ syncNow: adminProcedure.mutation(async () => {
+ const result = await syncModelEvalPromotions();
+ revalidateModelStatsRoutes();
+ return result;
+ }),
+
+ repullPromotion: adminProcedure
+ .input(z.object({ promotionName: z.string().min(1) }))
+ .mutation(async ({ input }) => {
+ const result = await syncModelEvalPromotions({ promotionName: input.promotionName });
+ revalidateModelStatsRoutes();
+ return result;
+ }),
+});
+
+function revalidateModelStatsRoutes(): void {
+ revalidatePath('/api/models/stats');
+ revalidatePath('/api/models/stats/[slug]', 'page');
+}
diff --git a/apps/web/src/routers/admin-router.ts b/apps/web/src/routers/admin-router.ts
index 0bcf509b90..4d72acbc94 100644
--- a/apps/web/src/routers/admin-router.ts
+++ b/apps/web/src/routers/admin-router.ts
@@ -50,6 +50,7 @@ import { adminWebhookTriggersRouter } from '@/routers/admin-webhook-triggers-rou
import { adminAlertingRouter } from '@/routers/admin-alerting-router';
import { adminBotRequestsRouter } from '@/routers/admin-bot-requests-router';
import { adminFreeModelUsageRouter } from '@/routers/admin/free-model-usage-router';
+import { adminModelEvalIngestRouter } from '@/routers/admin-model-eval-ingest-router';
import { workerInstanceId } from '@/lib/kiloclaw/instance-registry';
import { clearTrialInactivityStopAfterStart } from '@/lib/kiloclaw/instance-lifecycle';
import * as z from 'zod';
@@ -1864,4 +1865,5 @@ export const adminRouter = createTRPCRouter({
// the shell-security rebrand; the key/symbol asymmetry is intentional.
securityAdvisorContent: adminShellSecurityContentRouter,
freeModelUsage: adminFreeModelUsageRouter,
+ modelEvalIngest: adminModelEvalIngestRouter,
});
diff --git a/dev/local/services.ts b/dev/local/services.ts
index 87ad09e405..27be64eb7a 100644
--- a/dev/local/services.ts
+++ b/dev/local/services.ts
@@ -173,6 +173,11 @@ const serviceMeta: Record = {
dependsOn: ['nextjs'],
dir: 'services/o11y',
},
+ 'cloudflare-model-eval-ingest': {
+ group: 'observability',
+ dependsOn: ['postgres'],
+ dir: 'services/model-eval-ingest',
+ },
'cloudflare-ai-attribution': {
group: 'observability',
dependsOn: [],
diff --git a/packages/db/src/migrations/0136_neat_lady_deathstrike.sql b/packages/db/src/migrations/0136_neat_lady_deathstrike.sql
new file mode 100644
index 0000000000..81950a3f0b
--- /dev/null
+++ b/packages/db/src/migrations/0136_neat_lady_deathstrike.sql
@@ -0,0 +1,29 @@
+CREATE TABLE "model_eval_ingestions" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "bench_eval_name" text NOT NULL,
+ "bench_eval_url" text NOT NULL,
+ "provider" text NOT NULL,
+ "model" text NOT NULL,
+ "model_stats_id" uuid,
+ "variant" text,
+ "task_source" text NOT NULL,
+ "n_total_trials" integer NOT NULL,
+ "total_score" numeric(14, 6) NOT NULL,
+ "overall_score" numeric(12, 8) NOT NULL,
+ "n_errored" integer NOT NULL,
+ "avg_cost_microdollars" bigint,
+ "avg_input_tokens" integer,
+ "avg_output_tokens" integer,
+ "avg_cache_read_tokens" integer,
+ "avg_execution_ms" integer,
+ "promoted_at" timestamp with time zone NOT NULL,
+ "promoted_by_email" text NOT NULL,
+ "promotion_note" text,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "model_eval_ingestions_bench_eval_name_unique" UNIQUE("bench_eval_name")
+);
+--> statement-breakpoint
+ALTER TABLE "model_eval_ingestions" ADD CONSTRAINT "model_eval_ingestions_model_stats_id_model_stats_id_fk" FOREIGN KEY ("model_stats_id") REFERENCES "public"."model_stats"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "IDX_model_eval_ingestions_lookup" ON "model_eval_ingestions" USING btree ("provider","model","variant","task_source","promoted_at");--> statement-breakpoint
+CREATE INDEX "IDX_model_eval_ingestions_model_stats" ON "model_eval_ingestions" USING btree ("model_stats_id");--> statement-breakpoint
+CREATE INDEX "IDX_model_eval_ingestions_promoted_by_email_lower" ON "model_eval_ingestions" USING btree (LOWER("promoted_by_email"));
\ No newline at end of file
diff --git a/packages/db/src/migrations/meta/0136_snapshot.json b/packages/db/src/migrations/meta/0136_snapshot.json
new file mode 100644
index 0000000000..649d4fc6dc
--- /dev/null
+++ b/packages/db/src/migrations/meta/0136_snapshot.json
@@ -0,0 +1,23220 @@
+{
+ "id": "e60aab72-f1aa-49cf-a335-ac32fe05df8f",
+ "prevId": "818fdde6-960b-41ff-a3b2-8d194d667437",
+ "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_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
+ },
+ "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
+ },
+ "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_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
+ },
+ "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'"
+ },
+ "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
+ },
+ "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_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.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
+ },
+ "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": {},
+ "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.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()"
+ },
+ "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": {
+ "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_user_id": {
+ "name": "UQ_impact_advocate_participants_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "UQ_impact_advocate_participants_opaque_referral_identifier": {
+ "name": "UQ_impact_advocate_participants_opaque_referral_identifier",
+ "nullsNotDistinct": false,
+ "columns": [
+ "opaque_referral_identifier"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "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()"
+ },
+ "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_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_kiloclaw_referral_rewards_id_fk": {
+ "name": "impact_advocate_reward_redemptions_reward_id_kiloclaw_referral_rewards_id_fk",
+ "tableFrom": "impact_advocate_reward_redemptions",
+ "tableTo": "kiloclaw_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_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_kiloclaw_referral_conversions_id_fk": {
+ "name": "impact_conversion_reports_conversion_id_kiloclaw_referral_conversions_id_fk",
+ "tableFrom": "impact_conversion_reports",
+ "tableTo": "kiloclaw_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.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', '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')"
+ }
+ },
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time 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')"
+ }
+ },
+ "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.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_attribution_touches": {
+ "name": "kiloclaw_attribution_touches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "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_kiloclaw_attribution_touches_user_id": {
+ "name": "IDX_kiloclaw_attribution_touches_user_id",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_attribution_touches_anonymous_id": {
+ "name": "IDX_kiloclaw_attribution_touches_anonymous_id",
+ "columns": [
+ {
+ "expression": "anonymous_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_attribution_touches_expires_at": {
+ "name": "IDX_kiloclaw_attribution_touches_expires_at",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_attribution_touches_sale_attributed_at": {
+ "name": "IDX_kiloclaw_attribution_touches_sale_attributed_at",
+ "columns": [
+ {
+ "expression": "sale_attributed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_attribution_touches_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_attribution_touches_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_attribution_touches",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kiloclaw_attribution_touches_dedupe_key": {
+ "name": "UQ_kiloclaw_attribution_touches_dedupe_key",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_attribution_touches_touch_type_check": {
+ "name": "kiloclaw_attribution_touches_touch_type_check",
+ "value": "\"kiloclaw_attribution_touches\".\"touch_type\" IN ('affiliate', 'referral')"
+ },
+ "kiloclaw_attribution_touches_provider_check": {
+ "name": "kiloclaw_attribution_touches_provider_check",
+ "value": "\"kiloclaw_attribution_touches\".\"provider\" IN ('impact_performance', 'impact_advocate')"
+ },
+ "kiloclaw_attribution_touches_tracking_value_length_non_negative_check": {
+ "name": "kiloclaw_attribution_touches_tracking_value_length_non_negative_check",
+ "value": "\"kiloclaw_attribution_touches\".\"tracking_value_length\" >= 0"
+ }
+ },
+ "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_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_referral_conversions": {
+ "name": "kiloclaw_referral_conversions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "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
+ },
+ "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_kiloclaw_referral_conversions_referee_user_id": {
+ "name": "IDX_kiloclaw_referral_conversions_referee_user_id",
+ "columns": [
+ {
+ "expression": "referee_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_referral_conversions_referrer_user_id": {
+ "name": "IDX_kiloclaw_referral_conversions_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_referral_conversions_referee_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_referral_conversions_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referral_conversions_referrer_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_referral_conversions_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_referral_conversions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referral_conversions_source_touch_id_kiloclaw_attribution_touches_id_fk": {
+ "name": "kiloclaw_referral_conversions_source_touch_id_kiloclaw_attribution_touches_id_fk",
+ "tableFrom": "kiloclaw_referral_conversions",
+ "tableTo": "kiloclaw_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kiloclaw_referral_conversions_source_payment_id": {
+ "name": "UQ_kiloclaw_referral_conversions_source_payment_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_payment_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_referral_conversions_winning_touch_type_check": {
+ "name": "kiloclaw_referral_conversions_winning_touch_type_check",
+ "value": "\"kiloclaw_referral_conversions\".\"winning_touch_type\" IN ('referral', 'affiliate', 'none')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_referral_reward_applications": {
+ "name": "kiloclaw_referral_reward_applications",
+ "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
+ },
+ "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_kiloclaw_referral_reward_applications_reward_id": {
+ "name": "IDX_kiloclaw_referral_reward_applications_reward_id",
+ "columns": [
+ {
+ "expression": "reward_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_referral_reward_applications_beneficiary_user_id": {
+ "name": "IDX_kiloclaw_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": {
+ "kiloclaw_referral_reward_applications_reward_id_kiloclaw_referral_rewards_id_fk": {
+ "name": "kiloclaw_referral_reward_applications_reward_id_kiloclaw_referral_rewards_id_fk",
+ "tableFrom": "kiloclaw_referral_reward_applications",
+ "tableTo": "kiloclaw_referral_rewards",
+ "columnsFrom": [
+ "reward_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_referral_reward_applications_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_referral_reward_applications",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_referral_reward_decisions": {
+ "name": "kiloclaw_referral_reward_decisions",
+ "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": 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
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "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_kiloclaw_referral_reward_decisions_beneficiary_user_id": {
+ "name": "IDX_kiloclaw_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": {
+ "kiloclaw_referral_reward_decisions_conversion_id_kiloclaw_referral_conversions_id_fk": {
+ "name": "kiloclaw_referral_reward_decisions_conversion_id_kiloclaw_referral_conversions_id_fk",
+ "tableFrom": "kiloclaw_referral_reward_decisions",
+ "tableTo": "kiloclaw_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_referral_reward_decisions_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_referral_reward_decisions",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kiloclaw_referral_reward_decisions_conversion_role": {
+ "name": "UQ_kiloclaw_referral_reward_decisions_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_referral_reward_decisions_beneficiary_role_check": {
+ "name": "kiloclaw_referral_reward_decisions_beneficiary_role_check",
+ "value": "\"kiloclaw_referral_reward_decisions\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "kiloclaw_referral_reward_decisions_outcome_check": {
+ "name": "kiloclaw_referral_reward_decisions_outcome_check",
+ "value": "\"kiloclaw_referral_reward_decisions\".\"outcome\" IN ('granted', 'cap_limited', 'disqualified')"
+ },
+ "kiloclaw_referral_reward_decisions_months_granted_non_negative_check": {
+ "name": "kiloclaw_referral_reward_decisions_months_granted_non_negative_check",
+ "value": "\"kiloclaw_referral_reward_decisions\".\"months_granted\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_referral_rewards": {
+ "name": "kiloclaw_referral_rewards",
+ "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": 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
+ },
+ "months_granted": {
+ "name": "months_granted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "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
+ },
+ "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_kiloclaw_referral_rewards_beneficiary_user_id": {
+ "name": "IDX_kiloclaw_referral_rewards_beneficiary_user_id",
+ "columns": [
+ {
+ "expression": "beneficiary_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_referral_rewards_status": {
+ "name": "IDX_kiloclaw_referral_rewards_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_referral_rewards_conversion_id_kiloclaw_referral_conversions_id_fk": {
+ "name": "kiloclaw_referral_rewards_conversion_id_kiloclaw_referral_conversions_id_fk",
+ "tableFrom": "kiloclaw_referral_rewards",
+ "tableTo": "kiloclaw_referral_conversions",
+ "columnsFrom": [
+ "conversion_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referral_rewards_decision_id_kiloclaw_referral_reward_decisions_id_fk": {
+ "name": "kiloclaw_referral_rewards_decision_id_kiloclaw_referral_reward_decisions_id_fk",
+ "tableFrom": "kiloclaw_referral_rewards",
+ "tableTo": "kiloclaw_referral_reward_decisions",
+ "columnsFrom": [
+ "decision_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referral_rewards_beneficiary_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_referral_rewards_beneficiary_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_referral_rewards",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "beneficiary_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kiloclaw_referral_rewards_conversion_role": {
+ "name": "UQ_kiloclaw_referral_rewards_conversion_role",
+ "nullsNotDistinct": false,
+ "columns": [
+ "conversion_id",
+ "beneficiary_role"
+ ]
+ },
+ "UQ_kiloclaw_referral_rewards_decision_id": {
+ "name": "UQ_kiloclaw_referral_rewards_decision_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "decision_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "kiloclaw_referral_rewards_beneficiary_role_check": {
+ "name": "kiloclaw_referral_rewards_beneficiary_role_check",
+ "value": "\"kiloclaw_referral_rewards\".\"beneficiary_role\" IN ('referrer', 'referee')"
+ },
+ "kiloclaw_referral_rewards_status_check": {
+ "name": "kiloclaw_referral_rewards_status_check",
+ "value": "\"kiloclaw_referral_rewards\".\"status\" IN ('pending', 'earned', 'applied', 'reversed', 'expired', 'canceled', 'review_required')"
+ },
+ "kiloclaw_referral_rewards_months_granted_positive_check": {
+ "name": "kiloclaw_referral_rewards_months_granted_positive_check",
+ "value": "\"kiloclaw_referral_rewards\".\"months_granted\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.kiloclaw_referrals": {
+ "name": "kiloclaw_referrals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "pg_catalog.gen_random_uuid()"
+ },
+ "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_kiloclaw_referrals_referrer_user_id": {
+ "name": "IDX_kiloclaw_referrals_referrer_user_id",
+ "columns": [
+ {
+ "expression": "referrer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "IDX_kiloclaw_referrals_source_touch_id": {
+ "name": "IDX_kiloclaw_referrals_source_touch_id",
+ "columns": [
+ {
+ "expression": "source_touch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "kiloclaw_referrals_referee_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_referrals_referee_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referrals_referrer_user_id_kilocode_users_id_fk": {
+ "name": "kiloclaw_referrals_referrer_user_id_kilocode_users_id_fk",
+ "tableFrom": "kiloclaw_referrals",
+ "tableTo": "kilocode_users",
+ "columnsFrom": [
+ "referrer_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "kiloclaw_referrals_source_touch_id_kiloclaw_attribution_touches_id_fk": {
+ "name": "kiloclaw_referrals_source_touch_id_kiloclaw_attribution_touches_id_fk",
+ "tableFrom": "kiloclaw_referrals",
+ "tableTo": "kiloclaw_attribution_touches",
+ "columnsFrom": [
+ "source_touch_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "UQ_kiloclaw_referrals_referee_user_id": {
+ "name": "UQ_kiloclaw_referrals_referee_user_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "referee_user_id"
+ ]
+ }
+ },
+ "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
+ },
+ "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
+ },
+ "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_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"
+ }
+ },
+ "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.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
+ }
+ },
+ "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_created_at": {
+ "name": "idx_microdollar_usage_metadata_session_id_created_at",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "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
+ },
+ "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
+ },
+ "avg_input_tokens": {
+ "name": "avg_input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_output_tokens": {
+ "name": "avg_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avg_cache_read_tokens": {
+ "name": "avg_cache_read_tokens",
+ "type": "integer",
+ "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
+ },
+ "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": true,
+ "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
+ },
+ "system_prompt_sha256": {
+ "name": "system_prompt_sha256",
+ "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": {},
+ "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_system_prompt_sha256_format": {
+ "name": "model_experiment_request_system_prompt_sha256_format",
+ "value": "\"model_experiment_request\".\"system_prompt_sha256\" ~ '^[0-9a-f]{64}$' OR \"model_experiment_request\".\"system_prompt_sha256\" IN ('__absent__', '__failed__', '__deleted__')"
+ },
+ "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
+ },
+ "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": {},
+ "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_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
+ },
+ "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": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "organizations_name_not_empty_check": {
+ "name": "organizations_name_not_empty_check",
+ "value": "length(trim(\"organizations\".\"name\")) > 0"
+ }
+ },
+ "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_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
+ },
+ "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": {}
+ },
+ "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.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_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
+ },
+ "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
+ },
+ "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": {}
+ }
+ },
+ "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.status_change', 'security.finding.dismissed', 'security.finding.auto_dismissed', 'security.finding.analysis_started', 'security.finding.analysis_completed', 'security.finding.deleted', 'security.config.enabled', 'security.config.disabled', 'security.config.updated', 'security.sync.triggered', 'security.sync.completed', 'security.audit_log.exported')"
+ }
+ },
+ "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": {
+ "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": {
+ "uq_security_findings_source": {
+ "name": "uq_security_findings_source",
+ "nullsNotDistinct": false,
+ "columns": [
+ "repo_full_name",
+ "source",
+ "source_id"
+ ]
+ }
+ },
+ "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.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.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_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
+ }
+ },
+ "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 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 0219e26998..6b89202566 100644
--- a/packages/db/src/migrations/meta/_journal.json
+++ b/packages/db/src/migrations/meta/_journal.json
@@ -953,6 +953,13 @@
"when": 1779174606902,
"tag": "0135_little_ezekiel_stane",
"breakpoints": true
+ },
+ {
+ "idx": 136,
+ "version": "7",
+ "when": 1779200166216,
+ "tag": "0136_neat_lady_deathstrike",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts
index 5c323507e9..d0f3b3b4d0 100644
--- a/packages/db/src/schema.ts
+++ b/packages/db/src/schema.ts
@@ -2918,6 +2918,28 @@ export const ModelStatsBenchmarksSchema = z
lastUpdated: z.string().optional(),
})
.optional(),
+ kiloBench: z
+ .object({
+ overallScore: z.number(),
+ evals: z.record(
+ z.string(),
+ z.object({
+ taskSource: z.string(),
+ displayName: z.string().optional(),
+ overallScore: z.number(),
+ totalScore: z.number(),
+ avgCostUsd: z.number().nullable(),
+ avgInputTokens: z.number().nullable(),
+ avgOutputTokens: z.number().nullable(),
+ avgCacheReadTokens: z.number().nullable(),
+ avgExecutionMs: z.number().nullable(),
+ nTotalTrials: z.number(),
+ nErrored: z.number(),
+ lastPromotedAt: z.string(),
+ })
+ ),
+ })
+ .optional(),
})
.optional();
@@ -3019,6 +3041,51 @@ export const modelStats = pgTable(
export type ModelStats = typeof modelStats.$inferSelect;
export type NewModelStats = typeof modelStats.$inferInsert;
+export const model_eval_ingestions = pgTable(
+ 'model_eval_ingestions',
+ {
+ id: uuid('id').primaryKey().defaultRandom(),
+ bench_eval_name: text('bench_eval_name').notNull().unique(),
+ bench_eval_url: text('bench_eval_url').notNull(),
+ provider: text('provider').notNull(),
+ model: text('model').notNull(),
+ model_stats_id: uuid('model_stats_id').references(() => modelStats.id),
+ variant: text('variant'),
+ task_source: text('task_source').notNull(),
+ n_total_trials: integer('n_total_trials').notNull(),
+ total_score: decimal('total_score', { precision: 14, scale: 6, mode: 'number' }).notNull(),
+ overall_score: decimal('overall_score', { precision: 12, scale: 8, mode: 'number' }).notNull(),
+ n_errored: integer('n_errored').notNull(),
+ avg_cost_microdollars: bigint('avg_cost_microdollars', { mode: 'number' }),
+ avg_input_tokens: integer('avg_input_tokens'),
+ avg_output_tokens: integer('avg_output_tokens'),
+ avg_cache_read_tokens: integer('avg_cache_read_tokens'),
+ avg_execution_ms: integer('avg_execution_ms'),
+ promoted_at: timestamp('promoted_at', { withTimezone: true, mode: 'string' }).notNull(),
+ promoted_by_email: text('promoted_by_email').notNull(),
+ promotion_note: text('promotion_note'),
+ created_at: timestamp('created_at', { withTimezone: true, mode: 'string' })
+ .defaultNow()
+ .notNull(),
+ },
+ table => [
+ index('IDX_model_eval_ingestions_lookup').on(
+ table.provider,
+ table.model,
+ table.variant,
+ table.task_source,
+ table.promoted_at
+ ),
+ index('IDX_model_eval_ingestions_model_stats').on(table.model_stats_id),
+ index('IDX_model_eval_ingestions_promoted_by_email_lower').on(
+ sql`LOWER(${table.promoted_by_email})`
+ ),
+ ]
+);
+
+export type ModelEvalIngestion = typeof model_eval_ingestions.$inferSelect;
+export type NewModelEvalIngestion = typeof model_eval_ingestions.$inferInsert;
+
export const MODELS_BY_PROVIDER_ADMIN_URL = '/admin/sync-providers';
export const contributor_champion_contributors = pgTable(
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 30bb2527f9..d3f5fbc2c2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2249,6 +2249,34 @@ importers:
specifier: 'catalog:'
version: 4.1.6(@opentelemetry/api@1.9.1)(@types/node@25.5.2)(@vitest/coverage-v8@4.1.6)(@vitest/ui@4.1.6)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4)
+ services/model-eval-ingest:
+ dependencies:
+ '@kilocode/db':
+ specifier: workspace:*
+ version: link:../../packages/db
+ drizzle-orm:
+ specifier: 0.45.2
+ version: 0.45.2(@cloudflare/workers-types@4.20260511.1)(@opentelemetry/api@1.9.1)(@types/pg@8.18.0)(bun-types@1.3.14)(pg@8.20.0)
+ zod:
+ specifier: 'catalog:'
+ version: 4.4.3
+ devDependencies:
+ '@types/node':
+ specifier: '>=24 <25'
+ version: 24.12.4
+ '@typescript/native-preview':
+ specifier: 'catalog:'
+ version: 7.0.0-dev.20260514.1
+ typescript:
+ specifier: 'catalog:'
+ version: 5.9.3
+ vitest:
+ specifier: ^3.2.4
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4)
+ wrangler:
+ specifier: 'catalog:'
+ version: 4.90.1(@cloudflare/workers-types@4.20260511.1)(bufferutil@4.1.0)(utf-8-validate@6.0.6)
+
services/notifications:
dependencies:
'@kilocode/db':
@@ -19530,7 +19558,7 @@ snapshots:
'@jest/console@29.7.0':
dependencies:
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
jest-message-util: 29.7.0
jest-util: 29.7.0
@@ -19539,7 +19567,7 @@ snapshots:
'@jest/console@30.3.0':
dependencies:
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
jest-message-util: 30.3.0
jest-util: 30.3.0
@@ -19552,14 +19580,14 @@ snapshots:
'@jest/test-result': 29.7.0
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
ansi-escapes: 4.3.2
chalk: 4.1.2
ci-info: 3.9.0
exit: 0.1.2
graceful-fs: 4.2.11
jest-changed-files: 29.7.0
- jest-config: 29.7.0(@types/node@20.19.41)
+ jest-config: 29.7.0(@types/node@24.12.4)
jest-haste-map: 29.7.0
jest-message-util: 29.7.0
jest-regex-util: 29.6.3
@@ -19588,14 +19616,14 @@ snapshots:
'@jest/test-result': 30.3.0
'@jest/transform': 30.3.0
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
ansi-escapes: 4.3.2
chalk: 4.1.2
ci-info: 4.4.0
exit-x: 0.2.2
graceful-fs: 4.2.11
jest-changed-files: 30.3.0
- jest-config: 30.3.0(@types/node@20.19.41)(esbuild-register@3.6.0(esbuild@0.27.4))
+ jest-config: 30.3.0(@types/node@24.12.4)(esbuild-register@3.6.0(esbuild@0.27.4))
jest-haste-map: 30.3.0
jest-message-util: 30.3.0
jest-regex-util: 30.0.1
@@ -19629,14 +19657,14 @@ snapshots:
dependencies:
'@jest/fake-timers': 29.7.0
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-mock: 29.7.0
'@jest/environment@30.3.0':
dependencies:
'@jest/fake-timers': 30.3.0
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-mock: 30.3.0
'@jest/expect-utils@29.7.0':
@@ -19665,7 +19693,7 @@ snapshots:
dependencies:
'@jest/types': 29.6.3
'@sinonjs/fake-timers': 10.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-message-util: 29.7.0
jest-mock: 29.7.0
jest-util: 29.7.0
@@ -19674,7 +19702,7 @@ snapshots:
dependencies:
'@jest/types': 30.3.0
'@sinonjs/fake-timers': 15.1.1
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-message-util: 30.3.0
jest-mock: 30.3.0
jest-util: 30.3.0
@@ -19701,7 +19729,7 @@ snapshots:
'@jest/pattern@30.0.1':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-regex-util: 30.0.1
'@jest/reporters@29.7.0':
@@ -19712,7 +19740,7 @@ snapshots:
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
'@jridgewell/trace-mapping': 0.3.31
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
collect-v8-coverage: 1.0.3
exit: 0.1.2
@@ -19741,7 +19769,7 @@ snapshots:
'@jest/transform': 30.3.0
'@jest/types': 30.3.0
'@jridgewell/trace-mapping': 0.3.31
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
collect-v8-coverage: 1.0.3
exit-x: 0.2.2
@@ -19860,7 +19888,7 @@ snapshots:
'@jest/schemas': 29.6.3
'@types/istanbul-lib-coverage': 2.0.6
'@types/istanbul-reports': 3.0.4
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/yargs': 17.0.35
chalk: 4.1.2
@@ -19870,7 +19898,7 @@ snapshots:
'@jest/schemas': 30.0.5
'@types/istanbul-lib-coverage': 2.0.6
'@types/istanbul-reports': 3.0.4
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/yargs': 17.0.35
chalk: 4.1.2
@@ -23143,7 +23171,7 @@ snapshots:
'@slack/logger@4.0.1':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@slack/oauth@3.0.5':
dependencies:
@@ -23160,7 +23188,7 @@ snapshots:
dependencies:
'@slack/logger': 4.0.1
'@slack/web-api': 7.15.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/ws': 8.18.1
eventemitter3: 5.0.4
ws: 8.19.0(bufferutil@4.1.0)(utf-8-validate@6.0.6)
@@ -23178,7 +23206,7 @@ snapshots:
dependencies:
'@slack/logger': 4.0.1
'@slack/types': 2.20.1
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/retry': 0.12.0
axios: 1.16.1
eventemitter3: 5.0.4
@@ -24482,7 +24510,7 @@ snapshots:
'@types/connect@3.4.38':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/content-disposition@0.5.9': {}
@@ -24536,7 +24564,7 @@ snapshots:
'@types/graceful-fs@4.1.9':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/hammerjs@2.0.46': {}
@@ -24598,11 +24626,11 @@ snapshots:
'@types/mysql@2.15.27':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/node-fetch@2.6.13':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
form-data: 4.0.5
'@types/node@20.19.41':
@@ -24629,7 +24657,7 @@ snapshots:
'@types/pg@8.15.6':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
pg-protocol: 1.13.0
pg-types: 2.2.0
@@ -24649,7 +24677,7 @@ snapshots:
'@types/readdir-glob@1.1.5':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/resolve@1.20.6': {}
@@ -24665,7 +24693,7 @@ snapshots:
'@types/tedious@4.0.14':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/trusted-types@2.0.7':
optional: true
@@ -24680,11 +24708,11 @@ snapshots:
'@types/wait-on@5.3.4':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/ws@8.18.1':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@types/yargs-parser@21.0.3': {}
@@ -24694,7 +24722,7 @@ snapshots:
'@types/yauzl@2.10.3':
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
optional: true
'@typescript-eslint/project-service@8.57.0(typescript@5.9.3)':
@@ -24918,6 +24946,14 @@ snapshots:
optionalDependencies:
vite: 8.0.10(@types/node@22.19.19)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4)
+ '@vitest/mocker@3.2.4(vite@8.0.10(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4))':
+ dependencies:
+ '@vitest/spy': 3.2.4
+ estree-walker: 3.0.3
+ magic-string: 0.30.21
+ optionalDependencies:
+ vite: 8.0.10(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4)
+
'@vitest/mocker@3.2.4(vite@8.0.10(@types/node@25.5.2)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4))':
dependencies:
'@vitest/spy': 3.2.4
@@ -25774,7 +25810,7 @@ snapshots:
bun-types@1.3.14:
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
bytes@3.1.2: {}
@@ -25896,7 +25932,7 @@ snapshots:
chrome-launcher@0.15.2:
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
escape-string-regexp: 4.0.0
is-wsl: 2.2.0
lighthouse-logger: 1.4.2
@@ -25907,7 +25943,7 @@ snapshots:
chromium-edge-launcher@0.2.0:
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
escape-string-regexp: 4.0.0
is-wsl: 2.2.0
lighthouse-logger: 1.4.2
@@ -28548,7 +28584,7 @@ snapshots:
'@jest/expect': 29.7.0
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
co: 4.6.0
dedent: 1.7.2
@@ -28574,7 +28610,7 @@ snapshots:
'@jest/expect': 30.3.0
'@jest/test-result': 30.3.0
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
co: 4.6.0
dedent: 1.7.2
@@ -28651,36 +28687,6 @@ snapshots:
- supports-color
- ts-node
- jest-config@29.7.0(@types/node@20.19.41):
- dependencies:
- '@babel/core': 7.29.0
- '@jest/test-sequencer': 29.7.0
- '@jest/types': 29.6.3
- babel-jest: 29.7.0(@babel/core@7.29.0)
- chalk: 4.1.2
- ci-info: 3.9.0
- deepmerge: 4.3.1
- glob: 13.0.6
- graceful-fs: 4.2.11
- jest-circus: 29.7.0
- jest-environment-node: 29.7.0
- jest-get-type: 29.6.3
- jest-regex-util: 29.6.3
- jest-resolve: 29.7.0
- jest-runner: 29.7.0
- jest-util: 29.7.0
- jest-validate: 29.7.0
- micromatch: 4.0.8
- parse-json: 5.2.0
- pretty-format: 29.7.0
- slash: 3.0.0
- strip-json-comments: 3.1.1
- optionalDependencies:
- '@types/node': 20.19.41
- transitivePeerDependencies:
- - babel-plugin-macros
- - supports-color
-
jest-config@29.7.0(@types/node@24.12.4):
dependencies:
'@babel/core': 7.29.0
@@ -28741,38 +28747,6 @@ snapshots:
- babel-plugin-macros
- supports-color
- jest-config@30.3.0(@types/node@20.19.41)(esbuild-register@3.6.0(esbuild@0.27.4)):
- dependencies:
- '@babel/core': 7.29.0
- '@jest/get-type': 30.1.0
- '@jest/pattern': 30.0.1
- '@jest/test-sequencer': 30.3.0
- '@jest/types': 30.3.0
- babel-jest: 30.3.0(@babel/core@7.29.0)
- chalk: 4.1.2
- ci-info: 4.4.0
- deepmerge: 4.3.1
- glob: 13.0.6
- graceful-fs: 4.2.11
- jest-circus: 30.3.0
- jest-docblock: 30.2.0
- jest-environment-node: 30.3.0
- jest-regex-util: 30.0.1
- jest-resolve: 30.3.0
- jest-runner: 30.3.0
- jest-util: 30.3.0
- jest-validate: 30.3.0
- parse-json: 5.2.0
- pretty-format: 30.3.0
- slash: 3.0.0
- strip-json-comments: 3.1.1
- optionalDependencies:
- '@types/node': 20.19.41
- esbuild-register: 3.6.0(esbuild@0.27.4)
- transitivePeerDependencies:
- - babel-plugin-macros
- - supports-color
-
jest-config@30.3.0(@types/node@24.12.4)(esbuild-register@3.6.0(esbuild@0.27.4)):
dependencies:
'@babel/core': 7.29.0
@@ -28848,7 +28822,7 @@ snapshots:
'@jest/environment': 29.7.0
'@jest/fake-timers': 29.7.0
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-mock: 29.7.0
jest-util: 29.7.0
@@ -28857,7 +28831,7 @@ snapshots:
'@jest/environment': 30.3.0
'@jest/fake-timers': 30.3.0
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-mock: 30.3.0
jest-util: 30.3.0
jest-validate: 30.3.0
@@ -28868,7 +28842,7 @@ snapshots:
dependencies:
'@jest/types': 29.6.3
'@types/graceful-fs': 4.1.9
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
anymatch: 3.1.3
fb-watchman: 2.0.2
graceful-fs: 4.2.11
@@ -28883,7 +28857,7 @@ snapshots:
jest-haste-map@30.3.0:
dependencies:
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
anymatch: 3.1.3
fb-watchman: 2.0.2
graceful-fs: 4.2.11
@@ -28953,13 +28927,13 @@ snapshots:
jest-mock@29.7.0:
dependencies:
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-util: 29.7.0
jest-mock@30.3.0:
dependencies:
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-util: 30.3.0
jest-playwright-preset@4.0.0(jest-circus@29.7.0)(jest-environment-node@29.7.0)(jest-runner@29.7.0)(jest@29.7.0(@types/node@25.5.2)):
@@ -29050,7 +29024,7 @@ snapshots:
'@jest/test-result': 29.7.0
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
emittery: 0.13.1
graceful-fs: 4.2.11
@@ -29076,7 +29050,7 @@ snapshots:
'@jest/test-result': 30.3.0
'@jest/transform': 30.3.0
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
emittery: 0.13.1
exit-x: 0.2.2
@@ -29105,7 +29079,7 @@ snapshots:
'@jest/test-result': 29.7.0
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
cjs-module-lexer: 1.4.3
collect-v8-coverage: 1.0.3
@@ -29132,7 +29106,7 @@ snapshots:
'@jest/test-result': 30.3.0
'@jest/transform': 30.3.0
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
cjs-module-lexer: 2.2.0
collect-v8-coverage: 1.0.3
@@ -29208,7 +29182,7 @@ snapshots:
jest-util@29.7.0:
dependencies:
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
ci-info: 3.9.0
graceful-fs: 4.2.11
@@ -29217,7 +29191,7 @@ snapshots:
jest-util@30.3.0:
dependencies:
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
chalk: 4.1.2
ci-info: 4.4.0
graceful-fs: 4.2.11
@@ -29256,7 +29230,7 @@ snapshots:
dependencies:
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
ansi-escapes: 4.3.2
chalk: 4.1.2
emittery: 0.13.1
@@ -29267,7 +29241,7 @@ snapshots:
dependencies:
'@jest/test-result': 30.3.0
'@jest/types': 30.3.0
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
ansi-escapes: 4.3.2
chalk: 4.1.2
emittery: 0.13.1
@@ -29276,20 +29250,20 @@ snapshots:
jest-worker@27.5.1:
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
merge-stream: 2.0.0
supports-color: 8.1.1
jest-worker@29.7.0:
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
jest-util: 29.7.0
merge-stream: 2.0.0
supports-color: 8.1.1
jest-worker@30.3.0:
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
'@ungap/structured-clone': 1.3.0
jest-util: 30.3.0
merge-stream: 2.0.0
@@ -31569,7 +31543,7 @@ snapshots:
protobufjs@8.0.3:
dependencies:
- '@types/node': 20.19.41
+ '@types/node': 24.12.4
long: 5.3.2
proxy-addr@2.0.7:
@@ -33704,6 +33678,28 @@ snapshots:
- tsx
- yaml
+ vite-node@3.2.4(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4):
+ dependencies:
+ cac: 6.7.14
+ debug: 4.4.3
+ es-module-lexer: 1.7.0
+ pathe: 2.0.3
+ vite: 8.0.10(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4)
+ transitivePeerDependencies:
+ - '@types/node'
+ - '@vitejs/devtools'
+ - esbuild
+ - jiti
+ - less
+ - sass
+ - sass-embedded
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+ - tsx
+ - yaml
+
vite-node@3.2.4(@types/node@25.5.2)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4):
dependencies:
cac: 6.7.14
@@ -33817,6 +33813,49 @@ snapshots:
- tsx
- yaml
+ vitest@3.2.4(@types/debug@4.1.12)(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4):
+ dependencies:
+ '@types/chai': 5.2.3
+ '@vitest/expect': 3.2.4
+ '@vitest/mocker': 3.2.4(vite@8.0.10(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4))
+ '@vitest/pretty-format': 3.2.4
+ '@vitest/runner': 3.2.4
+ '@vitest/snapshot': 3.2.4
+ '@vitest/spy': 3.2.4
+ '@vitest/utils': 3.2.4
+ chai: 5.3.3
+ debug: 4.4.3
+ expect-type: 1.3.0
+ magic-string: 0.30.21
+ pathe: 2.0.3
+ picomatch: 4.0.4
+ std-env: 3.10.0
+ tinybench: 2.9.0
+ tinyexec: 0.3.2
+ tinyglobby: 0.2.16
+ tinypool: 1.1.1
+ tinyrainbow: 2.0.0
+ vite: 8.0.10(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4)
+ vite-node: 3.2.4(@types/node@24.12.4)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4)
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@types/debug': 4.1.12
+ '@types/node': 24.12.4
+ transitivePeerDependencies:
+ - '@vitejs/devtools'
+ - esbuild
+ - jiti
+ - less
+ - msw
+ - sass
+ - sass-embedded
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+ - tsx
+ - yaml
+
vitest@3.2.4(@types/debug@4.1.12)(@types/node@25.5.2)(esbuild@0.27.4)(jiti@2.6.1)(terser@5.46.0)(tsx@4.21.0)(yaml@2.8.4):
dependencies:
'@types/chai': 5.2.3
diff --git a/services/model-eval-ingest/.dev.vars.example b/services/model-eval-ingest/.dev.vars.example
new file mode 100644
index 0000000000..f8cc7d27be
--- /dev/null
+++ b/services/model-eval-ingest/.dev.vars.example
@@ -0,0 +1,4 @@
+# Shared secret required for local manual sync; secrets store is unavailable in wrangler dev.
+# Copy repo-root .env.local INTERNAL_API_SECRET so apps/web and this Worker agree.
+# @from INTERNAL_API_SECRET
+INTERNAL_API_SECRET=
diff --git a/services/model-eval-ingest/README.md b/services/model-eval-ingest/README.md
new file mode 100644
index 0000000000..3f04016c45
--- /dev/null
+++ b/services/model-eval-ingest/README.md
@@ -0,0 +1,116 @@
+# Model Eval Ingest Worker
+
+Cloudflare Worker that pulls promoted eval aggregates from the kilo-bench dashboard WorkerEntrypoint, stores append-only cloud audit rows, and recomputes public `model_stats.benchmarks.kiloBench` caches.
+
+## Architecture
+
+- Scheduled Worker syncs promotions from the kilo-bench dashboard Service Binding.
+- Admin-triggered syncs call `POST /internal/sync` over HTTP from `apps/web`.
+- The HTTP admin path uses the shared `INTERNAL_API_SECRET`; the Worker-to-bench hop uses only the Service Binding.
+- Promotion rows are idempotent by `bench_eval_name`.
+
+## Local Development
+
+### 1. Sync local env files
+
+From the cloud repo root, run:
+
+```bash
+pnpm dev:env
+```
+
+This repo-standard env sync reads `.env.local` plus the `.example` templates and writes:
+
+- `services/model-eval-ingest/.dev.vars`, including `INTERNAL_API_SECRET` copied from `.env.local`
+- `apps/web/.env.development.local`, including `MODEL_EVAL_INGEST_URL` generated from the local Worker port
+
+The manual sync secret must match on both sides because `apps/web` calls the Worker's HTTP `/internal/sync` route. The Worker-to-bench hop remains a Service Binding and does not use this secret.
+
+If `pnpm dev:env` is unavailable for some reason, the equivalent manual setup is:
+
+```bash
+cd services/model-eval-ingest
+cp .dev.vars.example .dev.vars
+```
+
+```env
+# services/model-eval-ingest/.dev.vars
+INTERNAL_API_SECRET=
+```
+
+```env
+# apps/web/.env.development.local
+MODEL_EVAL_INGEST_URL=http://localhost:8798
+```
+
+Relevant templates are kept in:
+
+- `.env.local.example`
+- `apps/web/.env.development.local.example`
+- `services/model-eval-ingest/.dev.vars.example`
+
+### 2. Start kilo-bench dashboard locally
+
+The Service Binding target must be running from the sibling `../kilo-bench` checkout with its `dev` Wrangler environment name.
+
+```bash
+cd ../kilo-bench/dashboard
+pnpm build
+pnpm db:migrate:local
+pnpm dev
+```
+
+The dashboard Worker serves `http://localhost:8811` and exposes the `Dashboard` WorkerEntrypoint used by this service.
+
+### 3. Start model-eval-ingest locally
+
+```bash
+cd services/model-eval-ingest
+pnpm dev
+```
+
+Wrangler serves the Worker at `http://localhost:8798` by default.
+
+### 4. Restart Next.js after env changes
+
+If `pnpm dev:env` updated `apps/web/.env.development.local` after Next.js was already running, restart it so the admin sync client sees `MODEL_EVAL_INGEST_URL`:
+
+```bash
+pnpm dev:restart nextjs
+```
+
+## Manual Verification
+
+### Health check
+
+```bash
+curl http://localhost:8798/health
+```
+
+### Trigger a direct sync
+
+```bash
+curl -X POST http://localhost:8798/internal/sync \
+ -H "content-type: application/json" \
+ -H "x-internal-api-key: $INTERNAL_API_SECRET" \
+ -d '{}'
+```
+
+### Admin UI
+
+Open:
+
+```text
+http://localhost:3000/admin/model-eval-ingest
+```
+
+Use `Sync now` for a full pull or `Repull` for a single named promotion already visible in the ingest history.
+
+## Deployment Configuration
+
+Production/dev deployments need:
+
+- Worker Secrets Store binding for `INTERNAL_API_SECRET`.
+- Web/Vercel `INTERNAL_API_SECRET` with the same value.
+- Web/Vercel `MODEL_EVAL_INGEST_URL` pointing at the deployed Worker URL.
+- Cloudflare Service Binding `BENCH_DASHBOARD` targeting the kilo-bench dashboard WorkerEntrypoint.
diff --git a/services/model-eval-ingest/package.json b/services/model-eval-ingest/package.json
new file mode 100644
index 0000000000..557fcec3c3
--- /dev/null
+++ b/services/model-eval-ingest/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "cloudflare-model-eval-ingest",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "deploy:prod": "wrangler deploy",
+ "deploy:dev": "wrangler deploy --env dev",
+ "dev": "wrangler dev --env dev",
+ "typecheck": "tsgo --noEmit",
+ "lint": "pnpm -w exec oxlint --config .oxlintrc.json services/model-eval-ingest/src",
+ "types": "wrangler types --env-interface CloudflareEnv worker-configuration.d.ts",
+ "test": "vitest run"
+ },
+ "dependencies": {
+ "@kilocode/db": "workspace:*",
+ "drizzle-orm": "catalog:",
+ "zod": "catalog:"
+ },
+ "devDependencies": {
+ "@types/node": ">=24 <25",
+ "@typescript/native-preview": "catalog:",
+ "typescript": "catalog:",
+ "vitest": "^3.2.4",
+ "wrangler": "catalog:"
+ }
+}
diff --git a/services/model-eval-ingest/src/index.ts b/services/model-eval-ingest/src/index.ts
new file mode 100644
index 0000000000..38ffe2c0f5
--- /dev/null
+++ b/services/model-eval-ingest/src/index.ts
@@ -0,0 +1,100 @@
+import { timingSafeEqual as nodeTimingSafeEqual } from 'crypto';
+import { getWorkerDb } from '@kilocode/db/client';
+import * as z from 'zod';
+import { createPromotionStore, syncPromotionsFromBench } from './sync.js';
+
+const SyncRequestSchema = z.object({ promotionName: z.string().min(1).optional() }).optional();
+
+async function sendBetterStackHeartbeat(
+ heartbeatUrl: string | undefined,
+ failed: boolean
+): Promise {
+ if (!heartbeatUrl) return;
+ const url = failed ? `${heartbeatUrl}/fail` : heartbeatUrl;
+ try {
+ await fetch(url, { signal: AbortSignal.timeout(5000) });
+ } catch {
+ // best-effort heartbeat
+ }
+}
+
+async function timingSafeEqual(left: string, right: string): Promise {
+ const encoder = new TextEncoder();
+ const [leftDigest, rightDigest] = await Promise.all([
+ crypto.subtle.digest('SHA-256', encoder.encode(left)),
+ crypto.subtle.digest('SHA-256', encoder.encode(right)),
+ ]);
+ return nodeTimingSafeEqual(new Uint8Array(leftDigest), new Uint8Array(rightDigest));
+}
+
+async function runSync(env: CloudflareEnv, promotionName?: string) {
+ const db = getWorkerDb(env.HYPERDRIVE.connectionString, { statement_timeout: 30_000 });
+ return syncPromotionsFromBench(env.BENCH_DASHBOARD, createPromotionStore(db), { promotionName });
+}
+
+async function getInternalApiSecret(secret: SecretBinding | string): Promise {
+ return typeof secret === 'string' ? secret : secret.get();
+}
+
+async function handleFetch(request: Request, env: CloudflareEnv): Promise {
+ const url = new URL(request.url);
+
+ if (request.method === 'GET' && url.pathname === '/health') {
+ return Response.json({
+ status: 'ok',
+ service: 'model-eval-ingest',
+ timestamp: new Date().toISOString(),
+ });
+ }
+
+ if (request.method !== 'POST' || url.pathname !== '/internal/sync') {
+ return Response.json({ error: 'Not found' }, { status: 404 });
+ }
+
+ const internalSecret = await getInternalApiSecret(env.INTERNAL_API_SECRET);
+ const authHeader = request.headers.get('x-internal-api-key');
+ if (!authHeader || !internalSecret || !(await timingSafeEqual(authHeader, internalSecret))) {
+ return Response.json({ error: 'Unauthorized' }, { status: 401 });
+ }
+
+ const rawBody = await request.text();
+ let requestBody: unknown;
+ try {
+ requestBody = rawBody ? JSON.parse(rawBody) : undefined;
+ } catch {
+ return Response.json({ error: 'Invalid sync request body' }, { status: 400 });
+ }
+
+ const parsedBody = SyncRequestSchema.safeParse(requestBody);
+ if (!parsedBody.success) {
+ return Response.json(
+ { error: 'Invalid sync request', issues: parsedBody.error.issues },
+ { status: 400 }
+ );
+ }
+
+ const result = await runSync(env, parsedBody.data?.promotionName);
+ return Response.json({ success: true, ...result });
+}
+
+export default {
+ async fetch(request: Request, env: CloudflareEnv): Promise {
+ return handleFetch(request, env);
+ },
+
+ async scheduled(
+ _controller: ScheduledController,
+ env: CloudflareEnv,
+ ctx: ExecutionContext
+ ): Promise {
+ let failed = false;
+ try {
+ await runSync(env);
+ } catch (error) {
+ failed = true;
+ throw error;
+ } finally {
+ ctx.waitUntil(sendBetterStackHeartbeat(env.BETTERSTACK_HEARTBEAT_URL, failed));
+ }
+ },
+};
diff --git a/services/model-eval-ingest/src/sync.test.ts b/services/model-eval-ingest/src/sync.test.ts
new file mode 100644
index 0000000000..2243116f3f
--- /dev/null
+++ b/services/model-eval-ingest/src/sync.test.ts
@@ -0,0 +1,236 @@
+import { describe, expect, it } from 'vitest';
+import {
+ roundAverage,
+ syncPromotionsFromBench,
+ usdToMicrodollars,
+ type PromotionStore,
+} from './sync.js';
+import type {
+ KiloBenchBenchmarks,
+ LatestPromotion,
+ ModelStatsTarget,
+ PromotionRecord,
+ PromotionTuple,
+} from './types.js';
+
+class MemoryPromotionStore implements PromotionStore {
+ readonly rows = new Map();
+ readonly cache = new Map();
+ readonly modelStats = new Map();
+
+ constructor(models: ModelStatsTarget[]) {
+ for (const model of models) this.modelStats.set(model.model, model);
+ }
+
+ async getLatestPromotedAtMs(): Promise {
+ let latest = 0;
+ for (const row of this.rows.values()) latest = Math.max(latest, row.promotion.promoted_at);
+ return latest;
+ }
+
+ async findModelStatsTargets(models: string[]): Promise> {
+ return new Map(
+ models.flatMap(model => {
+ const target = this.modelStats.get(model);
+ return target ? [[model, target]] : [];
+ })
+ );
+ }
+
+ async insertPromotions(
+ promotions: Array<{ promotion: PromotionRecord; modelStatsId: string | null }>
+ ): Promise> {
+ const inserted = new Set();
+ for (const { promotion, modelStatsId } of promotions) {
+ if (this.rows.has(promotion.bench_eval_name)) continue;
+ this.rows.set(promotion.bench_eval_name, { promotion, modelStatsId });
+ inserted.add(promotion.bench_eval_name);
+ }
+ return inserted;
+ }
+
+ async listLatestPromotions(
+ tuple: Omit
+ ): Promise {
+ const rows = [...this.rows.values()]
+ .map(row => row.promotion)
+ .filter(
+ promotion =>
+ promotion.provider === tuple.provider &&
+ promotion.model === tuple.model &&
+ promotion.variant === tuple.variant
+ )
+ .sort((left, right) => right.promoted_at - left.promoted_at);
+
+ const latestByTask = new Map();
+ for (const promotion of rows) {
+ if (latestByTask.has(promotion.task_source)) continue;
+ latestByTask.set(promotion.task_source, {
+ taskSource: promotion.task_source,
+ totalScore: promotion.total_score,
+ overallScore: promotion.overall_score,
+ avgCostMicrodollars: usdToMicrodollars(promotion.avg_cost_usd),
+ avgInputTokens: roundAverage(promotion.avg_input_tokens),
+ avgOutputTokens: roundAverage(promotion.avg_output_tokens),
+ avgCacheReadTokens: roundAverage(promotion.avg_cache_read_tokens),
+ avgExecutionMs: roundAverage(promotion.avg_execution_ms),
+ nTotalTrials: promotion.n_total_trials,
+ nErrored: promotion.n_errored,
+ promotedAt: new Date(promotion.promoted_at).toISOString(),
+ });
+ }
+
+ return [...latestByTask.values()];
+ }
+
+ async writeKiloBenchBenchmarks(
+ modelStatsId: string,
+ benchmarks: KiloBenchBenchmarks
+ ): Promise {
+ this.cache.set(modelStatsId, benchmarks);
+ }
+}
+
+class MemoryBenchDashboard {
+ constructor(private readonly promotions: PromotionRecord[]) {}
+
+ async listPromotions(opts?: { sinceMs?: number; limit?: number }): Promise {
+ const sinceMs = opts?.sinceMs ?? 0;
+ const limit = opts?.limit ?? this.promotions.length;
+ return this.promotions
+ .filter(promotion => promotion.promoted_at >= sinceMs)
+ .sort((left, right) => left.promoted_at - right.promoted_at)
+ .slice(0, limit);
+ }
+
+ async getPromotion(name: string): Promise {
+ return this.promotions.find(promotion => promotion.bench_eval_name === name) ?? null;
+ }
+}
+
+describe('syncPromotionsFromBench', () => {
+ it('ingests an empty cloud store and preserves fractional promotion scores', async () => {
+ const store = createStore();
+ const bench = new MemoryBenchDashboard([
+ promotion({
+ bench_eval_name: 'fractional-terminal',
+ task_source: 'terminal-bench',
+ total_score: 1.5,
+ overall_score: 0.375,
+ n_total_trials: 4,
+ }),
+ promotion({
+ bench_eval_name: 'swebench-latest',
+ task_source: 'swebench-verified',
+ total_score: 3,
+ overall_score: 0.75,
+ n_total_trials: 4,
+ promoted_at: Date.parse('2026-05-14T11:00:00.000Z'),
+ }),
+ ]);
+
+ const result = await syncPromotionsFromBench(bench, store);
+
+ expect(result).toEqual({ inserted: 2, alreadyHad: 0, cacheRecomputes: 1, fetched: 2 });
+ expect(store.rows.size).toBe(2);
+ const cache = store.cache.get('model-stats-1');
+ expect(cache?.evals['terminal-bench']).toMatchObject({
+ totalScore: 1.5,
+ overallScore: 0.375,
+ avgCostUsd: 0.25,
+ avgInputTokens: 101,
+ avgOutputTokens: 50,
+ avgCacheReadTokens: 10,
+ avgExecutionMs: 251,
+ nTotalTrials: 4,
+ });
+ expect(cache?.overallScore).toBe(0.5625);
+ });
+
+ it('does not duplicate rows on an idempotent rerun', async () => {
+ const store = createStore();
+ const bench = new MemoryBenchDashboard([promotion({ bench_eval_name: 'idempotent-row' })]);
+
+ await syncPromotionsFromBench(bench, store);
+ const rerun = await syncPromotionsFromBench(bench, store);
+
+ expect(store.rows.size).toBe(1);
+ expect(rerun.inserted).toBe(0);
+ expect(rerun.alreadyHad).toBe(1);
+ expect(rerun.cacheRecomputes).toBe(0);
+ });
+
+ it('recomputes cache on an explicit admin re-pull of an existing promotion', async () => {
+ const store = createStore();
+ const bench = new MemoryBenchDashboard([promotion({ bench_eval_name: 'repull-row' })]);
+
+ await syncPromotionsFromBench(bench, store);
+ const repull = await syncPromotionsFromBench(bench, store, {
+ promotionName: 'repull-row',
+ });
+
+ expect(repull.inserted).toBe(0);
+ expect(repull.alreadyHad).toBe(1);
+ expect(repull.cacheRecomputes).toBe(1);
+ });
+
+ it('uses the latest promoted task row and excludes audit-only promotion details from cache', async () => {
+ const store = createStore();
+ const bench = new MemoryBenchDashboard([
+ promotion({
+ bench_eval_name: 'old-terminal',
+ task_source: 'terminal-bench',
+ total_score: 1,
+ overall_score: 0.25,
+ promoted_at: Date.parse('2026-05-14T09:00:00.000Z'),
+ }),
+ promotion({
+ bench_eval_name: 'new-terminal',
+ task_source: 'terminal-bench',
+ total_score: 1.5,
+ overall_score: 0.375,
+ promoted_at: Date.parse('2026-05-14T10:00:00.000Z'),
+ }),
+ ]);
+
+ await syncPromotionsFromBench(bench, store);
+
+ const cache = store.cache.get('model-stats-1');
+ expect(cache?.evals['terminal-bench']).toMatchObject({
+ totalScore: 1.5,
+ overallScore: 0.375,
+ lastPromotedAt: '2026-05-14T10:00:00.000Z',
+ });
+ expect(JSON.stringify(cache)).not.toContain('bench.example.com');
+ expect(JSON.stringify(cache)).not.toContain('promoter@example.com');
+ expect(JSON.stringify(cache)).not.toContain('new-terminal');
+ });
+});
+
+function createStore(): MemoryPromotionStore {
+ return new MemoryPromotionStore([{ id: 'model-stats-1', model: 'kilo/openai/gpt-5.5' }]);
+}
+
+function promotion(overrides: Partial): PromotionRecord {
+ return {
+ bench_eval_name: 'bench-promotion',
+ bench_eval_url: 'https://bench.example.com/jobs/bench-promotion',
+ provider: 'kilo',
+ model: 'kilo/openai/gpt-5.5',
+ variant: null,
+ task_source: 'terminal-bench',
+ n_total_trials: 4,
+ total_score: 2,
+ overall_score: 0.5,
+ n_errored: 0,
+ avg_cost_usd: 0.25,
+ avg_input_tokens: 100.5,
+ avg_output_tokens: 50.25,
+ avg_cache_read_tokens: 10.125,
+ avg_execution_ms: 250.75,
+ promoted_at: Date.parse('2026-05-14T10:00:00.000Z'),
+ promoted_by_email: 'promoter@example.com',
+ promotion_note: null,
+ ...overrides,
+ };
+}
diff --git a/services/model-eval-ingest/src/sync.ts b/services/model-eval-ingest/src/sync.ts
new file mode 100644
index 0000000000..0e87ce04b9
--- /dev/null
+++ b/services/model-eval-ingest/src/sync.ts
@@ -0,0 +1,282 @@
+import type { WorkerDb } from '@kilocode/db/client';
+import { model_eval_ingestions, modelStats } from '@kilocode/db/schema';
+import { and, desc, eq, inArray, isNull, sql } from 'drizzle-orm';
+import {
+ PromotionRecordSchema,
+ type KiloBenchBenchmarks,
+ type LatestPromotion,
+ type ModelStatsTarget,
+ type PromotionRecord,
+ type PromotionTuple,
+ type SyncResult,
+} from './types.js';
+
+const PROMOTION_PULL_LIMIT = 1000;
+const MICRODOLLARS_PER_DOLLAR = 1_000_000;
+
+export function usdToMicrodollars(value: number | null): number | null {
+ return value === null ? null : Math.round(value * MICRODOLLARS_PER_DOLLAR);
+}
+
+export function roundAverage(value: number | null): number | null {
+ return value === null ? null : Math.round(value);
+}
+
+function microdollarsToUsd(value: number | null): number | null {
+ return value === null ? null : value / MICRODOLLARS_PER_DOLLAR;
+}
+
+type BenchDashboard = {
+ listPromotions(opts?: { sinceMs?: number; limit?: number }): Promise;
+ getPromotion(name: string): Promise;
+};
+
+type PromotionInsert = {
+ promotion: PromotionRecord;
+ modelStatsId: string | null;
+};
+
+export type PromotionStore = {
+ getLatestPromotedAtMs(): Promise;
+ findModelStatsTargets(models: string[]): Promise>;
+ insertPromotions(promotions: PromotionInsert[]): Promise>;
+ listLatestPromotions(tuple: Omit): Promise;
+ writeKiloBenchBenchmarks(modelStatsId: string, benchmarks: KiloBenchBenchmarks): Promise;
+};
+
+export function createPromotionStore(db: WorkerDb): PromotionStore {
+ return {
+ async getLatestPromotedAtMs(): Promise {
+ const [latest] = await db
+ .select({ promotedAt: model_eval_ingestions.promoted_at })
+ .from(model_eval_ingestions)
+ .orderBy(desc(model_eval_ingestions.promoted_at))
+ .limit(1);
+
+ return latest ? Date.parse(latest.promotedAt) : 0;
+ },
+
+ async findModelStatsTargets(models: string[]): Promise> {
+ if (models.length === 0) return new Map();
+
+ const targets = await db
+ .select({ id: modelStats.id, model: modelStats.openrouterId })
+ .from(modelStats)
+ .where(inArray(modelStats.openrouterId, models));
+
+ return new Map(targets.map(target => [target.model, target]));
+ },
+
+ async insertPromotions(promotions: PromotionInsert[]): Promise> {
+ if (promotions.length === 0) return new Set();
+
+ const inserted = await db
+ .insert(model_eval_ingestions)
+ .values(
+ promotions.map(({ promotion, modelStatsId }) => ({
+ bench_eval_name: promotion.bench_eval_name,
+ bench_eval_url: promotion.bench_eval_url,
+ provider: promotion.provider,
+ model: promotion.model,
+ model_stats_id: modelStatsId,
+ variant: promotion.variant,
+ task_source: promotion.task_source,
+ n_total_trials: promotion.n_total_trials,
+ total_score: promotion.total_score,
+ overall_score: promotion.overall_score,
+ n_errored: promotion.n_errored,
+ avg_cost_microdollars: usdToMicrodollars(promotion.avg_cost_usd),
+ avg_input_tokens: roundAverage(promotion.avg_input_tokens),
+ avg_output_tokens: roundAverage(promotion.avg_output_tokens),
+ avg_cache_read_tokens: roundAverage(promotion.avg_cache_read_tokens),
+ avg_execution_ms: roundAverage(promotion.avg_execution_ms),
+ promoted_at: new Date(promotion.promoted_at).toISOString(),
+ promoted_by_email: promotion.promoted_by_email,
+ promotion_note: promotion.promotion_note,
+ }))
+ )
+ .onConflictDoNothing({ target: model_eval_ingestions.bench_eval_name })
+ .returning({ benchEvalName: model_eval_ingestions.bench_eval_name });
+
+ return new Set(inserted.map(row => row.benchEvalName));
+ },
+
+ async listLatestPromotions(
+ tuple: Omit
+ ): Promise {
+ const variantCondition =
+ tuple.variant === null
+ ? isNull(model_eval_ingestions.variant)
+ : eq(model_eval_ingestions.variant, tuple.variant);
+ const rows = await db
+ .select({
+ taskSource: model_eval_ingestions.task_source,
+ totalScore: model_eval_ingestions.total_score,
+ overallScore: model_eval_ingestions.overall_score,
+ avgCostMicrodollars: model_eval_ingestions.avg_cost_microdollars,
+ avgInputTokens: model_eval_ingestions.avg_input_tokens,
+ avgOutputTokens: model_eval_ingestions.avg_output_tokens,
+ avgCacheReadTokens: model_eval_ingestions.avg_cache_read_tokens,
+ avgExecutionMs: model_eval_ingestions.avg_execution_ms,
+ nTotalTrials: model_eval_ingestions.n_total_trials,
+ nErrored: model_eval_ingestions.n_errored,
+ promotedAt: model_eval_ingestions.promoted_at,
+ })
+ .from(model_eval_ingestions)
+ .where(
+ and(
+ eq(model_eval_ingestions.provider, tuple.provider),
+ eq(model_eval_ingestions.model, tuple.model),
+ variantCondition
+ )
+ )
+ .orderBy(
+ desc(model_eval_ingestions.promoted_at),
+ desc(model_eval_ingestions.bench_eval_name)
+ );
+
+ const latestByTaskSource = new Map();
+ for (const row of rows) {
+ if (!latestByTaskSource.has(row.taskSource)) {
+ latestByTaskSource.set(row.taskSource, row);
+ }
+ }
+
+ return [...latestByTaskSource.values()];
+ },
+
+ async writeKiloBenchBenchmarks(
+ modelStatsId: string,
+ benchmarks: KiloBenchBenchmarks
+ ): Promise {
+ await db
+ .update(modelStats)
+ .set({
+ benchmarks: sql`
+ COALESCE(${modelStats.benchmarks}, '{}'::jsonb) ||
+ ${JSON.stringify({ kiloBench: benchmarks })}::jsonb
+ `,
+ })
+ .where(eq(modelStats.id, modelStatsId));
+ },
+ };
+}
+
+export function buildKiloBenchBenchmarks(rows: LatestPromotion[]): KiloBenchBenchmarks {
+ let totalScore = 0;
+ let nTotalTrials = 0;
+ const evals: KiloBenchBenchmarks['evals'] = {};
+
+ for (const row of rows) {
+ totalScore += row.totalScore;
+ nTotalTrials += row.nTotalTrials;
+ evals[row.taskSource] = {
+ taskSource: row.taskSource,
+ overallScore: row.overallScore,
+ totalScore: row.totalScore,
+ avgCostUsd: microdollarsToUsd(row.avgCostMicrodollars),
+ avgInputTokens: row.avgInputTokens,
+ avgOutputTokens: row.avgOutputTokens,
+ avgCacheReadTokens: row.avgCacheReadTokens,
+ avgExecutionMs: row.avgExecutionMs,
+ nTotalTrials: row.nTotalTrials,
+ nErrored: row.nErrored,
+ lastPromotedAt: new Date(row.promotedAt).toISOString(),
+ };
+ }
+
+ return {
+ overallScore: nTotalTrials > 0 ? totalScore / nTotalTrials : 0,
+ evals,
+ };
+}
+
+export async function recomputeModelStatsKiloBench(
+ store: PromotionStore,
+ tuple: PromotionTuple
+): Promise {
+ const rows = await store.listLatestPromotions({
+ provider: tuple.provider,
+ model: tuple.model,
+ variant: tuple.variant,
+ });
+ await store.writeKiloBenchBenchmarks(tuple.modelStatsId, buildKiloBenchBenchmarks(rows));
+}
+
+export async function syncPromotionsFromBench(
+ benchDashboard: BenchDashboard,
+ store: PromotionStore,
+ opts: { promotionName?: string } = {}
+): Promise {
+ const rawPromotions = opts.promotionName
+ ? await getNamedPromotion(benchDashboard, opts.promotionName)
+ : await listNewPromotions(benchDashboard, store);
+ const promotions = rawPromotions.map(promotion => PromotionRecordSchema.parse(promotion));
+
+ let inserted = 0;
+ let alreadyHad = 0;
+ const tuplesToRecompute = new Map();
+ const modelStatsTargets = await store.findModelStatsTargets([
+ ...new Set(promotions.map(promotion => promotion.model)),
+ ]);
+ const promotionsToInsert = promotions.map(promotion => {
+ const modelStatsTarget = modelStatsTargets.get(promotion.model);
+ return {
+ promotion,
+ modelStatsId: modelStatsTarget?.id ?? null,
+ } satisfies PromotionInsert;
+ });
+ const insertedPromotionNames = await store.insertPromotions(promotionsToInsert);
+
+ for (const promotion of promotions) {
+ const modelStatsTarget = modelStatsTargets.get(promotion.model);
+ const wasInserted = insertedPromotionNames.has(promotion.bench_eval_name);
+ if (wasInserted) {
+ inserted++;
+ } else {
+ alreadyHad++;
+ }
+
+ // Named admin re-pulls refresh the model cache even when the audit row is already present.
+ if (modelStatsTarget && (wasInserted || opts.promotionName != null)) {
+ const tuple = {
+ provider: promotion.provider,
+ model: promotion.model,
+ variant: promotion.variant,
+ modelStatsId: modelStatsTarget.id,
+ } satisfies PromotionTuple;
+ tuplesToRecompute.set(tupleKey(tuple), tuple);
+ }
+ }
+
+ for (const tuple of tuplesToRecompute.values()) {
+ await recomputeModelStatsKiloBench(store, tuple);
+ }
+
+ return {
+ inserted,
+ alreadyHad,
+ cacheRecomputes: tuplesToRecompute.size,
+ fetched: promotions.length,
+ };
+}
+
+async function listNewPromotions(
+ benchDashboard: BenchDashboard,
+ store: PromotionStore
+): Promise {
+ const sinceMs = await store.getLatestPromotedAtMs();
+ return benchDashboard.listPromotions({ sinceMs, limit: PROMOTION_PULL_LIMIT });
+}
+
+async function getNamedPromotion(
+ benchDashboard: BenchDashboard,
+ promotionName: string
+): Promise {
+ const promotion = await benchDashboard.getPromotion(promotionName);
+ return promotion ? [promotion] : [];
+}
+
+function tupleKey(tuple: PromotionTuple): string {
+ return `${tuple.provider}\u0000${tuple.model}\u0000${tuple.variant ?? ''}\u0000${tuple.modelStatsId}`;
+}
diff --git a/services/model-eval-ingest/src/types.ts b/services/model-eval-ingest/src/types.ts
new file mode 100644
index 0000000000..297c77a4fb
--- /dev/null
+++ b/services/model-eval-ingest/src/types.ts
@@ -0,0 +1,76 @@
+import * as z from 'zod';
+
+export const PromotionRecordSchema = z.object({
+ bench_eval_name: z.string().min(1),
+ bench_eval_url: z.string().url(),
+ provider: z.string().min(1),
+ model: z.string().min(1),
+ variant: z.string().nullable(),
+ task_source: z.string().min(1),
+ n_total_trials: z.number().int().nonnegative(),
+ total_score: z.number().finite(),
+ overall_score: z.number().finite(),
+ n_errored: z.number().int().nonnegative(),
+ avg_cost_usd: z.number().finite().nullable(),
+ avg_input_tokens: z.number().finite().nullable(),
+ avg_output_tokens: z.number().finite().nullable(),
+ avg_cache_read_tokens: z.number().finite().nullable(),
+ avg_execution_ms: z.number().finite().nullable(),
+ promoted_at: z.number().int().nonnegative(),
+ promoted_by_email: z.string().min(1),
+ promotion_note: z.string().nullable(),
+});
+
+export type PromotionRecord = z.infer;
+
+export type KiloBenchEval = {
+ taskSource: string;
+ overallScore: number;
+ totalScore: number;
+ avgCostUsd: number | null;
+ avgInputTokens: number | null;
+ avgOutputTokens: number | null;
+ avgCacheReadTokens: number | null;
+ avgExecutionMs: number | null;
+ nTotalTrials: number;
+ nErrored: number;
+ lastPromotedAt: string;
+};
+
+export type KiloBenchBenchmarks = {
+ overallScore: number;
+ evals: Record;
+};
+
+export type LatestPromotion = {
+ taskSource: string;
+ totalScore: number;
+ overallScore: number;
+ avgCostMicrodollars: number | null;
+ avgInputTokens: number | null;
+ avgOutputTokens: number | null;
+ avgCacheReadTokens: number | null;
+ avgExecutionMs: number | null;
+ nTotalTrials: number;
+ nErrored: number;
+ promotedAt: string;
+};
+
+export type ModelStatsTarget = {
+ id: string;
+ model: string;
+};
+
+export type PromotionTuple = {
+ provider: string;
+ model: string;
+ variant: string | null;
+ modelStatsId: string;
+};
+
+export type SyncResult = {
+ inserted: number;
+ alreadyHad: number;
+ cacheRecomputes: number;
+ fetched: number;
+};
diff --git a/services/model-eval-ingest/tsconfig.json b/services/model-eval-ingest/tsconfig.json
new file mode 100644
index 0000000000..fc9830188e
--- /dev/null
+++ b/services/model-eval-ingest/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "target": "esnext",
+ "lib": ["esnext"],
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "types": ["@types/node", "./worker-configuration.d.ts"],
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "skipLibCheck": true,
+ "noEmit": true
+ },
+ "include": ["src/**/*.ts", "vitest.config.ts", "worker-configuration.d.ts"]
+}
diff --git a/services/model-eval-ingest/vitest.config.ts b/services/model-eval-ingest/vitest.config.ts
new file mode 100644
index 0000000000..7dd13254e7
--- /dev/null
+++ b/services/model-eval-ingest/vitest.config.ts
@@ -0,0 +1,9 @@
+import { defineConfig } from 'vitest/config';
+
+export default defineConfig({
+ test: {
+ globals: true,
+ environment: 'node',
+ include: ['src/**/*.test.ts'],
+ },
+});
diff --git a/services/model-eval-ingest/worker-configuration.d.ts b/services/model-eval-ingest/worker-configuration.d.ts
new file mode 100644
index 0000000000..9759a80fb3
--- /dev/null
+++ b/services/model-eval-ingest/worker-configuration.d.ts
@@ -0,0 +1,32 @@
+declare type Hyperdrive = {
+ connectionString: string;
+};
+
+declare type SecretBinding = {
+ get(): Promise;
+};
+
+declare type ScheduledController = {
+ scheduledTime: number;
+ cron: string;
+ noRetry(): void;
+};
+
+declare type ExecutionContext = {
+ waitUntil(promise: Promise): void;
+ passThroughOnException(): void;
+};
+
+declare type PromotionRecord = import('./src/types').PromotionRecord;
+
+declare type BenchDashboardService = {
+ listPromotions(opts?: { sinceMs?: number; limit?: number }): Promise;
+ getPromotion(name: string): Promise;
+};
+
+declare type CloudflareEnv = {
+ HYPERDRIVE: Hyperdrive;
+ BENCH_DASHBOARD: BenchDashboardService;
+ INTERNAL_API_SECRET: SecretBinding | string;
+ BETTERSTACK_HEARTBEAT_URL: string | undefined;
+};
diff --git a/services/model-eval-ingest/wrangler.jsonc b/services/model-eval-ingest/wrangler.jsonc
new file mode 100644
index 0000000000..a77b045b35
--- /dev/null
+++ b/services/model-eval-ingest/wrangler.jsonc
@@ -0,0 +1,68 @@
+{
+ "$schema": "node_modules/wrangler/config-schema.json",
+ "name": "model-eval-ingest",
+ "account_id": "e115e769bcdd4c3d66af59d3332cb394",
+ "main": "src/index.ts",
+ "compatibility_date": "2026-02-26",
+ "compatibility_flags": ["nodejs_compat"],
+ "workers_dev": true,
+ "dev": {
+ "port": 8798,
+ "local_protocol": "http",
+ "ip": "0.0.0.0",
+ },
+ "observability": {
+ "enabled": true,
+ },
+ "triggers": {
+ "crons": ["*/15 * * * *"],
+ },
+ "hyperdrive": [
+ {
+ "binding": "HYPERDRIVE",
+ "id": "624ec80650dd414199349f4e217ddb10",
+ "localConnectionString": "postgres://postgres:postgres@localhost:5432/postgres",
+ },
+ ],
+ "services": [
+ {
+ "binding": "BENCH_DASHBOARD",
+ "service": "kilo-bench-dashboard",
+ "entrypoint": "Dashboard",
+ },
+ ],
+ "secrets_store_secrets": [
+ {
+ "binding": "INTERNAL_API_SECRET",
+ "store_id": "342a86d9e3a94da698e82d0c6e2a36f0",
+ "secret_name": "INTERNAL_API_SECRET_PROD",
+ },
+ ],
+ "env": {
+ "dev": {
+ "name": "model-eval-ingest-dev",
+ "workers_dev": true,
+ "hyperdrive": [
+ {
+ "binding": "HYPERDRIVE",
+ "id": "624ec80650dd414199349f4e217ddb10",
+ "localConnectionString": "postgres://postgres:postgres@localhost:5432/postgres",
+ },
+ ],
+ "services": [
+ {
+ "binding": "BENCH_DASHBOARD",
+ "service": "kilo-bench-dashboard-dev",
+ "entrypoint": "Dashboard",
+ },
+ ],
+ "secrets_store_secrets": [
+ {
+ "binding": "INTERNAL_API_SECRET",
+ "store_id": "342a86d9e3a94da698e82d0c6e2a36f0",
+ "secret_name": "INTERNAL_API_SECRET_DEV",
+ },
+ ],
+ },
+ },
+}