From 81bf2041be96b400a07afce68e138a7768faef80 Mon Sep 17 00:00:00 2001 From: Cato <41178744+catomean@users.noreply.github.com> Date: Sat, 5 Sep 2026 10:04:53 -0700 Subject: [PATCH] chore(billing): remove the Stripe rail, which was never configured anywhere (#508) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit STRIPE_SECRET_KEY and the seven other STRIPE_* vars appear zero times outside src/ and zero times in .env.example, so isStripeReady() could only ever return false. Three API routes, a checkout route, a tier grid and a "Manage subscription" button were all gated on it and permanently unreachable. Confirmed empty in production before touching the schema: select count(*) filter (where stripe_customer_id is not null), count(*) filter (where stripe_subscription_id is not null), count(*) from users; → 0 | 0 | 7 So this removes no data and, more to the point, changes nothing a user sees: every code path already fell through to the branch below it. WHAT STAYS. Plans are real and untouched. They are granted through the OrangeCat/Bitcoin rail (/api/orangecat/entitlement -> recordOcBillingGrant), with the expiry cron reverting a lapsed pass to free. The pricing CTA cascade loses only its unreachable middle step: free -> TBA -> [stripe] -> BTC -> start-free. WHAT WAS ACTIVELY WRONG. Because isStripeReady() was false, the one part of Billing that DID render was a notice telling the reader to "add STRIPE_SECRET_KEY and price IDs" — an environment variable shown to a person who does not deploy the app and could not act on it. That is the same mistake NotificationsPill's comment already calls out. Billing now states the plan and links to /pricing. Removed: lib/stripe.ts, api/stripe/{checkout,portal,webhook}, api/checkout/ [plan], getUserByStripeCustomerId, two user columns (migration 0063), two entries from the user-client-view redaction lists, the api/stripe/webhook entry in proxy.ts's public matcher, the stripe npm dependency, and the smoke/auth probes for routes that no longer exist. BillingSettings drops "use client" — with the handlers gone it holds no state, no effect and no search-param read. Two mentions deliberately KEPT because they are not the rail: the placeholder prose describing what a user might build ("Simple dashboard, automated reminders, Stripe payments…") and the demo project's stack string. pnpm run verify green. 28 files, 519 deletions. Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P Co-authored-by: Claude Opus 5 --- drizzle/0063_rainy_mattie_franklin.sql | 4 + drizzle/meta/0063_snapshot.json | 8838 +++++++++++++++++++ drizzle/meta/_journal.json | 7 + package.json | 1 - pnpm-lock.yaml | 16 - scripts/smoke.sh | 4 - scripts/test/account-export.ts | 5 +- scripts/test/api-route-auth.ts | 2 - scripts/test/authenticated-smoke.ts | 19 - scripts/test/no-raw-user-response.ts | 1 - scripts/test/solon-message.ts | 2 +- scripts/test/user-client-view.ts | 2 - src/app/(app)/settings/page.tsx | 3 - src/app/api/checkout/[plan]/route.ts | 75 - src/app/api/stripe/checkout/route.ts | 63 - src/app/api/stripe/portal/route.ts | 28 - src/app/api/stripe/webhook/route.ts | 87 - src/app/pricing/page.tsx | 22 +- src/components/settings/BillingSettings.tsx | 166 +- src/components/settings/SettingsTabs.tsx | 9 +- src/config/demo.ts | 1 - src/config/plans.ts | 2 +- src/db/queries/billing-grants.ts | 2 +- src/db/queries/revenue.ts | 2 +- src/db/queries/users.ts | 12 +- src/db/schema/users.ts | 4 +- src/lib/oc-pay.ts | 2 +- src/lib/stripe.ts | 29 - src/lib/user-client-view.ts | 9 +- src/proxy.ts | 3 +- 30 files changed, 8901 insertions(+), 519 deletions(-) create mode 100644 drizzle/0063_rainy_mattie_franklin.sql create mode 100644 drizzle/meta/0063_snapshot.json delete mode 100644 src/app/api/checkout/[plan]/route.ts delete mode 100644 src/app/api/stripe/checkout/route.ts delete mode 100644 src/app/api/stripe/portal/route.ts delete mode 100644 src/app/api/stripe/webhook/route.ts delete mode 100644 src/lib/stripe.ts diff --git a/drizzle/0063_rainy_mattie_franklin.sql b/drizzle/0063_rainy_mattie_franklin.sql new file mode 100644 index 000000000..b4c4610a9 --- /dev/null +++ b/drizzle/0063_rainy_mattie_franklin.sql @@ -0,0 +1,4 @@ +ALTER TABLE "users" DROP CONSTRAINT "users_stripe_customer_id_unique";--> statement-breakpoint +ALTER TABLE "users" DROP CONSTRAINT "users_stripe_subscription_id_unique";--> statement-breakpoint +ALTER TABLE "users" DROP COLUMN "stripe_customer_id";--> statement-breakpoint +ALTER TABLE "users" DROP COLUMN "stripe_subscription_id"; \ No newline at end of file diff --git a/drizzle/meta/0063_snapshot.json b/drizzle/meta/0063_snapshot.json new file mode 100644 index 000000000..51184e5df --- /dev/null +++ b/drizzle/meta/0063_snapshot.json @@ -0,0 +1,8838 @@ +{ + "id": "cbb570fc-70fe-46ce-bd2f-0da69d98e867", + "prevId": "d86a5e60-8926-4380-a375-e03598e6f5eb", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.actions": { + "name": "actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "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()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "executed_at": { + "name": "executed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_actions_user_id": { + "name": "idx_actions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_actions_status": { + "name": "idx_actions_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_actions_type": { + "name": "idx_actions_type", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_actions_created_at": { + "name": "idx_actions_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_actions_unique_draft_title": { + "name": "idx_actions_unique_draft_title", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "status = 'draft'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "actions_user_id_users_id_fk": { + "name": "actions_user_id_users_id_fk", + "tableFrom": "actions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_messages": { + "name": "agent_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "msg_id": { + "name": "msg_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_agent": { + "name": "from_agent", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_agent": { + "name": "to_agent", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "re": { + "name": "re", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "read": { + "name": "read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "ts": { + "name": "ts", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_messages_user_msg_unique": { + "name": "agent_messages_user_msg_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "msg_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_agent_messages_user_created": { + "name": "idx_agent_messages_user_created", + "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": {} + } + }, + "foreignKeys": { + "agent_messages_user_id_users_id_fk": { + "name": "agent_messages_user_id_users_id_fk", + "tableFrom": "agent_messages", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_sessions": { + "name": "agent_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cwd": { + "name": "cwd", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "agent": { + "name": "agent", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'claude'" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_agent_sessions_user_id": { + "name": "idx_agent_sessions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_agent_sessions_project_key": { + "name": "idx_agent_sessions_project_key", + "columns": [ + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_agent_sessions_open": { + "name": "idx_agent_sessions_open", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ended_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_sessions_user_id_users_id_fk": { + "name": "agent_sessions_user_id_users_id_fk", + "tableFrom": "agent_sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_sessions_project_id_entities_id_fk": { + "name": "agent_sessions_project_id_entities_id_fk", + "tableFrom": "agent_sessions", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_agent_sessions_user_session": { + "name": "uq_agent_sessions_user_session", + "nullsNotDistinct": false, + "columns": ["user_id", "session_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_tokens": { + "name": "agent_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_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_agent_tokens_user_id": { + "name": "idx_agent_tokens_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_agent_tokens_token": { + "name": "idx_agent_tokens_token", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_tokens_user_id_users_id_fk": { + "name": "agent_tokens_user_id_users_id_fk", + "tableFrom": "agent_tokens", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_tokens_org_id_orgs_id_fk": { + "name": "agent_tokens_org_id_orgs_id_fk", + "tableFrom": "agent_tokens", + "tableTo": "orgs", + "columnsFrom": ["org_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "agent_tokens_token_unique": { + "name": "agent_tokens_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_spend": { + "name": "ai_spend", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "tokens": { + "name": "tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "turns": { + "name": "turns", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_ai_spend_day": { + "name": "idx_ai_spend_day", + "columns": [ + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_spend_user_id_users_id_fk": { + "name": "ai_spend_user_id_users_id_fk", + "tableFrom": "ai_spend", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_ai_spend_user_day": { + "name": "uq_ai_spend_user_day", + "nullsNotDistinct": false, + "columns": ["user_id", "day"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.alerts": { + "name": "alerts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "dismissed": { + "name": "dismissed", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "action_url": { + "name": "action_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "dismissed_at": { + "name": "dismissed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_alerts_user_id": { + "name": "idx_alerts_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_alerts_type": { + "name": "idx_alerts_type", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_alerts_dismissed": { + "name": "idx_alerts_dismissed", + "columns": [ + { + "expression": "dismissed", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_alerts_severity": { + "name": "idx_alerts_severity", + "columns": [ + { + "expression": "severity", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_alerts_created_at": { + "name": "idx_alerts_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "alerts_user_id_users_id_fk": { + "name": "alerts_user_id_users_id_fk", + "tableFrom": "alerts", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.attributes": { + "name": "attributes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_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 + }, + "confidence": { + "name": "confidence", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "temporal": { + "name": "temporal", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'permanent'" + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_attributes_entity_id": { + "name": "idx_attributes_entity_id", + "columns": [ + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_attributes_user_id": { + "name": "idx_attributes_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_attributes_key": { + "name": "idx_attributes_key", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "uq_attributes_user_entity_key": { + "name": "uq_attributes_user_entity_key", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "attributes_user_id_users_id_fk": { + "name": "attributes_user_id_users_id_fk", + "tableFrom": "attributes", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "attributes_entity_id_entities_id_fk": { + "name": "attributes_entity_id_entities_id_fk", + "tableFrom": "attributes", + "tableTo": "entities", + "columnsFrom": ["entity_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.accounts": { + "name": "accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "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 + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_state": { + "name": "session_state", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "accounts_user_id_users_id_fk": { + "name": "accounts_user_id_users_id_fk", + "tableFrom": "accounts", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "accounts_provider_provider_account_id_pk": { + "name": "accounts_provider_provider_account_id_pk", + "columns": ["provider", "provider_account_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.authenticators": { + "name": "authenticators", + "schema": "", + "columns": { + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider_account_id": { + "name": "provider_account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credential_public_key": { + "name": "credential_public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "credential_device_type": { + "name": "credential_device_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credential_backed_up": { + "name": "credential_backed_up", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "transports": { + "name": "transports", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "authenticators_user_id_users_id_fk": { + "name": "authenticators_user_id_users_id_fk", + "tableFrom": "authenticators", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "authenticators_user_id_credential_id_pk": { + "name": "authenticators_user_id_credential_id_pk", + "columns": ["user_id", "credential_id"] + } + }, + "uniqueConstraints": { + "authenticators_credential_id_unique": { + "name": "authenticators_credential_id_unique", + "nullsNotDistinct": false, + "columns": ["credential_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification_tokens": { + "name": "verification_tokens", + "schema": "", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "verification_tokens_identifier_token_pk": { + "name": "verification_tokens_identifier_token_pk", + "columns": ["identifier", "token"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beacon_sessions": { + "name": "beacon_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project": { + "name": "project", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_content": { + "name": "session_content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "current_agent": { + "name": "current_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_agent": { + "name": "next_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "capacity_issue": { + "name": "capacity_issue", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "countdown_seconds": { + "name": "countdown_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "popup_mode": { + "name": "popup_mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "git_branch": { + "name": "git_branch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "choice": { + "name": "choice", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_beacon_sessions_user_id": { + "name": "idx_beacon_sessions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_beacon_sessions_project": { + "name": "idx_beacon_sessions_project", + "columns": [ + { + "expression": "project", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_beacon_sessions_pending": { + "name": "idx_beacon_sessions_pending", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "choice", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beacon_sessions_user_id_users_id_fk": { + "name": "beacon_sessions_user_id_users_id_fk", + "tableFrom": "beacon_sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beacon_settings": { + "name": "beacon_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "popup_mode": { + "name": "popup_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'web'" + }, + "countdown_seconds": { + "name": "countdown_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 12 + }, + "min_idle_seconds": { + "name": "min_idle_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "whisper_model": { + "name": "whisper_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'base'" + }, + "transcription_provider": { + "name": "transcription_provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'auto'" + }, + "auto_inject_mode": { + "name": "auto_inject_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'on'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_beacon_settings_user_id": { + "name": "idx_beacon_settings_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beacon_settings_user_id_users_id_fk": { + "name": "beacon_settings_user_id_users_id_fk", + "tableFrom": "beacon_settings", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "beacon_settings_user_id_unique": { + "name": "beacon_settings_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oc_billing_grants": { + "name": "oc_billing_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period_days": { + "name": "period_days", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "amount_btc": { + "name": "amount_btc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_oc_billing_grants_user": { + "name": "idx_oc_billing_grants_user", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oc_billing_grants_user_id_users_id_fk": { + "name": "oc_billing_grants_user_id_users_id_fk", + "tableFrom": "oc_billing_grants", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oc_billing_grants_external_id_unique": { + "name": "oc_billing_grants_external_id_unique", + "nullsNotDistinct": false, + "columns": ["external_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.captures": { + "name": "captures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_captures_user_id": { + "name": "idx_captures_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_captures_created_at": { + "name": "idx_captures_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "captures_user_id_users_id_fk": { + "name": "captures_user_id_users_id_fk", + "tableFrom": "captures", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.claude_code_history": { + "name": "claude_code_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_path": { + "name": "project_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "git_branch": { + "name": "git_branch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_uuid": { + "name": "event_uuid", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt_type": { + "name": "prompt_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt_text": { + "name": "prompt_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ingested_at": { + "name": "ingested_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_cc_history_session_event": { + "name": "idx_cc_history_session_event", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_uuid", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_cc_history_user_occurred": { + "name": "idx_cc_history_user_occurred", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_cc_history_project_key": { + "name": "idx_cc_history_project_key", + "columns": [ + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "claude_code_history_user_id_users_id_fk": { + "name": "claude_code_history_user_id_users_id_fk", + "tableFrom": "claude_code_history", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "claude_code_history_project_id_entities_id_fk": { + "name": "claude_code_history_project_id_entities_id_fk", + "tableFrom": "claude_code_history", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.commitments": { + "name": "commitments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "due_date": { + "name": "due_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + }, + "financial_impact": { + "name": "financial_impact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "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_commitments_user_id": { + "name": "idx_commitments_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_commitments_status": { + "name": "idx_commitments_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_commitments_due_date": { + "name": "idx_commitments_due_date", + "columns": [ + { + "expression": "due_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "commitments_user_id_users_id_fk": { + "name": "commitments_user_id_users_id_fk", + "tableFrom": "commitments", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "commitments_entity_id_entities_id_fk": { + "name": "commitments_entity_id_entities_id_fk", + "tableFrom": "commitments", + "tableTo": "entities", + "columnsFrom": ["entity_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.control_audit_events": { + "name": "control_audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tab_name": { + "name": "tab_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event": { + "name": "event", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "decision_source": { + "name": "decision_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "health": { + "name": "health", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocker_count": { + "name": "blocker_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "no_op_count": { + "name": "no_op_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "queue_length": { + "name": "queue_length", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt_hash": { + "name": "prompt_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt_preview": { + "name": "prompt_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "command_id": { + "name": "command_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "meta": { + "name": "meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_control_audit_user_time": { + "name": "idx_control_audit_user_time", + "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_control_audit_user_project_time": { + "name": "idx_control_audit_user_project_time", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_control_audit_event_time": { + "name": "idx_control_audit_event_time", + "columns": [ + { + "expression": "event", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_control_audit_action_time": { + "name": "idx_control_audit_action_time", + "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": { + "control_audit_events_user_id_users_id_fk": { + "name": "control_audit_events_user_id_users_id_fk", + "tableFrom": "control_audit_events", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "control_audit_events_project_id_entities_id_fk": { + "name": "control_audit_events_project_id_entities_id_fk", + "tableFrom": "control_audit_events", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_messages": { + "name": "conversation_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "meta": { + "name": "meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_conversation_messages_conversation_id": { + "name": "idx_conversation_messages_conversation_id", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_messages_conversation_id_conversations_id_fk": { + "name": "conversation_messages_conversation_id_conversations_id_fk", + "tableFrom": "conversation_messages", + "tableTo": "conversations", + "columnsFrom": ["conversation_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_keys": { + "name": "project_keys", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time 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_conversations_user_id": { + "name": "idx_conversations_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_user_id_users_id_fk": { + "name": "conversations_user_id_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cron_jobs": { + "name": "cron_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "job": { + "name": "job", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "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_cron_jobs_user_id": { + "name": "idx_cron_jobs_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_cron_jobs_user_enabled": { + "name": "idx_cron_jobs_user_enabled", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cron_jobs_user_id_users_id_fk": { + "name": "cron_jobs_user_id_users_id_fk", + "tableFrom": "cron_jobs", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.debug_logs": { + "name": "debug_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "meta": { + "name": "meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_debug_logs_created_at": { + "name": "idx_debug_logs_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_debug_logs_source": { + "name": "idx_debug_logs_source", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_verification_tokens": { + "name": "email_verification_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_evt_token": { + "name": "idx_evt_token", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_evt_user_id": { + "name": "idx_evt_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_verification_tokens_user_id_users_id_fk": { + "name": "email_verification_tokens_user_id_users_id_fk", + "tableFrom": "email_verification_tokens", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "email_verification_tokens_token_unique": { + "name": "email_verification_tokens_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.entities": { + "name": "entities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_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 + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "git_url": { + "name": "git_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_inject_mode_override": { + "name": "auto_inject_mode_override", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "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_entities_type": { + "name": "idx_entities_type", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_entities_user_id": { + "name": "idx_entities_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_entities_external_id": { + "name": "idx_entities_external_id", + "columns": [ + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_entities_source": { + "name": "idx_entities_source", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "uq_entities_user_name_type": { + "name": "uq_entities_user_name_type", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "entities_user_id_users_id_fk": { + "name": "entities_user_id_users_id_fk", + "tableFrom": "entities", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.entity_relations": { + "name": "entity_relations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "from_entity_id": { + "name": "from_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_entity_id": { + "name": "to_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "strength": { + "name": "strength", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "confidence": { + "name": "confidence", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time 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_relations_type": { + "name": "idx_relations_type", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_relations_user_id": { + "name": "idx_relations_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_relations_from": { + "name": "idx_relations_from", + "columns": [ + { + "expression": "from_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_relations_to": { + "name": "idx_relations_to", + "columns": [ + { + "expression": "to_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "uq_relations_edge": { + "name": "uq_relations_edge", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "entity_relations_user_id_users_id_fk": { + "name": "entity_relations_user_id_users_id_fk", + "tableFrom": "entity_relations", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "entity_relations_from_entity_id_entities_id_fk": { + "name": "entity_relations_from_entity_id_entities_id_fk", + "tableFrom": "entity_relations", + "tableTo": "entities", + "columnsFrom": ["from_entity_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "entity_relations_to_entity_id_entities_id_fk": { + "name": "entity_relations_to_entity_id_entities_id_fk", + "tableFrom": "entity_relations", + "tableTo": "entities", + "columnsFrom": ["to_entity_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_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 + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date_start": { + "name": "date_start", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "date_end": { + "name": "date_end", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deadline": { + "name": "deadline", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + }, + "source": { + "name": "source", + "type": "text", + "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()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_events_user_id": { + "name": "idx_events_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_events_type": { + "name": "idx_events_type", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_events_status": { + "name": "idx_events_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_events_date_start": { + "name": "idx_events_date_start", + "columns": [ + { + "expression": "date_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "events_user_id_users_id_fk": { + "name": "events_user_id_users_id_fk", + "tableFrom": "events", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frontier_digests": { + "name": "frontier_digests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "digest_date": { + "name": "digest_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "headline": { + "name": "headline", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intro": { + "name": "intro", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "items": { + "name": "items", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "candidate_count": { + "name": "candidate_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "source_count": { + "name": "source_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "generated_at": { + "name": "generated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "frontier_digests_digest_date_unique": { + "name": "frontier_digests_digest_date_unique", + "nullsNotDistinct": false, + "columns": ["digest_date"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frontier_proposals": { + "name": "frontier_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "digest_date": { + "name": "digest_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_urls": { + "name": "source_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "score": { + "name": "score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "verifier_scores": { + "name": "verifier_scores", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'proposed'" + }, + "created_goal_id": { + "name": "created_goal_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_frontier_proposals_user_status": { + "name": "idx_frontier_proposals_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": {} + } + }, + "foreignKeys": { + "frontier_proposals_user_id_users_id_fk": { + "name": "frontier_proposals_user_id_users_id_fk", + "tableFrom": "frontier_proposals", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "frontier_proposals_entity_id_entities_id_fk": { + "name": "frontier_proposals_entity_id_entities_id_fk", + "tableFrom": "frontier_proposals", + "tableTo": "entities", + "columnsFrom": ["entity_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.goals": { + "name": "goals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "parent_goal_id": { + "name": "parent_goal_id", + "type": "uuid", + "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": false, + "default": "'active'" + }, + "progress": { + "name": "progress", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "target_date": { + "name": "target_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "milestones": { + "name": "milestones", + "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()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_goals_user_id": { + "name": "idx_goals_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_goals_user_status": { + "name": "idx_goals_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_goals_status": { + "name": "idx_goals_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_goals_parent": { + "name": "idx_goals_parent", + "columns": [ + { + "expression": "parent_goal_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_goals_entity_id": { + "name": "idx_goals_entity_id", + "columns": [ + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "goals_user_id_users_id_fk": { + "name": "goals_user_id_users_id_fk", + "tableFrom": "goals", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "goals_entity_id_entities_id_fk": { + "name": "goals_entity_id_entities_id_fk", + "tableFrom": "goals", + "tableTo": "entities", + "columnsFrom": ["entity_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.habit_goals": { + "name": "habit_goals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "habit_id": { + "name": "habit_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "goal_id": { + "name": "goal_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_habit_goals_habit_id": { + "name": "idx_habit_goals_habit_id", + "columns": [ + { + "expression": "habit_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_habit_goals_goal_id": { + "name": "idx_habit_goals_goal_id", + "columns": [ + { + "expression": "goal_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "habit_goals_user_id_users_id_fk": { + "name": "habit_goals_user_id_users_id_fk", + "tableFrom": "habit_goals", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "habit_goals_habit_id_habits_id_fk": { + "name": "habit_goals_habit_id_habits_id_fk", + "tableFrom": "habit_goals", + "tableTo": "habits", + "columnsFrom": ["habit_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "habit_goals_goal_id_goals_id_fk": { + "name": "habit_goals_goal_id_goals_id_fk", + "tableFrom": "habit_goals", + "tableTo": "goals", + "columnsFrom": ["goal_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_habit_goal": { + "name": "uq_habit_goal", + "nullsNotDistinct": false, + "columns": ["habit_id", "goal_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.habit_completions": { + "name": "habit_completions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "habit_id": { + "name": "habit_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "completed_date": { + "name": "completed_date", + "type": "date", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_habit_completions_user_id": { + "name": "idx_habit_completions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_habit_completions_habit_id": { + "name": "idx_habit_completions_habit_id", + "columns": [ + { + "expression": "habit_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "habit_completions_user_id_users_id_fk": { + "name": "habit_completions_user_id_users_id_fk", + "tableFrom": "habit_completions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "habit_completions_habit_id_habits_id_fk": { + "name": "habit_completions_habit_id_habits_id_fk", + "tableFrom": "habit_completions", + "tableTo": "habits", + "columnsFrom": ["habit_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_habit_completion_per_day": { + "name": "uq_habit_completion_per_day", + "nullsNotDistinct": false, + "columns": ["habit_id", "completed_date"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.habits": { + "name": "habits", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'daily'" + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "active": { + "name": "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()" + } + }, + "indexes": { + "idx_habits_user_id": { + "name": "idx_habits_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "habits_user_id_users_id_fk": { + "name": "habits_user_id_users_id_fk", + "tableFrom": "habits", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.human_task_events": { + "name": "human_task_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor": { + "name": "actor", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "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_human_task_events_task": { + "name": "idx_human_task_events_task", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_human_task_events_user": { + "name": "idx_human_task_events_user", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "human_task_events_task_id_human_tasks_id_fk": { + "name": "human_task_events_task_id_human_tasks_id_fk", + "tableFrom": "human_task_events", + "tableTo": "human_tasks", + "columnsFrom": ["task_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "human_task_events_user_id_users_id_fk": { + "name": "human_task_events_user_id_users_id_fk", + "tableFrom": "human_task_events", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.human_tasks": { + "name": "human_tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "assignee_id": { + "name": "assignee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brief": { + "name": "brief", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "due_date": { + "name": "due_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "fee_amount": { + "name": "fee_amount", + "type": "numeric(20, 8)", + "primaryKey": false, + "notNull": false + }, + "fee_currency": { + "name": "fee_currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "orangecat_service_id": { + "name": "orangecat_service_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "orangecat_url": { + "name": "orangecat_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "share_token": { + "name": "share_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shared_at": { + "name": "shared_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "responded_at": { + "name": "responded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_human_tasks_user_id": { + "name": "idx_human_tasks_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_human_tasks_user_status": { + "name": "idx_human_tasks_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_human_tasks_assignee": { + "name": "idx_human_tasks_assignee", + "columns": [ + { + "expression": "assignee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_human_tasks_project": { + "name": "idx_human_tasks_project", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_human_tasks_due_date": { + "name": "idx_human_tasks_due_date", + "columns": [ + { + "expression": "due_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "uq_human_tasks_live_share_token": { + "name": "uq_human_tasks_live_share_token", + "columns": [ + { + "expression": "share_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "share_token IS NOT NULL AND revoked_at IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "human_tasks_user_id_users_id_fk": { + "name": "human_tasks_user_id_users_id_fk", + "tableFrom": "human_tasks", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "human_tasks_assignee_id_entities_id_fk": { + "name": "human_tasks_assignee_id_entities_id_fk", + "tableFrom": "human_tasks", + "tableTo": "entities", + "columnsFrom": ["assignee_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "human_tasks_project_id_entities_id_fk": { + "name": "human_tasks_project_id_entities_id_fk", + "tableFrom": "human_tasks", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_verified": { + "name": "email_verified", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "onboarded_at": { + "name": "onboarded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "orangecat_actor_id": { + "name": "orangecat_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'free'" + }, + "plan_status": { + "name": "plan_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan_expires_at": { + "name": "plan_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "private_zone_pin_hash": { + "name": "private_zone_pin_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "private_zone_pin_set_at": { + "name": "private_zone_pin_set_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "fleet_settings": { + "name": "fleet_settings", + "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": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + }, + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": ["username"] + }, + "users_orangecat_actor_id_unique": { + "name": "users_orangecat_actor_id_unique", + "nullsNotDistinct": false, + "columns": ["orangecat_actor_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_preferences": { + "name": "notification_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "email_digest_cadence": { + "name": "email_digest_cadence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "last_digest_sent_at": { + "name": "last_digest_sent_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_notification_preferences_user_id": { + "name": "idx_notification_preferences_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_preferences_user_id_users_id_fk": { + "name": "notification_preferences_user_id_users_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_memberships": { + "name": "org_memberships", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_org_memberships_org_id": { + "name": "idx_org_memberships_org_id", + "columns": [ + { + "expression": "org_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_org_memberships_user_id": { + "name": "idx_org_memberships_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "org_memberships_org_id_orgs_id_fk": { + "name": "org_memberships_org_id_orgs_id_fk", + "tableFrom": "org_memberships", + "tableTo": "orgs", + "columnsFrom": ["org_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "org_memberships_user_id_users_id_fk": { + "name": "org_memberships_user_id_users_id_fk", + "tableFrom": "org_memberships", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_org_memberships_org_user": { + "name": "uq_org_memberships_org_user", + "nullsNotDistinct": false, + "columns": ["org_id", "user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.orgs": { + "name": "orgs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "uuid", + "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_orgs_owner_id": { + "name": "idx_orgs_owner_id", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "orgs_owner_id_users_id_fk": { + "name": "orgs_owner_id_users_id_fk", + "tableFrom": "orgs", + "tableTo": "users", + "columnsFrom": ["owner_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "orgs_slug_unique": { + "name": "orgs_slug_unique", + "nullsNotDistinct": false, + "columns": ["slug"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.interactions": { + "name": "interactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_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_interactions_entity_id": { + "name": "idx_interactions_entity_id", + "columns": [ + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_interactions_user_id": { + "name": "idx_interactions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_interactions_channel": { + "name": "idx_interactions_channel", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_interactions_occurred_at": { + "name": "idx_interactions_occurred_at", + "columns": [ + { + "expression": "occurred_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "interactions_user_id_users_id_fk": { + "name": "interactions_user_id_users_id_fk", + "tableFrom": "interactions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "interactions_entity_id_entities_id_fk": { + "name": "interactions_entity_id_entities_id_fk", + "tableFrom": "interactions", + "tableTo": "entities", + "columnsFrom": ["entity_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subscriptions": { + "name": "subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "vendor": { + "name": "vendor", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'CHF'" + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'monthly'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + }, + "next_due": { + "name": "next_due", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "payment_method": { + "name": "payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "orangecat_service_id": { + "name": "orangecat_service_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": { + "idx_subscriptions_user_id": { + "name": "idx_subscriptions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_subscriptions_status": { + "name": "idx_subscriptions_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_subscriptions_next_due": { + "name": "idx_subscriptions_next_due", + "columns": [ + { + "expression": "next_due", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "subscriptions_user_id_users_id_fk": { + "name": "subscriptions_user_id_users_id_fk", + "tableFrom": "subscriptions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "subscriptions_entity_id_entities_id_fk": { + "name": "subscriptions_entity_id_entities_id_fk", + "tableFrom": "subscriptions", + "tableTo": "entities", + "columnsFrom": ["entity_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.orchestration_events": { + "name": "orchestration_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "adapter": { + "name": "adapter", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "intent": { + "name": "intent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "happened_at": { + "name": "happened_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_orch_events_user_project_time": { + "name": "idx_orch_events_user_project_time", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "happened_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orch_events_user_project_type_time": { + "name": "idx_orch_events_user_project_type_time", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "happened_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orch_events_project_id_time": { + "name": "idx_orch_events_project_id_time", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "happened_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "orchestration_events_dedupe_key_unique": { + "name": "orchestration_events_dedupe_key_unique", + "columns": [ + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "orchestration_events_user_id_users_id_fk": { + "name": "orchestration_events_user_id_users_id_fk", + "tableFrom": "orchestration_events", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "orchestration_events_project_id_entities_id_fk": { + "name": "orchestration_events_project_id_entities_id_fk", + "tableFrom": "orchestration_events", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.orchestration_runs": { + "name": "orchestration_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "adapter": { + "name": "adapter", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent": { + "name": "intent", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_path": { + "name": "project_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_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()" + }, + "tokens_in": { + "name": "tokens_in", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tokens_out": { + "name": "tokens_out", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tokens_cache_read": { + "name": "tokens_cache_read", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tokens_cache_write": { + "name": "tokens_cache_write", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "usage_detail": { + "name": "usage_detail", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "usage_updated_at": { + "name": "usage_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_orchestration_runs_user_id": { + "name": "idx_orchestration_runs_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orchestration_runs_org_id": { + "name": "idx_orchestration_runs_org_id", + "columns": [ + { + "expression": "org_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orchestration_runs_project_id": { + "name": "idx_orchestration_runs_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orchestration_runs_project_path": { + "name": "idx_orchestration_runs_project_path", + "columns": [ + { + "expression": "project_path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orchestration_runs_started_at": { + "name": "idx_orchestration_runs_started_at", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orchestration_runs_recent_outcomes": { + "name": "idx_orchestration_runs_recent_outcomes", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "finished_at DESC", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "orchestration_runs_user_id_users_id_fk": { + "name": "orchestration_runs_user_id_users_id_fk", + "tableFrom": "orchestration_runs", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orchestration_runs_org_id_orgs_id_fk": { + "name": "orchestration_runs_org_id_orgs_id_fk", + "tableFrom": "orchestration_runs", + "tableTo": "orgs", + "columnsFrom": ["org_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "orchestration_runs_project_id_entities_id_fk": { + "name": "orchestration_runs_project_id_entities_id_fk", + "tableFrom": "orchestration_runs", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prompt_history": { + "name": "prompt_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_path": { + "name": "project_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "adapter": { + "name": "adapter", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent": { + "name": "intent", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "custom_prompt": { + "name": "custom_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_prompt": { + "name": "resolved_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dispatched_at": { + "name": "dispatched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_prompt_history_user_id": { + "name": "idx_prompt_history_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prompt_history_project_id": { + "name": "idx_prompt_history_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prompt_history_project_key": { + "name": "idx_prompt_history_project_key", + "columns": [ + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prompt_history_dispatched_at": { + "name": "idx_prompt_history_dispatched_at", + "columns": [ + { + "expression": "dispatched_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prompt_history_run_id": { + "name": "idx_prompt_history_run_id", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "prompt_history_user_id_users_id_fk": { + "name": "prompt_history_user_id_users_id_fk", + "tableFrom": "prompt_history", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "prompt_history_project_id_entities_id_fk": { + "name": "prompt_history_project_id_entities_id_fk", + "tableFrom": "prompt_history", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "prompt_history_run_id_orchestration_runs_id_fk": { + "name": "prompt_history_run_id_orchestration_runs_id_fk", + "tableFrom": "prompt_history", + "tableTo": "orchestration_runs", + "columnsFrom": ["run_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_projects": { + "name": "user_projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "entity_project_id": { + "name": "entity_project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "dir_path": { + "name": "dir_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "git_url": { + "name": "git_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "live_url": { + "name": "live_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stack": { + "name": "stack", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_pref": { + "name": "agent_pref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model_pref": { + "name": "model_pref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resources": { + "name": "resources", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "dev_log": { + "name": "dev_log", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "orangecat_project_id": { + "name": "orangecat_project_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": { + "idx_user_projects_user_id": { + "name": "idx_user_projects_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_user_projects_user_active": { + "name": "idx_user_projects_user_active", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_user_projects_entity_project_id": { + "name": "idx_user_projects_entity_project_id", + "columns": [ + { + "expression": "entity_project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_user_projects_org_id": { + "name": "idx_user_projects_org_id", + "columns": [ + { + "expression": "org_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "uq_user_projects_user_name": { + "name": "uq_user_projects_user_name", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_projects_user_id_users_id_fk": { + "name": "user_projects_user_id_users_id_fk", + "tableFrom": "user_projects", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_projects_org_id_orgs_id_fk": { + "name": "user_projects_org_id_orgs_id_fk", + "tableFrom": "user_projects", + "tableTo": "orgs", + "columnsFrom": ["org_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "user_projects_entity_project_id_entities_id_fk": { + "name": "user_projects_entity_project_id_entities_id_fk", + "tableFrom": "user_projects", + "tableTo": "entities", + "columnsFrom": ["entity_project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project_states": { + "name": "project_states", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tab_name": { + "name": "tab_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_running": { + "name": "agent_running", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "tab_open": { + "name": "tab_open", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "active_agents": { + "name": "active_agents", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "ready_at": { + "name": "ready_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "lock_at": { + "name": "lock_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closing_at": { + "name": "closing_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "session_status": { + "name": "session_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_continue_enabled": { + "name": "auto_continue_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "prompt_queue": { + "name": "prompt_queue", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "prompt_queue_revision": { + "name": "prompt_queue_revision", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "session_done": { + "name": "session_done", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_next": { + "name": "session_next", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_tests": { + "name": "session_tests", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_todos": { + "name": "session_todos", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_health": { + "name": "session_health", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_tsc": { + "name": "session_tsc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_lint": { + "name": "session_lint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_commit": { + "name": "session_commit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_block_reason": { + "name": "session_block_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_no_op_count": { + "name": "session_no_op_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "session_updated_at": { + "name": "session_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "current_prompt_key": { + "name": "current_prompt_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_prompt_label": { + "name": "current_prompt_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_prompt_started_at": { + "name": "current_prompt_started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "runtime_observed_at": { + "name": "runtime_observed_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()" + } + }, + "indexes": { + "idx_project_states_user_id": { + "name": "idx_project_states_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_project_states_project_id": { + "name": "idx_project_states_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_project_states_workspace_id": { + "name": "idx_project_states_workspace_id", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_project_states_user_lower_key": { + "name": "idx_project_states_user_lower_key", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"project_key\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_states_user_id_users_id_fk": { + "name": "project_states_user_id_users_id_fk", + "tableFrom": "project_states", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_states_project_id_entities_id_fk": { + "name": "project_states_project_id_entities_id_fk", + "tableFrom": "project_states", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_states_user_id_project_key_pk": { + "name": "project_states_user_id_project_key_pk", + "columns": ["user_id", "project_key"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitations": { + "name": "invitations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "used_by": { + "name": "used_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_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_invitations_token": { + "name": "idx_invitations_token", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_invitations_created_by": { + "name": "idx_invitations_created_by", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitations_created_by_users_id_fk": { + "name": "invitations_created_by_users_id_fk", + "tableFrom": "invitations", + "tableTo": "users", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitations_used_by_users_id_fk": { + "name": "invitations_used_by_users_id_fk", + "tableFrom": "invitations", + "tableTo": "users", + "columnsFrom": ["used_by"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invitations_token_unique": { + "name": "invitations_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.password_reset_tokens": { + "name": "password_reset_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_prt_token": { + "name": "idx_prt_token", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prt_user_id": { + "name": "idx_prt_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "password_reset_tokens_user_id_users_id_fk": { + "name": "password_reset_tokens_user_id_users_id_fk", + "tableFrom": "password_reset_tokens", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "password_reset_tokens_token_unique": { + "name": "password_reset_tokens_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pending_commands": { + "name": "pending_commands", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "executed_at": { + "name": "executed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_pending_commands_user_id": { + "name": "idx_pending_commands_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_pending_commands_created_at": { + "name": "idx_pending_commands_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_pending_commands_open_run": { + "name": "idx_pending_commands_open_run", + "columns": [ + { + "expression": "((payload->>'runId'))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "executed_at IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pending_commands_user_id_users_id_fk": { + "name": "pending_commands_user_id_users_id_fk", + "tableFrom": "pending_commands", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.prompts": { + "name": "prompts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_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 + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'global'" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "variables": { + "name": "variables", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "forked_from_key": { + "name": "forked_from_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "run_count": { + "name": "run_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "success_count": { + "name": "success_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "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": { + "idx_prompts_user_id": { + "name": "idx_prompts_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prompts_project_id": { + "name": "idx_prompts_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prompts_scope": { + "name": "idx_prompts_scope", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_prompts_active": { + "name": "idx_prompts_active", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "prompts_user_id_users_id_fk": { + "name": "prompts_user_id_users_id_fk", + "tableFrom": "prompts", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "prompts_project_id_entities_id_fk": { + "name": "prompts_project_id_entities_id_fk", + "tableFrom": "prompts", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "prompts_org_id_orgs_id_fk": { + "name": "prompts_org_id_orgs_id_fk", + "tableFrom": "prompts", + "tableTo": "orgs", + "columnsFrom": ["org_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_preferences": { + "name": "user_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "home_city": { + "name": "home_city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "home_timezone": { + "name": "home_timezone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "home_locale": { + "name": "home_locale", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_city": { + "name": "current_city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_timezone": { + "name": "current_timezone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_city_until": { + "name": "current_city_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "writing_voice": { + "name": "writing_voice", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "memory_enabled": { + "name": "memory_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_user_preferences_user_id": { + "name": "idx_user_preferences_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_preferences_user_id_users_id_fk": { + "name": "user_preferences_user_id_users_id_fk", + "tableFrom": "user_preferences", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_preferences_user_id_unique": { + "name": "user_preferences_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.runtime_snapshots": { + "name": "runtime_snapshots", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'local'" + }, + "open_tabs": { + "name": "open_tabs", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "installed_agents": { + "name": "installed_agents", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "runner_version": { + "name": "runner_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "panes": { + "name": "panes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "power_source": { + "name": "power_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "observed_at": { + "name": "observed_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()" + } + }, + "indexes": {}, + "foreignKeys": { + "runtime_snapshots_user_id_users_id_fk": { + "name": "runtime_snapshots_user_id_users_id_fk", + "tableFrom": "runtime_snapshots", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "runtime_snapshots_user_id_channel_pk": { + "name": "runtime_snapshots_user_id_channel_pk", + "columns": ["user_id", "channel"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_push_subscriptions_user_id": { + "name": "idx_push_subscriptions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "push_subscriptions_endpoint_unique": { + "name": "push_subscriptions_endpoint_unique", + "nullsNotDistinct": false, + "columns": ["endpoint"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.runner_presence": { + "name": "runner_presence", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "connection_count": { + "name": "connection_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "connected": { + "name": "connected", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cloud_connection_count": { + "name": "cloud_connection_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cloud_connected": { + "name": "cloud_connected", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "local_connection_count": { + "name": "local_connection_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "local_connected": { + "name": "local_connected", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "connected_at": { + "name": "connected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_change_at": { + "name": "last_change_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "runner_presence_user_id_users_id_fk": { + "name": "runner_presence_user_id_users_id_fk", + "tableFrom": "runner_presence", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project_shares": { + "name": "project_shares", + "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 + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'advisor'" + }, + "include_roadmap": { + "name": "include_roadmap", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "include_changelog": { + "name": "include_changelog", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "include_resources": { + "name": "include_resources", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "include_repo": { + "name": "include_repo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "include_live_url": { + "name": "include_live_url", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_project_shares_token": { + "name": "idx_project_shares_token", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_project_shares_project_id": { + "name": "idx_project_shares_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_project_shares_user_id": { + "name": "idx_project_shares_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_shares_project_id_entities_id_fk": { + "name": "project_shares_project_id_entities_id_fk", + "tableFrom": "project_shares", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_shares_user_id_users_id_fk": { + "name": "project_shares_user_id_users_id_fk", + "tableFrom": "project_shares", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "project_shares_token_unique": { + "name": "project_shares_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.widget_tokens": { + "name": "widget_tokens", + "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 + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origins": { + "name": "origins", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "placement": { + "name": "placement", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_seen_origin": { + "name": "last_seen_origin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_widget_tokens_project": { + "name": "idx_widget_tokens_project", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_widget_tokens_user": { + "name": "idx_widget_tokens_user", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "widget_tokens_project_id_entities_id_fk": { + "name": "widget_tokens_project_id_entities_id_fk", + "tableFrom": "widget_tokens", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "widget_tokens_user_id_users_id_fk": { + "name": "widget_tokens_user_id_users_id_fk", + "tableFrom": "widget_tokens", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "widget_tokens_token_unique": { + "name": "widget_tokens_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_feedback": { + "name": "site_feedback", + "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 + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_id": { + "name": "token_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "suggestion": { + "name": "suggestion", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact": { + "name": "contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "page_title": { + "name": "page_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "selected_elements": { + "name": "selected_elements", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duplicate_count": { + "name": "duplicate_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "screenshot": { + "name": "screenshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "featured_at": { + "name": "featured_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "dispatched_run_id": { + "name": "dispatched_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_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_site_feedback_project": { + "name": "idx_site_feedback_project", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_site_feedback_user": { + "name": "idx_site_feedback_user", + "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_site_feedback_dedupe": { + "name": "idx_site_feedback_dedupe", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "content_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "site_feedback_project_id_entities_id_fk": { + "name": "site_feedback_project_id_entities_id_fk", + "tableFrom": "site_feedback", + "tableTo": "entities", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "site_feedback_user_id_users_id_fk": { + "name": "site_feedback_user_id_users_id_fk", + "tableFrom": "site_feedback", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "site_feedback_token_id_widget_tokens_id_fk": { + "name": "site_feedback_token_id_widget_tokens_id_fk", + "tableFrom": "site_feedback", + "tableTo": "widget_tokens", + "columnsFrom": ["token_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.orangecat_build_intents": { + "name": "orangecat_build_intents", + "schema": "", + "columns": { + "jti": { + "name": "jti", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "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_orangecat_build_intents_expiry": { + "name": "idx_orangecat_build_intents_expiry", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "orangecat_build_intents_user_id_users_id_fk": { + "name": "orangecat_build_intents_user_id_users_id_fk", + "tableFrom": "orangecat_build_intents", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "orangecat_build_intents_token_hash_unique": { + "name": "orangecat_build_intents_token_hash_unique", + "nullsNotDistinct": false, + "columns": ["token_hash"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.orangecat_entity_links": { + "name": "orangecat_entity_links", + "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 + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "public_url": { + "name": "public_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "uq_orangecat_entity_links_edge": { + "name": "uq_orangecat_entity_links_edge", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "role", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orangecat_entity_links_project": { + "name": "idx_orangecat_entity_links_project", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_orangecat_entity_links_entity": { + "name": "idx_orangecat_entity_links_entity", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "orangecat_entity_links_project_id_user_projects_id_fk": { + "name": "orangecat_entity_links_project_id_user_projects_id_fk", + "tableFrom": "orangecat_entity_links", + "tableTo": "user_projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "orangecat_entity_links_user_id_users_id_fk": { + "name": "orangecat_entity_links_user_id_users_id_fk", + "tableFrom": "orangecat_entity_links", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_snapshots": { + "name": "site_snapshots", + "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 + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requested_url": { + "name": "requested_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "final_url": { + "name": "final_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status_code": { + "name": "status_code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "ok": { + "name": "ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "response_ms": { + "name": "response_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preview_image_url": { + "name": "preview_image_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preview_ok": { + "name": "preview_ok", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "outbound_hosts": { + "name": "outbound_hosts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "internal_paths": { + "name": "internal_paths", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "uq_site_snapshots_project": { + "name": "uq_site_snapshots_project", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_site_snapshots_user": { + "name": "idx_site_snapshots_user", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "site_snapshots_project_id_user_projects_id_fk": { + "name": "site_snapshots_project_id_user_projects_id_fk", + "tableFrom": "site_snapshots", + "tableTo": "user_projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "site_snapshots_user_id_users_id_fk": { + "name": "site_snapshots_user_id_users_id_fk", + "tableFrom": "site_snapshots", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_guides": { + "name": "site_guides", + "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 + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "position": { + "name": "position", + "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_site_guides_project": { + "name": "idx_site_guides_project", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "position", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_site_guides_user": { + "name": "idx_site_guides_user", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "site_guides_project_id_user_projects_id_fk": { + "name": "site_guides_project_id_user_projects_id_fk", + "tableFrom": "site_guides", + "tableTo": "user_projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "site_guides_user_id_users_id_fk": { + "name": "site_guides_user_id_users_id_fk", + "tableFrom": "site_guides", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_embeddings": { + "name": "knowledge_embeddings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chunk": { + "name": "chunk", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "embedding": { + "name": "embedding", + "type": "vector(384)", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_knowledge_embeddings_user_type": { + "name": "idx_knowledge_embeddings_user_type", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_embeddings_user_id_users_id_fk": { + "name": "knowledge_embeddings_user_id_users_id_fk", + "tableFrom": "knowledge_embeddings", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_knowledge_embeddings_src": { + "name": "uq_knowledge_embeddings_src", + "nullsNotDistinct": false, + "columns": ["user_id", "source_type", "source_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.run_escalations": { + "name": "run_escalations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fail_streak": { + "name": "fail_streak", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_run_id": { + "name": "last_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_outcome": { + "name": "last_outcome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opened_at": { + "name": "opened_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_run_escalations_open": { + "name": "idx_run_escalations_open", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resolved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_run_escalations_opened_at": { + "name": "idx_run_escalations_opened_at", + "columns": [ + { + "expression": "opened_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "uq_run_escalations_one_open_per_project": { + "name": "uq_run_escalations_one_open_per_project", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"run_escalations\".\"resolved_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "run_escalations_user_id_users_id_fk": { + "name": "run_escalations_user_id_users_id_fk", + "tableFrom": "run_escalations", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.run_events": { + "name": "run_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_run_events_run_id": { + "name": "idx_run_events_run_id", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_run_events_user_created": { + "name": "idx_run_events_user_created", + "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": {} + } + }, + "foreignKeys": { + "run_events_run_id_orchestration_runs_id_fk": { + "name": "run_events_run_id_orchestration_runs_id_fk", + "tableFrom": "run_events", + "tableTo": "orchestration_runs", + "columnsFrom": ["run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "run_events_user_id_users_id_fk": { + "name": "run_events_user_id_users_id_fk", + "tableFrom": "run_events", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.newsletter_subscribers": { + "name": "newsletter_subscribers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "newsletter_subscribers_email_unique": { + "name": "newsletter_subscribers_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index e93da3409..8cb32766d 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -435,6 +435,13 @@ "when": 1788426696563, "tag": "0062_vengeful_lockjaw", "breakpoints": true + }, + { + "idx": 63, + "version": "7", + "when": 1788626716800, + "tag": "0063_rainy_mattie_franklin", + "breakpoints": true } ] } diff --git a/package.json b/package.json index a7b2a93e8..5b8e1a53b 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,6 @@ "react": "19.2.8", "react-dom": "19.2.8", "shadcn": "^4.19.0", - "stripe": "^22.6.0", "tailwind-merge": "^3.6.0", "tw-animate-css": "^1.4.0", "web-push": "^3.6.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 602bc400f..3c6ad59cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -110,9 +110,6 @@ importers: shadcn: specifier: ^4.19.0 version: 4.19.0(supports-color@8.1.1)(typescript@6.0.3) - stripe: - specifier: ^22.6.0 - version: 22.6.0(@types/node@26.4.0) tailwind-merge: specifier: ^3.6.0 version: 3.6.0 @@ -4495,15 +4492,6 @@ packages: resolution: {integrity: sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==} engines: {node: '>=18'} - stripe@22.6.0: - resolution: {integrity: sha512-Ezk+WYEEwX2DLxFrKfb6coznlCMZvCaCYMNPXNHFSZkBIEzF5Hgm7RLb38q/0h9Ol5jsUJGJRorvhzAvckgfhw==} - engines: {node: '>=18'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true - styled-jsx@5.1.6: resolution: {integrity: sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==} engines: {node: '>= 12.0.0'} @@ -9056,10 +9044,6 @@ snapshots: strip-final-newline@4.0.0: {} - stripe@22.6.0(@types/node@26.4.0): - optionalDependencies: - '@types/node': 26.4.0 - styled-jsx@5.1.6(@babel/core@7.29.7(supports-color@8.1.1))(react@19.2.8): dependencies: client-only: 0.0.1 diff --git a/scripts/smoke.sh b/scripts/smoke.sh index 3923fff39..d53b5213f 100755 --- a/scripts/smoke.sh +++ b/scripts/smoke.sh @@ -160,10 +160,6 @@ for route in "${AUTH_API_ROUTES[@]}"; do check_route "$route" 0 "$route" 1 done -# Routes that may return 503 when optional integrations (Stripe) are not configured. -# 401 (no session) or 503 (not configured) both prove the route isn't crashing. -check_route "/api/stripe/portal" 0 "/api/stripe/portal" 1 "503" - # Invitation token routes are excluded from the auth middleware so unauthenticated # users can accept invites. A bogus token must return 404 — if it returns 401 the # middleware exclusion regressed and new users can no longer accept invitations. diff --git a/scripts/test/account-export.ts b/scripts/test/account-export.ts index 821bfc20c..b634579a1 100644 --- a/scripts/test/account-export.ts +++ b/scripts/test/account-export.ts @@ -38,8 +38,6 @@ const userRow = { orangecatActorId: null, plan: "pro", planStatus: "active", - stripeCustomerId: "cus_123", - stripeSubscriptionId: "sub_456", planExpiresAt: null, privateZonePinSetAt: new Date("2026-01-01"), fleetSettings: { a: 1 }, @@ -59,11 +57,10 @@ for (const field of Object.keys(USER_WITHHELD_FIELDS)) { ok(!serialized.includes("bcrypt$secret"), "serialized export does not contain the password hash"); ok(!serialized.includes("scrypt$pin"), "serialized export does not contain the PIN hash"); -// Billing ids: withheld from the export specifically. +// Fields withheld from the export specifically. for (const field of USER_EXPORT_OMITTED_FIELDS) { ok(!(field in exported), `${field} omitted from export`); } -ok(!serialized.includes("cus_123"), "serialized export does not contain the Stripe customer id"); // Everything else the owner may see must survive — an export that quietly drops // data fails its purpose (right of access) as surely as one that leaks. diff --git a/scripts/test/api-route-auth.ts b/scripts/test/api-route-auth.ts index 5f84d789b..b9d7e9c27 100644 --- a/scripts/test/api-route-auth.ts +++ b/scripts/test/api-route-auth.ts @@ -54,8 +54,6 @@ const GUARDS = [ "getWidgetTokenByToken", // fcw_* write-only widget token // Signed webhooks from other services "WEBHOOK_SECRET", - "stripe-signature", - "constructEvent", ] as const; /** diff --git a/scripts/test/authenticated-smoke.ts b/scripts/test/authenticated-smoke.ts index 6550a3d34..dbb97460a 100644 --- a/scripts/test/authenticated-smoke.ts +++ b/scripts/test/authenticated-smoke.ts @@ -1381,25 +1381,6 @@ async function main(): Promise { }), ); - // Stripe portal — configured or 503 - probes.push( - await probe(cookieHeader, "/api/stripe/portal", { expectStatus: [200, 303, 307, 503] }), - ); - - const webhookRes = await fetch(`${BASE}/api/stripe/webhook`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: "{}", - signal: AbortSignal.timeout(15_000), - }); - probes.push({ - route: "CH04 POST /api/stripe/webhook (invalid sig)", - method: "POST", - status: webhookRes.status, - ok: [400, 503].includes(webhookRes.status), - note: webhookRes.status === 503 ? "Stripe not configured" : "signature rejected", - }); - const metaIssues: string[] = []; for (const [name, meta] of Object.entries(SUBSCRIPTION_META)) { try { diff --git a/scripts/test/no-raw-user-response.ts b/scripts/test/no-raw-user-response.ts index 5d686c553..2e28a0dc7 100644 --- a/scripts/test/no-raw-user-response.ts +++ b/scripts/test/no-raw-user-response.ts @@ -30,7 +30,6 @@ const FULL_ROW_SOURCES = [ "getUserByUsername", "getUserByEmail", "getDefaultUser", - "getUserByStripeCustomerId", "getUserByOrangeCatActorId", "createUser", "createInitialUser", diff --git a/scripts/test/solon-message.ts b/scripts/test/solon-message.ts index f4c519367..5093d30b1 100644 --- a/scripts/test/solon-message.ts +++ b/scripts/test/solon-message.ts @@ -161,7 +161,7 @@ import { join } from "node:path"; const proxySource = readFileSync(join(__dirname, "../../src/proxy.ts"), "utf8"); const matcherExclusion = proxySource.match(/"\/\(\(\?!(.+)\)\.\+\)"/)?.[1]; assert.ok(matcherExclusion, "proxy.ts matcher exclusion pattern not found"); -for (const receiver of ["api/orangecat/", "api/solon/", "api/stripe/webhook"]) { +for (const receiver of ["api/orangecat/", "api/solon/"]) { assert.ok( matcherExclusion.split("|").includes(receiver.replace(/\./g, "\\.")) || matcherExclusion.split("|").includes(receiver), diff --git a/scripts/test/user-client-view.ts b/scripts/test/user-client-view.ts index c7afa616e..40c9ab7d9 100644 --- a/scripts/test/user-client-view.ts +++ b/scripts/test/user-client-view.ts @@ -76,8 +76,6 @@ const row: User = { orangecatActorId: null, plan: "free", planStatus: null, - stripeCustomerId: null, - stripeSubscriptionId: null, planExpiresAt: null, privateZonePinHash: "deadbeef.cafe", privateZonePinSetAt: new Date("2026-02-01T00:00:00Z"), diff --git a/src/app/(app)/settings/page.tsx b/src/app/(app)/settings/page.tsx index 4e728374a..d142c5ae0 100644 --- a/src/app/(app)/settings/page.tsx +++ b/src/app/(app)/settings/page.tsx @@ -6,7 +6,6 @@ import { getUserById } from "@/db/queries/users"; import { getUserPreferences } from "@/db/queries/user-preferences"; import { SettingsTabs } from "@/components/settings/SettingsTabs"; import { PageLayout } from "@/components/ui/page-layout"; -import { isStripeReady } from "@/lib/stripe"; import { getEnabledAuthProviders } from "@/lib/auth-providers"; import { getProjectLimit, isUnlimitedProjects } from "@/lib/plan"; import { ROUTES } from "@/config/auth"; @@ -39,8 +38,6 @@ export default async function SettingsPage() { hasPassword: !!user.passwordHash, plan: user.plan, planStatus: user.planStatus ?? null, - stripeReady: isStripeReady(), - hasSubscription: !!user.stripeSubscriptionId, }} userPrefs={ userPrefs ?? { diff --git a/src/app/api/checkout/[plan]/route.ts b/src/app/api/checkout/[plan]/route.ts deleted file mode 100644 index 01cbe7790..000000000 --- a/src/app/api/checkout/[plan]/route.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { getSessionUserId } from "@/lib/session"; -import { stripe, STRIPE_PRICE_IDS, isStripeReady } from "@/lib/stripe"; -import { getUserById, updateUserBilling } from "@/db/queries/users"; -import { ROUTES } from "@/config/auth"; - -const PAID_PLANS = ["personal", "pro", "team"] as const; -type PaidPlan = (typeof PAID_PLANS)[number]; - -function isPaidPlan(value: string): value is PaidPlan { - return (PAID_PLANS as readonly string[]).includes(value); -} - -export async function GET(req: NextRequest, { params }: { params: Promise<{ plan: string }> }) { - const { plan } = await params; - - const userId = await getSessionUserId(); - if (!userId) { - const signInUrl = new URL(ROUTES.SIGN_IN, req.url); - signInUrl.searchParams.set("callbackUrl", `/api/checkout/${plan}`); - return NextResponse.redirect(signInUrl); - } - - if (!isPaidPlan(plan)) { - return NextResponse.redirect(new URL("/settings", req.url)); - } - - if (!isStripeReady() || !stripe) { - return NextResponse.redirect(new URL("/settings?billing=not-configured", req.url)); - } - - const user = await getUserById(userId); - if (!user) return NextResponse.redirect(new URL(ROUTES.SIGN_IN, req.url)); - - // Already on this plan - if (user.plan === plan && user.planStatus === "active") { - return NextResponse.redirect(new URL("/settings?billing=already-active", req.url)); - } - - const priceId = STRIPE_PRICE_IDS[plan].annual; - if (!priceId) { - return NextResponse.redirect(new URL("/settings?billing=not-configured", req.url)); - } - - let customerId = user.stripeCustomerId ?? undefined; - if (!customerId) { - const customer = await stripe.customers.create({ - email: user.email ?? undefined, - name: user.name ?? undefined, - metadata: { fleetcrownUserId: userId }, - }); - customerId = customer.id; - await updateUserBilling(userId, { stripeCustomerId: customerId }); - } - - const origin = new URL(req.url).origin; - - const checkoutSession = await stripe.checkout.sessions.create({ - mode: "subscription", - customer: customerId, - line_items: [{ price: priceId, quantity: 1 }], - success_url: `${origin}/settings?billing=success`, - cancel_url: `${origin}/settings?billing=canceled`, - metadata: { fleetcrownUserId: userId, plan }, - subscription_data: { - metadata: { fleetcrownUserId: userId, plan }, - }, - }); - - if (!checkoutSession.url) { - return NextResponse.redirect(new URL("/settings?billing=error", req.url)); - } - - return NextResponse.redirect(checkoutSession.url); -} diff --git a/src/app/api/stripe/checkout/route.ts b/src/app/api/stripe/checkout/route.ts deleted file mode 100644 index 9cbe1301b..000000000 --- a/src/app/api/stripe/checkout/route.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { stripe, STRIPE_PRICE_IDS, isStripeReady } from "@/lib/stripe"; -import { getSessionUserId } from "@/lib/session"; -import { getUserById, updateUserBilling } from "@/db/queries/users"; -import { readJsonBody, z } from "@/lib/api/route-helpers"; -import { LOCAL_DEV_URL } from "@/config/brand"; - -const CheckoutBody = z.object({ - plan: z.enum(["personal", "pro", "team"] as const), - billing: z.enum(["monthly", "annual"]).default("annual"), -}); - -export async function POST(req: NextRequest) { - if (!isStripeReady() || !stripe) { - return NextResponse.json({ error: "Stripe not configured" }, { status: 503 }); - } - - const userId = await getSessionUserId(); - if (!userId) return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); - - const dataOrResp = await readJsonBody(req, CheckoutBody); - if (dataOrResp instanceof NextResponse) return dataOrResp; - const { plan, billing } = dataOrResp; - - const priceId = STRIPE_PRICE_IDS[plan][billing]; - if (!priceId) { - return NextResponse.json( - { error: `No price configured for ${plan}/${billing}` }, - { status: 503 }, - ); - } - - const user = await getUserById(userId); - if (!user) return NextResponse.json({ error: "User not found" }, { status: 404 }); - - // Retrieve or create Stripe customer - let customerId = user.stripeCustomerId ?? undefined; - if (!customerId) { - const customer = await stripe.customers.create({ - email: user.email ?? undefined, - name: user.name ?? undefined, - metadata: { fleetcrownUserId: userId }, - }); - customerId = customer.id; - await updateUserBilling(userId, { stripeCustomerId: customerId }); - } - - const origin = req.headers.get("origin") ?? process.env.NEXTAUTH_URL ?? LOCAL_DEV_URL; - - const session = await stripe.checkout.sessions.create({ - mode: "subscription", - customer: customerId, - line_items: [{ price: priceId, quantity: 1 }], - success_url: `${origin}/settings?billing=success`, - cancel_url: `${origin}/settings?billing=canceled`, - metadata: { fleetcrownUserId: userId, plan }, - subscription_data: { - metadata: { fleetcrownUserId: userId, plan }, - }, - }); - - return NextResponse.json({ url: session.url }); -} diff --git a/src/app/api/stripe/portal/route.ts b/src/app/api/stripe/portal/route.ts deleted file mode 100644 index c465ffe88..000000000 --- a/src/app/api/stripe/portal/route.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { stripe, isStripeReady } from "@/lib/stripe"; -import { getSessionUserId } from "@/lib/session"; -import { getUserById } from "@/db/queries/users"; -import { LOCAL_DEV_URL } from "@/config/brand"; - -export async function GET(req: NextRequest) { - if (!isStripeReady() || !stripe) { - return NextResponse.json({ error: "Stripe not configured" }, { status: 503 }); - } - - const userId = await getSessionUserId(); - if (!userId) return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); - - const user = await getUserById(userId); - if (!user?.stripeCustomerId) { - return NextResponse.json({ error: "No billing account found" }, { status: 404 }); - } - - const origin = req.headers.get("origin") ?? process.env.NEXTAUTH_URL ?? LOCAL_DEV_URL; - - const session = await stripe.billingPortal.sessions.create({ - customer: user.stripeCustomerId, - return_url: `${origin}/settings`, - }); - - return NextResponse.redirect(session.url); -} diff --git a/src/app/api/stripe/webhook/route.ts b/src/app/api/stripe/webhook/route.ts deleted file mode 100644 index 68778acc2..000000000 --- a/src/app/api/stripe/webhook/route.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { stripe } from "@/lib/stripe"; -import { getUserByStripeCustomerId, updateUserBilling } from "@/db/queries/users"; -import type { Plan, PlanStatus } from "@/db/schema/users"; -import type Stripe from "stripe"; - -export async function POST(req: NextRequest) { - if (!stripe) return NextResponse.json({ error: "Stripe not configured" }, { status: 503 }); - - const body = await req.text(); - const signature = req.headers.get("stripe-signature") ?? ""; - const secret = process.env.STRIPE_WEBHOOK_SECRET ?? ""; - - let event: Stripe.Event; - try { - event = stripe.webhooks.constructEvent(body, signature, secret); - } catch { - return NextResponse.json({ error: "Invalid signature" }, { status: 400 }); - } - - try { - switch (event.type) { - case "checkout.session.completed": { - const session = event.data.object as Stripe.Checkout.Session; - if (session.mode !== "subscription") break; - const customerId = session.customer as string; - const plan = (session.metadata?.plan ?? "personal") as Plan; - const user = await getUserByStripeCustomerId(customerId); - if (user) { - await updateUserBilling(user.id, { - plan, - planStatus: "active", - stripeSubscriptionId: session.subscription as string, - }); - } - break; - } - - case "customer.subscription.updated": { - const sub = event.data.object as Stripe.Subscription; - const customerId = sub.customer as string; - const user = await getUserByStripeCustomerId(customerId); - if (!user) break; - - const rawStatus = sub.status; - const planStatus: PlanStatus | null = - rawStatus === "active" - ? "active" - : rawStatus === "past_due" - ? "past_due" - : rawStatus === "canceled" - ? "canceled" - : null; - - const plan = (sub.metadata?.plan ?? user.plan) as Plan; - await updateUserBilling(user.id, { plan, planStatus, stripeSubscriptionId: sub.id }); - break; - } - - case "customer.subscription.deleted": { - const sub = event.data.object as Stripe.Subscription; - const user = await getUserByStripeCustomerId(sub.customer as string); - if (user) { - await updateUserBilling(user.id, { - plan: "free", - planStatus: "canceled", - stripeSubscriptionId: null, - }); - } - break; - } - - default: - // Unhandled event types are silently ignored - break; - } - } catch (err) { - // Signature is already verified above; the risk here is a DB blip mid-event - // (getUserByStripeCustomerId / updateUserBilling). Don't let it surface as an - // unhandled 500 + stack — return 500 deliberately so Stripe retries this - // idempotent event later, and the user isn't left on a stale plan silently. - console.error("[stripe/webhook] handler failed:", event.type, err); - return NextResponse.json({ error: "handler failed" }, { status: 500 }); - } - - return NextResponse.json({ received: true }); -} diff --git a/src/app/pricing/page.tsx b/src/app/pricing/page.tsx index 6d8d85dc4..625b0cf72 100644 --- a/src/app/pricing/page.tsx +++ b/src/app/pricing/page.tsx @@ -4,7 +4,6 @@ import type { Metadata } from "next"; import { auth } from "@/auth"; import { PublicSurface } from "@/components/public/PublicSurface"; import { PublicHeaderActions } from "@/components/public/PublicHeaderActions"; -import { isStripeReady } from "@/lib/stripe"; import { orangeCatPayUrl } from "@/lib/oc-pay"; import { ROUTES } from "@/config/auth"; import { APP_NAME } from "@/config/brand"; @@ -22,17 +21,19 @@ export const metadata: Metadata = { }; /** - * Public pricing. Honest about billing state: paid CTAs open Stripe checkout - * only when it's configured (isStripeReady); until then every CTA routes to - * a free signup — never a dead "Buy" button. Flips live automatically the - * moment Stripe keys land, with no code change here. + * Public pricing. Honest about billing state: a paid CTA only appears when a + * rail can actually take the money — never a dead "Buy" button. + * + * The rail is Bitcoin via OrangeCat (orangeCatPayUrl), which needs no merchant + * account. A Stripe branch used to sit ahead of it, permanently unreachable: + * isStripeReady() was false in every environment, so every visitor already got + * the path below. Removing it changed no rendered output. */ export default async function PricingPage() { const session = await auth(); const signedIn = Boolean(session?.user); - const stripeReady = isStripeReady(); - // Resolve each plan's CTA target for the current state (signed-in? stripe live?). + // Resolve each plan's CTA target for the current state (signed in? BTC rail live?). function ctaFor(plan: PricingPlan): { href: string; label: string } { if (plan.key === "free") { return signedIn @@ -45,11 +46,8 @@ export default async function PricingPage() { ? { href: ROUTES.APP_HOME, label: `Open ${APP_NAME}` } : { href: ROUTES.SIGN_UP, label: "Start free" }; } - if (stripeReady) { - return { href: `/api/checkout/${plan.key}`, label: plan.cta }; - } - // Stripe blocked on incorporation — but the Bitcoin/OrangeCat rail needs no - // merchant account. If this tier has an OC pass configured, offer it. + // The Bitcoin/OrangeCat rail needs no merchant account. If this tier has + // an OC pass configured, offer it. const btc = orangeCatPayUrl(plan.key); if (btc) { return { href: btc, label: "Pay in Bitcoin" }; diff --git a/src/components/settings/BillingSettings.tsx b/src/components/settings/BillingSettings.tsx index 89b4e2d26..270231c82 100644 --- a/src/components/settings/BillingSettings.tsx +++ b/src/components/settings/BillingSettings.tsx @@ -1,9 +1,5 @@ -"use client"; - -import { useState, useEffect, useRef } from "react"; -import { useSearchParams, useRouter, usePathname } from "next/navigation"; -import { postJson } from "@/lib/api/fetch"; -import { PRICING_PLANS, PRICING_CURRENCY, PRICING_BILLING_NOTE } from "@/config/plans"; +import Link from "next/link"; +import { PRICING_BILLING_NOTE } from "@/config/plans"; import type { Plan } from "@/db/schema/users"; const PLAN_LABEL: Record = { @@ -16,151 +12,47 @@ const PLAN_LABEL: Record = { type Props = { plan: Plan; planStatus: string | null; - stripeReady: boolean; - hasSubscription: boolean; }; -const BILLING_MESSAGES: Record = { - success: { text: "Subscription activated — welcome to the plan!", type: "success" }, - canceled: { text: "Checkout canceled — no charge was made.", type: "info" }, - error: { text: "Something went wrong during checkout. Please try again.", type: "error" }, - "not-configured": { text: "Payment integration is not yet configured.", type: "info" }, - "already-active": { text: "You're already on this plan.", type: "info" }, -}; - -export function BillingSettings({ plan, planStatus, stripeReady, hasSubscription }: Props) { - const searchParams = useSearchParams(); - const router = useRouter(); - const pathname = usePathname(); - const didProcess = useRef(false); - const [loading, setLoading] = useState(null); - const [error, setError] = useState(""); - // The ?billing= outcome is known at mount (we land here from a Stripe - // redirect), so the banner is seeded via the lazy initializer instead of a - // setState inside the effect — the effect below only strips the query param. - const [notice] = useState<{ text: string; type: "success" | "info" | "error" } | null>(() => { - const billingParam = searchParams.get("billing"); - return billingParam ? (BILLING_MESSAGES[billingParam] ?? null) : null; - }); - - useEffect(() => { - if (didProcess.current) return; - if (!searchParams.get("billing")) return; - didProcess.current = true; - // Remove the query param so a page refresh doesn't re-show it - const params = new URLSearchParams(searchParams.toString()); - params.delete("billing"); - const newUrl = params.size > 0 ? `${pathname}?${params}` : pathname; - router.replace(newUrl, { scroll: false }); - }, [pathname, router, searchParams]); - - async function handleUpgrade(targetPlan: "personal" | "pro" | "team") { - setError(""); - setLoading(targetPlan); - try { - const res = await postJson("/api/stripe/checkout", { plan: targetPlan, billing: "annual" }); - const data = await res.json(); - if (!res.ok) { - setError(data.error ?? "Failed to start checkout."); - return; - } - // location.assign() (a method call, not a mutation of a captured value) - // — same navigation, and Stripe Checkout is an external URL. - if (data.url) window.location.assign(data.url); - } catch { - setError("Something went wrong."); - } finally { - setLoading(null); - } - } - - function handleManage() { - window.location.href = "/api/stripe/portal"; - } - +/** + * What plan you are on, and where to change it. + * + * This used to be a Stripe checkout surface: a tier grid, an upgrade handler + * posting to /api/stripe/checkout, a "Manage subscription" button opening the + * billing portal, and — because `isStripeReady()` was false in every + * environment — a permanent notice telling the reader to "add STRIPE_SECRET_KEY + * and price IDs". None of it could ever run, and the one part that DID render + * asked a person who does not deploy the app to set an environment variable. + * + * Stripe is gone (nothing was ever configured, no user row ever held a customer + * id). Plans themselves are real and stay: they are granted through the + * OrangeCat/Bitcoin rail at /api/orangecat/entitlement, with the expiry cron + * reverting a lapsed pass to free. So this section states the plan and points + * at the page that explains the tiers, rather than offering a checkout that + * does not exist. + * + * No "use client": with the handlers gone there is no state, no effect and no + * search-param read left in it. + */ +export function BillingSettings({ plan, planStatus }: Props) { return (
- {notice && ( -

- {notice.text} -

- )} -

Billing

Current plan:{" "} - {PLAN_LABEL[plan]} + {PLAN_LABEL[plan]} {planStatus === "past_due" && ( - · payment past due + · payment past due )}

- {hasSubscription && stripeReady && ( - - )} + + See plans +
- - {!stripeReady && ( -

- Payment integration is not yet configured. Add{" "} - STRIPE_SECRET_KEY and price IDs to - enable subscriptions. -

- )} - - {stripeReady && plan === "free" && ( - <> -
- {/* Tiers with a null price are to-be-announced — not sellable yet. */} - {PRICING_PLANS.filter((tier) => tier.key !== "free" && tier.priceMonthly !== null).map( - (tier) => { - const tierPlan = tier.key as "personal" | "pro" | "team"; - return ( -
-
-

- {tier.name} -

-

- {PRICING_CURRENCY} {tier.priceMonthly} - /mo -

-

{tier.tagline}

-
- -
- ); - }, - )} -
-

{PRICING_BILLING_NOTE}

- - )} - - {error &&

{error}

} +

{PRICING_BILLING_NOTE}

); } diff --git a/src/components/settings/SettingsTabs.tsx b/src/components/settings/SettingsTabs.tsx index ae2851a09..0e1d5077a 100644 --- a/src/components/settings/SettingsTabs.tsx +++ b/src/components/settings/SettingsTabs.tsx @@ -29,8 +29,6 @@ type Props = { hasPassword: boolean; plan: Plan; planStatus: string | null; - stripeReady: boolean; - hasSubscription: boolean; }; userPrefs: UserPreferencesData; projects: UserProject[]; @@ -166,12 +164,7 @@ export function SettingsTabs({ {activeTab === "team" && } {activeTab === "billing" && ( - + )} diff --git a/src/config/demo.ts b/src/config/demo.ts index 47322c1b3..e92191282 100644 --- a/src/config/demo.ts +++ b/src/config/demo.ts @@ -129,7 +129,6 @@ export const DEMO_DENIED_PREFIXES: ReadonlyArray { diff --git a/src/db/queries/revenue.ts b/src/db/queries/revenue.ts index 4c283c5f4..e170421dc 100644 --- a/src/db/queries/revenue.ts +++ b/src/db/queries/revenue.ts @@ -11,7 +11,7 @@ import type { Plan } from "@/db/schema/users"; * If improvement loops are only honest when they touch settled money, the * operator needs one place that sums it. Read-only; founder-scoped in the UI. * - * "Active paid" = any non-free plan whose pass hasn't lapsed. Stripe subs carry + * "Active paid" = any non-free plan whose pass hasn't lapsed. Grants carry * a null expiry (recurring); BTC passes carry a future expiry. The daily * downgrade cron flips lapsed passes back to free, so a non-free row with a * null-or-future expiry is genuinely paying right now. diff --git a/src/db/queries/users.ts b/src/db/queries/users.ts index 69df5503e..98d422fe8 100644 --- a/src/db/queries/users.ts +++ b/src/db/queries/users.ts @@ -86,27 +86,17 @@ export interface UpdateUserInput { export interface UpdateUserBillingInput { plan?: Plan; planStatus?: PlanStatus | null; - stripeCustomerId?: string; - stripeSubscriptionId?: string | null; /** OrangeCat/BTC-rail pass expiry (now + period). Null clears it (e.g. the - * expiry cron reverting to free, or a Stripe sub that manages its own cycle). */ + * expiry cron reverting to free). */ planExpiresAt?: Date | null; } -export async function getUserByStripeCustomerId(stripeCustomerId: string) { - return db.query.users.findFirst({ where: eq(users.stripeCustomerId, stripeCustomerId) }) ?? null; -} - export async function updateUserBilling(id: string, patch: UpdateUserBillingInput) { const [updated] = await db .update(users) .set({ ...(patch.plan !== undefined && { plan: patch.plan }), ...(patch.planStatus !== undefined && { planStatus: patch.planStatus }), - ...(patch.stripeCustomerId !== undefined && { stripeCustomerId: patch.stripeCustomerId }), - ...(patch.stripeSubscriptionId !== undefined && { - stripeSubscriptionId: patch.stripeSubscriptionId, - }), ...(patch.planExpiresAt !== undefined && { planExpiresAt: patch.planExpiresAt }), updatedAt: new Date(), }) diff --git a/src/db/schema/users.ts b/src/db/schema/users.ts index f81e04076..32a5f17f7 100644 --- a/src/db/schema/users.ts +++ b/src/db/schema/users.ts @@ -47,12 +47,10 @@ export const users = pgTable("users", { // Billing plan: text("plan").$type().default("free").notNull(), planStatus: text("plan_status").$type(), - stripeCustomerId: text("stripe_customer_id").unique(), - stripeSubscriptionId: text("stripe_subscription_id").unique(), // OrangeCat/Bitcoin-rail passes are time-boxed (BTC has no native recurring): // the entitlement webhook sets this to now + period, and the // downgrade-expired-plans cron reverts the plan to free once it passes. Null = - // no expiry (free tier, or a Stripe subscription which manages its own cycle). + // no expiry (free tier). planExpiresAt: timestamp("plan_expires_at", { withTimezone: true }), // Private-zone PIN — scrypt hash in `.` format. Null = no PIN // configured for this user; the gate stays open. Each user sets / changes diff --git a/src/lib/oc-pay.ts b/src/lib/oc-pay.ts index 1ddadd299..de845b2b6 100644 --- a/src/lib/oc-pay.ts +++ b/src/lib/oc-pay.ts @@ -5,7 +5,7 @@ import type { Plan } from "@/db/schema/users"; * * Each paid tier maps to an OrangeCat product/pass with a BTC price; the URL is * that pass's OC checkout. Read from env so the "Pay in Bitcoin" CTA lights up - * the moment the OC-side passes exist — no code change (mirrors isStripeReady). + * the moment the OC-side passes exist — no code change. * Null everywhere today because the OC passes aren't created yet. */ export function orangeCatPayUrl(plan: Plan): string | null { diff --git a/src/lib/stripe.ts b/src/lib/stripe.ts deleted file mode 100644 index 9d990ce7f..000000000 --- a/src/lib/stripe.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Stripe from "stripe"; -import type { Plan } from "@/db/schema/users"; - -// Returns null when STRIPE_SECRET_KEY is not set — routes guard against this. -export const stripe: Stripe | null = process.env.STRIPE_SECRET_KEY - ? new Stripe(process.env.STRIPE_SECRET_KEY) - : null; - -export const STRIPE_PRICE_IDS: Record< - Exclude, - { monthly: string; annual: string } -> = { - personal: { - monthly: process.env.STRIPE_PRICE_PERSONAL_MONTHLY ?? "", - annual: process.env.STRIPE_PRICE_PERSONAL_ANNUAL ?? "", - }, - pro: { - monthly: process.env.STRIPE_PRICE_PRO_MONTHLY ?? "", - annual: process.env.STRIPE_PRICE_PRO_ANNUAL ?? "", - }, - team: { - monthly: process.env.STRIPE_PRICE_TEAM_MONTHLY ?? "", - annual: process.env.STRIPE_PRICE_TEAM_ANNUAL ?? "", - }, -}; - -export function isStripeReady(): boolean { - return !!process.env.STRIPE_SECRET_KEY && !!process.env.STRIPE_WEBHOOK_SECRET; -} diff --git a/src/lib/user-client-view.ts b/src/lib/user-client-view.ts index dc886c18f..072094c3a 100644 --- a/src/lib/user-client-view.ts +++ b/src/lib/user-client-view.ts @@ -31,8 +31,6 @@ export const USER_CLIENT_FIELDS = [ "orangecatActorId", "plan", "planStatus", - "stripeCustomerId", - "stripeSubscriptionId", "planExpiresAt", // Not the PIN itself — only whether/when one was set, which Settings shows. "privateZonePinSetAt", @@ -68,10 +66,9 @@ export function toClientUser(user: User): ClientUser { * narrowing of the allow-list, never a second answer to what is secret — that * question has one answer, USER_WITHHELD_FIELDS, and both projections inherit it. */ -export const USER_EXPORT_OMITTED_FIELDS = [ - "stripeCustomerId", - "stripeSubscriptionId", -] as const satisfies ReadonlyArray<(typeof USER_CLIENT_FIELDS)[number]>; +export const USER_EXPORT_OMITTED_FIELDS = [] as const satisfies ReadonlyArray< + (typeof USER_CLIENT_FIELDS)[number] +>; export type ExportUser = Omit; diff --git a/src/proxy.ts b/src/proxy.ts index 2485f1467..479ae66ec 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -51,7 +51,6 @@ export const config = { * trailing slash keeps GET /api/invitations (list) protected * api/share/task/ – the assignee's read + accept/decline/deliver, by token; * the path segment keeps every other /api/share child protected - * api/stripe/webhook – Stripe webhook; verifies its own Stripe-Signature header * api/orangecat/ – OrangeCat webhooks (entitlement, events); each verifies its own HMAC signature * api/solon/ – Solon governance webhooks (decision.finalized); verifies its own HMAC signature * api/newsletter – public email-capture (zod + rate-limited in-handler) @@ -65,6 +64,6 @@ export const config = { * import-from-local\.sh – public bash one-liner users curl-pipe into their terminal * to scan ~/dev and POST detected repos to /api/projects/import-from-local */ - "/((?!_next/static|_next/image|favicon\\.ico|icon\\.svg|manifest\\.json|opengraph-image|twitter-image|robots\\.txt|sitemap\\.xml|rss\\.xml|sign-in|sign-up|forgot-password|reset-password|verify-email|setup|invite|download|whitepaper|thoughts|frontier|mission|philosophy|investors|roadmap|pricing|releases|privacy|terms|license|docs|blog|changelog|support|u/|share/project/|share/task/|beacon|import-from-local\\.sh|api/auth|api/agent/install|api/agent/daemon|api/health|api/setup|api/crons|api/system|api/beacon|api/invitations/|api/share/task/|api/stripe/webhook|api/orangecat/|api/solon/|api/newsletter|api/feedback|api/widget-boot|api/widget/transcribe|widget\\.js).+)", + "/((?!_next/static|_next/image|favicon\\.ico|icon\\.svg|manifest\\.json|opengraph-image|twitter-image|robots\\.txt|sitemap\\.xml|rss\\.xml|sign-in|sign-up|forgot-password|reset-password|verify-email|setup|invite|download|whitepaper|thoughts|frontier|mission|philosophy|investors|roadmap|pricing|releases|privacy|terms|license|docs|blog|changelog|support|u/|share/project/|share/task/|beacon|import-from-local\\.sh|api/auth|api/agent/install|api/agent/daemon|api/health|api/setup|api/crons|api/system|api/beacon|api/invitations/|api/share/task/|api/orangecat/|api/solon/|api/newsletter|api/feedback|api/widget-boot|api/widget/transcribe|widget\\.js).+)", ], };