@bettercms-ai/db 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -22197,11 +22197,11 @@ import {
22197
22197
  boolean as boolean7,
22198
22198
  integer as integer8,
22199
22199
  index as index10,
22200
- uniqueIndex as uniqueIndex3,
22200
+ uniqueIndex as uniqueIndex4,
22201
22201
  unique
22202
22202
  } from "drizzle-orm/pg-core";
22203
22203
  import { relations as relations9 } from "drizzle-orm/relations";
22204
- import { sql as sql5 } from "drizzle-orm";
22204
+ import { sql as sql6 } from "drizzle-orm";
22205
22205
 
22206
22206
  // src/schema/workspaces.ts
22207
22207
  import {
@@ -22321,9 +22321,11 @@ import {
22321
22321
  timestamp as timestamp5,
22322
22322
  jsonb as jsonb5,
22323
22323
  integer as integer4,
22324
- index as index4
22324
+ index as index4,
22325
+ uniqueIndex
22325
22326
  } from "drizzle-orm/pg-core";
22326
22327
  import { relations as relations3 } from "drizzle-orm/relations";
22328
+ import { sql as sql2 } from "drizzle-orm";
22327
22329
 
22328
22330
  // src/schema/content_entries.ts
22329
22331
  import {
@@ -22770,7 +22772,10 @@ var contentModels = pgTable4(
22770
22772
  // Soft-delete filtering
22771
22773
  index4("content_models_deleted_at_idx").on(table.deletedAt),
22772
22774
  // FLO-735: the Collections list filters on `page_id IS NULL` on every project load.
22773
- index4("content_models_page_id_idx").on(table.pageId)
22775
+ index4("content_models_page_id_idx").on(table.pageId),
22776
+ // 0356 + 0371: one Accounts / Proof collection per project PER BRANCH — ensureAbmModels
22777
+ // relies on it for idempotence, and a branch copy needs its own row under the same slug.
22778
+ uniqueIndex("content_models_project_abm_slug_idx").on(table.projectId, table.branchId, table.slug).where(sql2`deleted_at IS NULL AND slug IN ('abm-accounts', 'proof')`)
22774
22779
  ]
22775
22780
  );
22776
22781
  var contentModelsRelations = relations3(contentModels, ({ one, many }) => ({
@@ -22795,10 +22800,10 @@ import {
22795
22800
  real,
22796
22801
  boolean as boolean3,
22797
22802
  index as index6,
22798
- uniqueIndex as uniqueIndex2
22803
+ uniqueIndex as uniqueIndex3
22799
22804
  } from "drizzle-orm/pg-core";
22800
22805
  import { relations as relations5 } from "drizzle-orm/relations";
22801
- import { sql as sql3 } from "drizzle-orm";
22806
+ import { sql as sql4 } from "drizzle-orm";
22802
22807
 
22803
22808
  // src/schema/folders.ts
22804
22809
  import {
@@ -22807,9 +22812,9 @@ import {
22807
22812
  varchar as varchar5,
22808
22813
  timestamp as timestamp6,
22809
22814
  index as index5,
22810
- uniqueIndex
22815
+ uniqueIndex as uniqueIndex2
22811
22816
  } from "drizzle-orm/pg-core";
22812
- import { sql as sql2 } from "drizzle-orm";
22817
+ import { sql as sql3 } from "drizzle-orm";
22813
22818
  import { relations as relations4 } from "drizzle-orm/relations";
22814
22819
  var folders = pgTable5(
22815
22820
  "folders",
@@ -22835,7 +22840,7 @@ var folders = pgTable5(
22835
22840
  // Raw migration 0341 adds NULLS NOT DISTINCT; Drizzle's IndexBuilder cannot express it.
22836
22841
  // Without it this constrained nothing at the ROOT (parent_id IS NULL), where every folder the
22837
22842
  // Assets lane creates lives — so duplicate root folders were creatable through the API.
22838
- uniqueIndex("folders_sibling_name_uq").on(table.projectId, table.parentId, sql2`lower(${table.name})`).where(sql2`${table.deletedAt} IS NULL`)
22843
+ uniqueIndex2("folders_sibling_name_uq").on(table.projectId, table.parentId, sql3`lower(${table.name})`).where(sql3`${table.deletedAt} IS NULL`)
22839
22844
  ]
22840
22845
  );
22841
22846
  var foldersRelations = relations4(folders, ({ one, many }) => ({
@@ -22902,7 +22907,7 @@ var mediaAssets = pgTable6(
22902
22907
  //
22903
22908
  // NOT NULL DEFAULT [] rather than nullable: `tags @> ARRAY[…]` and `unnest(tags)` are both
22904
22909
  // wrong for a NULL, and "no tags" is genuinely an empty list, not an unknown one.
22905
- tags: text7("tags").array().notNull().$type().default(sql3`'{}'::text[]`),
22910
+ tags: text7("tags").array().notNull().$type().default(sql4`'{}'::text[]`),
22906
22911
  folderId: text7("folder_id"),
22907
22912
  // FK → folders.id; NULL = project root
22908
22913
  // The site-relative path a release-lane adoption came from (`/img/hero.png`), NULL for
@@ -22959,7 +22964,7 @@ var mediaAssets = pgTable6(
22959
22964
  // "Bookmarked" rail entry — PARTIAL index (only the starred minority). The
22960
22965
  // .where() must match migration 0157 exactly, or db:generate emits a spurious
22961
22966
  // diff for an index that already exists with a different definition.
22962
- index6("media_assets_bookmarked_idx").on(table.projectId).where(sql3`${table.bookmarked} = true`),
22967
+ index6("media_assets_bookmarked_idx").on(table.projectId).where(sql4`${table.bookmarked} = true`),
22963
22968
  // Tag filtering + the tag facet. GIN's default text[] opclass indexes containment (@>),
22964
22969
  // which is the operator the list route uses — a btree here would index nothing useful.
22965
22970
  index6("media_assets_tags_idx").using("gin", table.tags),
@@ -22967,7 +22972,7 @@ var mediaAssets = pgTable6(
22967
22972
  // up: PARTIAL (uploads are all NULL and must not collide) and UNIQUE, so two releases racing
22968
22973
  // the same path end with one row. Soft-deleted rows keep the key, so an asset the user
22969
22974
  // trashed is not re-adopted while it sits in Trash. Must match migration 0314 exactly.
22970
- uniqueIndex2("media_assets_project_source_path_idx").on(table.projectId, table.sourcePath).where(sql3`${table.sourcePath} IS NOT NULL`)
22975
+ uniqueIndex3("media_assets_project_source_path_idx").on(table.projectId, table.sourcePath).where(sql4`${table.sourcePath} IS NOT NULL`)
22971
22976
  ]
22972
22977
  );
22973
22978
  var mediaAssetsRelations = relations5(mediaAssets, ({ one }) => ({
@@ -23110,7 +23115,7 @@ import {
23110
23115
  index as index8
23111
23116
  } from "drizzle-orm/pg-core";
23112
23117
  import { relations as relations7 } from "drizzle-orm/relations";
23113
- import { sql as sql4 } from "drizzle-orm";
23118
+ import { sql as sql5 } from "drizzle-orm";
23114
23119
  var apiKeys = pgTable8(
23115
23120
  "api_keys",
23116
23121
  {
@@ -23132,7 +23137,7 @@ var apiKeys = pgTable8(
23132
23137
  // SHA-256 of the plaintext key
23133
23138
  keyPrefix: varchar8("key_prefix", { length: 16 }).notNull(),
23134
23139
  // first 12 chars for identification
23135
- permissions: text9("permissions").array().notNull().$type().default(sql4`ARRAY['content:read']`),
23140
+ permissions: text9("permissions").array().notNull().$type().default(sql5`ARRAY['content:read']`),
23136
23141
  tokenType: varchar8("token_type", { length: 20 }).notNull().default("read_only"),
23137
23142
  // Which front door minted this management key (0150): "device" | "authorization_code" |
23138
23143
  // "studio". Load-bearing for the workspace "External agents" switch — it is the ONLY thing
@@ -23613,13 +23618,13 @@ var projects = pgTable10(
23613
23618
  // Unique slug per workspace — partial on deleted_at IS NULL so a soft-deleted
23614
23619
  // project frees its slug (delete then recreate/re-import works). See migration
23615
23620
  // 0051; the create handler's conflict check also excludes soft-deleted rows.
23616
- uniqueIndex3("projects_workspace_slug_idx").on(table.workspaceId, table.slug).where(sql5`${table.deletedAt} IS NULL`),
23621
+ uniqueIndex4("projects_workspace_slug_idx").on(table.workspaceId, table.slug).where(sql6`${table.deletedAt} IS NULL`),
23617
23622
  // Workspace filtering
23618
23623
  index10("projects_workspace_idx").on(table.workspaceId),
23619
23624
  // Archive: every archive-aware list filters on this, so it earns an index like deletedAt.
23620
23625
  index10("projects_archived_at_idx").on(table.archivedAt),
23621
23626
  // Only the purge drain's rows: switch-archived and not yet deleted.
23622
- index10("projects_purge_after_idx").on(table.purgeAfter).where(sql5`${table.purgeAfter} IS NOT NULL AND ${table.deletedAt} IS NULL`)
23627
+ index10("projects_purge_after_idx").on(table.purgeAfter).where(sql6`${table.purgeAfter} IS NOT NULL AND ${table.deletedAt} IS NULL`)
23623
23628
  ]
23624
23629
  );
23625
23630
  var projectFolders = pgTable10("project_folders", {
@@ -23800,7 +23805,7 @@ import {
23800
23805
  varchar as varchar13,
23801
23806
  timestamp as timestamp15,
23802
23807
  index as index13,
23803
- uniqueIndex as uniqueIndex4
23808
+ uniqueIndex as uniqueIndex5
23804
23809
  } from "drizzle-orm/pg-core";
23805
23810
  var workspaceMembers = pgTable14(
23806
23811
  "workspace_members",
@@ -23822,7 +23827,7 @@ var workspaceMembers = pgTable14(
23822
23827
  },
23823
23828
  (table) => [
23824
23829
  // Unique membership: a user can only join a workspace once
23825
- uniqueIndex4("workspace_members_workspace_user_idx").on(
23830
+ uniqueIndex5("workspace_members_workspace_user_idx").on(
23826
23831
  table.workspaceId,
23827
23832
  table.userId
23828
23833
  ),
@@ -23844,7 +23849,7 @@ import {
23844
23849
  jsonb as jsonb10,
23845
23850
  boolean as boolean9,
23846
23851
  index as index14,
23847
- uniqueIndex as uniqueIndex5
23852
+ uniqueIndex as uniqueIndex6
23848
23853
  } from "drizzle-orm/pg-core";
23849
23854
  var workspaceRoles = pgTable15(
23850
23855
  "workspace_roles",
@@ -23867,7 +23872,7 @@ var workspaceRoles = pgTable15(
23867
23872
  updatedAt: timestamp16("updated_at").notNull().defaultNow()
23868
23873
  },
23869
23874
  (table) => [
23870
- uniqueIndex5("workspace_roles_workspace_key_idx").on(
23875
+ uniqueIndex6("workspace_roles_workspace_key_idx").on(
23871
23876
  table.workspaceId,
23872
23877
  table.key
23873
23878
  ),
@@ -23884,7 +23889,7 @@ import {
23884
23889
  boolean as boolean10,
23885
23890
  integer as integer9,
23886
23891
  index as index15,
23887
- uniqueIndex as uniqueIndex6
23892
+ uniqueIndex as uniqueIndex7
23888
23893
  } from "drizzle-orm/pg-core";
23889
23894
  var workflowStages = pgTable16(
23890
23895
  "workflow_stages",
@@ -23911,7 +23916,7 @@ var workflowStages = pgTable16(
23911
23916
  updatedAt: timestamp17("updated_at").notNull().defaultNow()
23912
23917
  },
23913
23918
  (table) => [
23914
- uniqueIndex6("workflow_stages_project_key_idx").on(table.projectId, table.key),
23919
+ uniqueIndex7("workflow_stages_project_key_idx").on(table.projectId, table.key),
23915
23920
  index15("workflow_stages_project_idx").on(table.projectId)
23916
23921
  ]
23917
23922
  );
@@ -23988,7 +23993,7 @@ import {
23988
23993
  text as text20,
23989
23994
  timestamp as timestamp20,
23990
23995
  unique as unique2,
23991
- uniqueIndex as uniqueIndex7,
23996
+ uniqueIndex as uniqueIndex8,
23992
23997
  varchar as varchar16
23993
23998
  } from "drizzle-orm/pg-core";
23994
23999
  var projectLayouts = pgTable19(
@@ -24009,7 +24014,7 @@ var projectLayouts = pgTable19(
24009
24014
  },
24010
24015
  (table) => [
24011
24016
  unique2("project_layouts_id_project_unique").on(table.id, table.projectId),
24012
- uniqueIndex7("project_layouts_project_unique").on(table.projectId),
24017
+ uniqueIndex8("project_layouts_project_unique").on(table.projectId),
24013
24018
  index18("project_layouts_workspace_idx").on(table.workspaceId)
24014
24019
  ]
24015
24020
  );
@@ -24031,14 +24036,14 @@ var projectLayoutVersions = pgTable19(
24031
24036
  foreignColumns: [projectLayouts.id, projectLayouts.projectId],
24032
24037
  name: "project_layout_versions_layout_project_fkey"
24033
24038
  }).onDelete("cascade"),
24034
- uniqueIndex7("project_layout_versions_layout_version_unique").on(table.layoutId, table.version),
24039
+ uniqueIndex8("project_layout_versions_layout_version_unique").on(table.layoutId, table.version),
24035
24040
  index18("project_layout_versions_project_idx").on(table.projectId, table.version)
24036
24041
  ]
24037
24042
  );
24038
24043
 
24039
24044
  // src/schema/page_folders.ts
24040
- import { pgTable as pgTable20, text as text21, varchar as varchar17, boolean as boolean11, index as index19, uniqueIndex as uniqueIndex8 } from "drizzle-orm/pg-core";
24041
- import { relations as relations10, sql as sql6 } from "drizzle-orm";
24045
+ import { pgTable as pgTable20, text as text21, varchar as varchar17, boolean as boolean11, index as index19, uniqueIndex as uniqueIndex9 } from "drizzle-orm/pg-core";
24046
+ import { relations as relations10, sql as sql7 } from "drizzle-orm";
24042
24047
  var pageFolders = pgTable20(
24043
24048
  "page_folders",
24044
24049
  {
@@ -24067,7 +24072,7 @@ var pageFolders = pgTable20(
24067
24072
  (t) => [
24068
24073
  index19("page_folders_project_idx").on(t.projectId),
24069
24074
  index19("page_folders_parent_idx").on(t.parentId),
24070
- uniqueIndex8("page_folders_project_slug_uniq").on(t.projectId, t.branchId, t.slug).where(sql6`deleted_at IS NULL`)
24075
+ uniqueIndex9("page_folders_project_slug_uniq").on(t.projectId, t.branchId, t.slug).where(sql7`deleted_at IS NULL`)
24071
24076
  ]
24072
24077
  );
24073
24078
  var pageFoldersRelations = relations10(pageFolders, ({ many }) => ({
@@ -24244,7 +24249,7 @@ import {
24244
24249
  integer as integer15,
24245
24250
  timestamp as timestamp26,
24246
24251
  index as index24,
24247
- uniqueIndex as uniqueIndex9
24252
+ uniqueIndex as uniqueIndex10
24248
24253
  } from "drizzle-orm/pg-core";
24249
24254
  import { relations as relations11 } from "drizzle-orm/relations";
24250
24255
  var formContacts = pgTable26(
@@ -24265,7 +24270,7 @@ var formContacts = pgTable26(
24265
24270
  },
24266
24271
  (t) => [
24267
24272
  // Dedup: one contact per email per workspace (also serves workspace lookups)
24268
- uniqueIndex9("form_contacts_workspace_email_uq").on(t.workspaceId, t.email),
24273
+ uniqueIndex10("form_contacts_workspace_email_uq").on(t.workspaceId, t.email),
24269
24274
  // Listing newest-first
24270
24275
  index24("form_contacts_workspace_seen_idx").on(t.workspaceId, t.lastSeenAt)
24271
24276
  ]
@@ -24521,7 +24526,7 @@ var auditLogs = pgTable31(
24521
24526
  );
24522
24527
 
24523
24528
  // src/schema/accounts.ts
24524
- import { pgTable as pgTable32, text as text33, timestamp as timestamp31, uniqueIndex as uniqueIndex10 } from "drizzle-orm/pg-core";
24529
+ import { pgTable as pgTable32, text as text33, timestamp as timestamp31, uniqueIndex as uniqueIndex11 } from "drizzle-orm/pg-core";
24525
24530
  var accounts = pgTable32(
24526
24531
  "accounts",
24527
24532
  {
@@ -24542,7 +24547,7 @@ var accounts = pgTable32(
24542
24547
  updatedAt: timestamp31("updated_at").notNull().defaultNow()
24543
24548
  },
24544
24549
  (table) => [
24545
- uniqueIndex10("accounts_user_id_provider_idx").on(table.userId, table.providerId)
24550
+ uniqueIndex11("accounts_user_id_provider_idx").on(table.userId, table.providerId)
24546
24551
  ]
24547
24552
  );
24548
24553
 
@@ -24579,7 +24584,7 @@ import {
24579
24584
  boolean as boolean15,
24580
24585
  timestamp as timestamp33,
24581
24586
  index as index31,
24582
- uniqueIndex as uniqueIndex11
24587
+ uniqueIndex as uniqueIndex12
24583
24588
  } from "drizzle-orm/pg-core";
24584
24589
  var pendingInvites = pgTable34(
24585
24590
  "pending_invites",
@@ -24611,7 +24616,7 @@ var pendingInvites = pgTable34(
24611
24616
  // Fast lookup by workspace (list pending invites)
24612
24617
  index31("pending_invites_workspace_idx").on(table.workspaceId),
24613
24618
  // Unique token for magic-link lookup
24614
- uniqueIndex11("pending_invites_token_idx").on(table.token),
24619
+ uniqueIndex12("pending_invites_token_idx").on(table.token),
24615
24620
  // Expiry cleanup queries
24616
24621
  index31("pending_invites_expires_idx").on(table.expiresAt)
24617
24622
  ]
@@ -24653,7 +24658,7 @@ var twoFactor = pgTable36(
24653
24658
  );
24654
24659
 
24655
24660
  // src/schema/passkeys.ts
24656
- import { pgTable as pgTable37, text as text38, boolean as boolean17, integer as integer18, timestamp as timestamp35, index as index34, uniqueIndex as uniqueIndex12 } from "drizzle-orm/pg-core";
24661
+ import { pgTable as pgTable37, text as text38, boolean as boolean17, integer as integer18, timestamp as timestamp35, index as index34, uniqueIndex as uniqueIndex13 } from "drizzle-orm/pg-core";
24657
24662
  var passkeys = pgTable37(
24658
24663
  "passkey",
24659
24664
  {
@@ -24678,13 +24683,13 @@ var passkeys = pgTable37(
24678
24683
  // what the database actually enforces. A plain index here plus a unique
24679
24684
  // constraint in the migration is exactly the drift that makes a later
24680
24685
  // `db:generate` propose dropping the constraint.
24681
- uniqueIndex12("passkey_credential_id_key").on(table.credentialID)
24686
+ uniqueIndex13("passkey_credential_id_key").on(table.credentialID)
24682
24687
  ]
24683
24688
  );
24684
24689
 
24685
24690
  // src/schema/sso.ts
24686
- import { pgTable as pgTable38, text as text39, boolean as boolean18, timestamp as timestamp36, index as index35, uniqueIndex as uniqueIndex13 } from "drizzle-orm/pg-core";
24687
- import { sql as sql7 } from "drizzle-orm";
24691
+ import { pgTable as pgTable38, text as text39, boolean as boolean18, timestamp as timestamp36, index as index35, uniqueIndex as uniqueIndex14 } from "drizzle-orm/pg-core";
24692
+ import { sql as sql8 } from "drizzle-orm";
24688
24693
  var ssoProviders = pgTable38(
24689
24694
  "sso_provider",
24690
24695
  {
@@ -24706,7 +24711,7 @@ var ssoProviders = pgTable38(
24706
24711
  // UNIQUE because the plugin declares `providerId` unique and generates the provider's
24707
24712
  // redirect URL from it. A plain index here plus a unique constraint in the migration is
24708
24713
  // exactly the drift that makes a later `db:generate` propose dropping the constraint.
24709
- uniqueIndex13("sso_provider_provider_id_key").on(table.providerId),
24714
+ uniqueIndex14("sso_provider_provider_id_key").on(table.providerId),
24710
24715
  // Sign-in resolves a provider by the email's domain, on every SSO login.
24711
24716
  index35("sso_provider_domain_idx").on(table.domain),
24712
24717
  // 🔴 GLOBAL, not partial on domain_verified. Sign-in resolves with
@@ -24714,10 +24719,10 @@ var ssoProviders = pgTable38(
24714
24719
  // an unverified row can be the one lookup returns — a partial index would let any
24715
24720
  // workspace shadow another tenant's verified domain and break their live logins.
24716
24721
  // The cost is squatting, which fails closed at onboarding instead of breaking working auth.
24717
- uniqueIndex13("sso_provider_domain_key").on(table.domain),
24722
+ uniqueIndex14("sso_provider_domain_key").on(table.domain),
24718
24723
  // One provider per workspace, enforced by the database — two concurrent PUTs would
24719
24724
  // otherwise both see "none", both register, and both bind.
24720
- uniqueIndex13("sso_provider_organization_key").on(table.organizationId).where(sql7`"organization_id" IS NOT NULL`),
24725
+ uniqueIndex14("sso_provider_organization_key").on(table.organizationId).where(sql8`"organization_id" IS NOT NULL`),
24721
24726
  // The gated wrapper lists and scopes by workspace on every read.
24722
24727
  index35("sso_provider_organization_idx").on(table.organizationId)
24723
24728
  ]
@@ -24813,7 +24818,7 @@ import {
24813
24818
  jsonb as jsonb23,
24814
24819
  timestamp as timestamp39,
24815
24820
  index as index38,
24816
- uniqueIndex as uniqueIndex14
24821
+ uniqueIndex as uniqueIndex15
24817
24822
  } from "drizzle-orm/pg-core";
24818
24823
  var collectionGrants = pgTable41(
24819
24824
  "collection_grants",
@@ -24832,7 +24837,7 @@ var collectionGrants = pgTable41(
24832
24837
  },
24833
24838
  (table) => [
24834
24839
  // One grant row per user per collection per workspace.
24835
- uniqueIndex14("collection_grants_ws_user_model_idx").on(
24840
+ uniqueIndex15("collection_grants_ws_user_model_idx").on(
24836
24841
  table.workspaceId,
24837
24842
  table.userId,
24838
24843
  table.contentModelId
@@ -24850,7 +24855,7 @@ import {
24850
24855
  boolean as boolean20,
24851
24856
  timestamp as timestamp40,
24852
24857
  index as index39,
24853
- uniqueIndex as uniqueIndex15
24858
+ uniqueIndex as uniqueIndex16
24854
24859
  } from "drizzle-orm/pg-core";
24855
24860
  var projectMembers = pgTable42(
24856
24861
  "project_members",
@@ -24879,7 +24884,7 @@ var projectMembers = pgTable42(
24879
24884
  },
24880
24885
  (table) => [
24881
24886
  // One role per user per project.
24882
- uniqueIndex15("project_members_project_user_idx").on(table.projectId, table.userId),
24887
+ uniqueIndex16("project_members_project_user_idx").on(table.projectId, table.userId),
24883
24888
  // Fast "members of this project" + "projects for this user" lookups.
24884
24889
  index39("project_members_project_idx").on(table.projectId),
24885
24890
  index39("project_members_user_idx").on(table.workspaceId, table.userId),
@@ -24896,10 +24901,10 @@ import {
24896
24901
  pgTable as pgTable43,
24897
24902
  text as text44,
24898
24903
  timestamp as timestamp41,
24899
- uniqueIndex as uniqueIndex16,
24904
+ uniqueIndex as uniqueIndex17,
24900
24905
  varchar as varchar27
24901
24906
  } from "drizzle-orm/pg-core";
24902
- import { sql as sql8 } from "drizzle-orm";
24907
+ import { sql as sql9 } from "drizzle-orm";
24903
24908
  var SUGGESTION_KINDS = ["chat", "pass", "link"];
24904
24909
  var projectSuggestions = pgTable43(
24905
24910
  "project_suggestions",
@@ -24932,12 +24937,12 @@ var projectSuggestions = pgTable43(
24932
24937
  (table) => [
24933
24938
  // One live suggestion per rule per project. Partial, so dismissing does not bar the rule
24934
24939
  // from firing again later.
24935
- uniqueIndex16("project_suggestions_live_uidx").on(table.projectId, table.ruleId).where(sql8`${table.dismissedAt} IS NULL`),
24940
+ uniqueIndex17("project_suggestions_live_uidx").on(table.projectId, table.ruleId).where(sql9`${table.dismissedAt} IS NULL`),
24936
24941
  // The read path: active suggestions for one project, best first.
24937
- index40("project_suggestions_project_rank_idx").on(table.projectId, table.rank).where(sql8`${table.dismissedAt} IS NULL`),
24942
+ index40("project_suggestions_project_rank_idx").on(table.projectId, table.rank).where(sql9`${table.dismissedAt} IS NULL`),
24938
24943
  check(
24939
24944
  "project_suggestions_kind_check",
24940
- sql8`${table.kind} IN ('chat','pass','link')`
24945
+ sql9`${table.kind} IN ('chat','pass','link')`
24941
24946
  )
24942
24947
  ]
24943
24948
  );
@@ -24951,7 +24956,7 @@ import {
24951
24956
  integer as integer20,
24952
24957
  boolean as boolean21,
24953
24958
  index as index41,
24954
- uniqueIndex as uniqueIndex17
24959
+ uniqueIndex as uniqueIndex18
24955
24960
  } from "drizzle-orm/pg-core";
24956
24961
  var deviceAuthorizations = pgTable44(
24957
24962
  "device_authorizations",
@@ -25026,8 +25031,8 @@ var deviceAuthorizations = pgTable44(
25026
25031
  createdAt: timestamp42("created_at").notNull().defaultNow()
25027
25032
  },
25028
25033
  (table) => [
25029
- uniqueIndex17("device_authorizations_device_code_hash_idx").on(table.deviceCodeHash),
25030
- uniqueIndex17("device_authorizations_user_code_idx").on(table.userCode),
25034
+ uniqueIndex18("device_authorizations_device_code_hash_idx").on(table.deviceCodeHash),
25035
+ uniqueIndex18("device_authorizations_user_code_idx").on(table.userCode),
25031
25036
  index41("device_authorizations_refresh_token_hash_idx").on(table.refreshTokenHash),
25032
25037
  index41("device_authorizations_prev_refresh_token_hash_idx").on(table.previousRefreshTokenHash),
25033
25038
  index41("device_authorizations_workspace_idx").on(table.workspaceId)
@@ -25261,7 +25266,7 @@ var githubInstallations = pgTable49("github_installations", {
25261
25266
  });
25262
25267
 
25263
25268
  // src/schema/custom_domains.ts
25264
- import { pgTable as pgTable50, text as text51, varchar as varchar34, boolean as boolean23, timestamp as timestamp46, index as index44, uniqueIndex as uniqueIndex18, jsonb as jsonb26 } from "drizzle-orm/pg-core";
25269
+ import { pgTable as pgTable50, text as text51, varchar as varchar34, boolean as boolean23, timestamp as timestamp46, index as index44, uniqueIndex as uniqueIndex19, jsonb as jsonb26 } from "drizzle-orm/pg-core";
25265
25270
  var customDomains = pgTable50(
25266
25271
  "custom_domains",
25267
25272
  {
@@ -25303,7 +25308,7 @@ var customDomains = pgTable50(
25303
25308
  ...auditColumns
25304
25309
  },
25305
25310
  (t) => [
25306
- uniqueIndex18("custom_domains_hostname_unique").on(t.hostname),
25311
+ uniqueIndex19("custom_domains_hostname_unique").on(t.hostname),
25307
25312
  index44("custom_domains_project_idx").on(t.projectId),
25308
25313
  // Mirrors the partial unique index from 0237. Drizzle cannot express the WHERE clause
25309
25314
  // here, so the DB is the source of truth for the constraint; this is the read hint.
@@ -25312,8 +25317,8 @@ var customDomains = pgTable50(
25312
25317
  );
25313
25318
 
25314
25319
  // src/schema/storage_configs.ts
25315
- import { pgTable as pgTable51, text as text52, varchar as varchar35, boolean as boolean24, timestamp as timestamp47, uniqueIndex as uniqueIndex19, index as index45 } from "drizzle-orm/pg-core";
25316
- import { sql as sql9 } from "drizzle-orm";
25320
+ import { pgTable as pgTable51, text as text52, varchar as varchar35, boolean as boolean24, timestamp as timestamp47, uniqueIndex as uniqueIndex20, index as index45 } from "drizzle-orm/pg-core";
25321
+ import { sql as sql10 } from "drizzle-orm";
25317
25322
  var storageConfigs = pgTable51(
25318
25323
  "storage_configs",
25319
25324
  {
@@ -25349,7 +25354,7 @@ var storageConfigs = pgTable51(
25349
25354
  index45("storage_configs_project_idx").on(t.projectId),
25350
25355
  index45("storage_configs_workspace_idx").on(t.workspaceId),
25351
25356
  // At most one active config per project.
25352
- uniqueIndex19("storage_configs_active_project_unique").on(t.projectId).where(sql9`deleted_at IS NULL`)
25357
+ uniqueIndex20("storage_configs_active_project_unique").on(t.projectId).where(sql10`deleted_at IS NULL`)
25353
25358
  ]
25354
25359
  );
25355
25360
 
@@ -25497,8 +25502,8 @@ var publishDeliveries = pgTable53(
25497
25502
  );
25498
25503
 
25499
25504
  // src/schema/hosting_connections.ts
25500
- import { pgTable as pgTable54, text as text55, varchar as varchar38, timestamp as timestamp50, index as index48, uniqueIndex as uniqueIndex20 } from "drizzle-orm/pg-core";
25501
- import { sql as sql10 } from "drizzle-orm";
25505
+ import { pgTable as pgTable54, text as text55, varchar as varchar38, timestamp as timestamp50, index as index48, uniqueIndex as uniqueIndex21 } from "drizzle-orm/pg-core";
25506
+ import { sql as sql11 } from "drizzle-orm";
25502
25507
  var hostingConnections = pgTable54(
25503
25508
  "hosting_connections",
25504
25509
  {
@@ -25536,13 +25541,13 @@ var hostingConnections = pgTable54(
25536
25541
  (t) => [
25537
25542
  index48("hosting_connections_workspace_idx").on(t.workspaceId),
25538
25543
  // Reconnecting the same account UPDATEs rather than accumulating a second live credential.
25539
- uniqueIndex20("hosting_connections_account_unique").on(t.workspaceId, t.provider, t.accountId).where(sql10`deleted_at IS NULL`)
25544
+ uniqueIndex21("hosting_connections_account_unique").on(t.workspaceId, t.provider, t.accountId).where(sql11`deleted_at IS NULL`)
25540
25545
  ]
25541
25546
  );
25542
25547
 
25543
25548
  // src/schema/external_deployments.ts
25544
- import { pgTable as pgTable55, text as text56, varchar as varchar39, integer as integer23, timestamp as timestamp51, index as index49, uniqueIndex as uniqueIndex21 } from "drizzle-orm/pg-core";
25545
- import { sql as sql11 } from "drizzle-orm";
25549
+ import { pgTable as pgTable55, text as text56, varchar as varchar39, integer as integer23, timestamp as timestamp51, index as index49, uniqueIndex as uniqueIndex22 } from "drizzle-orm/pg-core";
25550
+ import { sql as sql12 } from "drizzle-orm";
25546
25551
  var externalDeployments = pgTable55(
25547
25552
  "external_deployments",
25548
25553
  {
@@ -25578,7 +25583,7 @@ var externalDeployments = pgTable55(
25578
25583
  updatedAt: timestamp51("updated_at").notNull().defaultNow()
25579
25584
  },
25580
25585
  (t) => [
25581
- index49("external_deployments_claim_idx").on(t.state, t.createdAt).where(sql11`state IN ('queued', 'deploying')`),
25586
+ index49("external_deployments_claim_idx").on(t.state, t.createdAt).where(sql12`state IN ('queued', 'deploying')`),
25582
25587
  index49("external_deployments_workspace_idx").on(t.workspaceId),
25583
25588
  index49("external_deployments_project_idx").on(t.projectId, t.createdAt.desc()),
25584
25589
  /**
@@ -25588,12 +25593,12 @@ var externalDeployments = pgTable55(
25588
25593
  * Git-mode rows have sha NULL and are therefore NOT covered — NULLs never conflict — which is
25589
25594
  * correct: a git deploy carries no artifact identity, so two publishes are two real builds.
25590
25595
  */
25591
- uniqueIndex21("external_deployments_inflight_unique").on(t.targetId, t.sha).where(sql11`state IN ('queued', 'deploying')`)
25596
+ uniqueIndex22("external_deployments_inflight_unique").on(t.targetId, t.sha).where(sql12`state IN ('queued', 'deploying')`)
25592
25597
  ]
25593
25598
  );
25594
25599
 
25595
25600
  // src/schema/page_types.ts
25596
- import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as jsonb27, index as index50, uniqueIndex as uniqueIndex22 } from "drizzle-orm/pg-core";
25601
+ import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as jsonb27, index as index50, uniqueIndex as uniqueIndex23 } from "drizzle-orm/pg-core";
25597
25602
  var pageTypes = pgTable56(
25598
25603
  "page_types",
25599
25604
  {
@@ -25613,12 +25618,12 @@ var pageTypes = pgTable56(
25613
25618
  (t) => [
25614
25619
  index50("page_types_project_idx").on(t.projectId),
25615
25620
  index50("page_types_workspace_idx").on(t.workspaceId),
25616
- uniqueIndex22("page_types_project_slug_unique").on(t.projectId, t.branchId, t.slug)
25621
+ uniqueIndex23("page_types_project_slug_unique").on(t.projectId, t.branchId, t.slug)
25617
25622
  ]
25618
25623
  );
25619
25624
 
25620
25625
  // src/schema/build_triggers.ts
25621
- import { pgTable as pgTable57, text as text58, varchar as varchar41, boolean as boolean26, timestamp as timestamp53, integer as integer24, jsonb as jsonb28, index as index51, uniqueIndex as uniqueIndex23 } from "drizzle-orm/pg-core";
25626
+ import { pgTable as pgTable57, text as text58, varchar as varchar41, boolean as boolean26, timestamp as timestamp53, integer as integer24, jsonb as jsonb28, index as index51, uniqueIndex as uniqueIndex24 } from "drizzle-orm/pg-core";
25622
25627
  var BUILD_TRIGGER_KINDS = ["webhook", "content", "schedule"];
25623
25628
  var buildTriggers = pgTable57(
25624
25629
  "build_triggers",
@@ -25653,7 +25658,7 @@ var buildTriggers = pgTable57(
25653
25658
  (t) => [
25654
25659
  index51("build_triggers_project_idx").on(t.projectId),
25655
25660
  index51("build_triggers_workspace_idx").on(t.workspaceId),
25656
- uniqueIndex23("build_triggers_project_name_unique").on(t.projectId, t.name)
25661
+ uniqueIndex24("build_triggers_project_name_unique").on(t.projectId, t.name)
25657
25662
  ]
25658
25663
  );
25659
25664
  var buildTriggerRuns = pgTable57(
@@ -25716,7 +25721,7 @@ var generatedTypes = pgTable59("generated_types", {
25716
25721
  });
25717
25722
 
25718
25723
  // src/schema/agent_keys.ts
25719
- import { pgTable as pgTable60, text as text61, uniqueIndex as uniqueIndex24 } from "drizzle-orm/pg-core";
25724
+ import { pgTable as pgTable60, text as text61, uniqueIndex as uniqueIndex25 } from "drizzle-orm/pg-core";
25720
25725
  var agentKeys = pgTable60(
25721
25726
  "agent_keys",
25722
25727
  {
@@ -25728,11 +25733,11 @@ var agentKeys = pgTable60(
25728
25733
  // AES-256-GCM encrypted
25729
25734
  ...auditColumns
25730
25735
  },
25731
- (t) => [uniqueIndex24("agent_keys_workspace_unique").on(t.workspaceId)]
25736
+ (t) => [uniqueIndex25("agent_keys_workspace_unique").on(t.workspaceId)]
25732
25737
  );
25733
25738
 
25734
25739
  // src/schema/ai_provider_keys.ts
25735
- import { pgTable as pgTable61, text as text62, varchar as varchar44, uniqueIndex as uniqueIndex25 } from "drizzle-orm/pg-core";
25740
+ import { pgTable as pgTable61, text as text62, varchar as varchar44, uniqueIndex as uniqueIndex26 } from "drizzle-orm/pg-core";
25736
25741
  var aiProviderKeys = pgTable61(
25737
25742
  "ai_provider_keys",
25738
25743
  {
@@ -25746,7 +25751,7 @@ var aiProviderKeys = pgTable61(
25746
25751
  keyHint: varchar44("key_hint", { length: 8 }).notNull(),
25747
25752
  ...auditColumns
25748
25753
  },
25749
- (t) => [uniqueIndex25("ai_provider_keys_workspace_provider_key").on(t.workspaceId, t.provider)]
25754
+ (t) => [uniqueIndex26("ai_provider_keys_workspace_provider_key").on(t.workspaceId, t.provider)]
25750
25755
  );
25751
25756
 
25752
25757
  // src/schema/agent_sessions.ts
@@ -25800,7 +25805,7 @@ var agentMessages = pgTable62(
25800
25805
 
25801
25806
  // src/schema/agent_instructions.ts
25802
25807
  import { pgTable as pgTable63, text as text64, varchar as varchar46, boolean as boolean27, jsonb as jsonb30, timestamp as timestamp57, index as index53, check as check2 } from "drizzle-orm/pg-core";
25803
- import { sql as sql12 } from "drizzle-orm";
25808
+ import { sql as sql13 } from "drizzle-orm";
25804
25809
  var INSTRUCTION_KINDS = ["skill", "rule"];
25805
25810
  var INSTRUCTION_SOURCES = ["template", "manual", "import"];
25806
25811
  var INSTRUCTION_BODY_MAX = 8e3;
@@ -25835,9 +25840,9 @@ var agentInstructions = pgTable63(
25835
25840
  // creates the table from THIS file, after which 0167's `CREATE TABLE IF NOT EXISTS` no-ops —
25836
25841
  // so the CHECKs defined only in the SQL would never exist in a dev database. Names match 0167
25837
25842
  // exactly; a mismatch would have push and setup-db each try to own the constraint.
25838
- check2("agent_instructions_kind_check", sql12`${table.kind} IN ('skill', 'rule')`),
25839
- check2("agent_instructions_source_check", sql12`${table.source} IN ('template', 'manual', 'import')`),
25840
- check2("agent_instructions_body_len_check", sql12`char_length(${table.body}) <= 8000`)
25843
+ check2("agent_instructions_kind_check", sql13`${table.kind} IN ('skill', 'rule')`),
25844
+ check2("agent_instructions_source_check", sql13`${table.source} IN ('template', 'manual', 'import')`),
25845
+ check2("agent_instructions_body_len_check", sql13`char_length(${table.body}) <= 8000`)
25841
25846
  ]
25842
25847
  );
25843
25848
 
@@ -25851,10 +25856,10 @@ import {
25851
25856
  pgTable as pgTable64,
25852
25857
  text as text65,
25853
25858
  timestamp as timestamp58,
25854
- uniqueIndex as uniqueIndex26,
25859
+ uniqueIndex as uniqueIndex27,
25855
25860
  varchar as varchar47
25856
25861
  } from "drizzle-orm/pg-core";
25857
- import { sql as sql13 } from "drizzle-orm";
25862
+ import { sql as sql14 } from "drizzle-orm";
25858
25863
  var CUSTOM_AGENT_INSTRUCTIONS_MAX = 8e3;
25859
25864
  var CUSTOM_AGENT_CAPABILITIES = [
25860
25865
  "content-read",
@@ -25881,11 +25886,11 @@ var customAgents = pgTable64(
25881
25886
  archivedAt: timestamp58("archived_at", { withTimezone: true })
25882
25887
  },
25883
25888
  (table) => [
25884
- uniqueIndex26("custom_agents_workspace_slug_unique").on(table.workspaceId, table.slug),
25889
+ uniqueIndex27("custom_agents_workspace_slug_unique").on(table.workspaceId, table.slug),
25885
25890
  index54("custom_agents_workspace_status_idx").on(table.workspaceId, table.status, table.updatedAt),
25886
25891
  index54("custom_agents_project_status_idx").on(table.projectId, table.status, table.updatedAt),
25887
- check3("custom_agents_status_check", sql13`${table.status} IN ('active', 'archived')`),
25888
- check3("custom_agents_version_check", sql13`${table.optimisticVersion} > 0`)
25892
+ check3("custom_agents_status_check", sql14`${table.status} IN ('active', 'archived')`),
25893
+ check3("custom_agents_version_check", sql14`${table.optimisticVersion} > 0`)
25889
25894
  ]
25890
25895
  );
25891
25896
  var customAgentRevisions = pgTable64(
@@ -25905,16 +25910,16 @@ var customAgentRevisions = pgTable64(
25905
25910
  createdAt: timestamp58("created_at", { withTimezone: true }).notNull().defaultNow()
25906
25911
  },
25907
25912
  (table) => [
25908
- uniqueIndex26("custom_agent_revisions_agent_version_unique").on(table.agentId, table.version),
25913
+ uniqueIndex27("custom_agent_revisions_agent_version_unique").on(table.agentId, table.version),
25909
25914
  index54("custom_agent_revisions_workspace_agent_idx").on(table.workspaceId, table.agentId),
25910
- check3("custom_agent_revisions_version_check", sql13`${table.version} > 0`),
25911
- check3("custom_agent_revisions_speed_check", sql13`${table.speed} IN ('lite', 'balanced', 'max')`),
25912
- check3("custom_agent_revisions_review_check", sql13`${table.reviewPolicy} = 'draft_only'`),
25915
+ check3("custom_agent_revisions_version_check", sql14`${table.version} > 0`),
25916
+ check3("custom_agent_revisions_speed_check", sql14`${table.speed} IN ('lite', 'balanced', 'max')`),
25917
+ check3("custom_agent_revisions_review_check", sql14`${table.reviewPolicy} = 'draft_only'`),
25913
25918
  check3(
25914
25919
  "custom_agent_revisions_instructions_len_check",
25915
- sql13`char_length(${table.instructions}) BETWEEN 1 AND 8000`
25920
+ sql14`char_length(${table.instructions}) BETWEEN 1 AND 8000`
25916
25921
  ),
25917
- check3("custom_agent_revisions_capabilities_array_check", sql13`jsonb_typeof(${table.capabilities}) = 'array'`)
25922
+ check3("custom_agent_revisions_capabilities_array_check", sql14`jsonb_typeof(${table.capabilities}) = 'array'`)
25918
25923
  ]
25919
25924
  );
25920
25925
  var customAgentRuns = pgTable64(
@@ -25944,17 +25949,17 @@ var customAgentRuns = pgTable64(
25944
25949
  updatedAt: timestamp58("updated_at", { withTimezone: true }).notNull().defaultNow()
25945
25950
  },
25946
25951
  (table) => [
25947
- uniqueIndex26("custom_agent_runs_agent_idempotency_unique").on(table.agentId, table.idempotencyKey),
25952
+ uniqueIndex27("custom_agent_runs_agent_idempotency_unique").on(table.agentId, table.idempotencyKey),
25948
25953
  index54("custom_agent_runs_agent_created_idx").on(table.agentId, table.createdAt),
25949
25954
  index54("custom_agent_runs_workspace_status_idx").on(table.workspaceId, table.status, table.createdAt),
25950
25955
  index54("custom_agent_runs_project_status_idx").on(table.projectId, table.status, table.createdAt),
25951
- check3("custom_agent_runs_trigger_check", sql13`${table.trigger} = 'manual'`),
25952
- check3("custom_agent_runs_speed_check", sql13`${table.effectiveSpeed} IN ('lite', 'balanced', 'max')`),
25956
+ check3("custom_agent_runs_trigger_check", sql14`${table.trigger} = 'manual'`),
25957
+ check3("custom_agent_runs_speed_check", sql14`${table.effectiveSpeed} IN ('lite', 'balanced', 'max')`),
25953
25958
  check3(
25954
25959
  "custom_agent_runs_status_check",
25955
- sql13`${table.status} IN ('queued', 'running', 'stopping', 'completed', 'failed', 'stopped')`
25960
+ sql14`${table.status} IN ('queued', 'running', 'stopping', 'completed', 'failed', 'stopped')`
25956
25961
  ),
25957
- check3("custom_agent_runs_credits_check", sql13`${table.creditsQuoted} >= 0 AND ${table.creditsCharged} >= 0`)
25962
+ check3("custom_agent_runs_credits_check", sql14`${table.creditsQuoted} >= 0 AND ${table.creditsCharged} >= 0`)
25958
25963
  ]
25959
25964
  );
25960
25965
 
@@ -26096,8 +26101,8 @@ var abmShareTokens = pgTable68(
26096
26101
  );
26097
26102
 
26098
26103
  // src/schema/mcp_tasks.ts
26099
- import { check as check4, index as index58, integer as integer30, jsonb as jsonb34, pgTable as pgTable69, text as text70, timestamp as timestamp63, uniqueIndex as uniqueIndex27, varchar as varchar51 } from "drizzle-orm/pg-core";
26100
- import { sql as sql14 } from "drizzle-orm";
26104
+ import { check as check4, index as index58, integer as integer30, jsonb as jsonb34, pgTable as pgTable69, text as text70, timestamp as timestamp63, uniqueIndex as uniqueIndex28, varchar as varchar51 } from "drizzle-orm/pg-core";
26105
+ import { sql as sql15 } from "drizzle-orm";
26101
26106
  var MCP_TASK_STATUSES = [
26102
26107
  "working",
26103
26108
  "input_required",
@@ -26127,7 +26132,7 @@ var mcpTasks = pgTable69(
26127
26132
  updatedAt: timestamp63("updated_at").notNull().defaultNow()
26128
26133
  },
26129
26134
  (table) => [
26130
- uniqueIndex27("mcp_tasks_ai_job_uidx").on(table.aiJobId).where(sql14`${table.aiJobId} IS NOT NULL`),
26135
+ uniqueIndex28("mcp_tasks_ai_job_uidx").on(table.aiJobId).where(sql15`${table.aiJobId} IS NOT NULL`),
26131
26136
  index58("mcp_tasks_principal_idx").on(
26132
26137
  table.workspaceId,
26133
26138
  table.projectId,
@@ -26136,14 +26141,14 @@ var mcpTasks = pgTable69(
26136
26141
  table.createdAt
26137
26142
  ),
26138
26143
  index58("mcp_tasks_status_idx").on(table.workspaceId, table.status, table.updatedAt),
26139
- check4("mcp_tasks_status_check", sql14`${table.status} IN ('working','input_required','completed','failed','cancelled')`),
26140
- check4("mcp_tasks_principal_kind_check", sql14`${table.principalKind} IN ('api_key','device')`),
26141
- check4("mcp_tasks_ai_job_handle_check", sql14`${table.aiJobId} IS NULL OR ${table.aiJobId} = ${table.id}`),
26142
- check4("mcp_tasks_terminal_shape_check", sql14`
26144
+ check4("mcp_tasks_status_check", sql15`${table.status} IN ('working','input_required','completed','failed','cancelled')`),
26145
+ check4("mcp_tasks_principal_kind_check", sql15`${table.principalKind} IN ('api_key','device')`),
26146
+ check4("mcp_tasks_ai_job_handle_check", sql15`${table.aiJobId} IS NULL OR ${table.aiJobId} = ${table.id}`),
26147
+ check4("mcp_tasks_terminal_shape_check", sql15`
26143
26148
  (${table.status} IN ('completed','failed','cancelled') AND ${table.terminalAt} IS NOT NULL AND ${table.finalResult} IS NOT NULL)
26144
26149
  OR (${table.status} IN ('working','input_required') AND ${table.terminalAt} IS NULL AND ${table.finalResult} IS NULL)
26145
26150
  `),
26146
- check4("mcp_tasks_terminal_payload_check", sql14`
26151
+ check4("mcp_tasks_terminal_payload_check", sql15`
26147
26152
  (${table.status} IN ('completed','cancelled')
26148
26153
  AND ${table.finalResult}->>'resultType' = 'complete'
26149
26154
  AND jsonb_typeof(${table.finalResult}->'content') = 'array')
@@ -26152,13 +26157,13 @@ var mcpTasks = pgTable69(
26152
26157
  AND jsonb_typeof(${table.finalResult}->'message') = 'string')
26153
26158
  OR (${table.status} IN ('working','input_required') AND ${table.finalResult} IS NULL)
26154
26159
  `),
26155
- check4("mcp_tasks_ttl_check", sql14`${table.ttlMs} IS NULL OR ${table.ttlMs} > 0`),
26156
- check4("mcp_tasks_poll_interval_check", sql14`${table.pollIntervalMs} > 0`)
26160
+ check4("mcp_tasks_ttl_check", sql15`${table.ttlMs} IS NULL OR ${table.ttlMs} > 0`),
26161
+ check4("mcp_tasks_poll_interval_check", sql15`${table.pollIntervalMs} > 0`)
26157
26162
  ]
26158
26163
  );
26159
26164
 
26160
26165
  // src/schema/seo_reports.ts
26161
- import { pgTable as pgTable70, text as text71, date, jsonb as jsonb35, timestamp as timestamp64, uniqueIndex as uniqueIndex28, index as index59 } from "drizzle-orm/pg-core";
26166
+ import { pgTable as pgTable70, text as text71, date, jsonb as jsonb35, timestamp as timestamp64, uniqueIndex as uniqueIndex29, index as index59 } from "drizzle-orm/pg-core";
26162
26167
  var seoReports = pgTable70(
26163
26168
  "seo_reports",
26164
26169
  {
@@ -26174,7 +26179,7 @@ var seoReports = pgTable70(
26174
26179
  },
26175
26180
  (t) => [
26176
26181
  // Idempotency guard: one report per period (matches the per-minute cron).
26177
- uniqueIndex28("seo_reports_project_period_idx").on(t.projectId, t.periodStart, t.periodEnd),
26182
+ uniqueIndex29("seo_reports_project_period_idx").on(t.projectId, t.periodStart, t.periodEnd),
26178
26183
  index59("seo_reports_project_created_idx").on(t.projectId, t.createdAt)
26179
26184
  ]
26180
26185
  );
@@ -26285,10 +26290,10 @@ import {
26285
26290
  bigint as bigint3,
26286
26291
  smallint,
26287
26292
  index as index64,
26288
- uniqueIndex as uniqueIndex29,
26293
+ uniqueIndex as uniqueIndex30,
26289
26294
  primaryKey as primaryKey4
26290
26295
  } from "drizzle-orm/pg-core";
26291
- import { sql as sql15 } from "drizzle-orm";
26296
+ import { sql as sql16 } from "drizzle-orm";
26292
26297
  var analyticsEventsRaw = pgTable75(
26293
26298
  "analytics_events_raw",
26294
26299
  {
@@ -26323,7 +26328,7 @@ var analyticsEventsRaw = pgTable75(
26323
26328
  index64("analytics_events_raw_project_ts_idx").on(t.projectId, t.ts),
26324
26329
  index64("analytics_events_raw_ts_idx").on(t.ts),
26325
26330
  // Partial, so the nginx path (event_id NULL) is unconstrained and unchanged.
26326
- uniqueIndex29("analytics_events_raw_event_id_uidx").on(t.eventId).where(sql15`${t.eventId} IS NOT NULL`)
26331
+ uniqueIndex30("analytics_events_raw_event_id_uidx").on(t.eventId).where(sql16`${t.eventId} IS NOT NULL`)
26327
26332
  ]
26328
26333
  );
26329
26334
  var analyticsDailyTotals = pgTable75(
@@ -26400,7 +26405,7 @@ var analyticsCursor = pgTable75("analytics_cursor", {
26400
26405
  });
26401
26406
 
26402
26407
  // src/schema/site_files.ts
26403
- import { pgTable as pgTable76, text as text77, varchar as varchar56, integer as integer34, timestamp as timestamp70, uniqueIndex as uniqueIndex30 } from "drizzle-orm/pg-core";
26408
+ import { pgTable as pgTable76, text as text77, varchar as varchar56, integer as integer34, timestamp as timestamp70, uniqueIndex as uniqueIndex31 } from "drizzle-orm/pg-core";
26404
26409
  var SITE_FILE_KINDS = ["llms.txt", "llms-full.txt"];
26405
26410
  var siteFiles = pgTable76(
26406
26411
  "site_files",
@@ -26418,7 +26423,7 @@ var siteFiles = pgTable76(
26418
26423
  createdAt: timestamp70("created_at").notNull().defaultNow(),
26419
26424
  updatedAt: timestamp70("updated_at").notNull().defaultNow()
26420
26425
  },
26421
- (t) => [uniqueIndex30("site_files_project_kind_idx").on(t.projectId, t.kind)]
26426
+ (t) => [uniqueIndex31("site_files_project_kind_idx").on(t.projectId, t.kind)]
26422
26427
  );
26423
26428
 
26424
26429
  // src/schema/indexnow_submissions.ts
@@ -26502,7 +26507,7 @@ var webhookDeliveries = pgTable79(
26502
26507
  );
26503
26508
 
26504
26509
  // src/schema/markdown_files.ts
26505
- import { pgTable as pgTable80, text as text81, varchar as varchar59, timestamp as timestamp74, uniqueIndex as uniqueIndex31 } from "drizzle-orm/pg-core";
26510
+ import { pgTable as pgTable80, text as text81, varchar as varchar59, timestamp as timestamp74, uniqueIndex as uniqueIndex32 } from "drizzle-orm/pg-core";
26506
26511
  var MARKDOWN_FILE_STATUSES = ["draft", "published"];
26507
26512
  var markdownFiles = pgTable80(
26508
26513
  "markdown_files",
@@ -26521,7 +26526,7 @@ var markdownFiles = pgTable80(
26521
26526
  createdAt: timestamp74("created_at").notNull().defaultNow(),
26522
26527
  updatedAt: timestamp74("updated_at").notNull().defaultNow()
26523
26528
  },
26524
- (t) => [uniqueIndex31("markdown_files_project_path_idx").on(t.projectId, t.path)]
26529
+ (t) => [uniqueIndex32("markdown_files_project_path_idx").on(t.projectId, t.path)]
26525
26530
  );
26526
26531
  var DEFAULT_AEO_CONFIG = {
26527
26532
  llmsTxtEnabled: true,
@@ -26539,10 +26544,10 @@ import {
26539
26544
  integer as integer39,
26540
26545
  foreignKey as foreignKey4,
26541
26546
  index as index70,
26542
- uniqueIndex as uniqueIndex34
26547
+ uniqueIndex as uniqueIndex35
26543
26548
  } from "drizzle-orm/pg-core";
26544
26549
  import { relations as relations14 } from "drizzle-orm/relations";
26545
- import { sql as sql18 } from "drizzle-orm";
26550
+ import { sql as sql19 } from "drizzle-orm";
26546
26551
 
26547
26552
  // src/schema/component_variant_groups.ts
26548
26553
  import {
@@ -26553,10 +26558,10 @@ import {
26553
26558
  pgTable as pgTable81,
26554
26559
  text as text82,
26555
26560
  timestamp as timestamp75,
26556
- uniqueIndex as uniqueIndex32,
26561
+ uniqueIndex as uniqueIndex33,
26557
26562
  varchar as varchar60
26558
26563
  } from "drizzle-orm/pg-core";
26559
- import { sql as sql16 } from "drizzle-orm";
26564
+ import { sql as sql17 } from "drizzle-orm";
26560
26565
  var componentVariantGroups = pgTable81(
26561
26566
  "component_variant_groups",
26562
26567
  {
@@ -26582,7 +26587,7 @@ var componentVariantGroups = pgTable81(
26582
26587
  }).onDelete("cascade"),
26583
26588
  index68("component_variant_groups_workspace_idx").on(table.workspaceId),
26584
26589
  index68("component_variant_groups_project_idx").on(table.projectId),
26585
- uniqueIndex32("component_variant_groups_scope_slug_unique").on(table.workspaceId, table.projectId, table.slug).where(sql16`${table.deletedAt} IS NULL`)
26590
+ uniqueIndex33("component_variant_groups_scope_slug_unique").on(table.workspaceId, table.projectId, table.slug).where(sql17`${table.deletedAt} IS NULL`)
26586
26591
  ]
26587
26592
  );
26588
26593
 
@@ -26592,10 +26597,10 @@ import {
26592
26597
  index as index69,
26593
26598
  pgTable as pgTable82,
26594
26599
  text as text83,
26595
- uniqueIndex as uniqueIndex33,
26600
+ uniqueIndex as uniqueIndex34,
26596
26601
  varchar as varchar61
26597
26602
  } from "drizzle-orm/pg-core";
26598
- import { sql as sql17 } from "drizzle-orm";
26603
+ import { sql as sql18 } from "drizzle-orm";
26599
26604
  var componentGroups = pgTable82(
26600
26605
  "component_groups",
26601
26606
  {
@@ -26616,7 +26621,7 @@ var componentGroups = pgTable82(
26616
26621
  }).onDelete("cascade"),
26617
26622
  index69("component_groups_workspace_idx").on(table.workspaceId),
26618
26623
  index69("component_groups_project_idx").on(table.projectId),
26619
- uniqueIndex33("component_groups_project_slug_unique").on(table.projectId, table.slug).where(sql17`${table.deletedAt} IS NULL`)
26624
+ uniqueIndex34("component_groups_project_slug_unique").on(table.projectId, table.slug).where(sql18`${table.deletedAt} IS NULL`)
26620
26625
  ]
26621
26626
  );
26622
26627
 
@@ -26698,7 +26703,7 @@ var components = pgTable83(
26698
26703
  * application code to set a value the trigger overwrites. Do not conflate the two.
26699
26704
  */
26700
26705
  managedBy: text84("managed_by").notNull().default("dashboard").$type(),
26701
- allowedOn: text84("allowed_on").array().notNull().default(sql18`ARRAY[]::text[]`),
26706
+ allowedOn: text84("allowed_on").array().notNull().default(sql19`ARRAY[]::text[]`),
26702
26707
  description: text84("description"),
26703
26708
  // Organisational ownership only. Nullable for legacy rows; every new Component authored
26704
26709
  // through the canonical Content surface must choose or explicitly create a Group.
@@ -26769,15 +26774,15 @@ var components = pgTable83(
26769
26774
  * src/lib/sections/registry.ts, which is handed every candidate and applies precedence
26770
26775
  * itself. DB uniqueness here is data hygiene, not verdict correctness.
26771
26776
  */
26772
- uniqueIndex34("components_ws_proj_slug_managed_idx").on(table.workspaceId, table.projectId, table.branchId, table.slug, table.managedBy).where(sql18`${table.deletedAt} IS NULL`),
26773
- index70("components_managed_by_idx").on(table.managedBy).where(sql18`${table.deletedAt} IS NULL`),
26777
+ uniqueIndex35("components_ws_proj_slug_managed_idx").on(table.workspaceId, table.projectId, table.branchId, table.slug, table.managedBy).where(sql19`${table.deletedAt} IS NULL`),
26778
+ index70("components_managed_by_idx").on(table.managedBy).where(sql19`${table.deletedAt} IS NULL`),
26774
26779
  // Partial: the section library only reads live sections. Mirrors migration 0156 —
26775
26780
  // keep the two in step, or `drizzle-kit push` will want to drop the index it can't see.
26776
- index70("components_section_type_idx").on(table.sectionType).where(sql18`${table.sectionType} IS NOT NULL AND ${table.deletedAt} IS NULL`),
26781
+ index70("components_section_type_idx").on(table.sectionType).where(sql19`${table.sectionType} IS NOT NULL AND ${table.deletedAt} IS NULL`),
26777
26782
  // Migration 0342. Deliberately NOT unique: one band can produce several components when its
26778
26783
  // shape differs between pages (`hero`, `hero-2`), so this is a lookup hint the planner uses
26779
26784
  // only when exactly one row carries the key — not a key.
26780
- index70("components_ws_proj_source_key_idx").on(table.workspaceId, table.projectId, table.branchId, table.sourceKey).where(sql18`${table.sourceKey} IS NOT NULL AND ${table.deletedAt} IS NULL`)
26785
+ index70("components_ws_proj_source_key_idx").on(table.workspaceId, table.projectId, table.branchId, table.sourceKey).where(sql19`${table.sourceKey} IS NOT NULL AND ${table.deletedAt} IS NULL`)
26781
26786
  ]
26782
26787
  );
26783
26788
  var componentsRelations = relations14(components, ({ one }) => ({
@@ -26828,10 +26833,10 @@ import {
26828
26833
  integer as integer41,
26829
26834
  index as index72,
26830
26835
  unique as unique4,
26831
- uniqueIndex as uniqueIndex35
26836
+ uniqueIndex as uniqueIndex36
26832
26837
  } from "drizzle-orm/pg-core";
26833
26838
  import { relations as relations15 } from "drizzle-orm/relations";
26834
- import { sql as sql19 } from "drizzle-orm";
26839
+ import { sql as sql20 } from "drizzle-orm";
26835
26840
  var componentVariants = pgTable85(
26836
26841
  "component_variants",
26837
26842
  {
@@ -26865,7 +26870,7 @@ var componentVariants = pgTable85(
26865
26870
  ),
26866
26871
  index72("component_variants_workspace_idx").on(table.workspaceId),
26867
26872
  index72("component_variants_component_idx").on(table.componentId),
26868
- uniqueIndex35("component_variants_component_key_unique").on(table.componentId, table.key).where(sql19`${table.deletedAt} IS NULL`)
26873
+ uniqueIndex36("component_variants_component_key_unique").on(table.componentId, table.key).where(sql20`${table.deletedAt} IS NULL`)
26869
26874
  ]
26870
26875
  );
26871
26876
  var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
@@ -26890,11 +26895,11 @@ import {
26890
26895
  text as text87,
26891
26896
  timestamp as timestamp79,
26892
26897
  unique as unique5,
26893
- uniqueIndex as uniqueIndex36,
26898
+ uniqueIndex as uniqueIndex37,
26894
26899
  uuid as uuid2,
26895
26900
  varchar as varchar64
26896
26901
  } from "drizzle-orm/pg-core";
26897
- import { sql as sql20 } from "drizzle-orm";
26902
+ import { sql as sql21 } from "drizzle-orm";
26898
26903
  var componentImplementationCandidates = pgTable86(
26899
26904
  "component_implementation_candidates",
26900
26905
  {
@@ -26924,13 +26929,13 @@ var componentImplementationCandidates = pgTable86(
26924
26929
  // v1 candidates (created before 0263) have no exact family-contract bytes. They must not
26925
26930
  // occupy the v2 tuple: validation needs to append an exact candidate beside the legacy
26926
26931
  // row instead of either mutating it or selecting it by matching hashes alone.
26927
- uniqueIndex36("component_implementation_candidate_exact_tuple_unique").on(
26932
+ uniqueIndex37("component_implementation_candidate_exact_tuple_unique").on(
26928
26933
  table.projectId,
26929
26934
  table.componentId,
26930
26935
  table.schemaHash,
26931
26936
  table.brandContractHash,
26932
26937
  table.familyContractHash
26933
- ).where(sql20`${table.familyContract} IS NOT NULL`),
26938
+ ).where(sql21`${table.familyContract} IS NOT NULL`),
26934
26939
  unique5("component_implementation_candidate_scope_unique").on(table.id, table.projectId, table.componentId),
26935
26940
  index73("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
26936
26941
  ]
@@ -26962,7 +26967,7 @@ var componentFamilyManifests = pgTable86(
26962
26967
  unique5("component_family_manifests_scope_unique").on(table.id, table.projectId, table.familyKey),
26963
26968
  unique5("component_family_manifests_id_project_unique").on(table.id, table.projectId),
26964
26969
  unique5("component_family_manifests_evidence_unique").on(table.id, table.projectId, table.manifestHash),
26965
- uniqueIndex36("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
26970
+ uniqueIndex37("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
26966
26971
  index73("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
26967
26972
  ]
26968
26973
  );
@@ -27017,7 +27022,7 @@ var componentImplementationRequests = pgTable86(
27017
27022
  name: "component_implementation_requests_candidate_fkey"
27018
27023
  }).onDelete("cascade"),
27019
27024
  unique5("component_implementation_requests_scope_unique").on(table.id, table.projectId, table.componentId),
27020
- uniqueIndex36("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql20`${table.status} IN ('pending', 'claimed')`),
27025
+ uniqueIndex37("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql21`${table.status} IN ('pending', 'claimed')`),
27021
27026
  index73("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
27022
27027
  ]
27023
27028
  );
@@ -27069,8 +27074,8 @@ var componentImplementationEvidence = pgTable86(
27069
27074
  foreignColumns: [componentImplementationRequests.id, componentImplementationRequests.projectId, componentImplementationRequests.componentId],
27070
27075
  name: "component_implementation_evidence_request_fkey"
27071
27076
  }).onDelete("restrict"),
27072
- uniqueIndex36("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
27073
- uniqueIndex36("component_implementation_evidence_request_unique").on(table.requestId).where(sql20`${table.requestId} IS NOT NULL`),
27077
+ uniqueIndex37("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
27078
+ uniqueIndex37("component_implementation_evidence_request_unique").on(table.requestId).where(sql21`${table.requestId} IS NOT NULL`),
27074
27079
  unique5("component_implementation_evidence_scope_unique").on(table.id, table.projectId, table.componentId),
27075
27080
  index73("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
27076
27081
  ]
@@ -27103,7 +27108,7 @@ var componentImplementationApprovals = pgTable86(
27103
27108
  foreignColumns: [componentImplementationEvidence.id, componentImplementationEvidence.projectId, componentImplementationEvidence.componentId],
27104
27109
  name: "component_implementation_approvals_evidence_fkey"
27105
27110
  }).onDelete("cascade"),
27106
- uniqueIndex36("component_implementation_approval_evidence_unique").on(table.evidenceId),
27111
+ uniqueIndex37("component_implementation_approval_evidence_unique").on(table.evidenceId),
27107
27112
  unique5("component_implementation_approval_scope_unique").on(table.id, table.projectId, table.componentId),
27108
27113
  index73("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
27109
27114
  ]
@@ -27164,7 +27169,7 @@ var componentImplementationStates = pgTable86(
27164
27169
  foreignColumns: [projects.id, projects.workspaceId],
27165
27170
  name: "component_implementation_states_project_workspace_fkey"
27166
27171
  }).onDelete("cascade"),
27167
- uniqueIndex36("component_implementation_states_component_unique").on(table.projectId, table.componentId),
27172
+ uniqueIndex37("component_implementation_states_component_unique").on(table.projectId, table.componentId),
27168
27173
  index73("component_implementation_states_workspace_idx").on(table.workspaceId)
27169
27174
  ]
27170
27175
  );
@@ -27226,7 +27231,7 @@ var componentPreviewBundles = pgTable86(
27226
27231
  );
27227
27232
 
27228
27233
  // src/schema/orchestration.ts
27229
- import { sql as sql21 } from "drizzle-orm";
27234
+ import { sql as sql22 } from "drizzle-orm";
27230
27235
  import {
27231
27236
  check as check5,
27232
27237
  foreignKey as foreignKey7,
@@ -27238,7 +27243,7 @@ import {
27238
27243
  text as text88,
27239
27244
  timestamp as timestamp80,
27240
27245
  unique as unique6,
27241
- uniqueIndex as uniqueIndex37,
27246
+ uniqueIndex as uniqueIndex38,
27242
27247
  uuid as uuid3,
27243
27248
  varchar as varchar65
27244
27249
  } from "drizzle-orm/pg-core";
@@ -27267,7 +27272,7 @@ var projectOrchestrationStates = pgTable87(
27267
27272
  name: "project_orchestration_states_project_workspace_fkey"
27268
27273
  }).onDelete("cascade"),
27269
27274
  unique6("project_orchestration_states_scope_unique").on(table.projectId, table.workspaceId),
27270
- check5("project_orchestration_states_generation_check", sql21`${table.generation} >= 2`),
27275
+ check5("project_orchestration_states_generation_check", sql22`${table.generation} >= 2`),
27271
27276
  index74("project_orchestration_states_workspace_idx").on(table.workspaceId)
27272
27277
  ]
27273
27278
  );
@@ -27315,7 +27320,7 @@ var orchestrationRuns = pgTable87(
27315
27320
  table.projectId,
27316
27321
  table.startIdempotencyKey
27317
27322
  ),
27318
- uniqueIndex37("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql21`${table.status} IN ('open', 'paused', 'cancelling')`),
27323
+ uniqueIndex38("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql22`${table.status} IN ('open', 'paused', 'cancelling')`),
27319
27324
  index74("orchestration_runs_project_target_idx").on(
27320
27325
  table.projectId,
27321
27326
  table.targetKind,
@@ -27328,17 +27333,17 @@ var orchestrationRuns = pgTable87(
27328
27333
  table.status,
27329
27334
  table.updatedAt
27330
27335
  ),
27331
- check5("orchestration_runs_generation_check", sql21`${table.projectGeneration} >= 2`),
27336
+ check5("orchestration_runs_generation_check", sql22`${table.projectGeneration} >= 2`),
27332
27337
  check5(
27333
27338
  "orchestration_runs_start_idempotency_key_check",
27334
- sql21`length(btrim(${table.startIdempotencyKey})) BETWEEN 1 AND 255`
27339
+ sql22`length(btrim(${table.startIdempotencyKey})) BETWEEN 1 AND 255`
27335
27340
  ),
27336
- check5("orchestration_runs_target_kind_check", sql21`${table.targetKind} = 'component-variant'`),
27341
+ check5("orchestration_runs_target_kind_check", sql22`${table.targetKind} = 'component-variant'`),
27337
27342
  check5(
27338
27343
  "orchestration_runs_target_metadata_check",
27339
27344
  // The one-key branch preserves truthful pre-0269 provenance. The INSERT trigger
27340
27345
  // accepts only the fully bound branch and recomputes it from locked authoritative rows.
27341
- sql21`jsonb_typeof(${table.targetMetadata}) = 'object'
27346
+ sql22`jsonb_typeof(${table.targetMetadata}) = 'object'
27342
27347
  AND ${table.targetMetadata} ->> 'intent' = 'implementation-validation'
27343
27348
  AND (
27344
27349
  (${table.targetMetadata} - ARRAY['intent']::text[]) = '{}'::jsonb
@@ -27399,15 +27404,15 @@ var orchestrationRuns = pgTable87(
27399
27404
  ),
27400
27405
  check5(
27401
27406
  "orchestration_runs_status_check",
27402
- sql21`${table.status} IN ('open', 'paused', 'cancelling', 'cancelled', 'completed', 'abandoned')`
27407
+ sql22`${table.status} IN ('open', 'paused', 'cancelling', 'cancelled', 'completed', 'abandoned')`
27403
27408
  ),
27404
- check5("orchestration_runs_active_stage_check", sql21`length(btrim(${table.activeStage})) > 0`),
27405
- check5("orchestration_runs_version_check", sql21`${table.version} >= 1`),
27409
+ check5("orchestration_runs_active_stage_check", sql22`length(btrim(${table.activeStage})) > 0`),
27410
+ check5("orchestration_runs_version_check", sql22`${table.version} >= 1`),
27406
27411
  check5(
27407
27412
  "orchestration_runs_cancellation_check",
27408
- sql21`${table.status} NOT IN ('cancelling', 'cancelled') OR ${table.cancellationRequestedAt} IS NOT NULL`
27413
+ sql22`${table.status} NOT IN ('cancelling', 'cancelled') OR ${table.cancellationRequestedAt} IS NOT NULL`
27409
27414
  ),
27410
- check5("orchestration_runs_timestamps_check", sql21`${table.updatedAt} >= ${table.createdAt}`)
27415
+ check5("orchestration_runs_timestamps_check", sql22`${table.updatedAt} >= ${table.createdAt}`)
27411
27416
  ]
27412
27417
  );
27413
27418
  var orchestrationRunStartKeys = pgTable87(
@@ -27429,7 +27434,7 @@ var orchestrationRunStartKeys = pgTable87(
27429
27434
  index74("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
27430
27435
  check5(
27431
27436
  "orchestration_run_start_keys_idempotency_key_check",
27432
- sql21`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27437
+ sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27433
27438
  )
27434
27439
  ]
27435
27440
  );
@@ -27450,7 +27455,7 @@ var orchestrationRunEvents = pgTable87(
27450
27455
  correlationId: text88("correlation_id"),
27451
27456
  payload: jsonb47("payload").$type().notNull().default({}),
27452
27457
  payloadDigest: varchar65("payload_digest", { length: 71 }).generatedAlwaysAs(
27453
- sql21`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
27458
+ sql22`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
27454
27459
  ),
27455
27460
  createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow()
27456
27461
  },
@@ -27463,18 +27468,18 @@ var orchestrationRunEvents = pgTable87(
27463
27468
  unique6("orchestration_run_events_sequence_unique").on(table.runId, table.sequence),
27464
27469
  unique6("orchestration_run_events_idempotency_unique").on(table.runId, table.idempotencyKey),
27465
27470
  index74("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
27466
- check5("orchestration_run_events_sequence_check", sql21`${table.sequence} >= 1`),
27467
- check5("orchestration_run_events_schema_version_check", sql21`${table.schemaVersion} >= 1`),
27471
+ check5("orchestration_run_events_sequence_check", sql22`${table.sequence} >= 1`),
27472
+ check5("orchestration_run_events_schema_version_check", sql22`${table.schemaVersion} >= 1`),
27468
27473
  check5(
27469
27474
  "orchestration_run_events_idempotency_key_check",
27470
- sql21`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27475
+ sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27471
27476
  ),
27472
- check5("orchestration_run_events_type_check", sql21`length(btrim(${table.type})) > 0`),
27473
- check5("orchestration_run_events_actor_type_check", sql21`length(btrim(${table.actorType})) > 0`),
27474
- check5("orchestration_run_events_actor_id_check", sql21`length(btrim(${table.actorId})) > 0`),
27477
+ check5("orchestration_run_events_type_check", sql22`length(btrim(${table.type})) > 0`),
27478
+ check5("orchestration_run_events_actor_type_check", sql22`length(btrim(${table.actorType})) > 0`),
27479
+ check5("orchestration_run_events_actor_id_check", sql22`length(btrim(${table.actorId})) > 0`),
27475
27480
  check5(
27476
27481
  "orchestration_run_events_payload_check",
27477
- sql21`jsonb_typeof(${table.payload}) = 'object'`
27482
+ sql22`jsonb_typeof(${table.payload}) = 'object'`
27478
27483
  )
27479
27484
  ]
27480
27485
  );
@@ -27506,29 +27511,29 @@ var orchestrationRunCommandResults = pgTable87(
27506
27511
  ),
27507
27512
  check5(
27508
27513
  "orchestration_run_command_results_command_check",
27509
- sql21`${table.command} IN ('pause', 'resume', 'cancel')`
27514
+ sql22`${table.command} IN ('pause', 'resume', 'cancel')`
27510
27515
  ),
27511
27516
  check5(
27512
27517
  "orchestration_run_command_results_expected_version_check",
27513
- sql21`${table.expectedVersion} >= 1`
27518
+ sql22`${table.expectedVersion} >= 1`
27514
27519
  ),
27515
27520
  check5(
27516
27521
  "orchestration_run_command_results_resulting_version_check",
27517
- sql21`${table.resultingVersion} = ${table.expectedVersion} + 1`
27522
+ sql22`${table.resultingVersion} = ${table.expectedVersion} + 1`
27518
27523
  ),
27519
27524
  check5(
27520
27525
  "orchestration_run_command_results_actor_id_check",
27521
- sql21`length(btrim(${table.actorId})) > 0`
27526
+ sql22`length(btrim(${table.actorId})) > 0`
27522
27527
  ),
27523
27528
  check5(
27524
27529
  "orchestration_run_command_results_payload_check",
27525
- sql21`jsonb_typeof(${table.resultPayload}) = 'object'`
27530
+ sql22`jsonb_typeof(${table.resultPayload}) = 'object'`
27526
27531
  )
27527
27532
  ]
27528
27533
  );
27529
27534
 
27530
27535
  // src/schema/orchestration_executors.ts
27531
- import { sql as sql22 } from "drizzle-orm";
27536
+ import { sql as sql23 } from "drizzle-orm";
27532
27537
  import {
27533
27538
  bigint as bigint5,
27534
27539
  boolean as boolean30,
@@ -27541,7 +27546,7 @@ import {
27541
27546
  text as text89,
27542
27547
  timestamp as timestamp81,
27543
27548
  unique as unique7,
27544
- uniqueIndex as uniqueIndex38,
27549
+ uniqueIndex as uniqueIndex39,
27545
27550
  uuid as uuid4,
27546
27551
  varchar as varchar66
27547
27552
  } from "drizzle-orm/pg-core";
@@ -27614,36 +27619,36 @@ var orchestrationExecutorInstallations = pgTable88(
27614
27619
  table.projectId,
27615
27620
  table.status
27616
27621
  ),
27617
- uniqueIndex38("orchestration_executor_installations_grant_unique").on(table.projectId, table.grantId).where(sql22`${table.grantId} IS NOT NULL AND ${table.status} = 'active'`),
27618
- uniqueIndex38("orchestration_executor_installations_dashboard_unique").on(table.projectId).where(sql22`${table.kind} = 'dashboard-agent' AND ${table.status} = 'active'`),
27622
+ uniqueIndex39("orchestration_executor_installations_grant_unique").on(table.projectId, table.grantId).where(sql23`${table.grantId} IS NOT NULL AND ${table.status} = 'active'`),
27623
+ uniqueIndex39("orchestration_executor_installations_dashboard_unique").on(table.projectId).where(sql23`${table.kind} = 'dashboard-agent' AND ${table.status} = 'active'`),
27619
27624
  check6(
27620
27625
  "orchestration_executor_installations_kind_check",
27621
- sql22`${table.kind} IN ('dashboard-agent', 'native-bridge')`
27626
+ sql23`${table.kind} IN ('dashboard-agent', 'native-bridge')`
27622
27627
  ),
27623
27628
  check6(
27624
27629
  "orchestration_executor_installations_status_check",
27625
- sql22`${table.status} IN ('active', 'revoked', 'incompatible')`
27630
+ sql23`${table.status} IN ('active', 'revoked', 'incompatible')`
27626
27631
  ),
27627
27632
  // A native bridge executor must carry an external grant; the Dashboard Agent must not.
27628
27633
  check6(
27629
27634
  "orchestration_executor_installations_grant_required_check",
27630
- sql22`(${table.kind} = 'native-bridge') = (${table.grantId} IS NOT NULL)`
27635
+ sql23`(${table.kind} = 'native-bridge') = (${table.grantId} IS NOT NULL)`
27631
27636
  ),
27632
27637
  check6(
27633
27638
  "orchestration_executor_installations_capability_digest_check",
27634
- sql22`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
27639
+ sql23`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
27635
27640
  ),
27636
27641
  check6(
27637
27642
  "orchestration_executor_installations_protocol_version_check",
27638
- sql22`length(btrim(${table.protocolVersion})) > 0`
27643
+ sql23`length(btrim(${table.protocolVersion})) > 0`
27639
27644
  ),
27640
27645
  check6(
27641
27646
  "orchestration_executor_installations_repository_claim_check",
27642
- sql22`jsonb_typeof(${table.repositoryClaim}) = 'object'`
27647
+ sql23`jsonb_typeof(${table.repositoryClaim}) = 'object'`
27643
27648
  ),
27644
27649
  check6(
27645
27650
  "orchestration_executor_installations_updated_at_check",
27646
- sql22`${table.updatedAt} >= ${table.createdAt}`
27651
+ sql23`${table.updatedAt} >= ${table.createdAt}`
27647
27652
  )
27648
27653
  ]
27649
27654
  );
@@ -27689,27 +27694,27 @@ var orchestrationExecutorSessions = pgTable88(
27689
27694
  table.installationId,
27690
27695
  table.state
27691
27696
  ),
27692
- index75("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql22`${table.state} = 'open'`),
27693
- check6("orchestration_executor_sessions_epoch_check", sql22`${table.sessionEpoch} >= 1`),
27697
+ index75("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql23`${table.state} = 'open'`),
27698
+ check6("orchestration_executor_sessions_epoch_check", sql23`${table.sessionEpoch} >= 1`),
27694
27699
  check6(
27695
27700
  "orchestration_executor_sessions_state_check",
27696
- sql22`${table.state} IN ('open', 'fenced', 'closed')`
27701
+ sql23`${table.state} IN ('open', 'fenced', 'closed')`
27697
27702
  ),
27698
27703
  check6(
27699
27704
  "orchestration_executor_sessions_cursor_check",
27700
- sql22`${table.clientCursor} >= 0 AND ${table.serverCursor} >= 0`
27705
+ sql23`${table.clientCursor} >= 0 AND ${table.serverCursor} >= 0`
27701
27706
  ),
27702
27707
  check6(
27703
27708
  "orchestration_executor_sessions_credential_audience_check",
27704
- sql22`length(btrim(${table.credentialAudience})) > 0`
27709
+ sql23`length(btrim(${table.credentialAudience})) > 0`
27705
27710
  ),
27706
27711
  check6(
27707
27712
  "orchestration_executor_sessions_closed_state_check",
27708
- sql22`(${table.state} = 'closed') = (${table.closedAt} IS NOT NULL)`
27713
+ sql23`(${table.state} = 'closed') = (${table.closedAt} IS NOT NULL)`
27709
27714
  ),
27710
27715
  check6(
27711
27716
  "orchestration_executor_sessions_updated_at_check",
27712
- sql22`${table.updatedAt} >= ${table.createdAt}`
27717
+ sql23`${table.updatedAt} >= ${table.createdAt}`
27713
27718
  )
27714
27719
  ]
27715
27720
  );
@@ -27784,30 +27789,30 @@ var orchestrationImplementationAttempts = pgTable88(
27784
27789
  table.runId,
27785
27790
  table.createdAt
27786
27791
  ),
27787
- check6("orchestration_implementation_attempts_number_check", sql22`${table.attemptNumber} >= 1`),
27792
+ check6("orchestration_implementation_attempts_number_check", sql23`${table.attemptNumber} >= 1`),
27788
27793
  check6(
27789
27794
  "orchestration_implementation_attempts_target_kind_check",
27790
- sql22`${table.targetKind} = 'component-variant'`
27795
+ sql23`${table.targetKind} = 'component-variant'`
27791
27796
  ),
27792
27797
  check6(
27793
27798
  "orchestration_implementation_attempts_status_check",
27794
- sql22`${table.status} IN ('preflight', 'proposed', 'approved', 'implementing', 'suspended', 'superseded', 'cancelled', 'failed', 'completed')`
27799
+ sql23`${table.status} IN ('preflight', 'proposed', 'approved', 'implementing', 'suspended', 'superseded', 'cancelled', 'failed', 'completed')`
27795
27800
  ),
27796
27801
  check6(
27797
27802
  "orchestration_implementation_attempts_base_sha_check",
27798
- sql22`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
27803
+ sql23`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
27799
27804
  ),
27800
27805
  check6(
27801
27806
  "orchestration_implementation_attempts_superseded_check",
27802
- sql22`${table.supersededBy} IS NULL OR ${table.supersededBy} <> ${table.id}`
27807
+ sql23`${table.supersededBy} IS NULL OR ${table.supersededBy} <> ${table.id}`
27803
27808
  ),
27804
27809
  check6(
27805
27810
  "orchestration_implementation_attempts_binding_digest_check",
27806
- sql22`length(btrim(${table.targetBindingDigest})) BETWEEN 1 AND 255`
27811
+ sql23`length(btrim(${table.targetBindingDigest})) BETWEEN 1 AND 255`
27807
27812
  ),
27808
27813
  check6(
27809
27814
  "orchestration_implementation_attempts_updated_at_check",
27810
- sql22`${table.updatedAt} >= ${table.createdAt}`
27815
+ sql23`${table.updatedAt} >= ${table.createdAt}`
27811
27816
  )
27812
27817
  ]
27813
27818
  );
@@ -27979,47 +27984,47 @@ var orchestrationExecutionApprovals = pgTable88(
27979
27984
  index75("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
27980
27985
  check6(
27981
27986
  "orchestration_execution_approvals_idempotency_key_check",
27982
- sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27987
+ sql23`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27983
27988
  ),
27984
27989
  check6(
27985
27990
  "orchestration_execution_approvals_approved_by_check",
27986
- sql22`length(btrim(${table.approvedBy})) > 0`
27991
+ sql23`length(btrim(${table.approvedBy})) > 0`
27987
27992
  ),
27988
27993
  check6(
27989
27994
  "orchestration_execution_approvals_target_kind_check",
27990
- sql22`${table.targetKind} = 'component-variant'`
27995
+ sql23`${table.targetKind} = 'component-variant'`
27991
27996
  ),
27992
27997
  check6(
27993
27998
  "orchestration_execution_approvals_base_sha_check",
27994
- sql22`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
27999
+ sql23`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
27995
28000
  ),
27996
28001
  check6(
27997
28002
  "orchestration_execution_approvals_path_policy_check",
27998
- sql22`jsonb_typeof(${table.pathPolicy}) = 'object'`
28003
+ sql23`jsonb_typeof(${table.pathPolicy}) = 'object'`
27999
28004
  ),
28000
28005
  check6(
28001
28006
  "orchestration_execution_approvals_operation_classes_check",
28002
- sql22`jsonb_typeof(${table.operationClasses}) = 'array'`
28007
+ sql23`jsonb_typeof(${table.operationClasses}) = 'array'`
28003
28008
  ),
28004
28009
  check6(
28005
28010
  "orchestration_execution_approvals_mutation_budget_check",
28006
- sql22`jsonb_typeof(${table.mutationBudget}) = 'object'`
28011
+ sql23`jsonb_typeof(${table.mutationBudget}) = 'object'`
28007
28012
  ),
28008
28013
  check6(
28009
28014
  "orchestration_execution_approvals_plan_digest_check",
28010
- sql22`length(btrim(${table.planDigest})) BETWEEN 1 AND 255`
28015
+ sql23`length(btrim(${table.planDigest})) BETWEEN 1 AND 255`
28011
28016
  ),
28012
28017
  check6(
28013
28018
  "orchestration_execution_approvals_capability_digest_check",
28014
- sql22`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
28019
+ sql23`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
28015
28020
  ),
28016
28021
  check6(
28017
28022
  "orchestration_execution_approvals_validation_digest_check",
28018
- sql22`length(btrim(${table.validationDigest})) BETWEEN 1 AND 255`
28023
+ sql23`length(btrim(${table.validationDigest})) BETWEEN 1 AND 255`
28019
28024
  ),
28020
28025
  check6(
28021
28026
  "orchestration_execution_approvals_expiry_check",
28022
- sql22`${table.expiresAt} > ${table.createdAt}`
28027
+ sql23`${table.expiresAt} > ${table.createdAt}`
28023
28028
  )
28024
28029
  ]
28025
28030
  );
@@ -28076,24 +28081,24 @@ var orchestrationExecutorLeases = pgTable88(
28076
28081
  ),
28077
28082
  unique7("orchestration_executor_leases_epoch_unique").on(table.attemptId, table.leaseEpoch),
28078
28083
  // Plan invariant 6, enforced in the database: a run has at most one active executor lease.
28079
- uniqueIndex38("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql22`${table.state} = 'active'`),
28080
- index75("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql22`${table.state} = 'active'`),
28081
- check6("orchestration_executor_leases_epoch_check", sql22`${table.leaseEpoch} >= 1`),
28084
+ uniqueIndex39("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql23`${table.state} = 'active'`),
28085
+ index75("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql23`${table.state} = 'active'`),
28086
+ check6("orchestration_executor_leases_epoch_check", sql23`${table.leaseEpoch} >= 1`),
28082
28087
  check6(
28083
28088
  "orchestration_executor_leases_state_check",
28084
- sql22`${table.state} IN ('active', 'paused', 'revoked', 'released')`
28089
+ sql23`${table.state} IN ('active', 'paused', 'revoked', 'released')`
28085
28090
  ),
28086
28091
  check6(
28087
28092
  "orchestration_executor_leases_release_consistency_check",
28088
- sql22`(${table.state} IN ('revoked', 'released')) = (${table.releasedAt} IS NOT NULL)`
28093
+ sql23`(${table.state} IN ('revoked', 'released')) = (${table.releasedAt} IS NOT NULL)`
28089
28094
  ),
28090
28095
  check6(
28091
28096
  "orchestration_executor_leases_release_reason_check",
28092
- sql22`${table.releaseReason} IS NULL OR ${table.releaseReason} IN ('handoff', 'heartbeat-lost', 'cancelled', 'completed', 'superseded', 'revoked')`
28097
+ sql23`${table.releaseReason} IS NULL OR ${table.releaseReason} IN ('handoff', 'heartbeat-lost', 'cancelled', 'completed', 'superseded', 'revoked')`
28093
28098
  ),
28094
28099
  check6(
28095
28100
  "orchestration_executor_leases_updated_at_check",
28096
- sql22`${table.updatedAt} >= ${table.createdAt}`
28101
+ sql23`${table.updatedAt} >= ${table.createdAt}`
28097
28102
  )
28098
28103
  ]
28099
28104
  );
@@ -28118,7 +28123,7 @@ var orchestrationExecutorCommands = pgTable88(
28118
28123
  expectedRunVersion: integer44("expected_run_version").notNull(),
28119
28124
  payload: jsonb48("payload").$type().notNull().default({}),
28120
28125
  payloadDigest: varchar66("payload_digest", { length: 71 }).generatedAlwaysAs(
28121
- sql22`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
28126
+ sql23`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
28122
28127
  ),
28123
28128
  deliveredAt: timestamp81("delivered_at", { withTimezone: true }),
28124
28129
  acknowledgedAt: timestamp81("acknowledged_at", { withTimezone: true }),
@@ -28150,32 +28155,32 @@ var orchestrationExecutorCommands = pgTable88(
28150
28155
  ),
28151
28156
  index75("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
28152
28157
  // The long-poll cursor read: unacknowledged commands for a run, in order.
28153
- index75("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql22`${table.acknowledgedAt} IS NULL`),
28154
- check6("orchestration_executor_commands_sequence_check", sql22`${table.sequence} >= 1`),
28158
+ index75("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql23`${table.acknowledgedAt} IS NULL`),
28159
+ check6("orchestration_executor_commands_sequence_check", sql23`${table.sequence} >= 1`),
28155
28160
  check6(
28156
28161
  "orchestration_executor_commands_kind_check",
28157
- sql22`${table.kind} IN ('offer', 'inspect', 'propose', 'implement', 'suspend', 'resume', 'cancel', 'handoff')`
28162
+ sql23`${table.kind} IN ('offer', 'inspect', 'propose', 'implement', 'suspend', 'resume', 'cancel', 'handoff')`
28158
28163
  ),
28159
28164
  check6(
28160
28165
  "orchestration_executor_commands_idempotency_key_check",
28161
- sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
28166
+ sql23`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
28162
28167
  ),
28163
28168
  check6(
28164
28169
  "orchestration_executor_commands_expected_run_version_check",
28165
- sql22`${table.expectedRunVersion} >= 1`
28170
+ sql23`${table.expectedRunVersion} >= 1`
28166
28171
  ),
28167
28172
  check6(
28168
28173
  "orchestration_executor_commands_payload_check",
28169
- sql22`jsonb_typeof(${table.payload}) = 'object'`
28174
+ sql23`jsonb_typeof(${table.payload}) = 'object'`
28170
28175
  ),
28171
28176
  check6(
28172
28177
  "orchestration_executor_commands_lease_epoch_check",
28173
- sql22`(${table.leaseId} IS NULL) = (${table.leaseEpoch} IS NULL)`
28178
+ sql23`(${table.leaseId} IS NULL) = (${table.leaseEpoch} IS NULL)`
28174
28179
  ),
28175
28180
  // Acknowledgement implies delivery. The reverse is not true and must not be assumed.
28176
28181
  check6(
28177
28182
  "orchestration_executor_commands_ack_implies_delivery_check",
28178
- sql22`${table.acknowledgedAt} IS NULL OR ${table.deliveredAt} IS NOT NULL`
28183
+ sql23`${table.acknowledgedAt} IS NULL OR ${table.deliveredAt} IS NOT NULL`
28179
28184
  )
28180
28185
  ]
28181
28186
  );
@@ -28222,29 +28227,29 @@ var orchestrationPatchManifests = pgTable88(
28222
28227
  unique7("orchestration_patch_manifests_sequence_unique").on(table.attemptId, table.sequence),
28223
28228
  unique7("orchestration_patch_manifests_path_unique").on(table.attemptId, table.path),
28224
28229
  index75("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
28225
- check6("orchestration_patch_manifests_sequence_check", sql22`${table.sequence} >= 1`),
28230
+ check6("orchestration_patch_manifests_sequence_check", sql23`${table.sequence} >= 1`),
28226
28231
  check6(
28227
28232
  "orchestration_patch_manifests_operation_check",
28228
- sql22`${table.operation} IN ('create', 'update', 'delete')`
28233
+ sql23`${table.operation} IN ('create', 'update', 'delete')`
28229
28234
  ),
28230
28235
  check6(
28231
28236
  "orchestration_patch_manifests_mode_check",
28232
- sql22`${table.fileMode} IN ('100644', '100755')`
28237
+ sql23`${table.fileMode} IN ('100644', '100755')`
28233
28238
  ),
28234
28239
  check6(
28235
28240
  "orchestration_patch_manifests_path_check",
28236
- sql22`length(btrim(${table.path})) BETWEEN 1 AND 2048`
28241
+ sql23`length(btrim(${table.path})) BETWEEN 1 AND 2048`
28237
28242
  ),
28238
28243
  // A create must not claim a predecessor; a delete must not claim a result.
28239
28244
  check6(
28240
28245
  "orchestration_patch_manifests_create_check",
28241
- sql22`${table.operation} <> 'create' OR ${table.expectedBefore} IS NULL`
28246
+ sql23`${table.operation} <> 'create' OR ${table.expectedBefore} IS NULL`
28242
28247
  ),
28243
28248
  check6(
28244
28249
  "orchestration_patch_manifests_delete_check",
28245
- sql22`${table.operation} <> 'delete' OR ${table.resultingBlobSha} IS NULL`
28250
+ sql23`${table.operation} <> 'delete' OR ${table.resultingBlobSha} IS NULL`
28246
28251
  ),
28247
- check6("orchestration_patch_manifests_byte_count_check", sql22`${table.byteCount} >= 0`)
28252
+ check6("orchestration_patch_manifests_byte_count_check", sql23`${table.byteCount} >= 0`)
28248
28253
  ]
28249
28254
  );
28250
28255
  var orchestrationPullRequestReceipts = pgTable88(
@@ -28300,34 +28305,34 @@ var orchestrationPullRequestReceipts = pgTable88(
28300
28305
  table.generation
28301
28306
  ),
28302
28307
  index75("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
28303
- check6("orchestration_pull_request_receipts_generation_check", sql22`${table.generation} >= 1`),
28304
- check6("orchestration_pull_request_receipts_number_check", sql22`${table.pullRequestNumber} >= 1`),
28308
+ check6("orchestration_pull_request_receipts_generation_check", sql23`${table.generation} >= 1`),
28309
+ check6("orchestration_pull_request_receipts_number_check", sql23`${table.pullRequestNumber} >= 1`),
28305
28310
  check6(
28306
28311
  "orchestration_pull_request_receipts_base_sha_check",
28307
- sql22`${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
28312
+ sql23`${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
28308
28313
  ),
28309
28314
  check6(
28310
28315
  "orchestration_pull_request_receipts_head_sha_check",
28311
- sql22`${table.headSha} ~ '^[0-9a-f]{7,64}$'`
28316
+ sql23`${table.headSha} ~ '^[0-9a-f]{7,64}$'`
28312
28317
  ),
28313
28318
  // Same-repository PR only: a fork head is not a branch the adapter can own or advance.
28314
28319
  check6(
28315
28320
  "orchestration_pull_request_receipts_refs_check",
28316
- sql22`length(btrim(${table.baseRef})) > 0 AND length(btrim(${table.headRef})) > 0 AND ${table.baseRef} <> ${table.headRef}`
28321
+ sql23`length(btrim(${table.baseRef})) > 0 AND length(btrim(${table.headRef})) > 0 AND ${table.baseRef} <> ${table.headRef}`
28317
28322
  ),
28318
28323
  check6(
28319
28324
  "orchestration_pull_request_receipts_url_check",
28320
- sql22`${table.pullRequestUrl} ~ '^https://'`
28325
+ sql23`${table.pullRequestUrl} ~ '^https://'`
28321
28326
  ),
28322
28327
  check6(
28323
28328
  "orchestration_pull_request_receipts_updated_at_check",
28324
- sql22`${table.updatedAt} >= ${table.createdAt}`
28329
+ sql23`${table.updatedAt} >= ${table.createdAt}`
28325
28330
  )
28326
28331
  ]
28327
28332
  );
28328
28333
 
28329
28334
  // src/schema/conversion_proposals.ts
28330
- import { sql as sql23 } from "drizzle-orm";
28335
+ import { sql as sql24 } from "drizzle-orm";
28331
28336
  import { check as check7, foreignKey as foreignKey9, index as index76, integer as integer45, jsonb as jsonb49, pgTable as pgTable89, text as text90, timestamp as timestamp82, unique as unique8, uuid as uuid5, varchar as varchar67 } from "drizzle-orm/pg-core";
28332
28337
  var CONVERSION_PROPOSAL_STATUSES = ["draft", "approved", "superseded"];
28333
28338
  var conversionProposals = pgTable89(
@@ -28343,9 +28348,9 @@ var conversionProposals = pgTable89(
28343
28348
  baseHeadOid: varchar67("base_head_oid", { length: 64 }).notNull(),
28344
28349
  baseBranch: text90("base_branch").notNull(),
28345
28350
  /** Brief paths whose `original` was not found in any source file. */
28346
- unlocated: jsonb49("unlocated").notNull().default(sql23`'[]'::jsonb`),
28351
+ unlocated: jsonb49("unlocated").notNull().default(sql24`'[]'::jsonb`),
28347
28352
  /** Files that matched a brief original but fell outside the acquisition caps. */
28348
- omittedByCap: jsonb49("omitted_by_cap").notNull().default(sql23`'[]'::jsonb`),
28353
+ omittedByCap: jsonb49("omitted_by_cap").notNull().default(sql24`'[]'::jsonb`),
28349
28354
  /**
28350
28355
  * The codemod's receipt (migration 0296) — every path it bound, and every one it could not.
28351
28356
  *
@@ -28378,17 +28383,17 @@ var conversionProposals = pgTable89(
28378
28383
  foreignColumns: [projects.id, projects.workspaceId],
28379
28384
  name: "conversion_proposals_project_workspace_fkey"
28380
28385
  }).onDelete("cascade"),
28381
- check7("conversion_proposals_status_check", sql23`${table.status} IN ('draft', 'approved', 'superseded')`),
28382
- check7("conversion_proposals_version_check", sql23`${table.version} >= 1`),
28386
+ check7("conversion_proposals_status_check", sql24`${table.status} IN ('draft', 'approved', 'superseded')`),
28387
+ check7("conversion_proposals_version_check", sql24`${table.version} >= 1`),
28383
28388
  check7(
28384
28389
  "conversion_proposals_receipt_object_check",
28385
- sql23`${table.receipt} IS NULL OR jsonb_typeof(${table.receipt}) = 'object'`
28390
+ sql24`${table.receipt} IS NULL OR jsonb_typeof(${table.receipt}) = 'object'`
28386
28391
  )
28387
28392
  ]
28388
28393
  );
28389
28394
 
28390
28395
  // src/schema/conversion_briefs_issued.ts
28391
- import { sql as sql24 } from "drizzle-orm";
28396
+ import { sql as sql25 } from "drizzle-orm";
28392
28397
  import { check as check8, foreignKey as foreignKey10, index as index77, jsonb as jsonb50, pgTable as pgTable90, text as text91, timestamp as timestamp83, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
28393
28398
  var conversionBriefsIssued = pgTable90(
28394
28399
  "conversion_briefs_issued",
@@ -28399,7 +28404,7 @@ var conversionBriefsIssued = pgTable90(
28399
28404
  /** sha256 of the canonical brief — `briefDigest`, computed identically by the codemod. */
28400
28405
  briefDigest: text91("brief_digest").notNull(),
28401
28406
  /** `[{ route, scope, path, kind, locator? }]` — every bindable path the brief listed. */
28402
- paths: jsonb50("paths").notNull().default(sql24`'[]'::jsonb`),
28407
+ paths: jsonb50("paths").notNull().default(sql25`'[]'::jsonb`),
28403
28408
  /**
28404
28409
  * The codemod's account of the run against THIS digest (`submit_conversion_receipt`): which
28405
28410
  * paths it rewrote, which it could not, and why. Null until one is submitted — a hand
@@ -28417,13 +28422,13 @@ var conversionBriefsIssued = pgTable90(
28417
28422
  foreignColumns: [projects.id, projects.workspaceId],
28418
28423
  name: "conversion_briefs_issued_project_workspace_fkey"
28419
28424
  }).onDelete("cascade"),
28420
- check8("conversion_briefs_issued_brief_digest_check", sql24`${table.briefDigest} ~ '^sha256:[0-9a-f]{64}$'`),
28421
- check8("conversion_briefs_issued_paths_array_check", sql24`jsonb_typeof(${table.paths}) = 'array'`)
28425
+ check8("conversion_briefs_issued_brief_digest_check", sql25`${table.briefDigest} ~ '^sha256:[0-9a-f]{64}$'`),
28426
+ check8("conversion_briefs_issued_paths_array_check", sql25`jsonb_typeof(${table.paths}) = 'array'`)
28422
28427
  ]
28423
28428
  );
28424
28429
 
28425
28430
  // src/schema/orchestration_validation.ts
28426
- import { sql as sql25 } from "drizzle-orm";
28431
+ import { sql as sql26 } from "drizzle-orm";
28427
28432
  import {
28428
28433
  bigint as bigint6,
28429
28434
  check as check9,
@@ -28435,7 +28440,7 @@ import {
28435
28440
  text as text92,
28436
28441
  timestamp as timestamp84,
28437
28442
  unique as unique10,
28438
- uniqueIndex as uniqueIndex39,
28443
+ uniqueIndex as uniqueIndex40,
28439
28444
  uuid as uuid7,
28440
28445
  varchar as varchar68
28441
28446
  } from "drizzle-orm/pg-core";
@@ -28518,15 +28523,15 @@ var orchestrationValidationEnvelopes = pgTable91(
28518
28523
  }).onDelete("set null"),
28519
28524
  // One live envelope per (attempt, head): two validators can never both be authoritative for
28520
28525
  // the same commit. The index arbitrates, so no read-then-write can lose the race.
28521
- uniqueIndex39("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql25`status IN ('queued', 'dispatched', 'action_required')`),
28526
+ uniqueIndex40("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql26`status IN ('queued', 'dispatched', 'action_required')`),
28522
28527
  index78("orchestration_validation_envelopes_attempt_idx").on(
28523
28528
  table.attemptId,
28524
28529
  table.createdAt.desc()
28525
28530
  ),
28526
- index78("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql25`status IN ('queued', 'dispatched')`),
28531
+ index78("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql26`status IN ('queued', 'dispatched')`),
28527
28532
  check9(
28528
28533
  "orchestration_validation_envelopes_status_check",
28529
- sql25`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
28534
+ sql26`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
28530
28535
  ),
28531
28536
  // Passing is not assignable. It requires evidence that was ingested, an attestation that was
28532
28537
  // written, and a nonce that was consumed — so executor success alone cannot spell it.
@@ -28535,7 +28540,7 @@ var orchestrationValidationEnvelopes = pgTable91(
28535
28540
  // evidence, which is exactly what an honest failing result is.
28536
28541
  check9(
28537
28542
  "orchestration_validation_envelopes_passed_requires_evidence",
28538
- sql25`${table.status} <> 'passed' OR (${table.evidenceId} IS NOT NULL AND ${table.attestationDigest} IS NOT NULL AND ${table.nonceConsumedAt} IS NOT NULL)`
28543
+ sql26`${table.status} <> 'passed' OR (${table.evidenceId} IS NOT NULL AND ${table.attestationDigest} IS NOT NULL AND ${table.nonceConsumedAt} IS NOT NULL)`
28539
28544
  )
28540
28545
  ]
28541
28546
  );
@@ -28590,19 +28595,19 @@ var orchestrationValidationEvidence = pgTable91(
28590
28595
  index78("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
28591
28596
  check9(
28592
28597
  "orchestration_validation_evidence_status_check",
28593
- sql25`${table.status} IN ('passed', 'failed')`
28598
+ sql26`${table.status} IN ('passed', 'failed')`
28594
28599
  )
28595
28600
  ]
28596
28601
  );
28597
28602
 
28598
28603
  // src/schema/orchestration_executor_grants.ts
28599
- import { sql as sql26 } from "drizzle-orm";
28600
- import { check as check10, foreignKey as foreignKey12, index as index79, integer as integer47, pgTable as pgTable92, text as text93, timestamp as timestamp85, unique as unique11, uniqueIndex as uniqueIndex40, uuid as uuid8, varchar as varchar69 } from "drizzle-orm/pg-core";
28604
+ import { sql as sql27 } from "drizzle-orm";
28605
+ import { check as check10, foreignKey as foreignKey12, index as index79, integer as integer47, pgTable as pgTable92, text as text93, timestamp as timestamp85, unique as unique11, uniqueIndex as uniqueIndex41, uuid as uuid8, varchar as varchar69 } from "drizzle-orm/pg-core";
28601
28606
  var EXECUTOR_GRANT_STATUSES = ["active", "revoked", "expired"];
28602
28607
  var orchestrationExecutorGrants = pgTable92(
28603
28608
  "orchestration_executor_grants",
28604
28609
  {
28605
- id: text93("id").primaryKey().default(sql26`gen_random_uuid()`),
28610
+ id: text93("id").primaryKey().default(sql27`gen_random_uuid()`),
28606
28611
  workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28607
28612
  projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28608
28613
  installationId: uuid8("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
@@ -28636,21 +28641,21 @@ var orchestrationExecutorGrants = pgTable92(
28636
28641
  }).onDelete("cascade"),
28637
28642
  // One live credential per installation. Two would mean two processes can each present a valid
28638
28643
  // one, and the exclusion argument collapses before the lease layer is reached.
28639
- uniqueIndex40("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql26`status = 'active'`),
28640
- index79("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql26`status = 'active'`),
28644
+ uniqueIndex41("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql27`status = 'active'`),
28645
+ index79("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql27`status = 'active'`),
28641
28646
  check10(
28642
28647
  "orchestration_executor_grants_status_check",
28643
- sql26`${table.status} IN ('active', 'revoked', 'expired')`
28648
+ sql27`${table.status} IN ('active', 'revoked', 'expired')`
28644
28649
  ),
28645
28650
  check10(
28646
28651
  "orchestration_executor_grants_revocation_paired",
28647
- sql26`(${table.status} = 'revoked') = (${table.revokedAt} IS NOT NULL)`
28652
+ sql27`(${table.status} = 'revoked') = (${table.revokedAt} IS NOT NULL)`
28648
28653
  )
28649
28654
  ]
28650
28655
  );
28651
28656
 
28652
28657
  // src/schema/component_presets.ts
28653
- import { pgTable as pgTable93, text as text94, varchar as varchar70, timestamp as timestamp86, jsonb as jsonb52, integer as integer48, index as index80, uniqueIndex as uniqueIndex41 } from "drizzle-orm/pg-core";
28658
+ import { pgTable as pgTable93, text as text94, varchar as varchar70, timestamp as timestamp86, jsonb as jsonb52, integer as integer48, index as index80, uniqueIndex as uniqueIndex42 } from "drizzle-orm/pg-core";
28654
28659
  import { relations as relations16 } from "drizzle-orm";
28655
28660
  var componentPresets = pgTable93(
28656
28661
  "component_presets",
@@ -28671,7 +28676,7 @@ var componentPresets = pgTable93(
28671
28676
  },
28672
28677
  (t) => [
28673
28678
  index80("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
28674
- uniqueIndex41("component_presets_component_slug_key").on(t.componentId, t.slug)
28679
+ uniqueIndex42("component_presets_component_slug_key").on(t.componentId, t.slug)
28675
28680
  ]
28676
28681
  );
28677
28682
  var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
@@ -28691,10 +28696,10 @@ import {
28691
28696
  text as text95,
28692
28697
  timestamp as timestamp87,
28693
28698
  unique as unique12,
28694
- uniqueIndex as uniqueIndex42,
28699
+ uniqueIndex as uniqueIndex43,
28695
28700
  varchar as varchar71
28696
28701
  } from "drizzle-orm/pg-core";
28697
- import { sql as sql27 } from "drizzle-orm";
28702
+ import { sql as sql28 } from "drizzle-orm";
28698
28703
  var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
28699
28704
  "queued",
28700
28705
  "dispatching",
@@ -28721,7 +28726,7 @@ var sectionDefinitions = pgTable94(
28721
28726
  name: "section_definitions_project_workspace_fkey"
28722
28727
  }).onDelete("cascade").onUpdate("cascade"),
28723
28728
  unique12("section_definitions_id_project_unique").on(table.id, table.projectId),
28724
- uniqueIndex42("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
28729
+ uniqueIndex43("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
28725
28730
  index81("section_definitions_workspace_idx").on(table.workspaceId),
28726
28731
  index81("section_definitions_project_idx").on(table.projectId)
28727
28732
  ]
@@ -28780,7 +28785,7 @@ var sectionZones = pgTable94(
28780
28785
  name: "section_zones_project_workspace_fkey"
28781
28786
  }).onDelete("cascade").onUpdate("cascade"),
28782
28787
  unique12("section_zones_id_project_unique").on(table.id, table.projectId),
28783
- uniqueIndex42("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
28788
+ uniqueIndex43("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
28784
28789
  index81("section_zones_workspace_idx").on(table.workspaceId)
28785
28790
  ]
28786
28791
  );
@@ -28831,7 +28836,7 @@ var sectionZoneAttachments = pgTable94(
28831
28836
  ],
28832
28837
  name: "section_zone_attachments_published_version_fkey"
28833
28838
  }).onDelete("restrict"),
28834
- uniqueIndex42("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
28839
+ uniqueIndex43("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
28835
28840
  index81("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
28836
28841
  ]
28837
28842
  );
@@ -29010,7 +29015,7 @@ var sectionImplementationRequests = pgTable94(
29010
29015
  name: "section_implementation_requests_validation_project_fkey"
29011
29016
  }).onDelete("restrict"),
29012
29017
  unique12("section_implementation_requests_id_project_unique").on(table.id, table.projectId),
29013
- uniqueIndex42("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql27`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
29018
+ uniqueIndex43("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql28`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
29014
29019
  index81("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
29015
29020
  ]
29016
29021
  );
@@ -29044,7 +29049,7 @@ var sectionZoneReleases = pgTable94(
29044
29049
 
29045
29050
  // src/schema/content_locks.ts
29046
29051
  import { check as check11, index as index82, jsonb as jsonb54, pgTable as pgTable95, text as text96, timestamp as timestamp88 } from "drizzle-orm/pg-core";
29047
- import { sql as sql28 } from "drizzle-orm";
29052
+ import { sql as sql29 } from "drizzle-orm";
29048
29053
  var CONTENT_LOCK_TARGET_KINDS = [
29049
29054
  "page",
29050
29055
  "content_entry",
@@ -29075,9 +29080,9 @@ var contentLocks = pgTable95(
29075
29080
  (table) => [
29076
29081
  index82("content_locks_workspace_idx").on(table.workspaceId),
29077
29082
  index82("content_locks_project_idx").on(table.projectId),
29078
- index82("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql28`${table.releasedAt} IS NULL`),
29079
- check11("content_locks_target_kind_check", sql28`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
29080
- check11("content_locks_mode_check", sql28`${table.mode} IN ('all','agents')`)
29083
+ index82("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql29`${table.releasedAt} IS NULL`),
29084
+ check11("content_locks_target_kind_check", sql29`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
29085
+ check11("content_locks_mode_check", sql29`${table.mode} IN ('all','agents')`)
29081
29086
  // `content_locks_shape_check` lives in migration 0192 ONLY: it calls
29082
29087
  // content_lock_field_path_valid(), which that migration creates. Declared here it went into
29083
29088
  // `drizzle-kit push`'s CREATE TABLE on an empty database, where the function does not exist
@@ -29096,9 +29101,9 @@ import {
29096
29101
  varchar as varchar72,
29097
29102
  timestamp as timestamp89,
29098
29103
  index as index83,
29099
- uniqueIndex as uniqueIndex43
29104
+ uniqueIndex as uniqueIndex44
29100
29105
  } from "drizzle-orm/pg-core";
29101
- import { sql as sql29 } from "drizzle-orm";
29106
+ import { sql as sql30 } from "drizzle-orm";
29102
29107
  var projectTransfers = pgTable96(
29103
29108
  "project_transfers",
29104
29109
  {
@@ -29134,7 +29139,7 @@ var projectTransfers = pgTable96(
29134
29139
  (table) => [
29135
29140
  // At most one OPEN transfer per project. Partial-unique so completed/declined/
29136
29141
  // cancelled/expired/failed rows never wedge a re-initiation.
29137
- uniqueIndex43("project_transfers_one_pending_idx").on(table.projectId).where(sql29`${table.status} = 'pending'`),
29142
+ uniqueIndex44("project_transfers_one_pending_idx").on(table.projectId).where(sql30`${table.status} = 'pending'`),
29138
29143
  // Recipient inbox lookup (GET /me/transfers by email + status).
29139
29144
  index83("project_transfers_recipient_idx").on(
29140
29145
  table.recipientEmail,
@@ -29144,9 +29149,9 @@ var projectTransfers = pgTable96(
29144
29149
  index83("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
29145
29150
  index83("project_transfers_project_idx").on(table.projectId),
29146
29151
  // Magic-link resolution.
29147
- uniqueIndex43("project_transfers_token_idx").on(table.token),
29152
+ uniqueIndex44("project_transfers_token_idx").on(table.token),
29148
29153
  // Expiry sweep — only pending rows are ever candidates.
29149
- index83("project_transfers_expires_idx").on(table.expiresAt).where(sql29`${table.status} = 'pending'`)
29154
+ index83("project_transfers_expires_idx").on(table.expiresAt).where(sql30`${table.status} = 'pending'`)
29150
29155
  ]
29151
29156
  );
29152
29157
 
@@ -29271,8 +29276,8 @@ var cloneLinks = pgTable99(
29271
29276
  );
29272
29277
 
29273
29278
  // src/schema/clone_jobs.ts
29274
- import { pgTable as pgTable100, text as text101, varchar as varchar75, integer as integer52, jsonb as jsonb58, timestamp as timestamp93, index as index87, uniqueIndex as uniqueIndex44 } from "drizzle-orm/pg-core";
29275
- import { sql as sql30 } from "drizzle-orm";
29279
+ import { pgTable as pgTable100, text as text101, varchar as varchar75, integer as integer52, jsonb as jsonb58, timestamp as timestamp93, index as index87, uniqueIndex as uniqueIndex45 } from "drizzle-orm/pg-core";
29280
+ import { sql as sql31 } from "drizzle-orm";
29276
29281
  var cloneJobs = pgTable100(
29277
29282
  "clone_jobs",
29278
29283
  {
@@ -29306,7 +29311,7 @@ var cloneJobs = pgTable100(
29306
29311
  index87("clone_jobs_workspace_idx").on(t.workspaceId),
29307
29312
  // One unfinished hybrid→headless switch per source (0343). The route maps its 23505 to
29308
29313
  // SWITCH_ALREADY_PENDING.
29309
- uniqueIndex44("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql30`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
29314
+ uniqueIndex45("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql31`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
29310
29315
  ]
29311
29316
  );
29312
29317
 
@@ -29317,9 +29322,9 @@ import {
29317
29322
  varchar as varchar76,
29318
29323
  timestamp as timestamp94,
29319
29324
  index as index88,
29320
- uniqueIndex as uniqueIndex45
29325
+ uniqueIndex as uniqueIndex46
29321
29326
  } from "drizzle-orm/pg-core";
29322
- import { sql as sql31 } from "drizzle-orm";
29327
+ import { sql as sql32 } from "drizzle-orm";
29323
29328
  var projectBranches = pgTable101(
29324
29329
  "project_branches",
29325
29330
  {
@@ -29336,12 +29341,12 @@ var projectBranches = pgTable101(
29336
29341
  },
29337
29342
  (t) => [
29338
29343
  index88("project_branches_project_idx").on(t.projectId),
29339
- uniqueIndex45("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql31`${t.status} = 'open'`)
29344
+ uniqueIndex46("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql32`${t.status} = 'open'`)
29340
29345
  ]
29341
29346
  );
29342
29347
 
29343
29348
  // src/schema/branch_preview_share.ts
29344
- import { pgTable as pgTable102, text as text103, boolean as boolean32, timestamp as timestamp95, index as index89, uniqueIndex as uniqueIndex46 } from "drizzle-orm/pg-core";
29349
+ import { pgTable as pgTable102, text as text103, boolean as boolean32, timestamp as timestamp95, index as index89, uniqueIndex as uniqueIndex47 } from "drizzle-orm/pg-core";
29345
29350
  var branchPreviewShares = pgTable102(
29346
29351
  "branch_preview_shares",
29347
29352
  {
@@ -29356,8 +29361,8 @@ var branchPreviewShares = pgTable102(
29356
29361
  updatedAt: timestamp95("updated_at").notNull().defaultNow()
29357
29362
  },
29358
29363
  (t) => [
29359
- uniqueIndex46("branch_preview_shares_branch_idx").on(t.branchId),
29360
- uniqueIndex46("branch_preview_shares_active_token_idx").on(t.publicToken),
29364
+ uniqueIndex47("branch_preview_shares_branch_idx").on(t.branchId),
29365
+ uniqueIndex47("branch_preview_shares_active_token_idx").on(t.publicToken),
29361
29366
  index89("branch_preview_shares_project_idx").on(t.projectId),
29362
29367
  index89("branch_preview_shares_workspace_idx").on(t.workspaceId)
29363
29368
  ]
@@ -29374,7 +29379,7 @@ var branchPreviewGrants = pgTable102(
29374
29379
  createdAt: timestamp95("created_at").notNull().defaultNow()
29375
29380
  },
29376
29381
  (t) => [
29377
- uniqueIndex46("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
29382
+ uniqueIndex47("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
29378
29383
  index89("branch_preview_grants_project_idx").on(t.projectId)
29379
29384
  ]
29380
29385
  );
@@ -29415,10 +29420,10 @@ import {
29415
29420
  jsonb as jsonb59,
29416
29421
  integer as integer53,
29417
29422
  index as index91,
29418
- uniqueIndex as uniqueIndex47
29423
+ uniqueIndex as uniqueIndex48
29419
29424
  } from "drizzle-orm/pg-core";
29420
29425
  import { relations as relations17 } from "drizzle-orm/relations";
29421
- import { sql as sql32 } from "drizzle-orm";
29426
+ import { sql as sql33 } from "drizzle-orm";
29422
29427
  var templates = pgTable104(
29423
29428
  "templates",
29424
29429
  {
@@ -29456,9 +29461,9 @@ var templates = pgTable104(
29456
29461
  index91("templates_workspace_idx").on(table.workspaceId),
29457
29462
  // Partial: only live rows. A soft-deleted template frees its slug (mirrors
29458
29463
  // components_ws_proj_slug_idx / migration 0114).
29459
- uniqueIndex47("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql32`${table.deletedAt} IS NULL`),
29464
+ uniqueIndex48("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql33`${table.deletedAt} IS NULL`),
29460
29465
  // Public gallery scan (created_at DESC over live public rows).
29461
- index91("templates_public_idx").on(table.visibility).where(sql32`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
29466
+ index91("templates_public_idx").on(table.visibility).where(sql33`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
29462
29467
  ]
29463
29468
  );
29464
29469
  var templatesRelations = relations17(templates, ({ one }) => ({
@@ -29551,7 +29556,7 @@ var billingAddons = pgTable107(
29551
29556
  );
29552
29557
 
29553
29558
  // src/schema/billing_customers.ts
29554
- import { pgTable as pgTable108, text as text109, varchar as varchar80, timestamp as timestamp100, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
29559
+ import { pgTable as pgTable108, text as text109, varchar as varchar80, timestamp as timestamp100, uniqueIndex as uniqueIndex49 } from "drizzle-orm/pg-core";
29555
29560
  var billingCustomers = pgTable108(
29556
29561
  "billing_customers",
29557
29562
  {
@@ -29565,14 +29570,14 @@ var billingCustomers = pgTable108(
29565
29570
  updatedAt: timestamp100("updated_at").notNull().defaultNow()
29566
29571
  },
29567
29572
  (t) => [
29568
- uniqueIndex48("billing_customers_workspace_idx").on(t.workspaceId),
29569
- uniqueIndex48("billing_customers_dodo_idx").on(t.dodoCustomerId)
29573
+ uniqueIndex49("billing_customers_workspace_idx").on(t.workspaceId),
29574
+ uniqueIndex49("billing_customers_dodo_idx").on(t.dodoCustomerId)
29570
29575
  ]
29571
29576
  );
29572
29577
 
29573
29578
  // src/schema/subscriptions.ts
29574
- import { pgTable as pgTable109, text as text110, varchar as varchar81, boolean as boolean35, timestamp as timestamp101, index as index95, uniqueIndex as uniqueIndex49 } from "drizzle-orm/pg-core";
29575
- import { sql as sql33 } from "drizzle-orm";
29579
+ import { pgTable as pgTable109, text as text110, varchar as varchar81, boolean as boolean35, timestamp as timestamp101, index as index95, uniqueIndex as uniqueIndex50 } from "drizzle-orm/pg-core";
29580
+ import { sql as sql34 } from "drizzle-orm";
29576
29581
  var subscriptions = pgTable109(
29577
29582
  "subscriptions",
29578
29583
  {
@@ -29599,17 +29604,17 @@ var subscriptions = pgTable109(
29599
29604
  },
29600
29605
  (t) => [
29601
29606
  index95("subscriptions_workspace_idx").on(t.workspaceId),
29602
- uniqueIndex49("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql33`${t.dodoSubscriptionId} IS NOT NULL`),
29607
+ uniqueIndex50("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql34`${t.dodoSubscriptionId} IS NOT NULL`),
29603
29608
  // At most one workspace-level subscription per workspace.
29604
- uniqueIndex49("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql33`${t.projectId} IS NULL`),
29609
+ uniqueIndex50("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql34`${t.projectId} IS NULL`),
29605
29610
  // At most one subscription per site.
29606
- uniqueIndex49("subscriptions_project_unique").on(t.projectId).where(sql33`${t.projectId} IS NOT NULL`)
29611
+ uniqueIndex50("subscriptions_project_unique").on(t.projectId).where(sql34`${t.projectId} IS NOT NULL`)
29607
29612
  ]
29608
29613
  );
29609
29614
 
29610
29615
  // src/schema/subscription_addons.ts
29611
- import { pgTable as pgTable110, text as text111, varchar as varchar82, integer as integer56, timestamp as timestamp102, index as index96, uniqueIndex as uniqueIndex50 } from "drizzle-orm/pg-core";
29612
- import { sql as sql34 } from "drizzle-orm";
29616
+ import { pgTable as pgTable110, text as text111, varchar as varchar82, integer as integer56, timestamp as timestamp102, index as index96, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
29617
+ import { sql as sql35 } from "drizzle-orm";
29613
29618
  var subscriptionAddons = pgTable110(
29614
29619
  "subscription_addons",
29615
29620
  {
@@ -29629,12 +29634,12 @@ var subscriptionAddons = pgTable110(
29629
29634
  },
29630
29635
  (t) => [
29631
29636
  index96("subscription_addons_workspace_idx").on(t.workspaceId),
29632
- uniqueIndex50("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql34`${t.dodoSubscriptionId} IS NOT NULL`)
29637
+ uniqueIndex51("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql35`${t.dodoSubscriptionId} IS NOT NULL`)
29633
29638
  ]
29634
29639
  );
29635
29640
 
29636
29641
  // src/schema/billing_alerts.ts
29637
- import { pgTable as pgTable111, text as text112, varchar as varchar83, timestamp as timestamp103, index as index97, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
29642
+ import { pgTable as pgTable111, text as text112, varchar as varchar83, timestamp as timestamp103, index as index97, uniqueIndex as uniqueIndex52 } from "drizzle-orm/pg-core";
29638
29643
  var billingAlerts = pgTable111(
29639
29644
  "billing_alerts",
29640
29645
  {
@@ -29654,14 +29659,14 @@ var billingAlerts = pgTable111(
29654
29659
  sentAt: timestamp103("sent_at", { withTimezone: true }).notNull().defaultNow()
29655
29660
  },
29656
29661
  (t) => [
29657
- uniqueIndex51("billing_alerts_dedupe_idx").on(t.dedupeKey),
29662
+ uniqueIndex52("billing_alerts_dedupe_idx").on(t.dedupeKey),
29658
29663
  index97("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
29659
29664
  ]
29660
29665
  );
29661
29666
 
29662
29667
  // src/schema/ai_credit_ledger.ts
29663
- import { pgTable as pgTable112, text as text113, varchar as varchar84, integer as integer57, timestamp as timestamp104, index as index98, uniqueIndex as uniqueIndex52 } from "drizzle-orm/pg-core";
29664
- import { sql as sql35 } from "drizzle-orm";
29668
+ import { pgTable as pgTable112, text as text113, varchar as varchar84, integer as integer57, timestamp as timestamp104, index as index98, uniqueIndex as uniqueIndex53 } from "drizzle-orm/pg-core";
29669
+ import { sql as sql36 } from "drizzle-orm";
29665
29670
  var aiCreditLedger = pgTable112(
29666
29671
  "ai_credit_ledger",
29667
29672
  {
@@ -29680,7 +29685,7 @@ var aiCreditLedger = pgTable112(
29680
29685
  },
29681
29686
  (t) => [
29682
29687
  index98("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt),
29683
- uniqueIndex52("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql35`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
29688
+ uniqueIndex53("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql36`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
29684
29689
  ]
29685
29690
  );
29686
29691
 
@@ -29889,7 +29894,7 @@ import {
29889
29894
  varchar as varchar90,
29890
29895
  timestamp as timestamp110,
29891
29896
  index as index104,
29892
- uniqueIndex as uniqueIndex53
29897
+ uniqueIndex as uniqueIndex54
29893
29898
  } from "drizzle-orm/pg-core";
29894
29899
  var ENV_VAR_SCOPES = ["production", "preview", "development"];
29895
29900
  var projectEnvVars = pgTable118(
@@ -29912,7 +29917,7 @@ var projectEnvVars = pgTable118(
29912
29917
  },
29913
29918
  (table) => [
29914
29919
  // One value per key per scope — the same key MAY exist in production and preview.
29915
- uniqueIndex53("project_env_vars_project_key_scope_idx").on(
29920
+ uniqueIndex54("project_env_vars_project_key_scope_idx").on(
29916
29921
  table.projectId,
29917
29922
  table.key,
29918
29923
  table.scope
@@ -29922,8 +29927,8 @@ var projectEnvVars = pgTable118(
29922
29927
  );
29923
29928
 
29924
29929
  // src/schema/mcp_connections.ts
29925
- import { pgTable as pgTable119, text as text120, varchar as varchar91, jsonb as jsonb63, timestamp as timestamp111, index as index105, uniqueIndex as uniqueIndex54 } from "drizzle-orm/pg-core";
29926
- import { sql as sql36 } from "drizzle-orm";
29930
+ import { pgTable as pgTable119, text as text120, varchar as varchar91, jsonb as jsonb63, timestamp as timestamp111, index as index105, uniqueIndex as uniqueIndex55 } from "drizzle-orm/pg-core";
29931
+ import { sql as sql37 } from "drizzle-orm";
29927
29932
  var mcpConnections = pgTable119(
29928
29933
  "mcp_connections",
29929
29934
  {
@@ -29986,7 +29991,7 @@ var mcpConnections = pgTable119(
29986
29991
  index105("mcp_connections_project_idx").on(t.projectId),
29987
29992
  // Reconnecting a catalog provider UPDATEs rather than accumulating a second live credential.
29988
29993
  // Custom connectors are excluded: a project may legitimately add many distinct MCP servers.
29989
- uniqueIndex54("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql36`deleted_at IS NULL AND provider_slug <> 'custom'`)
29994
+ uniqueIndex55("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql37`deleted_at IS NULL AND provider_slug <> 'custom'`)
29990
29995
  ]
29991
29996
  );
29992
29997
 
@@ -29998,7 +30003,7 @@ import {
29998
30003
  boolean as boolean38,
29999
30004
  jsonb as jsonb64,
30000
30005
  integer as integer59,
30001
- uniqueIndex as uniqueIndex55
30006
+ uniqueIndex as uniqueIndex56
30002
30007
  } from "drizzle-orm/pg-core";
30003
30008
  var crmConnections = pgTable120(
30004
30009
  "crm_connections",
@@ -30018,7 +30023,7 @@ var crmConnections = pgTable120(
30018
30023
  updatedAt: timestamp112("updated_at").notNull().defaultNow()
30019
30024
  },
30020
30025
  (t) => [
30021
- uniqueIndex55("crm_connection_account_uq").on(
30026
+ uniqueIndex56("crm_connection_account_uq").on(
30022
30027
  t.workspaceId,
30023
30028
  t.provider,
30024
30029
  t.accountId
@@ -30056,7 +30061,7 @@ var formIntegrationDeliveries = pgTable120(
30056
30061
  updatedAt: timestamp112("updated_at").notNull().defaultNow()
30057
30062
  },
30058
30063
  (t) => [
30059
- uniqueIndex55("crm_delivery_event_uq").on(
30064
+ uniqueIndex56("crm_delivery_event_uq").on(
30060
30065
  t.workspaceId,
30061
30066
  t.eventId,
30062
30067
  t.integrationId
@@ -30128,7 +30133,7 @@ async function reserveWithDeadline() {
30128
30133
  })
30129
30134
  ]);
30130
30135
  } catch (err) {
30131
- void pending.then((sql38) => sql38.release()).catch((cause) => console.error("[db-pool] orphaned acquire failed:", cause));
30136
+ void pending.then((sql39) => sql39.release()).catch((cause) => console.error("[db-pool] orphaned acquire failed:", cause));
30132
30137
  throw err;
30133
30138
  } finally {
30134
30139
  clearTimeout(timer);
@@ -30338,7 +30343,7 @@ var queries = {
30338
30343
  };
30339
30344
 
30340
30345
  // src/lib/workspace-context.ts
30341
- import { sql as sql37 } from "drizzle-orm";
30346
+ import { sql as sql38 } from "drizzle-orm";
30342
30347
  import { eq as eq2 } from "drizzle-orm";
30343
30348
  import { nanoid } from "nanoid";
30344
30349
  var writeOrigins = new Set(WRITE_ORIGINS);
@@ -30372,7 +30377,7 @@ async function getWorkspaceSlugById(workspaceId) {
30372
30377
  }
30373
30378
  async function lookupApiKeyByHash(keyHash) {
30374
30379
  const rows = await db.execute(
30375
- sql37`SELECT * FROM lookup_api_key_by_hash(${keyHash})`
30380
+ sql38`SELECT * FROM lookup_api_key_by_hash(${keyHash})`
30376
30381
  );
30377
30382
  const r = rows[0];
30378
30383
  if (!r) return null;
@@ -30403,7 +30408,7 @@ async function lookupApiKeyByHash(keyHash) {
30403
30408
  }
30404
30409
  async function publicWorkspaceBySlug(slug) {
30405
30410
  const rows = await db.execute(
30406
- sql37`SELECT id, slug FROM public_workspace_by_slug(${slug})`
30411
+ sql38`SELECT id, slug FROM public_workspace_by_slug(${slug})`
30407
30412
  );
30408
30413
  const r = rows[0];
30409
30414
  return r?.id ? { id: r.id, slug: r.slug ?? slug } : null;
@@ -30413,7 +30418,7 @@ async function getDefaultWorkspaceId(userId) {
30413
30418
  return row?.id ?? null;
30414
30419
  }
30415
30420
  async function resolveUserWorkspace(userId, workspaceId) {
30416
- const rows = await db.execute(sql37`
30421
+ const rows = await db.execute(sql38`
30417
30422
  SELECT workspace_id, role
30418
30423
  FROM resolve_user_workspace(${userId}, ${workspaceId ?? null})
30419
30424
  `);
@@ -30449,7 +30454,7 @@ async function ensureDefaultWorkspace(userId, name = "My Workspace", slug) {
30449
30454
  for (let attempt = 1; attempt <= MAX_SLUG_ATTEMPTS; attempt++) {
30450
30455
  console.log("[ensureDefaultWorkspace] Creating workspace + owner membership:", { workspaceId, slug: candidateSlug, attempt });
30451
30456
  try {
30452
- await db.execute(sql37`
30457
+ await db.execute(sql38`
30453
30458
  SELECT create_default_workspace(${workspaceId}, ${userId}, ${memberId}, ${name}, ${candidateSlug})
30454
30459
  `);
30455
30460
  console.log("[ensureDefaultWorkspace] Workspace + owner membership created with slug:", candidateSlug);