@bettercms-ai/db 0.1.0 → 0.2.0
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.d.ts +1387 -4
- package/dist/index.js +1249 -1069
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
package/dist/index.js
CHANGED
|
@@ -11629,18 +11629,18 @@ var require_common = __commonJS({
|
|
|
11629
11629
|
if (typeof args[0] !== "string") {
|
|
11630
11630
|
args.unshift("%O");
|
|
11631
11631
|
}
|
|
11632
|
-
let
|
|
11632
|
+
let index103 = 0;
|
|
11633
11633
|
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
11634
11634
|
if (match === "%%") {
|
|
11635
11635
|
return "%";
|
|
11636
11636
|
}
|
|
11637
|
-
|
|
11637
|
+
index103++;
|
|
11638
11638
|
const formatter = createDebug.formatters[format];
|
|
11639
11639
|
if (typeof formatter === "function") {
|
|
11640
|
-
const val = args[
|
|
11640
|
+
const val = args[index103];
|
|
11641
11641
|
match = formatter.call(self2, val);
|
|
11642
|
-
args.splice(
|
|
11643
|
-
|
|
11642
|
+
args.splice(index103, 1);
|
|
11643
|
+
index103--;
|
|
11644
11644
|
}
|
|
11645
11645
|
return match;
|
|
11646
11646
|
});
|
|
@@ -11876,15 +11876,15 @@ var require_browser = __commonJS({
|
|
|
11876
11876
|
}
|
|
11877
11877
|
const c = "color: " + this.color;
|
|
11878
11878
|
args.splice(1, 0, c, "color: inherit");
|
|
11879
|
-
let
|
|
11879
|
+
let index103 = 0;
|
|
11880
11880
|
let lastC = 0;
|
|
11881
11881
|
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
11882
11882
|
if (match === "%%") {
|
|
11883
11883
|
return;
|
|
11884
11884
|
}
|
|
11885
|
-
|
|
11885
|
+
index103++;
|
|
11886
11886
|
if (match === "%c") {
|
|
11887
|
-
lastC =
|
|
11887
|
+
lastC = index103;
|
|
11888
11888
|
}
|
|
11889
11889
|
});
|
|
11890
11890
|
args.splice(lastC, 0, c);
|
|
@@ -13368,10 +13368,10 @@ var require_axios = __commonJS({
|
|
|
13368
13368
|
value = JSON.stringify(value);
|
|
13369
13369
|
} else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
|
|
13370
13370
|
key = removeBrackets(key);
|
|
13371
|
-
arr.forEach(function each(el,
|
|
13371
|
+
arr.forEach(function each(el, index103) {
|
|
13372
13372
|
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
13373
13373
|
// eslint-disable-next-line no-nested-ternary
|
|
13374
|
-
indexes === true ? renderKey([key],
|
|
13374
|
+
indexes === true ? renderKey([key], index103, dots) : indexes === null ? key : key + "[]",
|
|
13375
13375
|
convertValue(el)
|
|
13376
13376
|
);
|
|
13377
13377
|
});
|
|
@@ -13618,11 +13618,11 @@ var require_axios = __commonJS({
|
|
|
13618
13618
|
return obj;
|
|
13619
13619
|
}
|
|
13620
13620
|
function formDataToJSON(formData) {
|
|
13621
|
-
function buildPath(path2, value, target,
|
|
13622
|
-
let name = path2[
|
|
13621
|
+
function buildPath(path2, value, target, index103) {
|
|
13622
|
+
let name = path2[index103++];
|
|
13623
13623
|
if (name === "__proto__") return true;
|
|
13624
13624
|
const isNumericKey = Number.isFinite(+name);
|
|
13625
|
-
const isLast =
|
|
13625
|
+
const isLast = index103 >= path2.length;
|
|
13626
13626
|
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
13627
13627
|
if (isLast) {
|
|
13628
13628
|
if (utils$1.hasOwnProp(target, name)) {
|
|
@@ -13635,7 +13635,7 @@ var require_axios = __commonJS({
|
|
|
13635
13635
|
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
13636
13636
|
target[name] = [];
|
|
13637
13637
|
}
|
|
13638
|
-
const result = buildPath(path2, value, target[name],
|
|
13638
|
+
const result = buildPath(path2, value, target[name], index103);
|
|
13639
13639
|
if (result && utils$1.isArray(target[name])) {
|
|
13640
13640
|
target[name] = arrayToObject(target[name]);
|
|
13641
13641
|
}
|
|
@@ -14563,12 +14563,12 @@ var require_axios = __commonJS({
|
|
|
14563
14563
|
};
|
|
14564
14564
|
}
|
|
14565
14565
|
function throttle(fn, freq) {
|
|
14566
|
-
let
|
|
14566
|
+
let timestamp109 = 0;
|
|
14567
14567
|
let threshold = 1e3 / freq;
|
|
14568
14568
|
let lastArgs;
|
|
14569
14569
|
let timer;
|
|
14570
14570
|
const invoke = (args, now = Date.now()) => {
|
|
14571
|
-
|
|
14571
|
+
timestamp109 = now;
|
|
14572
14572
|
lastArgs = null;
|
|
14573
14573
|
if (timer) {
|
|
14574
14574
|
clearTimeout(timer);
|
|
@@ -14578,7 +14578,7 @@ var require_axios = __commonJS({
|
|
|
14578
14578
|
};
|
|
14579
14579
|
const throttled = (...args) => {
|
|
14580
14580
|
const now = Date.now();
|
|
14581
|
-
const passed = now -
|
|
14581
|
+
const passed = now - timestamp109;
|
|
14582
14582
|
if (passed >= threshold) {
|
|
14583
14583
|
invoke(args, now);
|
|
14584
14584
|
} else {
|
|
@@ -16406,9 +16406,9 @@ var require_axios = __commonJS({
|
|
|
16406
16406
|
if (!this._listeners) {
|
|
16407
16407
|
return;
|
|
16408
16408
|
}
|
|
16409
|
-
const
|
|
16410
|
-
if (
|
|
16411
|
-
this._listeners.splice(
|
|
16409
|
+
const index103 = this._listeners.indexOf(listener);
|
|
16410
|
+
if (index103 !== -1) {
|
|
16411
|
+
this._listeners.splice(index103, 1);
|
|
16412
16412
|
}
|
|
16413
16413
|
}
|
|
16414
16414
|
toAbortSignal() {
|
|
@@ -20130,6 +20130,7 @@ __export(index_exports, {
|
|
|
20130
20130
|
bcmsMigrationFlags: () => bcmsMigrationFlags,
|
|
20131
20131
|
betaWaitlist: () => betaWaitlist,
|
|
20132
20132
|
billingAddons: () => billingAddons,
|
|
20133
|
+
billingAlerts: () => billingAlerts,
|
|
20133
20134
|
billingCustomers: () => billingCustomers,
|
|
20134
20135
|
branchColumns: () => branchColumns,
|
|
20135
20136
|
branchPreviewGrants: () => branchPreviewGrants,
|
|
@@ -20163,10 +20164,13 @@ __export(index_exports, {
|
|
|
20163
20164
|
contentLocks: () => contentLocks,
|
|
20164
20165
|
contentModels: () => contentModels,
|
|
20165
20166
|
contentModelsRelations: () => contentModelsRelations,
|
|
20167
|
+
contentNavigation: () => contentNavigation,
|
|
20166
20168
|
contentVersions: () => contentVersions,
|
|
20167
20169
|
conversionBriefsIssued: () => conversionBriefsIssued,
|
|
20168
20170
|
conversionProposals: () => conversionProposals,
|
|
20171
|
+
crmConnections: () => crmConnections,
|
|
20169
20172
|
crmDeals: () => crmDeals,
|
|
20173
|
+
crmOauthStates: () => crmOauthStates,
|
|
20170
20174
|
customDomains: () => customDomains,
|
|
20171
20175
|
deployTargets: () => deployTargets,
|
|
20172
20176
|
deviceAuthorizations: () => deviceAuthorizations,
|
|
@@ -20176,6 +20180,7 @@ __export(index_exports, {
|
|
|
20176
20180
|
foldersRelations: () => foldersRelations,
|
|
20177
20181
|
formContacts: () => formContacts,
|
|
20178
20182
|
formContactsRelations: () => formContactsRelations,
|
|
20183
|
+
formIntegrationDeliveries: () => formIntegrationDeliveries,
|
|
20179
20184
|
formIntegrations: () => formIntegrations,
|
|
20180
20185
|
formIntegrationsRelations: () => formIntegrationsRelations,
|
|
20181
20186
|
formSubmissions: () => formSubmissions,
|
|
@@ -20358,8 +20363,12 @@ import { sql } from "drizzle-orm";
|
|
|
20358
20363
|
var workspaces = pgTable(
|
|
20359
20364
|
"workspaces",
|
|
20360
20365
|
{
|
|
20366
|
+
// TEXT, but the values are UUIDs: workspaces are created with crypto.randomUUID()
|
|
20367
|
+
// (src/workspaces.ts). That matters — setWorkspaceContext() pins RLS with
|
|
20368
|
+
// set_current_workspace(<id>::uuid), and there is a TEXT overload it does NOT use, so
|
|
20369
|
+
// reading this as a nanoid suggests the standard RLS pinning helper would throw on a
|
|
20370
|
+
// real id. It does not. Other tables here genuinely are nanoid; this one is not.
|
|
20361
20371
|
id: text2("id").primaryKey(),
|
|
20362
|
-
// nanoid — consistent with BetterAuth approach
|
|
20363
20372
|
name: varchar("name", { length: 255 }).notNull(),
|
|
20364
20373
|
slug: varchar("slug", { length: 255 }).notNull().unique(),
|
|
20365
20374
|
// used in API paths: /api/v1/:workspace/...
|
|
@@ -21432,6 +21441,8 @@ var projects = pgTable10(
|
|
|
21432
21441
|
// Brand kit (0162): colors/type/shape/logos/voice. NULL = never configured; the
|
|
21433
21442
|
// API substitutes DEFAULT_BRAND_KIT rather than storing a row of defaults.
|
|
21434
21443
|
brandKit: jsonb8("brand_kit").$type(),
|
|
21444
|
+
brandDesign: jsonb8("brand_design").$type(),
|
|
21445
|
+
brandDesignTarget: varchar10("brand_design_target", { length: 64 }),
|
|
21435
21446
|
/**
|
|
21436
21447
|
* Last annotate run per release slot (migration 0229): which declared field paths could not
|
|
21437
21448
|
* be bound to an element on the built page. Lets the Visual Editor say "3 fields unbindable"
|
|
@@ -21532,8 +21543,14 @@ var projects = pgTable10(
|
|
|
21532
21543
|
canvasEnabled: boolean7("canvas_enabled").notNull().default(false),
|
|
21533
21544
|
// Validate components automatically once a release is live (migration 0324). Defaults FALSE: the run spends the
|
|
21534
21545
|
// customer's own GitHub Actions minutes. `componentValidationDispatchedAt` debounces a release storm.
|
|
21535
|
-
componentAutoValidate: boolean7("component_auto_validate").notNull().default(
|
|
21546
|
+
componentAutoValidate: boolean7("component_auto_validate").notNull().default(true),
|
|
21536
21547
|
componentValidationDispatchedAt: timestamp11("component_validation_dispatched_at", { withTimezone: true }),
|
|
21548
|
+
// The last automatic pass left components out (LIMIT_REACHED); its batch's last report starts the next pass (0331).
|
|
21549
|
+
componentValidationOverflow: boolean7("component_validation_overflow").notNull().default(false),
|
|
21550
|
+
// The last automatic validation pass's decision, whatever it was (0333) — so a project that never validates says why.
|
|
21551
|
+
componentValidationLastPass: jsonb8("component_validation_last_pass").$type(),
|
|
21552
|
+
// The release commit the last dispatching automatic pass ran for: a redeploy of that commit does not dispatch (0333).
|
|
21553
|
+
componentValidationCommitSha: text11("component_validation_commit_sha"),
|
|
21537
21554
|
// How nginx resolves a page request for this project (FLO-947; migration 0211, widened
|
|
21538
21555
|
// to 'node' by 0225).
|
|
21539
21556
|
// 'static' = today's disk-first `try_files`; the CMS renderer only fills gaps.
|
|
@@ -21609,6 +21626,21 @@ var projects = pgTable10(
|
|
|
21609
21626
|
* bar until someone actually publishes. NULL = nothing waiting. Migration 0288.
|
|
21610
21627
|
*/
|
|
21611
21628
|
pendingMainPublish: jsonb8("pending_main_publish").$type(),
|
|
21629
|
+
/**
|
|
21630
|
+
* Archived: retired from the working set but NOT deleted. Three distinct axes, and
|
|
21631
|
+
* conflating any two of them is the bug this comment exists to prevent:
|
|
21632
|
+
*
|
|
21633
|
+
* deleted_at hard-delete tombstone. The row and its children are going away.
|
|
21634
|
+
* unpublished_at the site is off the internet. The project is still worked on.
|
|
21635
|
+
* archived_at the project is put away. It is ALSO off the internet, by rule.
|
|
21636
|
+
*
|
|
21637
|
+
* 🔴 An archived project must be neither live nor able to go live — the same rule
|
|
21638
|
+
* pages.archivedAt carries one level down. It is enforced in ONE place:
|
|
21639
|
+
* project_publishing_lock() (migration 0330) reports `source = 'archived'`, so both
|
|
21640
|
+
* publishing-lock seams refuse the publish and no route has to remember.
|
|
21641
|
+
* Archiving therefore unpublishes first, and refuses to archive if that fails.
|
|
21642
|
+
*/
|
|
21643
|
+
archivedAt: timestamp11("archived_at"),
|
|
21612
21644
|
...auditColumns,
|
|
21613
21645
|
...softDeleteColumn
|
|
21614
21646
|
},
|
|
@@ -21621,7 +21653,9 @@ var projects = pgTable10(
|
|
|
21621
21653
|
// 0051; the create handler's conflict check also excludes soft-deleted rows.
|
|
21622
21654
|
uniqueIndex3("projects_workspace_slug_idx").on(table.workspaceId, table.slug).where(sql5`${table.deletedAt} IS NULL`),
|
|
21623
21655
|
// Workspace filtering
|
|
21624
|
-
index10("projects_workspace_idx").on(table.workspaceId)
|
|
21656
|
+
index10("projects_workspace_idx").on(table.workspaceId),
|
|
21657
|
+
// Archive: every archive-aware list filters on this, so it earns an index like deletedAt.
|
|
21658
|
+
index10("projects_archived_at_idx").on(table.archivedAt)
|
|
21625
21659
|
]
|
|
21626
21660
|
);
|
|
21627
21661
|
var projectFolders = pgTable10("project_folders", {
|
|
@@ -23065,7 +23099,8 @@ import {
|
|
|
23065
23099
|
timestamp as timestamp44,
|
|
23066
23100
|
integer as integer21,
|
|
23067
23101
|
index as index43,
|
|
23068
|
-
unique as unique3
|
|
23102
|
+
unique as unique3,
|
|
23103
|
+
jsonb as jsonb25
|
|
23069
23104
|
} from "drizzle-orm/pg-core";
|
|
23070
23105
|
var releases = pgTable46(
|
|
23071
23106
|
"releases",
|
|
@@ -23083,6 +23118,11 @@ var releases = pgTable46(
|
|
|
23083
23118
|
commitMessage: text47("commit_message"),
|
|
23084
23119
|
// pending | ingested | releasing | live | failed | rolled_back
|
|
23085
23120
|
status: varchar30("status", { length: 20 }).notNull().default("ingested"),
|
|
23121
|
+
designInput: jsonb25("design_input").$type(),
|
|
23122
|
+
designSnapshot: jsonb25("design_snapshot").$type(),
|
|
23123
|
+
designError: text47("design_error"),
|
|
23124
|
+
designAttempts: integer21("design_attempts").notNull().default(0),
|
|
23125
|
+
designRetryAt: timestamp44("design_retry_at"),
|
|
23086
23126
|
// Artifact triple. NULL on a row that records a FAILED BUILD (0175): the build
|
|
23087
23127
|
// never produced a .tgz, so there is nothing to key, checksum or size. Every
|
|
23088
23128
|
// reader that resolves a deployable release must therefore filter on a status
|
|
@@ -23239,7 +23279,7 @@ var githubInstallations = pgTable49("github_installations", {
|
|
|
23239
23279
|
});
|
|
23240
23280
|
|
|
23241
23281
|
// src/schema/custom_domains.ts
|
|
23242
|
-
import { pgTable as pgTable50, text as text51, varchar as varchar34, boolean as boolean23, timestamp as timestamp46, index as index44, uniqueIndex as uniqueIndex18, jsonb as
|
|
23282
|
+
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";
|
|
23243
23283
|
var customDomains = pgTable50(
|
|
23244
23284
|
"custom_domains",
|
|
23245
23285
|
{
|
|
@@ -23273,7 +23313,7 @@ var customDomains = pgTable50(
|
|
|
23273
23313
|
*/
|
|
23274
23314
|
deployTargetId: text51("deploy_target_id"),
|
|
23275
23315
|
/** The DNS the PROVIDER asked for: pointing record plus any ownership challenge. */
|
|
23276
|
-
providerRecords:
|
|
23316
|
+
providerRecords: jsonb26("provider_records").$type(),
|
|
23277
23317
|
/** Nonce published at `_bettercms.<host>` as `verify=<token>`; checked by POST /verify. */
|
|
23278
23318
|
verificationToken: text51("verification_token"),
|
|
23279
23319
|
/** When that TXT last matched. NULL = never confirmed BY US (≠ Cloudflare's ssl_status). */
|
|
@@ -23571,7 +23611,7 @@ var externalDeployments = pgTable55(
|
|
|
23571
23611
|
);
|
|
23572
23612
|
|
|
23573
23613
|
// src/schema/page_types.ts
|
|
23574
|
-
import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as
|
|
23614
|
+
import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as jsonb27, index as index50, uniqueIndex as uniqueIndex22 } from "drizzle-orm/pg-core";
|
|
23575
23615
|
var pageTypes = pgTable56(
|
|
23576
23616
|
"page_types",
|
|
23577
23617
|
{
|
|
@@ -23582,8 +23622,8 @@ var pageTypes = pgTable56(
|
|
|
23582
23622
|
slug: varchar40("slug", { length: 255 }).notNull(),
|
|
23583
23623
|
/** Same ContentModelField[] shape `pages.fields` holds — a type exists so several pages
|
|
23584
23624
|
* can SHARE one schema instead of each carrying a copy. */
|
|
23585
|
-
fields:
|
|
23586
|
-
routingJson:
|
|
23625
|
+
fields: jsonb27("fields").$type().notNull().default([]),
|
|
23626
|
+
routingJson: jsonb27("routing_json").$type(),
|
|
23587
23627
|
...branchColumns,
|
|
23588
23628
|
...auditColumns,
|
|
23589
23629
|
...softDeleteColumn
|
|
@@ -23596,7 +23636,7 @@ var pageTypes = pgTable56(
|
|
|
23596
23636
|
);
|
|
23597
23637
|
|
|
23598
23638
|
// src/schema/build_triggers.ts
|
|
23599
|
-
import { pgTable as pgTable57, text as text58, varchar as varchar41, boolean as boolean26, timestamp as timestamp53, integer as integer24, jsonb as
|
|
23639
|
+
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";
|
|
23600
23640
|
var BUILD_TRIGGER_KINDS = ["webhook", "content", "schedule"];
|
|
23601
23641
|
var buildTriggers = pgTable57(
|
|
23602
23642
|
"build_triggers",
|
|
@@ -23618,7 +23658,7 @@ var buildTriggers = pgTable57(
|
|
|
23618
23658
|
prevSecretEnc: text58("prev_secret_enc"),
|
|
23619
23659
|
prevSecretExpiresAt: timestamp53("prev_secret_expires_at"),
|
|
23620
23660
|
/** `[]` = every publish. Model SLUGS, not ids — ids break across a model rebuild. */
|
|
23621
|
-
contentScopes:
|
|
23661
|
+
contentScopes: jsonb28("content_scopes").$type().notNull().default([]),
|
|
23622
23662
|
schedule: varchar41("schedule", { length: 120 }),
|
|
23623
23663
|
/** IANA zone. "Rebuild at 9am" means 9am where the customer is. */
|
|
23624
23664
|
timezone: varchar41("timezone", { length: 64 }).notNull().default("UTC"),
|
|
@@ -23728,7 +23768,7 @@ var aiProviderKeys = pgTable61(
|
|
|
23728
23768
|
);
|
|
23729
23769
|
|
|
23730
23770
|
// src/schema/agent_sessions.ts
|
|
23731
|
-
import { pgTable as pgTable62, text as text63, varchar as varchar45, timestamp as timestamp56, doublePrecision, jsonb as
|
|
23771
|
+
import { pgTable as pgTable62, text as text63, varchar as varchar45, timestamp as timestamp56, doublePrecision, jsonb as jsonb29, index as index52 } from "drizzle-orm/pg-core";
|
|
23732
23772
|
var agentSessions = pgTable62(
|
|
23733
23773
|
"agent_sessions",
|
|
23734
23774
|
{
|
|
@@ -23769,7 +23809,7 @@ var agentMessages = pgTable62(
|
|
|
23769
23809
|
sessionId: text63("session_id").notNull(),
|
|
23770
23810
|
role: varchar45("role", { length: 16 }).notNull(),
|
|
23771
23811
|
// user | assistant | tool
|
|
23772
|
-
content:
|
|
23812
|
+
content: jsonb29("content").notNull(),
|
|
23773
23813
|
// { text? , toolName?, toolInput?, toolResult? ... }
|
|
23774
23814
|
createdAt: timestamp56("created_at").notNull().defaultNow()
|
|
23775
23815
|
},
|
|
@@ -23777,7 +23817,7 @@ var agentMessages = pgTable62(
|
|
|
23777
23817
|
);
|
|
23778
23818
|
|
|
23779
23819
|
// src/schema/agent_instructions.ts
|
|
23780
|
-
import { pgTable as pgTable63, text as text64, varchar as varchar46, boolean as boolean27, jsonb as
|
|
23820
|
+
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";
|
|
23781
23821
|
import { sql as sql12 } from "drizzle-orm";
|
|
23782
23822
|
var INSTRUCTION_KINDS = ["skill", "rule"];
|
|
23783
23823
|
var INSTRUCTION_SOURCES = ["template", "manual", "import"];
|
|
@@ -23797,7 +23837,7 @@ var agentInstructions = pgTable63(
|
|
|
23797
23837
|
/** Master switch. Off = ignored everywhere, regardless of `disabledFor`. */
|
|
23798
23838
|
enabled: boolean27("enabled").notNull().default(true),
|
|
23799
23839
|
/** Project ids that opted OUT. Workspace-wide by default, scoped by exception. */
|
|
23800
|
-
disabledFor:
|
|
23840
|
+
disabledFor: jsonb30("disabled_for").$type().notNull().default([]),
|
|
23801
23841
|
source: varchar46("source", { length: 16 }).$type().notNull().default("manual"),
|
|
23802
23842
|
templateId: varchar46("template_id", { length: 64 }),
|
|
23803
23843
|
// set when source === "template"
|
|
@@ -23820,7 +23860,7 @@ var agentInstructions = pgTable63(
|
|
|
23820
23860
|
);
|
|
23821
23861
|
|
|
23822
23862
|
// src/schema/ai_generation_jobs.ts
|
|
23823
|
-
import { pgTable as pgTable64, text as text65, varchar as varchar47, integer as integer26, jsonb as
|
|
23863
|
+
import { pgTable as pgTable64, text as text65, varchar as varchar47, integer as integer26, jsonb as jsonb31, timestamp as timestamp58, index as index54 } from "drizzle-orm/pg-core";
|
|
23824
23864
|
var aiGenerationJobs = pgTable64(
|
|
23825
23865
|
"ai_generation_jobs",
|
|
23826
23866
|
{
|
|
@@ -23836,9 +23876,9 @@ var aiGenerationJobs = pgTable64(
|
|
|
23836
23876
|
// Durable because the drain runs after the request connection (and its GUCs) is gone.
|
|
23837
23877
|
// AI-produced content is always an agent write, even when a human queued the job.
|
|
23838
23878
|
writeOrigin: text65("write_origin").$type().notNull().default("agent:tab"),
|
|
23839
|
-
mapping:
|
|
23879
|
+
mapping: jsonb31("mapping").notNull(),
|
|
23840
23880
|
// GenerateMapping (generate) | { contentModelId } (seo)
|
|
23841
|
-
rows:
|
|
23881
|
+
rows: jsonb31("rows").notNull(),
|
|
23842
23882
|
/**
|
|
23843
23883
|
* needs_approval | queued | running | done | failed
|
|
23844
23884
|
*
|
|
@@ -23857,7 +23897,7 @@ var aiGenerationJobs = pgTable64(
|
|
|
23857
23897
|
* scope/estimate that is approved is the scope/estimate that runs. Null on jobs that never
|
|
23858
23898
|
* needed approval. Mirrors the migration_jobs.plan precedent.
|
|
23859
23899
|
*/
|
|
23860
|
-
plan:
|
|
23900
|
+
plan: jsonb31("plan"),
|
|
23861
23901
|
total: integer26("total").notNull().default(0),
|
|
23862
23902
|
processed: integer26("processed").notNull().default(0),
|
|
23863
23903
|
cursor: integer26("cursor").notNull().default(0),
|
|
@@ -23873,7 +23913,7 @@ var aiGenerationJobs = pgTable64(
|
|
|
23873
23913
|
);
|
|
23874
23914
|
|
|
23875
23915
|
// src/schema/mcp_tasks.ts
|
|
23876
|
-
import { check as check3, index as index55, integer as integer27, jsonb as
|
|
23916
|
+
import { check as check3, index as index55, integer as integer27, jsonb as jsonb32, pgTable as pgTable65, text as text66, timestamp as timestamp59, uniqueIndex as uniqueIndex26, varchar as varchar48 } from "drizzle-orm/pg-core";
|
|
23877
23917
|
import { sql as sql13 } from "drizzle-orm";
|
|
23878
23918
|
var MCP_TASK_STATUSES = [
|
|
23879
23919
|
"working",
|
|
@@ -23894,8 +23934,8 @@ var mcpTasks = pgTable65(
|
|
|
23894
23934
|
aiJobId: text66("ai_job_id"),
|
|
23895
23935
|
status: varchar48("status", { length: 24 }).$type().notNull().default("working"),
|
|
23896
23936
|
statusMessage: text66("status_message"),
|
|
23897
|
-
inputState:
|
|
23898
|
-
finalResult:
|
|
23937
|
+
inputState: jsonb32("input_state").$type().notNull().default({}),
|
|
23938
|
+
finalResult: jsonb32("final_result").$type(),
|
|
23899
23939
|
ttlMs: integer27("ttl_ms"),
|
|
23900
23940
|
pollIntervalMs: integer27("poll_interval_ms").notNull().default(2e3),
|
|
23901
23941
|
cancelRequestedAt: timestamp59("cancel_requested_at"),
|
|
@@ -23935,7 +23975,7 @@ var mcpTasks = pgTable65(
|
|
|
23935
23975
|
);
|
|
23936
23976
|
|
|
23937
23977
|
// src/schema/seo_reports.ts
|
|
23938
|
-
import { pgTable as pgTable66, text as text67, date, jsonb as
|
|
23978
|
+
import { pgTable as pgTable66, text as text67, date, jsonb as jsonb33, timestamp as timestamp60, uniqueIndex as uniqueIndex27, index as index56 } from "drizzle-orm/pg-core";
|
|
23939
23979
|
var seoReports = pgTable66(
|
|
23940
23980
|
"seo_reports",
|
|
23941
23981
|
{
|
|
@@ -23945,7 +23985,7 @@ var seoReports = pgTable66(
|
|
|
23945
23985
|
projectId: text67("project_id").notNull(),
|
|
23946
23986
|
periodStart: date("period_start").notNull(),
|
|
23947
23987
|
periodEnd: date("period_end").notNull(),
|
|
23948
|
-
metricsJson:
|
|
23988
|
+
metricsJson: jsonb33("metrics_json").$type().notNull(),
|
|
23949
23989
|
summary: text67("summary").notNull(),
|
|
23950
23990
|
createdAt: timestamp60("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
23951
23991
|
},
|
|
@@ -23957,7 +23997,7 @@ var seoReports = pgTable66(
|
|
|
23957
23997
|
);
|
|
23958
23998
|
|
|
23959
23999
|
// src/schema/qa_reports.ts
|
|
23960
|
-
import { pgTable as pgTable67, text as text68, integer as integer28, jsonb as
|
|
24000
|
+
import { pgTable as pgTable67, text as text68, integer as integer28, jsonb as jsonb34, timestamp as timestamp61, index as index57 } from "drizzle-orm/pg-core";
|
|
23961
24001
|
var qaReports = pgTable67(
|
|
23962
24002
|
"qa_reports",
|
|
23963
24003
|
{
|
|
@@ -23965,7 +24005,7 @@ var qaReports = pgTable67(
|
|
|
23965
24005
|
// nanoid
|
|
23966
24006
|
workspaceId: text68("workspace_id").notNull(),
|
|
23967
24007
|
projectId: text68("project_id").notNull(),
|
|
23968
|
-
findingsJson:
|
|
24008
|
+
findingsJson: jsonb34("findings_json").$type().notNull(),
|
|
23969
24009
|
summary: text68("summary").notNull(),
|
|
23970
24010
|
criticalCount: integer28("critical_count").notNull().default(0),
|
|
23971
24011
|
createdAt: timestamp61("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
@@ -23974,7 +24014,7 @@ var qaReports = pgTable67(
|
|
|
23974
24014
|
);
|
|
23975
24015
|
|
|
23976
24016
|
// src/schema/webflow_integrations.ts
|
|
23977
|
-
import { pgTable as pgTable68, text as text69, varchar as varchar49, jsonb as
|
|
24017
|
+
import { pgTable as pgTable68, text as text69, varchar as varchar49, jsonb as jsonb35, timestamp as timestamp62, index as index58 } from "drizzle-orm/pg-core";
|
|
23978
24018
|
var webflowIntegrations = pgTable68(
|
|
23979
24019
|
"webflow_integrations",
|
|
23980
24020
|
{
|
|
@@ -23988,7 +24028,7 @@ var webflowIntegrations = pgTable68(
|
|
|
23988
24028
|
// display only; may be absent
|
|
23989
24029
|
accessToken: text69("access_token").notNull(),
|
|
23990
24030
|
// encrypted at rest
|
|
23991
|
-
scopes:
|
|
24031
|
+
scopes: jsonb35("scopes").$type().notNull().default([]),
|
|
23992
24032
|
connectedBy: text69("connected_by"),
|
|
23993
24033
|
// FK → users.id
|
|
23994
24034
|
createdAt: timestamp62("created_at").notNull().defaultNow(),
|
|
@@ -23998,7 +24038,7 @@ var webflowIntegrations = pgTable68(
|
|
|
23998
24038
|
);
|
|
23999
24039
|
|
|
24000
24040
|
// src/schema/migration_jobs.ts
|
|
24001
|
-
import { pgTable as pgTable69, text as text70, varchar as varchar50, integer as integer29, jsonb as
|
|
24041
|
+
import { pgTable as pgTable69, text as text70, varchar as varchar50, integer as integer29, jsonb as jsonb36, timestamp as timestamp63, index as index59 } from "drizzle-orm/pg-core";
|
|
24002
24042
|
var migrationJobs = pgTable69(
|
|
24003
24043
|
"migration_jobs",
|
|
24004
24044
|
{
|
|
@@ -24011,11 +24051,11 @@ var migrationJobs = pgTable69(
|
|
|
24011
24051
|
// webflow | framer
|
|
24012
24052
|
framework: varchar50("framework", { length: 16 }).notNull().default("astro"),
|
|
24013
24053
|
// astro | next
|
|
24014
|
-
plan:
|
|
24054
|
+
plan: jsonb36("plan").notNull(),
|
|
24015
24055
|
// MigrationPlan (user-confirmed mapping)
|
|
24016
|
-
graph:
|
|
24056
|
+
graph: jsonb36("graph"),
|
|
24017
24057
|
// reserved for a future per-phase checkpoint — NOT written today
|
|
24018
|
-
report:
|
|
24058
|
+
report: jsonb36("report"),
|
|
24019
24059
|
// MigrationReport, written once when the job reaches done | failed
|
|
24020
24060
|
// queued | crawling | binding | seeding | media | repo | done | failed
|
|
24021
24061
|
status: varchar50("status", { length: 16 }).notNull().default("queued"),
|
|
@@ -24035,7 +24075,7 @@ var migrationJobs = pgTable69(
|
|
|
24035
24075
|
);
|
|
24036
24076
|
|
|
24037
24077
|
// src/schema/ai_reports.ts
|
|
24038
|
-
import { pgTable as pgTable70, text as text71, varchar as varchar51, jsonb as
|
|
24078
|
+
import { pgTable as pgTable70, text as text71, varchar as varchar51, jsonb as jsonb37, timestamp as timestamp64, index as index60 } from "drizzle-orm/pg-core";
|
|
24039
24079
|
var aiReports = pgTable70(
|
|
24040
24080
|
"ai_reports",
|
|
24041
24081
|
{
|
|
@@ -24044,7 +24084,7 @@ var aiReports = pgTable70(
|
|
|
24044
24084
|
workspaceId: text71("workspace_id").notNull(),
|
|
24045
24085
|
projectId: text71("project_id").notNull(),
|
|
24046
24086
|
kind: varchar51("kind", { length: 16 }).$type().notNull(),
|
|
24047
|
-
findingsJson:
|
|
24087
|
+
findingsJson: jsonb37("findings_json").$type().notNull(),
|
|
24048
24088
|
summary: text71("summary").notNull(),
|
|
24049
24089
|
createdAt: timestamp64("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
24050
24090
|
},
|
|
@@ -24199,7 +24239,7 @@ var siteFiles = pgTable72(
|
|
|
24199
24239
|
);
|
|
24200
24240
|
|
|
24201
24241
|
// src/schema/indexnow_submissions.ts
|
|
24202
|
-
import { pgTable as pgTable73, text as text74, varchar as varchar54, integer as integer32, jsonb as
|
|
24242
|
+
import { pgTable as pgTable73, text as text74, varchar as varchar54, integer as integer32, jsonb as jsonb38, timestamp as timestamp67, index as index62 } from "drizzle-orm/pg-core";
|
|
24203
24243
|
var INDEXNOW_KINDS = ["auto", "manual", "retry"];
|
|
24204
24244
|
var INDEXNOW_STATUSES = ["ok", "failed"];
|
|
24205
24245
|
var indexnowSubmissions = pgTable73(
|
|
@@ -24212,7 +24252,7 @@ var indexnowSubmissions = pgTable73(
|
|
|
24212
24252
|
// FK → projects.id ON DELETE CASCADE (migration 0234)
|
|
24213
24253
|
/** The host as submitted, kept verbatim so a 422 stays explainable after a domain move. */
|
|
24214
24254
|
host: text74("host").notNull(),
|
|
24215
|
-
urls:
|
|
24255
|
+
urls: jsonb38("urls").$type().notNull().default([]),
|
|
24216
24256
|
urlCount: integer32("url_count").notNull().default(0),
|
|
24217
24257
|
status: varchar54("status", { length: 8 }).$type().notNull(),
|
|
24218
24258
|
/** NULL only when the request never got a response at all (DNS/timeout after 3 attempts). */
|
|
@@ -24225,7 +24265,7 @@ var indexnowSubmissions = pgTable73(
|
|
|
24225
24265
|
);
|
|
24226
24266
|
|
|
24227
24267
|
// src/schema/brand_kit_versions.ts
|
|
24228
|
-
import { pgTable as pgTable74, text as text75, integer as integer33, jsonb as
|
|
24268
|
+
import { pgTable as pgTable74, text as text75, integer as integer33, jsonb as jsonb39, timestamp as timestamp68, primaryKey as primaryKey5, index as index63 } from "drizzle-orm/pg-core";
|
|
24229
24269
|
var brandKitVersions = pgTable74(
|
|
24230
24270
|
"brand_kit_versions",
|
|
24231
24271
|
{
|
|
@@ -24236,7 +24276,7 @@ var brandKitVersions = pgTable74(
|
|
|
24236
24276
|
projectId: text75("project_id").notNull(),
|
|
24237
24277
|
// FK → projects.id ON DELETE CASCADE (0239)
|
|
24238
24278
|
version: integer33("version").notNull(),
|
|
24239
|
-
snapshot:
|
|
24279
|
+
snapshot: jsonb39("snapshot").$type().notNull(),
|
|
24240
24280
|
createdBy: text75("created_by"),
|
|
24241
24281
|
// FK → users(id), nullable: a system write has no author
|
|
24242
24282
|
createdAt: timestamp68("created_at").notNull().defaultNow()
|
|
@@ -24312,7 +24352,7 @@ import {
|
|
|
24312
24352
|
text as text80,
|
|
24313
24353
|
varchar as varchar59,
|
|
24314
24354
|
timestamp as timestamp72,
|
|
24315
|
-
jsonb as
|
|
24355
|
+
jsonb as jsonb41,
|
|
24316
24356
|
integer as integer36,
|
|
24317
24357
|
foreignKey as foreignKey4,
|
|
24318
24358
|
index as index67,
|
|
@@ -24326,7 +24366,7 @@ import {
|
|
|
24326
24366
|
foreignKey as foreignKey2,
|
|
24327
24367
|
index as index65,
|
|
24328
24368
|
integer as integer35,
|
|
24329
|
-
jsonb as
|
|
24369
|
+
jsonb as jsonb40,
|
|
24330
24370
|
pgTable as pgTable77,
|
|
24331
24371
|
text as text78,
|
|
24332
24372
|
timestamp as timestamp71,
|
|
@@ -24342,8 +24382,8 @@ var componentVariantGroups = pgTable77(
|
|
|
24342
24382
|
projectId: text78("project_id"),
|
|
24343
24383
|
name: varchar57("name", { length: 255 }).notNull(),
|
|
24344
24384
|
slug: varchar57("slug", { length: 255 }).notNull(),
|
|
24345
|
-
canonicalInputs:
|
|
24346
|
-
publishedCanonicalInputs:
|
|
24385
|
+
canonicalInputs: jsonb40("canonical_inputs").$type().notNull().default([]),
|
|
24386
|
+
publishedCanonicalInputs: jsonb40("published_canonical_inputs").$type(),
|
|
24347
24387
|
status: varchar57("status", { length: 20 }).notNull().default("draft"),
|
|
24348
24388
|
publishedAt: timestamp71("published_at"),
|
|
24349
24389
|
optimisticVersion: integer35("optimistic_version").notNull().default(0),
|
|
@@ -24427,15 +24467,15 @@ var components = pgTable79(
|
|
|
24427
24467
|
publishedVariantGroupId: text80("published_variant_group_id").references(() => componentVariantGroups.id, {
|
|
24428
24468
|
onDelete: "restrict"
|
|
24429
24469
|
}),
|
|
24430
|
-
variantInputMappings:
|
|
24470
|
+
variantInputMappings: jsonb41("variant_input_mappings").$type().notNull().default([]),
|
|
24431
24471
|
// The live canonical-input mapping snapshot. Draft mapping edits must never alter
|
|
24432
24472
|
// already-published Layout output before the Component is explicitly re-published.
|
|
24433
|
-
publishedVariantInputMappings:
|
|
24473
|
+
publishedVariantInputMappings: jsonb41("published_variant_input_mappings").$type(),
|
|
24434
24474
|
// Exact immutable family version adopted by this live variant. Legacy published rows
|
|
24435
24475
|
// have no manifest pin and use the one-time `publishedCanonicalInputs` snapshot instead.
|
|
24436
24476
|
publishedFamilyManifestId: text80("published_family_manifest_id"),
|
|
24437
24477
|
publishedFamilyManifestHash: varchar59("published_family_manifest_hash", { length: 64 }),
|
|
24438
|
-
publishedCanonicalInputs:
|
|
24478
|
+
publishedCanonicalInputs: jsonb41("published_canonical_inputs").$type(),
|
|
24439
24479
|
// Placement governance (migration 0190). Existing rows were backfilled to ["*"] so
|
|
24440
24480
|
// rollout preserves the old everywhere-visible behaviour; new project components start
|
|
24441
24481
|
// with [] and are deliberately approved from the section picker. Tokens are
|
|
@@ -24467,8 +24507,8 @@ var components = pgTable79(
|
|
|
24467
24507
|
groupId: text80("group_id").references(() => componentGroups.id, { onDelete: "restrict" }),
|
|
24468
24508
|
// Stored as unknown[] to keep @bettercms-ai/db decoupled from @bettercms-ai/types,
|
|
24469
24509
|
// matching pages.block_json. Validated as ContentBlock[] at the API layer.
|
|
24470
|
-
blockJson:
|
|
24471
|
-
props:
|
|
24510
|
+
blockJson: jsonb41("block_json").$type().notNull().default([]),
|
|
24511
|
+
props: jsonb41("props").$type().notNull().default([]),
|
|
24472
24512
|
// Draft/live split (migration 0186_component_draft_live_split.sql). `blockJson`/`props`
|
|
24473
24513
|
// above are the DRAFT; these two are the LIVE snapshot that get_components_by_handle()
|
|
24474
24514
|
// serves. Nullable: a never-published component has no live copy. A DB trigger fills them
|
|
@@ -24476,8 +24516,8 @@ var components = pgTable79(
|
|
|
24476
24516
|
// trigger deliberately skips published -> published, or every autosave would go live).
|
|
24477
24517
|
// `props` splits alongside `blockJson` because applyOverrides() targets
|
|
24478
24518
|
// props[].target.blockId/path — a live tree paired with draft prop-defs mis-targets.
|
|
24479
|
-
publishedBlockJson:
|
|
24480
|
-
publishedProps:
|
|
24519
|
+
publishedBlockJson: jsonb41("published_block_json").$type(),
|
|
24520
|
+
publishedProps: jsonb41("published_props").$type(),
|
|
24481
24521
|
status: varchar59("status", { length: 20 }).$type().notNull().default("draft"),
|
|
24482
24522
|
publishedAt: timestamp72("published_at"),
|
|
24483
24523
|
// Out of the working set, still serving (FLO-1012). Deliberately NOT a third `status`
|
|
@@ -24485,6 +24525,10 @@ var components = pgTable79(
|
|
|
24485
24525
|
// the draft/published bit that restore has to put back. NULL = active.
|
|
24486
24526
|
archivedAt: timestamp72("archived_at"),
|
|
24487
24527
|
thumbnail: varchar59("thumbnail", { length: 2048 }),
|
|
24528
|
+
// A snapshot of the validated Output (0334), stored under component-preview/<projectId>/snapshots/. Never written to `thumbnail`.
|
|
24529
|
+
outputSnapshotKey: text80("output_snapshot_key"),
|
|
24530
|
+
outputSnapshotCommitSha: text80("output_snapshot_commit_sha"),
|
|
24531
|
+
outputSnapshotAt: timestamp72("output_snapshot_at", { withTimezone: true }),
|
|
24488
24532
|
optimisticVersion: integer36("optimistic_version").notNull().default(0),
|
|
24489
24533
|
...writeGovernanceColumns,
|
|
24490
24534
|
...branchColumns,
|
|
@@ -24545,30 +24589,53 @@ var componentsRelations = relations14(components, ({ one }) => ({
|
|
|
24545
24589
|
})
|
|
24546
24590
|
}));
|
|
24547
24591
|
|
|
24592
|
+
// src/schema/content_navigation.ts
|
|
24593
|
+
import { foreignKey as foreignKey5, index as index68, integer as integer37, jsonb as jsonb42, pgTable as pgTable80, text as text81, timestamp as timestamp73 } from "drizzle-orm/pg-core";
|
|
24594
|
+
var contentNavigation = pgTable80(
|
|
24595
|
+
"content_navigation",
|
|
24596
|
+
{
|
|
24597
|
+
projectId: text81("project_id").primaryKey(),
|
|
24598
|
+
workspaceId: text81("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24599
|
+
doc: jsonb42("doc").$type().notNull().default({ schema: 1, folders: [], items: [] }),
|
|
24600
|
+
version: integer37("version").notNull().default(1),
|
|
24601
|
+
updatedBy: text81("updated_by"),
|
|
24602
|
+
createdAt: timestamp73("created_at").notNull().defaultNow(),
|
|
24603
|
+
updatedAt: timestamp73("updated_at").notNull().defaultNow()
|
|
24604
|
+
},
|
|
24605
|
+
(table) => [
|
|
24606
|
+
foreignKey5({
|
|
24607
|
+
columns: [table.projectId, table.workspaceId],
|
|
24608
|
+
foreignColumns: [projects.id, projects.workspaceId],
|
|
24609
|
+
name: "content_navigation_project_workspace_fkey"
|
|
24610
|
+
}).onDelete("cascade").onUpdate("cascade"),
|
|
24611
|
+
index68("content_navigation_workspace_idx").on(table.workspaceId)
|
|
24612
|
+
]
|
|
24613
|
+
);
|
|
24614
|
+
|
|
24548
24615
|
// src/schema/component_variants.ts
|
|
24549
24616
|
import {
|
|
24550
|
-
pgTable as
|
|
24551
|
-
text as
|
|
24617
|
+
pgTable as pgTable81,
|
|
24618
|
+
text as text82,
|
|
24552
24619
|
varchar as varchar60,
|
|
24553
|
-
timestamp as
|
|
24554
|
-
jsonb as
|
|
24555
|
-
integer as
|
|
24556
|
-
index as
|
|
24620
|
+
timestamp as timestamp74,
|
|
24621
|
+
jsonb as jsonb43,
|
|
24622
|
+
integer as integer38,
|
|
24623
|
+
index as index69,
|
|
24557
24624
|
unique as unique4,
|
|
24558
24625
|
uniqueIndex as uniqueIndex34
|
|
24559
24626
|
} from "drizzle-orm/pg-core";
|
|
24560
24627
|
import { relations as relations15 } from "drizzle-orm/relations";
|
|
24561
24628
|
import { sql as sql18 } from "drizzle-orm";
|
|
24562
|
-
var componentVariants =
|
|
24629
|
+
var componentVariants = pgTable81(
|
|
24563
24630
|
"component_variants",
|
|
24564
24631
|
{
|
|
24565
|
-
id:
|
|
24566
|
-
workspaceId:
|
|
24567
|
-
componentId:
|
|
24632
|
+
id: text82("id").primaryKey(),
|
|
24633
|
+
workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24634
|
+
componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24568
24635
|
name: varchar60("name", { length: 255 }).notNull(),
|
|
24569
24636
|
// `<component-root>-<variant-name>`, e.g. `footer-compact`.
|
|
24570
24637
|
key: varchar60("key", { length: 356 }).notNull(),
|
|
24571
|
-
delta:
|
|
24638
|
+
delta: jsonb43("delta").$type().notNull().default({
|
|
24572
24639
|
fieldOverrides: [],
|
|
24573
24640
|
addedProps: [],
|
|
24574
24641
|
removedFieldKeys: [],
|
|
@@ -24576,13 +24643,13 @@ var componentVariants = pgTable80(
|
|
|
24576
24643
|
valueOverrides: {},
|
|
24577
24644
|
addedBlocks: []
|
|
24578
24645
|
}),
|
|
24579
|
-
publishedDelta:
|
|
24646
|
+
publishedDelta: jsonb43("published_delta").$type(),
|
|
24580
24647
|
status: varchar60("status", { length: 20 }).$type().notNull().default("draft"),
|
|
24581
|
-
publishedAt:
|
|
24582
|
-
optimisticVersion:
|
|
24583
|
-
createdAt:
|
|
24584
|
-
updatedAt:
|
|
24585
|
-
deletedAt:
|
|
24648
|
+
publishedAt: timestamp74("published_at"),
|
|
24649
|
+
optimisticVersion: integer38("optimistic_version").notNull().default(0),
|
|
24650
|
+
createdAt: timestamp74("created_at").notNull().defaultNow(),
|
|
24651
|
+
updatedAt: timestamp74("updated_at").notNull().defaultNow(),
|
|
24652
|
+
deletedAt: timestamp74("deleted_at")
|
|
24586
24653
|
},
|
|
24587
24654
|
(table) => [
|
|
24588
24655
|
unique4("component_variants_id_workspace_component_unique").on(
|
|
@@ -24590,8 +24657,8 @@ var componentVariants = pgTable80(
|
|
|
24590
24657
|
table.workspaceId,
|
|
24591
24658
|
table.componentId
|
|
24592
24659
|
),
|
|
24593
|
-
|
|
24594
|
-
|
|
24660
|
+
index69("component_variants_workspace_idx").on(table.workspaceId),
|
|
24661
|
+
index69("component_variants_component_idx").on(table.componentId),
|
|
24595
24662
|
uniqueIndex34("component_variants_component_key_unique").on(table.componentId, table.key).where(sql18`${table.deletedAt} IS NULL`)
|
|
24596
24663
|
]
|
|
24597
24664
|
);
|
|
@@ -24609,41 +24676,41 @@ var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
|
|
|
24609
24676
|
// src/schema/component_implementation_evidence.ts
|
|
24610
24677
|
import {
|
|
24611
24678
|
bigint as bigint4,
|
|
24612
|
-
foreignKey as
|
|
24613
|
-
index as
|
|
24614
|
-
integer as
|
|
24615
|
-
jsonb as
|
|
24616
|
-
pgTable as
|
|
24617
|
-
text as
|
|
24618
|
-
timestamp as
|
|
24679
|
+
foreignKey as foreignKey6,
|
|
24680
|
+
index as index70,
|
|
24681
|
+
integer as integer39,
|
|
24682
|
+
jsonb as jsonb44,
|
|
24683
|
+
pgTable as pgTable82,
|
|
24684
|
+
text as text83,
|
|
24685
|
+
timestamp as timestamp75,
|
|
24619
24686
|
unique as unique5,
|
|
24620
24687
|
uniqueIndex as uniqueIndex35,
|
|
24621
24688
|
uuid as uuid2,
|
|
24622
24689
|
varchar as varchar61
|
|
24623
24690
|
} from "drizzle-orm/pg-core";
|
|
24624
24691
|
import { sql as sql19 } from "drizzle-orm";
|
|
24625
|
-
var componentImplementationCandidates =
|
|
24692
|
+
var componentImplementationCandidates = pgTable82(
|
|
24626
24693
|
"component_implementation_candidates",
|
|
24627
24694
|
{
|
|
24628
|
-
id:
|
|
24629
|
-
workspaceId:
|
|
24630
|
-
projectId:
|
|
24631
|
-
componentId:
|
|
24632
|
-
variantGroupId:
|
|
24633
|
-
familyKey:
|
|
24695
|
+
id: text83("id").primaryKey(),
|
|
24696
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24697
|
+
projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
24698
|
+
componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24699
|
+
variantGroupId: text83("variant_group_id"),
|
|
24700
|
+
familyKey: text83("family_key").notNull(),
|
|
24634
24701
|
familyContractHash: varchar61("family_contract_hash", { length: 64 }).notNull(),
|
|
24635
24702
|
// Exact value-bearing family contract. Unlike `contract.canonicalInputs` (the
|
|
24636
24703
|
// renderer/schema projection), this snapshot deliberately retains defaults because it
|
|
24637
24704
|
// becomes the immutable public-input source pinned by each published variant.
|
|
24638
|
-
familyContract:
|
|
24705
|
+
familyContract: jsonb44("family_contract").$type(),
|
|
24639
24706
|
schemaHash: varchar61("schema_hash", { length: 64 }).notNull(),
|
|
24640
24707
|
brandContractHash: varchar61("brand_contract_hash", { length: 64 }).notNull(),
|
|
24641
|
-
contract:
|
|
24642
|
-
createdBy:
|
|
24643
|
-
createdAt:
|
|
24708
|
+
contract: jsonb44("contract").$type().notNull(),
|
|
24709
|
+
createdBy: text83("created_by"),
|
|
24710
|
+
createdAt: timestamp75("created_at").notNull().defaultNow()
|
|
24644
24711
|
},
|
|
24645
24712
|
(table) => [
|
|
24646
|
-
|
|
24713
|
+
foreignKey6({
|
|
24647
24714
|
columns: [table.projectId, table.workspaceId],
|
|
24648
24715
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24649
24716
|
name: "component_implementation_candidates_project_workspace_fkey"
|
|
@@ -24659,29 +24726,29 @@ var componentImplementationCandidates = pgTable81(
|
|
|
24659
24726
|
table.familyContractHash
|
|
24660
24727
|
).where(sql19`${table.familyContract} IS NOT NULL`),
|
|
24661
24728
|
unique5("component_implementation_candidate_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
24662
|
-
|
|
24729
|
+
index70("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
|
|
24663
24730
|
]
|
|
24664
24731
|
);
|
|
24665
|
-
var componentFamilyManifests =
|
|
24732
|
+
var componentFamilyManifests = pgTable82(
|
|
24666
24733
|
"component_family_manifests",
|
|
24667
24734
|
{
|
|
24668
|
-
id:
|
|
24669
|
-
workspaceId:
|
|
24670
|
-
projectId:
|
|
24671
|
-
familyKey:
|
|
24735
|
+
id: text83("id").primaryKey(),
|
|
24736
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24737
|
+
projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
24738
|
+
familyKey: text83("family_key").notNull(),
|
|
24672
24739
|
familyContractHash: varchar61("family_contract_hash", { length: 64 }).notNull(),
|
|
24673
|
-
familyContract:
|
|
24740
|
+
familyContract: jsonb44("family_contract").$type(),
|
|
24674
24741
|
commitSha: varchar61("commit_sha", { length: 64 }).notNull(),
|
|
24675
24742
|
adapterHash: varchar61("adapter_hash", { length: 64 }).notNull(),
|
|
24676
24743
|
manifestHash: varchar61("manifest_hash", { length: 64 }).notNull(),
|
|
24677
|
-
previewOrigin:
|
|
24678
|
-
nativeViewports:
|
|
24679
|
-
adapter:
|
|
24680
|
-
createdBy:
|
|
24681
|
-
createdAt:
|
|
24744
|
+
previewOrigin: text83("preview_origin").notNull(),
|
|
24745
|
+
nativeViewports: jsonb44("native_viewports").$type().notNull(),
|
|
24746
|
+
adapter: jsonb44("adapter").$type().notNull(),
|
|
24747
|
+
createdBy: text83("created_by"),
|
|
24748
|
+
createdAt: timestamp75("created_at").notNull().defaultNow()
|
|
24682
24749
|
},
|
|
24683
24750
|
(table) => [
|
|
24684
|
-
|
|
24751
|
+
foreignKey6({
|
|
24685
24752
|
columns: [table.projectId, table.workspaceId],
|
|
24686
24753
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24687
24754
|
name: "component_family_manifests_project_workspace_fkey"
|
|
@@ -24690,21 +24757,21 @@ var componentFamilyManifests = pgTable81(
|
|
|
24690
24757
|
unique5("component_family_manifests_id_project_unique").on(table.id, table.projectId),
|
|
24691
24758
|
unique5("component_family_manifests_evidence_unique").on(table.id, table.projectId, table.manifestHash),
|
|
24692
24759
|
uniqueIndex35("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
|
|
24693
|
-
|
|
24760
|
+
index70("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
|
|
24694
24761
|
]
|
|
24695
24762
|
);
|
|
24696
|
-
var componentImplementationRequests =
|
|
24763
|
+
var componentImplementationRequests = pgTable82(
|
|
24697
24764
|
"component_implementation_requests",
|
|
24698
24765
|
{
|
|
24699
|
-
id:
|
|
24700
|
-
workspaceId:
|
|
24701
|
-
projectId:
|
|
24702
|
-
componentId:
|
|
24703
|
-
candidateId:
|
|
24704
|
-
componentVersion:
|
|
24766
|
+
id: text83("id").primaryKey(),
|
|
24767
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24768
|
+
projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
24769
|
+
componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24770
|
+
candidateId: text83("candidate_id").notNull(),
|
|
24771
|
+
componentVersion: integer39("component_version").notNull(),
|
|
24705
24772
|
provider: varchar61("provider", { length: 20 }).$type().notNull(),
|
|
24706
24773
|
status: varchar61("status", { length: 20 }).$type().notNull(),
|
|
24707
|
-
familyKey:
|
|
24774
|
+
familyKey: text83("family_key").notNull(),
|
|
24708
24775
|
familyContractHash: varchar61("family_contract_hash", { length: 64 }).notNull(),
|
|
24709
24776
|
schemaHash: varchar61("schema_hash", { length: 64 }).notNull(),
|
|
24710
24777
|
brandContractHash: varchar61("brand_contract_hash", { length: 64 }).notNull(),
|
|
@@ -24712,86 +24779,86 @@ var componentImplementationRequests = pgTable81(
|
|
|
24712
24779
|
commitSha: varchar61("commit_sha", { length: 64 }),
|
|
24713
24780
|
adapterHash: varchar61("adapter_hash", { length: 64 }),
|
|
24714
24781
|
familyManifestHash: varchar61("family_manifest_hash", { length: 64 }),
|
|
24715
|
-
previewOrigin:
|
|
24716
|
-
nativeViewports:
|
|
24717
|
-
adapter:
|
|
24718
|
-
providerProvenance:
|
|
24719
|
-
claimedByApiKeyId:
|
|
24782
|
+
previewOrigin: text83("preview_origin"),
|
|
24783
|
+
nativeViewports: jsonb44("native_viewports").$type(),
|
|
24784
|
+
adapter: jsonb44("adapter").$type(),
|
|
24785
|
+
providerProvenance: jsonb44("provider_provenance").$type(),
|
|
24786
|
+
claimedByApiKeyId: text83("claimed_by_api_key_id"),
|
|
24720
24787
|
claimCredentialHash: varchar61("claim_credential_hash", { length: 64 }),
|
|
24721
|
-
claimCredentialExpiresAt:
|
|
24722
|
-
claimCredentialConsumedAt:
|
|
24788
|
+
claimCredentialExpiresAt: timestamp75("claim_credential_expires_at", { withTimezone: true }),
|
|
24789
|
+
claimCredentialConsumedAt: timestamp75("claim_credential_consumed_at", { withTimezone: true }),
|
|
24723
24790
|
completionHash: varchar61("completion_hash", { length: 64 }),
|
|
24724
|
-
evidenceId:
|
|
24725
|
-
errorCode:
|
|
24726
|
-
errorMessage:
|
|
24727
|
-
requestedBy:
|
|
24728
|
-
createdAt:
|
|
24729
|
-
expiresAt:
|
|
24730
|
-
claimedAt:
|
|
24731
|
-
completedAt:
|
|
24732
|
-
failedAt:
|
|
24733
|
-
updatedAt:
|
|
24791
|
+
evidenceId: text83("evidence_id"),
|
|
24792
|
+
errorCode: text83("error_code"),
|
|
24793
|
+
errorMessage: text83("error_message"),
|
|
24794
|
+
requestedBy: text83("requested_by"),
|
|
24795
|
+
createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
24796
|
+
expiresAt: timestamp75("expires_at", { withTimezone: true }).notNull(),
|
|
24797
|
+
claimedAt: timestamp75("claimed_at", { withTimezone: true }),
|
|
24798
|
+
completedAt: timestamp75("completed_at", { withTimezone: true }),
|
|
24799
|
+
failedAt: timestamp75("failed_at", { withTimezone: true }),
|
|
24800
|
+
updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
24734
24801
|
},
|
|
24735
24802
|
(table) => [
|
|
24736
|
-
|
|
24803
|
+
foreignKey6({
|
|
24737
24804
|
columns: [table.projectId, table.workspaceId],
|
|
24738
24805
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24739
24806
|
name: "component_implementation_requests_project_workspace_fkey"
|
|
24740
24807
|
}).onDelete("cascade"),
|
|
24741
|
-
|
|
24808
|
+
foreignKey6({
|
|
24742
24809
|
columns: [table.candidateId, table.projectId, table.componentId],
|
|
24743
24810
|
foreignColumns: [componentImplementationCandidates.id, componentImplementationCandidates.projectId, componentImplementationCandidates.componentId],
|
|
24744
24811
|
name: "component_implementation_requests_candidate_fkey"
|
|
24745
24812
|
}).onDelete("cascade"),
|
|
24746
24813
|
unique5("component_implementation_requests_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
24747
24814
|
uniqueIndex35("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql19`${table.status} IN ('pending', 'claimed')`),
|
|
24748
|
-
|
|
24815
|
+
index70("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
|
|
24749
24816
|
]
|
|
24750
24817
|
);
|
|
24751
|
-
var componentImplementationEvidence =
|
|
24818
|
+
var componentImplementationEvidence = pgTable82(
|
|
24752
24819
|
"component_implementation_evidence",
|
|
24753
24820
|
{
|
|
24754
|
-
id:
|
|
24755
|
-
workspaceId:
|
|
24756
|
-
projectId:
|
|
24757
|
-
componentId:
|
|
24758
|
-
candidateId:
|
|
24759
|
-
familyManifestId:
|
|
24821
|
+
id: text83("id").primaryKey(),
|
|
24822
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24823
|
+
projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
24824
|
+
componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24825
|
+
candidateId: text83("candidate_id").notNull(),
|
|
24826
|
+
familyManifestId: text83("family_manifest_id").notNull(),
|
|
24760
24827
|
familyManifestHash: varchar61("family_manifest_hash", { length: 64 }).notNull(),
|
|
24761
24828
|
variantBindingHash: varchar61("variant_binding_hash", { length: 64 }).notNull(),
|
|
24762
|
-
variantBinding:
|
|
24763
|
-
requestId:
|
|
24829
|
+
variantBinding: jsonb44("variant_binding").$type().notNull(),
|
|
24830
|
+
requestId: text83("request_id"),
|
|
24764
24831
|
schemaHash: varchar61("schema_hash", { length: 64 }).notNull(),
|
|
24765
24832
|
brandContractHash: varchar61("brand_contract_hash", { length: 64 }).notNull(),
|
|
24766
24833
|
commitSha: varchar61("commit_sha", { length: 64 }).notNull(),
|
|
24767
24834
|
adapterHash: varchar61("adapter_hash", { length: 64 }).notNull(),
|
|
24768
|
-
previewOrigin:
|
|
24769
|
-
nativeViewports:
|
|
24770
|
-
adapter:
|
|
24835
|
+
previewOrigin: text83("preview_origin").notNull(),
|
|
24836
|
+
nativeViewports: jsonb44("native_viewports").$type().notNull(),
|
|
24837
|
+
adapter: jsonb44("adapter").$type().notNull(),
|
|
24771
24838
|
status: varchar61("status", { length: 20 }).$type().notNull(),
|
|
24772
|
-
checks:
|
|
24839
|
+
checks: jsonb44("checks").$type().notNull(),
|
|
24773
24840
|
evidenceDigest: varchar61("evidence_digest", { length: 128 }).notNull(),
|
|
24774
24841
|
evidenceTupleHash: varchar61("evidence_tuple_hash", { length: 64 }).notNull(),
|
|
24775
|
-
createdBy:
|
|
24776
|
-
createdAt:
|
|
24842
|
+
createdBy: text83("created_by"),
|
|
24843
|
+
createdAt: timestamp75("created_at").notNull().defaultNow()
|
|
24777
24844
|
},
|
|
24778
24845
|
(table) => [
|
|
24779
|
-
|
|
24846
|
+
foreignKey6({
|
|
24780
24847
|
columns: [table.projectId, table.workspaceId],
|
|
24781
24848
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24782
24849
|
name: "component_implementation_evidence_project_workspace_fkey"
|
|
24783
24850
|
}).onDelete("cascade"),
|
|
24784
|
-
|
|
24851
|
+
foreignKey6({
|
|
24785
24852
|
columns: [table.familyManifestId, table.projectId, table.familyManifestHash],
|
|
24786
24853
|
foreignColumns: [componentFamilyManifests.id, componentFamilyManifests.projectId, componentFamilyManifests.manifestHash],
|
|
24787
24854
|
name: "component_implementation_evidence_manifest_fkey"
|
|
24788
24855
|
}).onDelete("restrict"),
|
|
24789
|
-
|
|
24856
|
+
foreignKey6({
|
|
24790
24857
|
columns: [table.candidateId, table.projectId, table.componentId],
|
|
24791
24858
|
foreignColumns: [componentImplementationCandidates.id, componentImplementationCandidates.projectId, componentImplementationCandidates.componentId],
|
|
24792
24859
|
name: "component_implementation_evidence_candidate_fkey"
|
|
24793
24860
|
}).onDelete("cascade"),
|
|
24794
|
-
|
|
24861
|
+
foreignKey6({
|
|
24795
24862
|
columns: [table.requestId, table.projectId, table.componentId],
|
|
24796
24863
|
foreignColumns: [componentImplementationRequests.id, componentImplementationRequests.projectId, componentImplementationRequests.componentId],
|
|
24797
24864
|
name: "component_implementation_evidence_request_fkey"
|
|
@@ -24799,43 +24866,43 @@ var componentImplementationEvidence = pgTable81(
|
|
|
24799
24866
|
uniqueIndex35("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
|
|
24800
24867
|
uniqueIndex35("component_implementation_evidence_request_unique").on(table.requestId).where(sql19`${table.requestId} IS NOT NULL`),
|
|
24801
24868
|
unique5("component_implementation_evidence_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
24802
|
-
|
|
24869
|
+
index70("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
|
|
24803
24870
|
]
|
|
24804
24871
|
);
|
|
24805
|
-
var componentImplementationApprovals =
|
|
24872
|
+
var componentImplementationApprovals = pgTable82(
|
|
24806
24873
|
"component_implementation_approvals",
|
|
24807
24874
|
{
|
|
24808
|
-
id:
|
|
24809
|
-
workspaceId:
|
|
24810
|
-
projectId:
|
|
24811
|
-
componentId:
|
|
24812
|
-
candidateId:
|
|
24813
|
-
evidenceId:
|
|
24814
|
-
approvedBy:
|
|
24815
|
-
approvedAt:
|
|
24875
|
+
id: text83("id").primaryKey(),
|
|
24876
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24877
|
+
projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
24878
|
+
componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24879
|
+
candidateId: text83("candidate_id").notNull(),
|
|
24880
|
+
evidenceId: text83("evidence_id").notNull(),
|
|
24881
|
+
approvedBy: text83("approved_by").notNull(),
|
|
24882
|
+
approvedAt: timestamp75("approved_at").notNull().defaultNow()
|
|
24816
24883
|
},
|
|
24817
24884
|
(table) => [
|
|
24818
|
-
|
|
24885
|
+
foreignKey6({
|
|
24819
24886
|
columns: [table.projectId, table.workspaceId],
|
|
24820
24887
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24821
24888
|
name: "component_implementation_approvals_project_workspace_fkey"
|
|
24822
24889
|
}).onDelete("cascade"),
|
|
24823
|
-
|
|
24890
|
+
foreignKey6({
|
|
24824
24891
|
columns: [table.candidateId, table.projectId, table.componentId],
|
|
24825
24892
|
foreignColumns: [componentImplementationCandidates.id, componentImplementationCandidates.projectId, componentImplementationCandidates.componentId],
|
|
24826
24893
|
name: "component_implementation_approvals_candidate_fkey"
|
|
24827
24894
|
}).onDelete("cascade"),
|
|
24828
|
-
|
|
24895
|
+
foreignKey6({
|
|
24829
24896
|
columns: [table.evidenceId, table.projectId, table.componentId],
|
|
24830
24897
|
foreignColumns: [componentImplementationEvidence.id, componentImplementationEvidence.projectId, componentImplementationEvidence.componentId],
|
|
24831
24898
|
name: "component_implementation_approvals_evidence_fkey"
|
|
24832
24899
|
}).onDelete("cascade"),
|
|
24833
24900
|
uniqueIndex35("component_implementation_approval_evidence_unique").on(table.evidenceId),
|
|
24834
24901
|
unique5("component_implementation_approval_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
24835
|
-
|
|
24902
|
+
index70("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
|
|
24836
24903
|
]
|
|
24837
24904
|
);
|
|
24838
|
-
var componentImplementationAdapters =
|
|
24905
|
+
var componentImplementationAdapters = pgTable82(
|
|
24839
24906
|
"component_implementation_adapters",
|
|
24840
24907
|
{
|
|
24841
24908
|
// uuid generated BY THE DATABASE, unlike this file's older `text` ids with app-side prefixes.
|
|
@@ -24843,104 +24910,112 @@ var componentImplementationAdapters = pgTable81(
|
|
|
24843
24910
|
// (project_id, component_id), which is unique — so there is nothing for a readable prefix to
|
|
24844
24911
|
// help with, and one fewer identifier for a writer to have to mint correctly.
|
|
24845
24912
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
24846
|
-
workspaceId:
|
|
24847
|
-
projectId:
|
|
24848
|
-
componentId:
|
|
24849
|
-
adapter:
|
|
24913
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24914
|
+
projectId: text83("project_id").notNull(),
|
|
24915
|
+
componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24916
|
+
adapter: jsonb44("adapter").$type().notNull(),
|
|
24850
24917
|
adapterHash: varchar61("adapter_hash", { length: 64 }).notNull(),
|
|
24851
24918
|
source: varchar61("source", { length: 24 }).$type().notNull(),
|
|
24852
|
-
declaredBy:
|
|
24853
|
-
declaredAt:
|
|
24854
|
-
updatedAt:
|
|
24919
|
+
declaredBy: text83("declared_by"),
|
|
24920
|
+
declaredAt: timestamp75("declared_at", { withTimezone: true }).notNull().defaultNow(),
|
|
24921
|
+
updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
24855
24922
|
},
|
|
24856
24923
|
(table) => [
|
|
24857
|
-
|
|
24924
|
+
foreignKey6({
|
|
24858
24925
|
columns: [table.projectId, table.workspaceId],
|
|
24859
24926
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24860
24927
|
name: "component_implementation_adapters_scope_fkey"
|
|
24861
24928
|
}).onDelete("cascade"),
|
|
24862
24929
|
unique5("component_implementation_adapters_component_unique").on(table.projectId, table.componentId),
|
|
24863
|
-
|
|
24930
|
+
index70("component_implementation_adapters_project_idx").on(table.projectId, table.componentId)
|
|
24864
24931
|
]
|
|
24865
24932
|
);
|
|
24866
|
-
var componentImplementationStates =
|
|
24933
|
+
var componentImplementationStates = pgTable82(
|
|
24867
24934
|
"component_implementation_states",
|
|
24868
24935
|
{
|
|
24869
|
-
id:
|
|
24870
|
-
workspaceId:
|
|
24871
|
-
projectId:
|
|
24872
|
-
componentId:
|
|
24873
|
-
selectedCandidateId:
|
|
24874
|
-
selectedEvidenceId:
|
|
24875
|
-
selectedApprovalId:
|
|
24876
|
-
publishedCandidateId:
|
|
24877
|
-
publishedEvidenceId:
|
|
24878
|
-
publishedApprovalId:
|
|
24879
|
-
requestId:
|
|
24936
|
+
id: text83("id").primaryKey(),
|
|
24937
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24938
|
+
projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
24939
|
+
componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24940
|
+
selectedCandidateId: text83("selected_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
|
|
24941
|
+
selectedEvidenceId: text83("selected_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
|
|
24942
|
+
selectedApprovalId: text83("selected_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
|
|
24943
|
+
publishedCandidateId: text83("published_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
|
|
24944
|
+
publishedEvidenceId: text83("published_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
|
|
24945
|
+
publishedApprovalId: text83("published_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
|
|
24946
|
+
requestId: text83("request_id"),
|
|
24880
24947
|
requestProvider: varchar61("request_provider", { length: 20 }).$type(),
|
|
24881
24948
|
requestStatus: varchar61("request_status", { length: 20 }).$type().notNull().default("not-requested"),
|
|
24882
|
-
requestErrorCode:
|
|
24883
|
-
requestErrorMessage:
|
|
24884
|
-
requestedBy:
|
|
24885
|
-
requestedAt:
|
|
24886
|
-
updatedAt:
|
|
24949
|
+
requestErrorCode: text83("request_error_code"),
|
|
24950
|
+
requestErrorMessage: text83("request_error_message"),
|
|
24951
|
+
requestedBy: text83("requested_by"),
|
|
24952
|
+
requestedAt: timestamp75("requested_at"),
|
|
24953
|
+
updatedAt: timestamp75("updated_at").notNull().defaultNow()
|
|
24887
24954
|
},
|
|
24888
24955
|
(table) => [
|
|
24889
|
-
|
|
24956
|
+
foreignKey6({
|
|
24890
24957
|
columns: [table.projectId, table.workspaceId],
|
|
24891
24958
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24892
24959
|
name: "component_implementation_states_project_workspace_fkey"
|
|
24893
24960
|
}).onDelete("cascade"),
|
|
24894
24961
|
uniqueIndex35("component_implementation_states_component_unique").on(table.projectId, table.componentId),
|
|
24895
|
-
|
|
24962
|
+
index70("component_implementation_states_workspace_idx").on(table.workspaceId)
|
|
24896
24963
|
]
|
|
24897
24964
|
);
|
|
24898
|
-
var componentPreviewSources =
|
|
24965
|
+
var componentPreviewSources = pgTable82(
|
|
24899
24966
|
"component_preview_sources",
|
|
24900
24967
|
{
|
|
24901
24968
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
24902
|
-
workspaceId:
|
|
24903
|
-
projectId:
|
|
24904
|
-
componentId:
|
|
24905
|
-
sourcePath:
|
|
24969
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24970
|
+
projectId: text83("project_id").notNull(),
|
|
24971
|
+
componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
24972
|
+
sourcePath: text83("source_path").notNull(),
|
|
24906
24973
|
sourceExport: varchar61("source_export", { length: 128 }).notNull().default("default"),
|
|
24907
24974
|
/** `file`: props are the component's fields. `section`: codemod-extracted, props `{ blockId, bind, overrides, page }` (0321). */
|
|
24908
24975
|
sourceKind: varchar61("source_kind", { length: 16 }).$type().notNull().default("file"),
|
|
24909
24976
|
recordedBy: varchar61("recorded_by", { length: 24 }).$type().notNull().default("agent"),
|
|
24910
|
-
updatedBy:
|
|
24911
|
-
createdAt:
|
|
24912
|
-
updatedAt:
|
|
24977
|
+
updatedBy: text83("updated_by"),
|
|
24978
|
+
createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
24979
|
+
updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
24913
24980
|
},
|
|
24914
24981
|
(table) => [
|
|
24915
|
-
|
|
24982
|
+
foreignKey6({
|
|
24916
24983
|
columns: [table.projectId, table.workspaceId],
|
|
24917
24984
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24918
24985
|
name: "component_preview_sources_scope_fkey"
|
|
24919
24986
|
}).onDelete("cascade"),
|
|
24920
24987
|
unique5("component_preview_sources_component_unique").on(table.projectId, table.componentId),
|
|
24921
|
-
|
|
24988
|
+
index70("component_preview_sources_project_idx").on(table.projectId)
|
|
24922
24989
|
]
|
|
24923
24990
|
);
|
|
24924
|
-
var componentPreviewBundles =
|
|
24991
|
+
var componentPreviewBundles = pgTable82(
|
|
24925
24992
|
"component_preview_bundles",
|
|
24926
24993
|
{
|
|
24927
24994
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
24928
|
-
workspaceId:
|
|
24929
|
-
projectId:
|
|
24995
|
+
workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
24996
|
+
projectId: text83("project_id").notNull(),
|
|
24930
24997
|
commitSha: varchar61("commit_sha", { length: 64 }).notNull(),
|
|
24931
|
-
artifactKey:
|
|
24998
|
+
artifactKey: text83("artifact_key").notNull(),
|
|
24932
24999
|
checksum: varchar61("checksum", { length: 80 }).notNull(),
|
|
24933
25000
|
sizeBytes: bigint4("size_bytes", { mode: "number" }).notNull(),
|
|
24934
|
-
createdAt:
|
|
25001
|
+
createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25002
|
+
/** The preview-runtime version that built this bundle (0330); null from a runner before 0.5.0. */
|
|
25003
|
+
runtimeVersion: text83("runtime_version"),
|
|
25004
|
+
/** The latest runtime refresh of this commit: rebuilt with a newer runner without re-validating (0330). */
|
|
25005
|
+
refreshId: uuid2("refresh_id"),
|
|
25006
|
+
refreshStatus: text83("refresh_status"),
|
|
25007
|
+
refreshErrorCode: text83("refresh_error_code"),
|
|
25008
|
+
refreshErrorMessage: text83("refresh_error_message"),
|
|
25009
|
+
refreshDispatchedAt: timestamp75("refresh_dispatched_at", { withTimezone: true })
|
|
24935
25010
|
},
|
|
24936
25011
|
(table) => [
|
|
24937
|
-
|
|
25012
|
+
foreignKey6({
|
|
24938
25013
|
columns: [table.projectId, table.workspaceId],
|
|
24939
25014
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24940
25015
|
name: "component_preview_bundles_scope_fkey"
|
|
24941
25016
|
}).onDelete("cascade"),
|
|
24942
25017
|
unique5("component_preview_bundles_commit_unique").on(table.projectId, table.commitSha),
|
|
24943
|
-
|
|
25018
|
+
index70("component_preview_bundles_project_idx").on(table.projectId, table.createdAt)
|
|
24944
25019
|
]
|
|
24945
25020
|
);
|
|
24946
25021
|
|
|
@@ -24948,14 +25023,14 @@ var componentPreviewBundles = pgTable81(
|
|
|
24948
25023
|
import { sql as sql20 } from "drizzle-orm";
|
|
24949
25024
|
import {
|
|
24950
25025
|
check as check4,
|
|
24951
|
-
foreignKey as
|
|
24952
|
-
index as
|
|
24953
|
-
integer as
|
|
24954
|
-
jsonb as
|
|
24955
|
-
pgTable as
|
|
25026
|
+
foreignKey as foreignKey7,
|
|
25027
|
+
index as index71,
|
|
25028
|
+
integer as integer40,
|
|
25029
|
+
jsonb as jsonb45,
|
|
25030
|
+
pgTable as pgTable83,
|
|
24956
25031
|
primaryKey as primaryKey6,
|
|
24957
|
-
text as
|
|
24958
|
-
timestamp as
|
|
25032
|
+
text as text84,
|
|
25033
|
+
timestamp as timestamp76,
|
|
24959
25034
|
unique as unique6,
|
|
24960
25035
|
uniqueIndex as uniqueIndex36,
|
|
24961
25036
|
uuid as uuid3,
|
|
@@ -24969,62 +25044,62 @@ var ORCHESTRATION_RUN_STATUSES = [
|
|
|
24969
25044
|
"completed",
|
|
24970
25045
|
"abandoned"
|
|
24971
25046
|
];
|
|
24972
|
-
var projectOrchestrationStates =
|
|
25047
|
+
var projectOrchestrationStates = pgTable83(
|
|
24973
25048
|
"project_orchestration_states",
|
|
24974
25049
|
{
|
|
24975
|
-
projectId:
|
|
24976
|
-
workspaceId:
|
|
24977
|
-
generation:
|
|
24978
|
-
enabledBy:
|
|
24979
|
-
enabledAt:
|
|
24980
|
-
updatedAt:
|
|
25050
|
+
projectId: text84("project_id").primaryKey().references(() => projects.id, { onDelete: "cascade" }),
|
|
25051
|
+
workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25052
|
+
generation: integer40("generation").notNull().default(2),
|
|
25053
|
+
enabledBy: text84("enabled_by").notNull(),
|
|
25054
|
+
enabledAt: timestamp76("enabled_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25055
|
+
updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
24981
25056
|
},
|
|
24982
25057
|
(table) => [
|
|
24983
|
-
|
|
25058
|
+
foreignKey7({
|
|
24984
25059
|
columns: [table.projectId, table.workspaceId],
|
|
24985
25060
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
24986
25061
|
name: "project_orchestration_states_project_workspace_fkey"
|
|
24987
25062
|
}).onDelete("cascade"),
|
|
24988
25063
|
unique6("project_orchestration_states_scope_unique").on(table.projectId, table.workspaceId),
|
|
24989
25064
|
check4("project_orchestration_states_generation_check", sql20`${table.generation} >= 2`),
|
|
24990
|
-
|
|
25065
|
+
index71("project_orchestration_states_workspace_idx").on(table.workspaceId)
|
|
24991
25066
|
]
|
|
24992
25067
|
);
|
|
24993
|
-
var orchestrationRuns =
|
|
25068
|
+
var orchestrationRuns = pgTable83(
|
|
24994
25069
|
"orchestration_runs",
|
|
24995
25070
|
{
|
|
24996
25071
|
id: uuid3("id").primaryKey().defaultRandom(),
|
|
24997
|
-
workspaceId:
|
|
24998
|
-
projectId:
|
|
24999
|
-
projectGeneration:
|
|
25000
|
-
startIdempotencyKey:
|
|
25072
|
+
workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25073
|
+
projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25074
|
+
projectGeneration: integer40("project_generation").notNull(),
|
|
25075
|
+
startIdempotencyKey: text84("start_idempotency_key").notNull(),
|
|
25001
25076
|
targetKind: varchar62("target_kind", { length: 32 }).$type().notNull().default("component-variant"),
|
|
25002
|
-
targetId:
|
|
25003
|
-
targetVariantId:
|
|
25004
|
-
targetMetadata:
|
|
25077
|
+
targetId: text84("target_id").notNull().references(() => components.id, { onDelete: "no action" }),
|
|
25078
|
+
targetVariantId: text84("target_variant_id"),
|
|
25079
|
+
targetMetadata: jsonb45("target_metadata").$type().notNull(),
|
|
25005
25080
|
status: varchar62("status", { length: 20 }).$type().notNull().default("open"),
|
|
25006
25081
|
activeStage: varchar62("active_stage", { length: 64 }).notNull().default("awaiting-executor"),
|
|
25007
|
-
version:
|
|
25008
|
-
preferredExecutorId:
|
|
25009
|
-
cancellationRequestedAt:
|
|
25010
|
-
cancellationRequestedBy:
|
|
25011
|
-
createdBy:
|
|
25082
|
+
version: integer40("version").notNull().default(1),
|
|
25083
|
+
preferredExecutorId: text84("preferred_executor_id"),
|
|
25084
|
+
cancellationRequestedAt: timestamp76("cancellation_requested_at", { withTimezone: true }),
|
|
25085
|
+
cancellationRequestedBy: text84("cancellation_requested_by"),
|
|
25086
|
+
createdBy: text84("created_by").notNull(),
|
|
25012
25087
|
policyVersion: varchar62("policy_version", { length: 64 }).notNull().default("orchestration-v2"),
|
|
25013
|
-
createdAt:
|
|
25014
|
-
updatedAt:
|
|
25088
|
+
createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25089
|
+
updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25015
25090
|
},
|
|
25016
25091
|
(table) => [
|
|
25017
|
-
|
|
25092
|
+
foreignKey7({
|
|
25018
25093
|
columns: [table.projectId, table.workspaceId],
|
|
25019
25094
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
25020
25095
|
name: "orchestration_runs_project_workspace_fkey"
|
|
25021
25096
|
}).onDelete("cascade"),
|
|
25022
|
-
|
|
25097
|
+
foreignKey7({
|
|
25023
25098
|
columns: [table.targetVariantId, table.workspaceId, table.targetId],
|
|
25024
25099
|
foreignColumns: [componentVariants.id, componentVariants.workspaceId, componentVariants.componentId],
|
|
25025
25100
|
name: "orchestration_runs_target_variant_scope_fkey"
|
|
25026
25101
|
}).onDelete("no action"),
|
|
25027
|
-
|
|
25102
|
+
foreignKey7({
|
|
25028
25103
|
columns: [table.projectId, table.workspaceId],
|
|
25029
25104
|
foreignColumns: [projectOrchestrationStates.projectId, projectOrchestrationStates.workspaceId],
|
|
25030
25105
|
name: "orchestration_runs_project_state_fkey"
|
|
@@ -25035,14 +25110,14 @@ var orchestrationRuns = pgTable82(
|
|
|
25035
25110
|
table.startIdempotencyKey
|
|
25036
25111
|
),
|
|
25037
25112
|
uniqueIndex36("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql20`${table.status} IN ('open', 'paused', 'cancelling')`),
|
|
25038
|
-
|
|
25113
|
+
index71("orchestration_runs_project_target_idx").on(
|
|
25039
25114
|
table.projectId,
|
|
25040
25115
|
table.targetKind,
|
|
25041
25116
|
table.targetId,
|
|
25042
25117
|
table.targetVariantId,
|
|
25043
25118
|
table.createdAt
|
|
25044
25119
|
),
|
|
25045
|
-
|
|
25120
|
+
index71("orchestration_runs_workspace_status_idx").on(
|
|
25046
25121
|
table.workspaceId,
|
|
25047
25122
|
table.status,
|
|
25048
25123
|
table.updatedAt
|
|
@@ -25129,59 +25204,59 @@ var orchestrationRuns = pgTable82(
|
|
|
25129
25204
|
check4("orchestration_runs_timestamps_check", sql20`${table.updatedAt} >= ${table.createdAt}`)
|
|
25130
25205
|
]
|
|
25131
25206
|
);
|
|
25132
|
-
var orchestrationRunStartKeys =
|
|
25207
|
+
var orchestrationRunStartKeys = pgTable83(
|
|
25133
25208
|
"orchestration_run_start_keys",
|
|
25134
25209
|
{
|
|
25135
|
-
workspaceId:
|
|
25136
|
-
projectId:
|
|
25137
|
-
idempotencyKey:
|
|
25210
|
+
workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25211
|
+
projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25212
|
+
idempotencyKey: text84("idempotency_key").notNull(),
|
|
25138
25213
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25139
|
-
createdAt:
|
|
25214
|
+
createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
25140
25215
|
},
|
|
25141
25216
|
(table) => [
|
|
25142
25217
|
primaryKey6({ columns: [table.projectId, table.idempotencyKey] }),
|
|
25143
|
-
|
|
25218
|
+
foreignKey7({
|
|
25144
25219
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25145
25220
|
foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
|
|
25146
25221
|
name: "orchestration_run_start_keys_run_scope_fkey"
|
|
25147
25222
|
}).onDelete("cascade"),
|
|
25148
|
-
|
|
25223
|
+
index71("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
|
|
25149
25224
|
check4(
|
|
25150
25225
|
"orchestration_run_start_keys_idempotency_key_check",
|
|
25151
25226
|
sql20`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
|
|
25152
25227
|
)
|
|
25153
25228
|
]
|
|
25154
25229
|
);
|
|
25155
|
-
var orchestrationRunEvents =
|
|
25230
|
+
var orchestrationRunEvents = pgTable83(
|
|
25156
25231
|
"orchestration_run_events",
|
|
25157
25232
|
{
|
|
25158
25233
|
id: uuid3("id").primaryKey().defaultRandom(),
|
|
25159
25234
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25160
|
-
workspaceId:
|
|
25161
|
-
projectId:
|
|
25162
|
-
sequence:
|
|
25163
|
-
schemaVersion:
|
|
25164
|
-
idempotencyKey:
|
|
25235
|
+
workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25236
|
+
projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25237
|
+
sequence: integer40("sequence").notNull(),
|
|
25238
|
+
schemaVersion: integer40("schema_version").notNull().default(1),
|
|
25239
|
+
idempotencyKey: text84("idempotency_key").notNull(),
|
|
25165
25240
|
type: varchar62("type", { length: 100 }).notNull(),
|
|
25166
25241
|
actorType: varchar62("actor_type", { length: 32 }).notNull(),
|
|
25167
|
-
actorId:
|
|
25168
|
-
causationId:
|
|
25169
|
-
correlationId:
|
|
25170
|
-
payload:
|
|
25242
|
+
actorId: text84("actor_id").notNull(),
|
|
25243
|
+
causationId: text84("causation_id"),
|
|
25244
|
+
correlationId: text84("correlation_id"),
|
|
25245
|
+
payload: jsonb45("payload").$type().notNull().default({}),
|
|
25171
25246
|
payloadDigest: varchar62("payload_digest", { length: 71 }).generatedAlwaysAs(
|
|
25172
25247
|
sql20`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
|
|
25173
25248
|
),
|
|
25174
|
-
createdAt:
|
|
25249
|
+
createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
25175
25250
|
},
|
|
25176
25251
|
(table) => [
|
|
25177
|
-
|
|
25252
|
+
foreignKey7({
|
|
25178
25253
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25179
25254
|
foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
|
|
25180
25255
|
name: "orchestration_run_events_run_scope_fkey"
|
|
25181
25256
|
}).onDelete("cascade"),
|
|
25182
25257
|
unique6("orchestration_run_events_sequence_unique").on(table.runId, table.sequence),
|
|
25183
25258
|
unique6("orchestration_run_events_idempotency_unique").on(table.runId, table.idempotencyKey),
|
|
25184
|
-
|
|
25259
|
+
index71("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
|
|
25185
25260
|
check4("orchestration_run_events_sequence_check", sql20`${table.sequence} >= 1`),
|
|
25186
25261
|
check4("orchestration_run_events_schema_version_check", sql20`${table.schemaVersion} >= 1`),
|
|
25187
25262
|
check4(
|
|
@@ -25197,29 +25272,29 @@ var orchestrationRunEvents = pgTable82(
|
|
|
25197
25272
|
)
|
|
25198
25273
|
]
|
|
25199
25274
|
);
|
|
25200
|
-
var orchestrationRunCommandResults =
|
|
25275
|
+
var orchestrationRunCommandResults = pgTable83(
|
|
25201
25276
|
"orchestration_run_command_results",
|
|
25202
25277
|
{
|
|
25203
25278
|
commandId: uuid3("command_id").primaryKey(),
|
|
25204
|
-
workspaceId:
|
|
25205
|
-
projectId:
|
|
25279
|
+
workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25280
|
+
projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25206
25281
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25207
25282
|
command: varchar62("command", { length: 20 }).$type().notNull(),
|
|
25208
|
-
expectedVersion:
|
|
25209
|
-
resultingVersion:
|
|
25210
|
-
actorId:
|
|
25283
|
+
expectedVersion: integer40("expected_version").notNull(),
|
|
25284
|
+
resultingVersion: integer40("resulting_version").notNull(),
|
|
25285
|
+
actorId: text84("actor_id").notNull(),
|
|
25211
25286
|
eventId: uuid3("event_id").notNull().references(() => orchestrationRunEvents.id, { onDelete: "cascade" }),
|
|
25212
|
-
resultPayload:
|
|
25213
|
-
createdAt:
|
|
25287
|
+
resultPayload: jsonb45("result_payload").$type().notNull(),
|
|
25288
|
+
createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
25214
25289
|
},
|
|
25215
25290
|
(table) => [
|
|
25216
|
-
|
|
25291
|
+
foreignKey7({
|
|
25217
25292
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25218
25293
|
foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
|
|
25219
25294
|
name: "orchestration_run_command_results_run_scope_fkey"
|
|
25220
25295
|
}).onDelete("cascade"),
|
|
25221
|
-
|
|
25222
|
-
|
|
25296
|
+
index71("orchestration_run_command_results_run_created_idx").on(table.runId, table.createdAt),
|
|
25297
|
+
index71("orchestration_run_command_results_project_created_idx").on(
|
|
25223
25298
|
table.projectId,
|
|
25224
25299
|
table.createdAt
|
|
25225
25300
|
),
|
|
@@ -25252,13 +25327,13 @@ import {
|
|
|
25252
25327
|
bigint as bigint5,
|
|
25253
25328
|
boolean as boolean29,
|
|
25254
25329
|
check as check5,
|
|
25255
|
-
foreignKey as
|
|
25256
|
-
index as
|
|
25257
|
-
integer as
|
|
25258
|
-
jsonb as
|
|
25259
|
-
pgTable as
|
|
25260
|
-
text as
|
|
25261
|
-
timestamp as
|
|
25330
|
+
foreignKey as foreignKey8,
|
|
25331
|
+
index as index72,
|
|
25332
|
+
integer as integer41,
|
|
25333
|
+
jsonb as jsonb46,
|
|
25334
|
+
pgTable as pgTable84,
|
|
25335
|
+
text as text85,
|
|
25336
|
+
timestamp as timestamp77,
|
|
25262
25337
|
unique as unique7,
|
|
25263
25338
|
uniqueIndex as uniqueIndex37,
|
|
25264
25339
|
uuid as uuid4,
|
|
@@ -25303,23 +25378,23 @@ var EXECUTOR_COMMAND_KINDS = [
|
|
|
25303
25378
|
"cancel",
|
|
25304
25379
|
"handoff"
|
|
25305
25380
|
];
|
|
25306
|
-
var orchestrationExecutorInstallations =
|
|
25381
|
+
var orchestrationExecutorInstallations = pgTable84(
|
|
25307
25382
|
"orchestration_executor_installations",
|
|
25308
25383
|
{
|
|
25309
25384
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25310
|
-
workspaceId:
|
|
25311
|
-
projectId:
|
|
25385
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25386
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25312
25387
|
kind: varchar63("kind", { length: 24 }).$type().notNull(),
|
|
25313
|
-
grantId:
|
|
25388
|
+
grantId: text85("grant_id").references(() => deviceAuthorizations.id, { onDelete: "cascade" }),
|
|
25314
25389
|
protocolVersion: varchar63("protocol_version", { length: 16 }).notNull(),
|
|
25315
|
-
capabilityDigest:
|
|
25316
|
-
repositoryClaim:
|
|
25390
|
+
capabilityDigest: text85("capability_digest").notNull(),
|
|
25391
|
+
repositoryClaim: jsonb46("repository_claim").$type().notNull().default({}),
|
|
25317
25392
|
status: varchar63("status", { length: 20 }).$type().notNull().default("active"),
|
|
25318
|
-
createdAt:
|
|
25319
|
-
updatedAt:
|
|
25393
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25394
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25320
25395
|
},
|
|
25321
25396
|
(table) => [
|
|
25322
|
-
|
|
25397
|
+
foreignKey8({
|
|
25323
25398
|
columns: [table.projectId, table.workspaceId],
|
|
25324
25399
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
25325
25400
|
name: "orchestration_executor_installations_project_workspace_fkey"
|
|
@@ -25329,7 +25404,7 @@ var orchestrationExecutorInstallations = pgTable83(
|
|
|
25329
25404
|
table.workspaceId,
|
|
25330
25405
|
table.projectId
|
|
25331
25406
|
),
|
|
25332
|
-
|
|
25407
|
+
index72("orchestration_executor_installations_project_status_idx").on(
|
|
25333
25408
|
table.projectId,
|
|
25334
25409
|
table.status
|
|
25335
25410
|
),
|
|
@@ -25366,27 +25441,27 @@ var orchestrationExecutorInstallations = pgTable83(
|
|
|
25366
25441
|
)
|
|
25367
25442
|
]
|
|
25368
25443
|
);
|
|
25369
|
-
var orchestrationExecutorSessions =
|
|
25444
|
+
var orchestrationExecutorSessions = pgTable84(
|
|
25370
25445
|
"orchestration_executor_sessions",
|
|
25371
25446
|
{
|
|
25372
25447
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25373
|
-
workspaceId:
|
|
25374
|
-
projectId:
|
|
25448
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25449
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25375
25450
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
25376
|
-
sessionEpoch:
|
|
25451
|
+
sessionEpoch: integer41("session_epoch").notNull().default(1),
|
|
25377
25452
|
credentialAudience: varchar63("credential_audience", { length: 64 }).notNull(),
|
|
25378
25453
|
state: varchar63("state", { length: 20 }).$type().notNull().default("open"),
|
|
25379
25454
|
clientCursor: bigint5("client_cursor", { mode: "number" }).notNull().default(0),
|
|
25380
25455
|
serverCursor: bigint5("server_cursor", { mode: "number" }).notNull().default(0),
|
|
25381
|
-
connectedAt:
|
|
25382
|
-
lastHeartbeatAt:
|
|
25383
|
-
serverReceivedAt:
|
|
25384
|
-
closedAt:
|
|
25385
|
-
createdAt:
|
|
25386
|
-
updatedAt:
|
|
25456
|
+
connectedAt: timestamp77("connected_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25457
|
+
lastHeartbeatAt: timestamp77("last_heartbeat_at", { withTimezone: true }),
|
|
25458
|
+
serverReceivedAt: timestamp77("server_received_at", { withTimezone: true }),
|
|
25459
|
+
closedAt: timestamp77("closed_at", { withTimezone: true }),
|
|
25460
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25461
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25387
25462
|
},
|
|
25388
25463
|
(table) => [
|
|
25389
|
-
|
|
25464
|
+
foreignKey8({
|
|
25390
25465
|
columns: [table.installationId, table.workspaceId, table.projectId],
|
|
25391
25466
|
foreignColumns: [
|
|
25392
25467
|
orchestrationExecutorInstallations.id,
|
|
@@ -25404,11 +25479,11 @@ var orchestrationExecutorSessions = pgTable83(
|
|
|
25404
25479
|
table.installationId,
|
|
25405
25480
|
table.sessionEpoch
|
|
25406
25481
|
),
|
|
25407
|
-
|
|
25482
|
+
index72("orchestration_executor_sessions_installation_state_idx").on(
|
|
25408
25483
|
table.installationId,
|
|
25409
25484
|
table.state
|
|
25410
25485
|
),
|
|
25411
|
-
|
|
25486
|
+
index72("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql21`${table.state} = 'open'`),
|
|
25412
25487
|
check5("orchestration_executor_sessions_epoch_check", sql21`${table.sessionEpoch} >= 1`),
|
|
25413
25488
|
check5(
|
|
25414
25489
|
"orchestration_executor_sessions_state_check",
|
|
@@ -25432,18 +25507,18 @@ var orchestrationExecutorSessions = pgTable83(
|
|
|
25432
25507
|
)
|
|
25433
25508
|
]
|
|
25434
25509
|
);
|
|
25435
|
-
var orchestrationImplementationAttempts =
|
|
25510
|
+
var orchestrationImplementationAttempts = pgTable84(
|
|
25436
25511
|
"orchestration_implementation_attempts",
|
|
25437
25512
|
{
|
|
25438
25513
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25439
|
-
workspaceId:
|
|
25440
|
-
projectId:
|
|
25514
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25515
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25441
25516
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25442
25517
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
25443
|
-
attemptNumber:
|
|
25518
|
+
attemptNumber: integer41("attempt_number").notNull(),
|
|
25444
25519
|
targetKind: varchar63("target_kind", { length: 32 }).notNull().default("component-variant"),
|
|
25445
|
-
targetId:
|
|
25446
|
-
targetBindingDigest:
|
|
25520
|
+
targetId: text85("target_id").notNull(),
|
|
25521
|
+
targetBindingDigest: text85("target_binding_digest").notNull(),
|
|
25447
25522
|
repositoryId: bigint5("repository_id", { mode: "number" }),
|
|
25448
25523
|
baseBranch: varchar63("base_branch", { length: 255 }),
|
|
25449
25524
|
baseSha: varchar63("base_sha", { length: 64 }),
|
|
@@ -25452,7 +25527,7 @@ var orchestrationImplementationAttempts = pgTable83(
|
|
|
25452
25527
|
* crash-safety line: if the process dies holding a branch, cancellation and reconciliation can
|
|
25453
25528
|
* still find it. Null until the branch exists. Shape-checked to run branches only (0278).
|
|
25454
25529
|
*/
|
|
25455
|
-
createdRef:
|
|
25530
|
+
createdRef: text85("created_ref"),
|
|
25456
25531
|
status: varchar63("status", { length: 24 }).$type().notNull().default("preflight"),
|
|
25457
25532
|
supersededBy: uuid4("superseded_by"),
|
|
25458
25533
|
/**
|
|
@@ -25460,19 +25535,19 @@ var orchestrationImplementationAttempts = pgTable83(
|
|
|
25460
25535
|
* withdrawn attempt's pull request is kept BY URL, so a reader of the run never has to
|
|
25461
25536
|
* discover from GitHub that one used to exist here.
|
|
25462
25537
|
*/
|
|
25463
|
-
withdrawnAt:
|
|
25464
|
-
withdrawnBy:
|
|
25465
|
-
withdrawnPullRequestUrl:
|
|
25466
|
-
createdAt:
|
|
25467
|
-
updatedAt:
|
|
25538
|
+
withdrawnAt: timestamp77("withdrawn_at", { withTimezone: true }),
|
|
25539
|
+
withdrawnBy: text85("withdrawn_by"),
|
|
25540
|
+
withdrawnPullRequestUrl: text85("withdrawn_pull_request_url"),
|
|
25541
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25542
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25468
25543
|
},
|
|
25469
25544
|
(table) => [
|
|
25470
|
-
|
|
25545
|
+
foreignKey8({
|
|
25471
25546
|
columns: [table.supersededBy],
|
|
25472
25547
|
foreignColumns: [table.id],
|
|
25473
25548
|
name: "orchestration_implementation_attempts_superseded_by_fkey"
|
|
25474
25549
|
}).onDelete("set null"),
|
|
25475
|
-
|
|
25550
|
+
foreignKey8({
|
|
25476
25551
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25477
25552
|
foreignColumns: [
|
|
25478
25553
|
orchestrationRuns.id,
|
|
@@ -25481,7 +25556,7 @@ var orchestrationImplementationAttempts = pgTable83(
|
|
|
25481
25556
|
],
|
|
25482
25557
|
name: "orchestration_implementation_attempts_run_scope_fkey"
|
|
25483
25558
|
}).onDelete("cascade"),
|
|
25484
|
-
|
|
25559
|
+
foreignKey8({
|
|
25485
25560
|
columns: [table.installationId, table.workspaceId, table.projectId],
|
|
25486
25561
|
foreignColumns: [
|
|
25487
25562
|
orchestrationExecutorInstallations.id,
|
|
@@ -25499,7 +25574,7 @@ var orchestrationImplementationAttempts = pgTable83(
|
|
|
25499
25574
|
table.runId,
|
|
25500
25575
|
table.attemptNumber
|
|
25501
25576
|
),
|
|
25502
|
-
|
|
25577
|
+
index72("orchestration_implementation_attempts_run_created_idx").on(
|
|
25503
25578
|
table.runId,
|
|
25504
25579
|
table.createdAt
|
|
25505
25580
|
),
|
|
@@ -25530,49 +25605,49 @@ var orchestrationImplementationAttempts = pgTable83(
|
|
|
25530
25605
|
)
|
|
25531
25606
|
]
|
|
25532
25607
|
);
|
|
25533
|
-
var orchestrationPlanSnapshots =
|
|
25608
|
+
var orchestrationPlanSnapshots = pgTable84(
|
|
25534
25609
|
"orchestration_plan_snapshots",
|
|
25535
25610
|
{
|
|
25536
|
-
planDigest:
|
|
25537
|
-
workspaceId:
|
|
25538
|
-
projectId:
|
|
25611
|
+
planDigest: text85("plan_digest").primaryKey(),
|
|
25612
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25613
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25539
25614
|
baseHeadOid: varchar63("base_head_oid", { length: 64 }).notNull(),
|
|
25540
|
-
budget:
|
|
25541
|
-
files:
|
|
25542
|
-
fileCount:
|
|
25615
|
+
budget: jsonb46("budget").notNull(),
|
|
25616
|
+
files: jsonb46("files").notNull(),
|
|
25617
|
+
fileCount: integer41("file_count").notNull(),
|
|
25543
25618
|
byteCount: bigint5("byte_count", { mode: "number" }).notNull(),
|
|
25544
|
-
createdAt:
|
|
25619
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
25545
25620
|
},
|
|
25546
|
-
(table) => [
|
|
25621
|
+
(table) => [index72("orchestration_plan_snapshots_project_idx").on(table.workspaceId, table.projectId, table.createdAt)]
|
|
25547
25622
|
);
|
|
25548
|
-
var orchestrationVisualApprovals =
|
|
25623
|
+
var orchestrationVisualApprovals = pgTable84(
|
|
25549
25624
|
"orchestration_visual_approvals",
|
|
25550
25625
|
{
|
|
25551
25626
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25552
|
-
workspaceId:
|
|
25553
|
-
projectId:
|
|
25627
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25628
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25554
25629
|
runId: uuid4("run_id").notNull(),
|
|
25555
25630
|
attemptId: uuid4("attempt_id").notNull(),
|
|
25556
25631
|
headSha: varchar63("head_sha", { length: 64 }).notNull(),
|
|
25557
25632
|
evidenceId: uuid4("evidence_id").notNull(),
|
|
25558
|
-
authorizedBy:
|
|
25559
|
-
idempotencyKey:
|
|
25560
|
-
expiresAt:
|
|
25561
|
-
consumedAt:
|
|
25562
|
-
consumedByRef:
|
|
25563
|
-
createdAt:
|
|
25564
|
-
updatedAt:
|
|
25633
|
+
authorizedBy: text85("authorized_by").notNull(),
|
|
25634
|
+
idempotencyKey: text85("idempotency_key").notNull(),
|
|
25635
|
+
expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
|
|
25636
|
+
consumedAt: timestamp77("consumed_at", { withTimezone: true }),
|
|
25637
|
+
consumedByRef: text85("consumed_by_ref"),
|
|
25638
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25639
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25565
25640
|
}
|
|
25566
25641
|
);
|
|
25567
|
-
var orchestrationMergeAuthorizations =
|
|
25642
|
+
var orchestrationMergeAuthorizations = pgTable84(
|
|
25568
25643
|
"orchestration_merge_authorizations",
|
|
25569
25644
|
{
|
|
25570
25645
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25571
|
-
workspaceId:
|
|
25572
|
-
projectId:
|
|
25646
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25647
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25573
25648
|
runId: uuid4("run_id").notNull(),
|
|
25574
25649
|
attemptId: uuid4("attempt_id").notNull(),
|
|
25575
|
-
pullRequestNumber:
|
|
25650
|
+
pullRequestNumber: integer41("pull_request_number").notNull(),
|
|
25576
25651
|
expectedHeadSha: varchar63("expected_head_sha", { length: 64 }).notNull(),
|
|
25577
25652
|
visualApprovalId: uuid4("visual_approval_id").notNull(),
|
|
25578
25653
|
/**
|
|
@@ -25580,88 +25655,88 @@ var orchestrationMergeAuthorizations = pgTable83(
|
|
|
25580
25655
|
* what an authorization BOUGHT, and a void bought nothing. A CHECK keeps the three together and
|
|
25581
25656
|
* forbids a row that is both spent and voided.
|
|
25582
25657
|
*/
|
|
25583
|
-
voidedAt:
|
|
25584
|
-
voidedBy:
|
|
25585
|
-
voidReason:
|
|
25586
|
-
authorizedBy:
|
|
25587
|
-
idempotencyKey:
|
|
25588
|
-
expiresAt:
|
|
25589
|
-
consumedAt:
|
|
25590
|
-
consumedByRef:
|
|
25591
|
-
createdAt:
|
|
25592
|
-
updatedAt:
|
|
25658
|
+
voidedAt: timestamp77("voided_at", { withTimezone: true }),
|
|
25659
|
+
voidedBy: text85("voided_by"),
|
|
25660
|
+
voidReason: text85("void_reason"),
|
|
25661
|
+
authorizedBy: text85("authorized_by").notNull(),
|
|
25662
|
+
idempotencyKey: text85("idempotency_key").notNull(),
|
|
25663
|
+
expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
|
|
25664
|
+
consumedAt: timestamp77("consumed_at", { withTimezone: true }),
|
|
25665
|
+
consumedByRef: text85("consumed_by_ref"),
|
|
25666
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25667
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25593
25668
|
}
|
|
25594
25669
|
);
|
|
25595
|
-
var orchestrationDeploymentAuthorizations =
|
|
25670
|
+
var orchestrationDeploymentAuthorizations = pgTable84(
|
|
25596
25671
|
"orchestration_deployment_authorizations",
|
|
25597
25672
|
{
|
|
25598
25673
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25599
|
-
workspaceId:
|
|
25600
|
-
projectId:
|
|
25674
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25675
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25601
25676
|
runId: uuid4("run_id").notNull(),
|
|
25602
25677
|
attemptId: uuid4("attempt_id").notNull(),
|
|
25603
25678
|
mergeSha: varchar63("merge_sha", { length: 64 }).notNull(),
|
|
25604
25679
|
artifactChecksum: varchar63("artifact_checksum", { length: 80 }).notNull(),
|
|
25605
25680
|
mergeAuthorizationId: uuid4("merge_authorization_id").notNull(),
|
|
25606
|
-
authorizedBy:
|
|
25607
|
-
idempotencyKey:
|
|
25608
|
-
expiresAt:
|
|
25609
|
-
consumedAt:
|
|
25610
|
-
consumedByRef:
|
|
25611
|
-
createdAt:
|
|
25612
|
-
updatedAt:
|
|
25681
|
+
authorizedBy: text85("authorized_by").notNull(),
|
|
25682
|
+
idempotencyKey: text85("idempotency_key").notNull(),
|
|
25683
|
+
expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
|
|
25684
|
+
consumedAt: timestamp77("consumed_at", { withTimezone: true }),
|
|
25685
|
+
consumedByRef: text85("consumed_by_ref"),
|
|
25686
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25687
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25613
25688
|
}
|
|
25614
25689
|
);
|
|
25615
|
-
var orchestrationDeploymentRequests =
|
|
25690
|
+
var orchestrationDeploymentRequests = pgTable84(
|
|
25616
25691
|
"orchestration_deployment_requests",
|
|
25617
25692
|
{
|
|
25618
25693
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25619
|
-
workspaceId:
|
|
25620
|
-
projectId:
|
|
25694
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25695
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25621
25696
|
runId: uuid4("run_id").notNull(),
|
|
25622
25697
|
attemptId: uuid4("attempt_id").notNull(),
|
|
25623
25698
|
authorizationId: uuid4("authorization_id").notNull(),
|
|
25624
25699
|
expectedMergeSha: varchar63("expected_merge_sha", { length: 64 }).notNull(),
|
|
25625
25700
|
artifactChecksum: varchar63("artifact_checksum", { length: 80 }).notNull(),
|
|
25626
25701
|
state: varchar63("state", { length: 12 }).$type().notNull().default("live"),
|
|
25627
|
-
voidReason:
|
|
25628
|
-
releaseId:
|
|
25629
|
-
createdAt:
|
|
25630
|
-
updatedAt:
|
|
25702
|
+
voidReason: text85("void_reason"),
|
|
25703
|
+
releaseId: text85("release_id"),
|
|
25704
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25705
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25631
25706
|
}
|
|
25632
25707
|
);
|
|
25633
|
-
var orchestrationExecutionApprovals =
|
|
25708
|
+
var orchestrationExecutionApprovals = pgTable84(
|
|
25634
25709
|
"orchestration_execution_approvals",
|
|
25635
25710
|
{
|
|
25636
25711
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25637
|
-
workspaceId:
|
|
25638
|
-
projectId:
|
|
25712
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25713
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25639
25714
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25640
25715
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
25641
25716
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
25642
|
-
idempotencyKey:
|
|
25643
|
-
approvedBy:
|
|
25717
|
+
idempotencyKey: text85("idempotency_key").notNull(),
|
|
25718
|
+
approvedBy: text85("approved_by").notNull(),
|
|
25644
25719
|
targetKind: varchar63("target_kind", { length: 32 }).notNull().default("component-variant"),
|
|
25645
|
-
targetId:
|
|
25646
|
-
targetBindingDigest:
|
|
25720
|
+
targetId: text85("target_id").notNull(),
|
|
25721
|
+
targetBindingDigest: text85("target_binding_digest").notNull(),
|
|
25647
25722
|
repositoryId: bigint5("repository_id", { mode: "number" }),
|
|
25648
25723
|
baseBranch: varchar63("base_branch", { length: 255 }),
|
|
25649
25724
|
baseSha: varchar63("base_sha", { length: 64 }),
|
|
25650
25725
|
/** Set when the approval is spent. 0274 grants UPDATE on THESE TWO COLUMNS ONLY, so every
|
|
25651
25726
|
* other field on a row a human signed stays as unwritable as it was before. */
|
|
25652
|
-
consumedAt:
|
|
25727
|
+
consumedAt: timestamp77("consumed_at", { withTimezone: true }),
|
|
25653
25728
|
consumedByAttemptId: uuid4("consumed_by_attempt_id"),
|
|
25654
|
-
pathPolicy:
|
|
25655
|
-
operationClasses:
|
|
25656
|
-
mutationBudget:
|
|
25657
|
-
planDigest:
|
|
25658
|
-
capabilityDigest:
|
|
25659
|
-
validationDigest:
|
|
25660
|
-
expiresAt:
|
|
25661
|
-
createdAt:
|
|
25729
|
+
pathPolicy: jsonb46("path_policy").$type().notNull().default({}),
|
|
25730
|
+
operationClasses: jsonb46("operation_classes").$type().notNull().default([]),
|
|
25731
|
+
mutationBudget: jsonb46("mutation_budget").$type().notNull().default({}),
|
|
25732
|
+
planDigest: text85("plan_digest").notNull(),
|
|
25733
|
+
capabilityDigest: text85("capability_digest").notNull(),
|
|
25734
|
+
validationDigest: text85("validation_digest").notNull(),
|
|
25735
|
+
expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
|
|
25736
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
25662
25737
|
},
|
|
25663
25738
|
(table) => [
|
|
25664
|
-
|
|
25739
|
+
foreignKey8({
|
|
25665
25740
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25666
25741
|
foreignColumns: [
|
|
25667
25742
|
orchestrationRuns.id,
|
|
@@ -25670,7 +25745,7 @@ var orchestrationExecutionApprovals = pgTable83(
|
|
|
25670
25745
|
],
|
|
25671
25746
|
name: "orchestration_execution_approvals_run_scope_fkey"
|
|
25672
25747
|
}).onDelete("cascade"),
|
|
25673
|
-
|
|
25748
|
+
foreignKey8({
|
|
25674
25749
|
columns: [table.attemptId, table.workspaceId, table.projectId],
|
|
25675
25750
|
foreignColumns: [
|
|
25676
25751
|
orchestrationImplementationAttempts.id,
|
|
@@ -25679,7 +25754,7 @@ var orchestrationExecutionApprovals = pgTable83(
|
|
|
25679
25754
|
],
|
|
25680
25755
|
name: "orchestration_execution_approvals_attempt_scope_fkey"
|
|
25681
25756
|
}).onDelete("cascade"),
|
|
25682
|
-
|
|
25757
|
+
foreignKey8({
|
|
25683
25758
|
columns: [table.installationId, table.workspaceId, table.projectId],
|
|
25684
25759
|
foreignColumns: [
|
|
25685
25760
|
orchestrationExecutorInstallations.id,
|
|
@@ -25695,7 +25770,7 @@ var orchestrationExecutionApprovals = pgTable83(
|
|
|
25695
25770
|
// One approval per attempt. A running implementation never introduces a second approval; a
|
|
25696
25771
|
// changed binding requires a NEW attempt, which is what makes the authority auditable.
|
|
25697
25772
|
unique7("orchestration_execution_approvals_attempt_unique").on(table.attemptId),
|
|
25698
|
-
|
|
25773
|
+
index72("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
|
|
25699
25774
|
check5(
|
|
25700
25775
|
"orchestration_execution_approvals_idempotency_key_check",
|
|
25701
25776
|
sql21`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
|
|
@@ -25742,26 +25817,26 @@ var orchestrationExecutionApprovals = pgTable83(
|
|
|
25742
25817
|
)
|
|
25743
25818
|
]
|
|
25744
25819
|
);
|
|
25745
|
-
var orchestrationExecutorLeases =
|
|
25820
|
+
var orchestrationExecutorLeases = pgTable84(
|
|
25746
25821
|
"orchestration_executor_leases",
|
|
25747
25822
|
{
|
|
25748
25823
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25749
|
-
workspaceId:
|
|
25750
|
-
projectId:
|
|
25824
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25825
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25751
25826
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25752
25827
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
25753
25828
|
sessionId: uuid4("session_id").notNull().references(() => orchestrationExecutorSessions.id, { onDelete: "cascade" }),
|
|
25754
|
-
leaseEpoch:
|
|
25829
|
+
leaseEpoch: integer41("lease_epoch").notNull().default(1),
|
|
25755
25830
|
state: varchar63("state", { length: 20 }).$type().notNull().default("active"),
|
|
25756
|
-
heartbeatDeadline:
|
|
25757
|
-
acquiredAt:
|
|
25758
|
-
releasedAt:
|
|
25831
|
+
heartbeatDeadline: timestamp77("heartbeat_deadline", { withTimezone: true }).notNull(),
|
|
25832
|
+
acquiredAt: timestamp77("acquired_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25833
|
+
releasedAt: timestamp77("released_at", { withTimezone: true }),
|
|
25759
25834
|
releaseReason: varchar63("release_reason", { length: 32 }).$type(),
|
|
25760
|
-
createdAt:
|
|
25761
|
-
updatedAt:
|
|
25835
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
25836
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25762
25837
|
},
|
|
25763
25838
|
(table) => [
|
|
25764
|
-
|
|
25839
|
+
foreignKey8({
|
|
25765
25840
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25766
25841
|
foreignColumns: [
|
|
25767
25842
|
orchestrationRuns.id,
|
|
@@ -25770,7 +25845,7 @@ var orchestrationExecutorLeases = pgTable83(
|
|
|
25770
25845
|
],
|
|
25771
25846
|
name: "orchestration_executor_leases_run_scope_fkey"
|
|
25772
25847
|
}).onDelete("cascade"),
|
|
25773
|
-
|
|
25848
|
+
foreignKey8({
|
|
25774
25849
|
columns: [table.attemptId, table.workspaceId, table.projectId],
|
|
25775
25850
|
foreignColumns: [
|
|
25776
25851
|
orchestrationImplementationAttempts.id,
|
|
@@ -25779,7 +25854,7 @@ var orchestrationExecutorLeases = pgTable83(
|
|
|
25779
25854
|
],
|
|
25780
25855
|
name: "orchestration_executor_leases_attempt_scope_fkey"
|
|
25781
25856
|
}).onDelete("cascade"),
|
|
25782
|
-
|
|
25857
|
+
foreignKey8({
|
|
25783
25858
|
columns: [table.sessionId, table.workspaceId, table.projectId],
|
|
25784
25859
|
foreignColumns: [
|
|
25785
25860
|
orchestrationExecutorSessions.id,
|
|
@@ -25796,7 +25871,7 @@ var orchestrationExecutorLeases = pgTable83(
|
|
|
25796
25871
|
unique7("orchestration_executor_leases_epoch_unique").on(table.attemptId, table.leaseEpoch),
|
|
25797
25872
|
// Plan invariant 6, enforced in the database: a run has at most one active executor lease.
|
|
25798
25873
|
uniqueIndex37("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql21`${table.state} = 'active'`),
|
|
25799
|
-
|
|
25874
|
+
index72("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql21`${table.state} = 'active'`),
|
|
25800
25875
|
check5("orchestration_executor_leases_epoch_check", sql21`${table.leaseEpoch} >= 1`),
|
|
25801
25876
|
check5(
|
|
25802
25877
|
"orchestration_executor_leases_state_check",
|
|
@@ -25816,35 +25891,35 @@ var orchestrationExecutorLeases = pgTable83(
|
|
|
25816
25891
|
)
|
|
25817
25892
|
]
|
|
25818
25893
|
);
|
|
25819
|
-
var orchestrationExecutorCommands =
|
|
25894
|
+
var orchestrationExecutorCommands = pgTable84(
|
|
25820
25895
|
"orchestration_executor_commands",
|
|
25821
25896
|
{
|
|
25822
25897
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25823
|
-
workspaceId:
|
|
25824
|
-
projectId:
|
|
25898
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25899
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25825
25900
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25826
25901
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
25827
25902
|
leaseId: uuid4("lease_id").references(() => orchestrationExecutorLeases.id, {
|
|
25828
25903
|
onDelete: "set null"
|
|
25829
25904
|
}),
|
|
25830
|
-
leaseEpoch:
|
|
25905
|
+
leaseEpoch: integer41("lease_epoch"),
|
|
25831
25906
|
approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
|
|
25832
25907
|
onDelete: "set null"
|
|
25833
25908
|
}),
|
|
25834
25909
|
sequence: bigint5("sequence", { mode: "number" }).notNull(),
|
|
25835
25910
|
kind: varchar63("kind", { length: 32 }).$type().notNull(),
|
|
25836
|
-
idempotencyKey:
|
|
25837
|
-
expectedRunVersion:
|
|
25838
|
-
payload:
|
|
25911
|
+
idempotencyKey: text85("idempotency_key").notNull(),
|
|
25912
|
+
expectedRunVersion: integer41("expected_run_version").notNull(),
|
|
25913
|
+
payload: jsonb46("payload").$type().notNull().default({}),
|
|
25839
25914
|
payloadDigest: varchar63("payload_digest", { length: 71 }).generatedAlwaysAs(
|
|
25840
25915
|
sql21`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
|
|
25841
25916
|
),
|
|
25842
|
-
deliveredAt:
|
|
25843
|
-
acknowledgedAt:
|
|
25844
|
-
createdAt:
|
|
25917
|
+
deliveredAt: timestamp77("delivered_at", { withTimezone: true }),
|
|
25918
|
+
acknowledgedAt: timestamp77("acknowledged_at", { withTimezone: true }),
|
|
25919
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
25845
25920
|
},
|
|
25846
25921
|
(table) => [
|
|
25847
|
-
|
|
25922
|
+
foreignKey8({
|
|
25848
25923
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25849
25924
|
foreignColumns: [
|
|
25850
25925
|
orchestrationRuns.id,
|
|
@@ -25853,7 +25928,7 @@ var orchestrationExecutorCommands = pgTable83(
|
|
|
25853
25928
|
],
|
|
25854
25929
|
name: "orchestration_executor_commands_run_scope_fkey"
|
|
25855
25930
|
}).onDelete("cascade"),
|
|
25856
|
-
|
|
25931
|
+
foreignKey8({
|
|
25857
25932
|
columns: [table.attemptId, table.workspaceId, table.projectId],
|
|
25858
25933
|
foreignColumns: [
|
|
25859
25934
|
orchestrationImplementationAttempts.id,
|
|
@@ -25867,9 +25942,9 @@ var orchestrationExecutorCommands = pgTable83(
|
|
|
25867
25942
|
table.runId,
|
|
25868
25943
|
table.idempotencyKey
|
|
25869
25944
|
),
|
|
25870
|
-
|
|
25945
|
+
index72("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
|
|
25871
25946
|
// The long-poll cursor read: unacknowledged commands for a run, in order.
|
|
25872
|
-
|
|
25947
|
+
index72("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql21`${table.acknowledgedAt} IS NULL`),
|
|
25873
25948
|
check5("orchestration_executor_commands_sequence_check", sql21`${table.sequence} >= 1`),
|
|
25874
25949
|
check5(
|
|
25875
25950
|
"orchestration_executor_commands_kind_check",
|
|
@@ -25899,28 +25974,28 @@ var orchestrationExecutorCommands = pgTable83(
|
|
|
25899
25974
|
]
|
|
25900
25975
|
);
|
|
25901
25976
|
var PATCH_OPERATIONS = ["create", "update", "delete"];
|
|
25902
|
-
var orchestrationPatchManifests =
|
|
25977
|
+
var orchestrationPatchManifests = pgTable84(
|
|
25903
25978
|
"orchestration_patch_manifests",
|
|
25904
25979
|
{
|
|
25905
25980
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25906
|
-
workspaceId:
|
|
25907
|
-
projectId:
|
|
25981
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
25982
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25908
25983
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25909
25984
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
25910
25985
|
approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
|
|
25911
25986
|
onDelete: "set null"
|
|
25912
25987
|
}),
|
|
25913
|
-
sequence:
|
|
25914
|
-
path:
|
|
25988
|
+
sequence: integer41("sequence").notNull(),
|
|
25989
|
+
path: text85("path").notNull(),
|
|
25915
25990
|
operation: varchar63("operation", { length: 16 }).$type().notNull(),
|
|
25916
25991
|
fileMode: varchar63("file_mode", { length: 6 }).notNull().default("100644"),
|
|
25917
25992
|
expectedBefore: varchar63("expected_before", { length: 64 }),
|
|
25918
25993
|
resultingBlobSha: varchar63("resulting_blob_sha", { length: 64 }),
|
|
25919
25994
|
byteCount: bigint5("byte_count", { mode: "number" }).notNull().default(0),
|
|
25920
|
-
createdAt:
|
|
25995
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
25921
25996
|
},
|
|
25922
25997
|
(table) => [
|
|
25923
|
-
|
|
25998
|
+
foreignKey8({
|
|
25924
25999
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25925
26000
|
foreignColumns: [
|
|
25926
26001
|
orchestrationRuns.id,
|
|
@@ -25929,7 +26004,7 @@ var orchestrationPatchManifests = pgTable83(
|
|
|
25929
26004
|
],
|
|
25930
26005
|
name: "orchestration_patch_manifests_run_scope_fkey"
|
|
25931
26006
|
}).onDelete("cascade"),
|
|
25932
|
-
|
|
26007
|
+
foreignKey8({
|
|
25933
26008
|
columns: [table.attemptId, table.workspaceId, table.projectId],
|
|
25934
26009
|
foreignColumns: [
|
|
25935
26010
|
orchestrationImplementationAttempts.id,
|
|
@@ -25940,7 +26015,7 @@ var orchestrationPatchManifests = pgTable83(
|
|
|
25940
26015
|
}).onDelete("cascade"),
|
|
25941
26016
|
unique7("orchestration_patch_manifests_sequence_unique").on(table.attemptId, table.sequence),
|
|
25942
26017
|
unique7("orchestration_patch_manifests_path_unique").on(table.attemptId, table.path),
|
|
25943
|
-
|
|
26018
|
+
index72("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
|
|
25944
26019
|
check5("orchestration_patch_manifests_sequence_check", sql21`${table.sequence} >= 1`),
|
|
25945
26020
|
check5(
|
|
25946
26021
|
"orchestration_patch_manifests_operation_check",
|
|
@@ -25966,19 +26041,19 @@ var orchestrationPatchManifests = pgTable83(
|
|
|
25966
26041
|
check5("orchestration_patch_manifests_byte_count_check", sql21`${table.byteCount} >= 0`)
|
|
25967
26042
|
]
|
|
25968
26043
|
);
|
|
25969
|
-
var orchestrationPullRequestReceipts =
|
|
26044
|
+
var orchestrationPullRequestReceipts = pgTable84(
|
|
25970
26045
|
"orchestration_pull_request_receipts",
|
|
25971
26046
|
{
|
|
25972
26047
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
25973
|
-
workspaceId:
|
|
25974
|
-
projectId:
|
|
26048
|
+
workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26049
|
+
projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
25975
26050
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
25976
26051
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
25977
26052
|
repositoryId: bigint5("repository_id", { mode: "number" }).notNull(),
|
|
25978
26053
|
installationId: bigint5("installation_id", { mode: "number" }),
|
|
25979
26054
|
pullRequestId: bigint5("pull_request_id", { mode: "number" }).notNull(),
|
|
25980
|
-
pullRequestNumber:
|
|
25981
|
-
pullRequestUrl:
|
|
26055
|
+
pullRequestNumber: integer41("pull_request_number").notNull(),
|
|
26056
|
+
pullRequestUrl: text85("pull_request_url").notNull(),
|
|
25982
26057
|
baseRef: varchar63("base_ref", { length: 255 }).notNull(),
|
|
25983
26058
|
baseSha: varchar63("base_sha", { length: 64 }).notNull(),
|
|
25984
26059
|
headRef: varchar63("head_ref", { length: 255 }).notNull(),
|
|
@@ -25986,13 +26061,13 @@ var orchestrationPullRequestReceipts = pgTable83(
|
|
|
25986
26061
|
/** True when BetterCMS created and owns the head branch. A head we do not own is observable
|
|
25987
26062
|
* but never advanceable by the adapter. */
|
|
25988
26063
|
branchOwned: boolean29("branch_owned").notNull().default(true),
|
|
25989
|
-
generation:
|
|
26064
|
+
generation: integer41("generation").notNull().default(1),
|
|
25990
26065
|
isDraft: boolean29("is_draft").notNull().default(true),
|
|
25991
|
-
createdAt:
|
|
25992
|
-
updatedAt:
|
|
26066
|
+
createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
26067
|
+
updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
25993
26068
|
},
|
|
25994
26069
|
(table) => [
|
|
25995
|
-
|
|
26070
|
+
foreignKey8({
|
|
25996
26071
|
columns: [table.runId, table.workspaceId, table.projectId],
|
|
25997
26072
|
foreignColumns: [
|
|
25998
26073
|
orchestrationRuns.id,
|
|
@@ -26001,7 +26076,7 @@ var orchestrationPullRequestReceipts = pgTable83(
|
|
|
26001
26076
|
],
|
|
26002
26077
|
name: "orchestration_pull_request_receipts_run_scope_fkey"
|
|
26003
26078
|
}).onDelete("cascade"),
|
|
26004
|
-
|
|
26079
|
+
foreignKey8({
|
|
26005
26080
|
columns: [table.attemptId, table.workspaceId, table.projectId],
|
|
26006
26081
|
foreignColumns: [
|
|
26007
26082
|
orchestrationImplementationAttempts.id,
|
|
@@ -26014,11 +26089,11 @@ var orchestrationPullRequestReceipts = pgTable83(
|
|
|
26014
26089
|
table.attemptId,
|
|
26015
26090
|
table.generation
|
|
26016
26091
|
),
|
|
26017
|
-
|
|
26092
|
+
index72("orchestration_pull_request_receipts_attempt_generation_idx").on(
|
|
26018
26093
|
table.attemptId,
|
|
26019
26094
|
table.generation
|
|
26020
26095
|
),
|
|
26021
|
-
|
|
26096
|
+
index72("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
|
|
26022
26097
|
check5("orchestration_pull_request_receipts_generation_check", sql21`${table.generation} >= 1`),
|
|
26023
26098
|
check5("orchestration_pull_request_receipts_number_check", sql21`${table.pullRequestNumber} >= 1`),
|
|
26024
26099
|
check5(
|
|
@@ -26047,24 +26122,24 @@ var orchestrationPullRequestReceipts = pgTable83(
|
|
|
26047
26122
|
|
|
26048
26123
|
// src/schema/conversion_proposals.ts
|
|
26049
26124
|
import { sql as sql22 } from "drizzle-orm";
|
|
26050
|
-
import { check as check6, foreignKey as
|
|
26125
|
+
import { check as check6, foreignKey as foreignKey9, index as index73, integer as integer42, jsonb as jsonb47, pgTable as pgTable85, text as text86, timestamp as timestamp78, unique as unique8, uuid as uuid5, varchar as varchar64 } from "drizzle-orm/pg-core";
|
|
26051
26126
|
var CONVERSION_PROPOSAL_STATUSES = ["draft", "approved", "superseded"];
|
|
26052
|
-
var conversionProposals =
|
|
26127
|
+
var conversionProposals = pgTable85(
|
|
26053
26128
|
"conversion_proposals",
|
|
26054
26129
|
{
|
|
26055
26130
|
id: uuid5("id").primaryKey().defaultRandom(),
|
|
26056
|
-
workspaceId:
|
|
26057
|
-
projectId:
|
|
26131
|
+
workspaceId: text86("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26132
|
+
projectId: text86("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26058
26133
|
/** The plan snapshot holding the proposed file contents. */
|
|
26059
|
-
planDigest:
|
|
26134
|
+
planDigest: text86("plan_digest").notNull().references(() => orchestrationPlanSnapshots.planDigest),
|
|
26060
26135
|
/** sha256 of the canonical brief — what the CMS held when this was proposed. */
|
|
26061
|
-
briefDigest:
|
|
26136
|
+
briefDigest: text86("brief_digest").notNull(),
|
|
26062
26137
|
baseHeadOid: varchar64("base_head_oid", { length: 64 }).notNull(),
|
|
26063
|
-
baseBranch:
|
|
26138
|
+
baseBranch: text86("base_branch").notNull(),
|
|
26064
26139
|
/** Brief paths whose `original` was not found in any source file. */
|
|
26065
|
-
unlocated:
|
|
26140
|
+
unlocated: jsonb47("unlocated").notNull().default(sql22`'[]'::jsonb`),
|
|
26066
26141
|
/** Files that matched a brief original but fell outside the acquisition caps. */
|
|
26067
|
-
omittedByCap:
|
|
26142
|
+
omittedByCap: jsonb47("omitted_by_cap").notNull().default(sql22`'[]'::jsonb`),
|
|
26068
26143
|
/**
|
|
26069
26144
|
* The codemod's receipt (migration 0296) — every path it bound, and every one it could not.
|
|
26070
26145
|
*
|
|
@@ -26072,27 +26147,27 @@ var conversionProposals = pgTable84(
|
|
|
26072
26147
|
* pending list for those, which is exactly the silent "nothing left to do" this lane refuses.
|
|
26073
26148
|
* Informative: `proposeConversion` re-derives every claim it acts on from the proposed files.
|
|
26074
26149
|
*/
|
|
26075
|
-
receipt:
|
|
26076
|
-
status:
|
|
26077
|
-
version:
|
|
26078
|
-
idempotencyKey:
|
|
26150
|
+
receipt: jsonb47("receipt"),
|
|
26151
|
+
status: text86("status").notNull().default("draft"),
|
|
26152
|
+
version: integer42("version").notNull().default(1),
|
|
26153
|
+
idempotencyKey: text86("idempotency_key").notNull(),
|
|
26079
26154
|
/**
|
|
26080
26155
|
* The key of the transition that put this row in its CURRENT terminal state — the approve, or
|
|
26081
26156
|
* the manual supersede. Separate from `idempotencyKey`, which belongs to the create: a client
|
|
26082
26157
|
* retrying one act must never be answered with the result of another.
|
|
26083
26158
|
*/
|
|
26084
|
-
transitionIdempotencyKey:
|
|
26085
|
-
createdBy:
|
|
26086
|
-
createdAt:
|
|
26087
|
-
approvedBy:
|
|
26088
|
-
approvedAt:
|
|
26089
|
-
supersededAt:
|
|
26090
|
-
supersededReason:
|
|
26159
|
+
transitionIdempotencyKey: text86("transition_idempotency_key"),
|
|
26160
|
+
createdBy: text86("created_by").notNull(),
|
|
26161
|
+
createdAt: timestamp78("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
26162
|
+
approvedBy: text86("approved_by"),
|
|
26163
|
+
approvedAt: timestamp78("approved_at", { withTimezone: true }),
|
|
26164
|
+
supersededAt: timestamp78("superseded_at", { withTimezone: true }),
|
|
26165
|
+
supersededReason: text86("superseded_reason")
|
|
26091
26166
|
},
|
|
26092
26167
|
(table) => [
|
|
26093
|
-
|
|
26168
|
+
index73("conversion_proposals_project_idx").on(table.workspaceId, table.projectId, table.createdAt),
|
|
26094
26169
|
unique8("conversion_proposals_idempotency_unique").on(table.projectId, table.idempotencyKey),
|
|
26095
|
-
|
|
26170
|
+
foreignKey9({
|
|
26096
26171
|
columns: [table.projectId, table.workspaceId],
|
|
26097
26172
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26098
26173
|
name: "conversion_proposals_project_workspace_fkey"
|
|
@@ -26108,30 +26183,30 @@ var conversionProposals = pgTable84(
|
|
|
26108
26183
|
|
|
26109
26184
|
// src/schema/conversion_briefs_issued.ts
|
|
26110
26185
|
import { sql as sql23 } from "drizzle-orm";
|
|
26111
|
-
import { check as check7, foreignKey as
|
|
26112
|
-
var conversionBriefsIssued =
|
|
26186
|
+
import { check as check7, foreignKey as foreignKey10, index as index74, jsonb as jsonb48, pgTable as pgTable86, text as text87, timestamp as timestamp79, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
|
|
26187
|
+
var conversionBriefsIssued = pgTable86(
|
|
26113
26188
|
"conversion_briefs_issued",
|
|
26114
26189
|
{
|
|
26115
26190
|
id: uuid6("id").primaryKey().defaultRandom(),
|
|
26116
|
-
workspaceId:
|
|
26117
|
-
projectId:
|
|
26191
|
+
workspaceId: text87("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26192
|
+
projectId: text87("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26118
26193
|
/** sha256 of the canonical brief — `briefDigest`, computed identically by the codemod. */
|
|
26119
|
-
briefDigest:
|
|
26194
|
+
briefDigest: text87("brief_digest").notNull(),
|
|
26120
26195
|
/** `[{ route, scope, path, kind, locator? }]` — every bindable path the brief listed. */
|
|
26121
|
-
paths:
|
|
26196
|
+
paths: jsonb48("paths").notNull().default(sql23`'[]'::jsonb`),
|
|
26122
26197
|
/**
|
|
26123
26198
|
* The codemod's account of the run against THIS digest (`submit_conversion_receipt`): which
|
|
26124
26199
|
* paths it rewrote, which it could not, and why. Null until one is submitted — a hand
|
|
26125
26200
|
* conversion never submits one and still counts toward coverage.
|
|
26126
26201
|
*/
|
|
26127
|
-
receipt:
|
|
26202
|
+
receipt: jsonb48("receipt"),
|
|
26128
26203
|
/** The LAST time this pin was issued. What a retention sweep keys on. */
|
|
26129
|
-
issuedAt:
|
|
26204
|
+
issuedAt: timestamp79("issued_at", { withTimezone: true }).notNull().defaultNow()
|
|
26130
26205
|
},
|
|
26131
26206
|
(table) => [
|
|
26132
|
-
|
|
26207
|
+
index74("conversion_briefs_issued_project_issued_idx").on(table.projectId, table.issuedAt),
|
|
26133
26208
|
unique9("conversion_briefs_issued_digest_unique").on(table.projectId, table.briefDigest),
|
|
26134
|
-
|
|
26209
|
+
foreignKey10({
|
|
26135
26210
|
columns: [table.projectId, table.workspaceId],
|
|
26136
26211
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26137
26212
|
name: "conversion_briefs_issued_project_workspace_fkey"
|
|
@@ -26146,13 +26221,13 @@ import { sql as sql24 } from "drizzle-orm";
|
|
|
26146
26221
|
import {
|
|
26147
26222
|
bigint as bigint6,
|
|
26148
26223
|
check as check8,
|
|
26149
|
-
foreignKey as
|
|
26150
|
-
index as
|
|
26151
|
-
integer as
|
|
26152
|
-
jsonb as
|
|
26153
|
-
pgTable as
|
|
26154
|
-
text as
|
|
26155
|
-
timestamp as
|
|
26224
|
+
foreignKey as foreignKey11,
|
|
26225
|
+
index as index75,
|
|
26226
|
+
integer as integer43,
|
|
26227
|
+
jsonb as jsonb49,
|
|
26228
|
+
pgTable as pgTable87,
|
|
26229
|
+
text as text88,
|
|
26230
|
+
timestamp as timestamp80,
|
|
26156
26231
|
unique as unique10,
|
|
26157
26232
|
uniqueIndex as uniqueIndex38,
|
|
26158
26233
|
uuid as uuid7,
|
|
@@ -26169,24 +26244,24 @@ var VALIDATION_ENVELOPE_STATUSES = [
|
|
|
26169
26244
|
"cancelled"
|
|
26170
26245
|
];
|
|
26171
26246
|
var VALIDATION_LIVE_STATUSES = ["queued", "dispatched", "action_required"];
|
|
26172
|
-
var orchestrationValidationEnvelopes =
|
|
26247
|
+
var orchestrationValidationEnvelopes = pgTable87(
|
|
26173
26248
|
"orchestration_validation_envelopes",
|
|
26174
26249
|
{
|
|
26175
26250
|
id: uuid7("id").primaryKey().defaultRandom(),
|
|
26176
|
-
workspaceId:
|
|
26177
|
-
projectId:
|
|
26251
|
+
workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26252
|
+
projectId: text88("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26178
26253
|
runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
26179
26254
|
attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
26180
26255
|
/** Null until a receipt writer exists (Phase 6). The head below is pinned regardless. */
|
|
26181
26256
|
receiptId: uuid7("receipt_id").references(() => orchestrationPullRequestReceipts.id, {
|
|
26182
26257
|
onDelete: "set null"
|
|
26183
26258
|
}),
|
|
26184
|
-
receiptGeneration:
|
|
26259
|
+
receiptGeneration: integer43("receipt_generation").notNull().default(1),
|
|
26185
26260
|
// The pinned tuple. Every field here is compared against returned evidence, and each mismatch
|
|
26186
26261
|
// has its own error code — "wrong repository" and "wrong head" are different recoveries.
|
|
26187
26262
|
repositoryId: bigint6("repository_id", { mode: "number" }).notNull(),
|
|
26188
26263
|
pullRequestId: bigint6("pull_request_id", { mode: "number" }).notNull(),
|
|
26189
|
-
pullRequestNumber:
|
|
26264
|
+
pullRequestNumber: integer43("pull_request_number").notNull(),
|
|
26190
26265
|
/** The exact commit this validation is about. A validation proves nothing about any other. */
|
|
26191
26266
|
headSha: varchar65("head_sha", { length: 64 }).notNull(),
|
|
26192
26267
|
baseSha: varchar65("base_sha", { length: 64 }).notNull(),
|
|
@@ -26195,25 +26270,25 @@ var orchestrationValidationEnvelopes = pgTable86(
|
|
|
26195
26270
|
brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
|
|
26196
26271
|
baselineDigest: varchar65("baseline_digest", { length: 71 }).notNull(),
|
|
26197
26272
|
toolchainHash: varchar65("toolchain_hash", { length: 64 }).notNull(),
|
|
26198
|
-
validatorVersion:
|
|
26273
|
+
validatorVersion: text88("validator_version").notNull(),
|
|
26199
26274
|
workflowSha256: varchar65("workflow_sha256", { length: 64 }).notNull(),
|
|
26200
26275
|
/** Digest only. The single-use credential itself is handed to the validator and never stored. */
|
|
26201
26276
|
nonceHash: varchar65("nonce_hash", { length: 64 }).notNull(),
|
|
26202
|
-
nonceExpiresAt:
|
|
26203
|
-
nonceConsumedAt:
|
|
26277
|
+
nonceExpiresAt: timestamp80("nonce_expires_at", { withTimezone: true }).notNull(),
|
|
26278
|
+
nonceConsumedAt: timestamp80("nonce_consumed_at", { withTimezone: true }),
|
|
26204
26279
|
status: varchar65("status", { length: 20 }).notNull().default("queued"),
|
|
26205
|
-
errorCode:
|
|
26206
|
-
errorMessage:
|
|
26280
|
+
errorCode: text88("error_code"),
|
|
26281
|
+
errorMessage: text88("error_message"),
|
|
26207
26282
|
/** Composite-FK'd to (evidence.id, evidence.envelope_id) in 0273, so an envelope cannot be
|
|
26208
26283
|
* marked passed while pointing at a DIFFERENT envelope's evidence. */
|
|
26209
26284
|
evidenceId: uuid7("evidence_id"),
|
|
26210
26285
|
/** Written on pass, read by nothing. The unlock that consumes it is a later phase. */
|
|
26211
26286
|
attestationDigest: varchar65("attestation_digest", { length: 71 }),
|
|
26212
|
-
dispatchedAt:
|
|
26287
|
+
dispatchedAt: timestamp80("dispatched_at", { withTimezone: true }),
|
|
26213
26288
|
/** A retry is a NEW row with a NEW nonce, linked back — never a status reset on this one. */
|
|
26214
26289
|
retryOf: uuid7("retry_of"),
|
|
26215
|
-
createdAt:
|
|
26216
|
-
updatedAt:
|
|
26290
|
+
createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
26291
|
+
updatedAt: timestamp80("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
26217
26292
|
},
|
|
26218
26293
|
(table) => [
|
|
26219
26294
|
unique10("orchestration_validation_envelopes_scope_unique").on(
|
|
@@ -26221,7 +26296,7 @@ var orchestrationValidationEnvelopes = pgTable86(
|
|
|
26221
26296
|
table.workspaceId,
|
|
26222
26297
|
table.projectId
|
|
26223
26298
|
),
|
|
26224
|
-
|
|
26299
|
+
foreignKey11({
|
|
26225
26300
|
columns: [table.attemptId, table.workspaceId, table.projectId],
|
|
26226
26301
|
foreignColumns: [
|
|
26227
26302
|
orchestrationImplementationAttempts.id,
|
|
@@ -26230,7 +26305,7 @@ var orchestrationValidationEnvelopes = pgTable86(
|
|
|
26230
26305
|
],
|
|
26231
26306
|
name: "orchestration_validation_envelopes_attempt_scope_fkey"
|
|
26232
26307
|
}).onDelete("cascade"),
|
|
26233
|
-
|
|
26308
|
+
foreignKey11({
|
|
26234
26309
|
columns: [table.retryOf],
|
|
26235
26310
|
foreignColumns: [table.id],
|
|
26236
26311
|
name: "orchestration_validation_envelopes_retry_of_fkey"
|
|
@@ -26238,11 +26313,11 @@ var orchestrationValidationEnvelopes = pgTable86(
|
|
|
26238
26313
|
// One live envelope per (attempt, head): two validators can never both be authoritative for
|
|
26239
26314
|
// the same commit. The index arbitrates, so no read-then-write can lose the race.
|
|
26240
26315
|
uniqueIndex38("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql24`status IN ('queued', 'dispatched', 'action_required')`),
|
|
26241
|
-
|
|
26316
|
+
index75("orchestration_validation_envelopes_attempt_idx").on(
|
|
26242
26317
|
table.attemptId,
|
|
26243
26318
|
table.createdAt.desc()
|
|
26244
26319
|
),
|
|
26245
|
-
|
|
26320
|
+
index75("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql24`status IN ('queued', 'dispatched')`),
|
|
26246
26321
|
check8(
|
|
26247
26322
|
"orchestration_validation_envelopes_status_check",
|
|
26248
26323
|
sql24`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
|
|
@@ -26258,28 +26333,28 @@ var orchestrationValidationEnvelopes = pgTable86(
|
|
|
26258
26333
|
)
|
|
26259
26334
|
]
|
|
26260
26335
|
);
|
|
26261
|
-
var orchestrationValidationEvidence =
|
|
26336
|
+
var orchestrationValidationEvidence = pgTable87(
|
|
26262
26337
|
"orchestration_validation_evidence",
|
|
26263
26338
|
{
|
|
26264
26339
|
id: uuid7("id").primaryKey().defaultRandom(),
|
|
26265
|
-
workspaceId:
|
|
26266
|
-
projectId:
|
|
26340
|
+
workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26341
|
+
projectId: text88("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26267
26342
|
runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
26268
26343
|
attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
26269
26344
|
envelopeId: uuid7("envelope_id").notNull().references(() => orchestrationValidationEnvelopes.id, { onDelete: "cascade" }),
|
|
26270
26345
|
headSha: varchar65("head_sha", { length: 64 }).notNull(),
|
|
26271
26346
|
evidenceDigest: varchar65("evidence_digest", { length: 71 }).notNull(),
|
|
26272
26347
|
artifactDigest: varchar65("artifact_digest", { length: 71 }).notNull(),
|
|
26273
|
-
validatorVersion:
|
|
26348
|
+
validatorVersion: text88("validator_version").notNull(),
|
|
26274
26349
|
/** The BrandKit contract this evidence is filed under. 0273 ties it to
|
|
26275
26350
|
* `checks->brandKit->contractHash`, so a payload cannot claim a different one. Comparing it
|
|
26276
26351
|
* against the ENVELOPE's hash is an ingest check — a CHECK cannot reach another table. */
|
|
26277
26352
|
brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
|
|
26278
26353
|
status: varchar65("status", { length: 10 }).notNull(),
|
|
26279
26354
|
/** brandKit / runtime / visual. The shape is enforced by CHECK in 0273, not by the writer. */
|
|
26280
|
-
checks:
|
|
26281
|
-
createdBy:
|
|
26282
|
-
createdAt:
|
|
26355
|
+
checks: jsonb49("checks").notNull(),
|
|
26356
|
+
createdBy: text88("created_by"),
|
|
26357
|
+
createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
26283
26358
|
},
|
|
26284
26359
|
(table) => [
|
|
26285
26360
|
unique10("orchestration_validation_evidence_scope_unique").on(
|
|
@@ -26287,7 +26362,7 @@ var orchestrationValidationEvidence = pgTable86(
|
|
|
26287
26362
|
table.workspaceId,
|
|
26288
26363
|
table.projectId
|
|
26289
26364
|
),
|
|
26290
|
-
|
|
26365
|
+
foreignKey11({
|
|
26291
26366
|
columns: [table.envelopeId, table.workspaceId, table.projectId],
|
|
26292
26367
|
foreignColumns: [
|
|
26293
26368
|
orchestrationValidationEnvelopes.id,
|
|
@@ -26306,7 +26381,7 @@ var orchestrationValidationEvidence = pgTable86(
|
|
|
26306
26381
|
table.attemptId,
|
|
26307
26382
|
table.evidenceDigest
|
|
26308
26383
|
),
|
|
26309
|
-
|
|
26384
|
+
index75("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
|
|
26310
26385
|
check8(
|
|
26311
26386
|
"orchestration_validation_evidence_status_check",
|
|
26312
26387
|
sql24`${table.status} IN ('passed', 'failed')`
|
|
@@ -26316,27 +26391,27 @@ var orchestrationValidationEvidence = pgTable86(
|
|
|
26316
26391
|
|
|
26317
26392
|
// src/schema/orchestration_executor_grants.ts
|
|
26318
26393
|
import { sql as sql25 } from "drizzle-orm";
|
|
26319
|
-
import { check as check9, foreignKey as
|
|
26394
|
+
import { check as check9, foreignKey as foreignKey12, index as index76, integer as integer44, pgTable as pgTable88, text as text89, timestamp as timestamp81, unique as unique11, uniqueIndex as uniqueIndex39, uuid as uuid8, varchar as varchar66 } from "drizzle-orm/pg-core";
|
|
26320
26395
|
var EXECUTOR_GRANT_STATUSES = ["active", "revoked", "expired"];
|
|
26321
|
-
var orchestrationExecutorGrants =
|
|
26396
|
+
var orchestrationExecutorGrants = pgTable88(
|
|
26322
26397
|
"orchestration_executor_grants",
|
|
26323
26398
|
{
|
|
26324
|
-
id:
|
|
26325
|
-
workspaceId:
|
|
26326
|
-
projectId:
|
|
26399
|
+
id: text89("id").primaryKey().default(sql25`gen_random_uuid()`),
|
|
26400
|
+
workspaceId: text89("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26401
|
+
projectId: text89("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26327
26402
|
installationId: uuid8("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
26328
26403
|
/** Digest only. The credential is returned once at mint and never stored. */
|
|
26329
26404
|
credentialHash: varchar66("credential_hash", { length: 64 }).notNull(),
|
|
26330
|
-
credentialAudience:
|
|
26331
|
-
credentialExpiresAt:
|
|
26405
|
+
credentialAudience: text89("credential_audience").notNull(),
|
|
26406
|
+
credentialExpiresAt: timestamp81("credential_expires_at", { withTimezone: true }).notNull(),
|
|
26332
26407
|
/** The epoch this credential is valid for. A fenced session's credential dies before it expires. */
|
|
26333
|
-
sessionEpoch:
|
|
26408
|
+
sessionEpoch: integer44("session_epoch").notNull(),
|
|
26334
26409
|
status: varchar66("status", { length: 16 }).notNull().default("active"),
|
|
26335
|
-
revokedAt:
|
|
26336
|
-
revokedBy:
|
|
26337
|
-
createdBy:
|
|
26338
|
-
createdAt:
|
|
26339
|
-
updatedAt:
|
|
26410
|
+
revokedAt: timestamp81("revoked_at", { withTimezone: true }),
|
|
26411
|
+
revokedBy: text89("revoked_by"),
|
|
26412
|
+
createdBy: text89("created_by"),
|
|
26413
|
+
createdAt: timestamp81("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
26414
|
+
updatedAt: timestamp81("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
26340
26415
|
},
|
|
26341
26416
|
(table) => [
|
|
26342
26417
|
unique11("orchestration_executor_grants_scope_unique").on(
|
|
@@ -26344,7 +26419,7 @@ var orchestrationExecutorGrants = pgTable87(
|
|
|
26344
26419
|
table.workspaceId,
|
|
26345
26420
|
table.projectId
|
|
26346
26421
|
),
|
|
26347
|
-
|
|
26422
|
+
foreignKey12({
|
|
26348
26423
|
columns: [table.installationId, table.workspaceId, table.projectId],
|
|
26349
26424
|
foreignColumns: [
|
|
26350
26425
|
orchestrationExecutorInstallations.id,
|
|
@@ -26356,7 +26431,7 @@ var orchestrationExecutorGrants = pgTable87(
|
|
|
26356
26431
|
// One live credential per installation. Two would mean two processes can each present a valid
|
|
26357
26432
|
// one, and the exclusion argument collapses before the lease layer is reached.
|
|
26358
26433
|
uniqueIndex39("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql25`status = 'active'`),
|
|
26359
|
-
|
|
26434
|
+
index76("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql25`status = 'active'`),
|
|
26360
26435
|
check9(
|
|
26361
26436
|
"orchestration_executor_grants_status_check",
|
|
26362
26437
|
sql25`${table.status} IN ('active', 'revoked', 'expired')`
|
|
@@ -26369,27 +26444,27 @@ var orchestrationExecutorGrants = pgTable87(
|
|
|
26369
26444
|
);
|
|
26370
26445
|
|
|
26371
26446
|
// src/schema/component_presets.ts
|
|
26372
|
-
import { pgTable as
|
|
26447
|
+
import { pgTable as pgTable89, text as text90, varchar as varchar67, timestamp as timestamp82, jsonb as jsonb50, integer as integer45, index as index77, uniqueIndex as uniqueIndex40 } from "drizzle-orm/pg-core";
|
|
26373
26448
|
import { relations as relations16 } from "drizzle-orm";
|
|
26374
|
-
var componentPresets =
|
|
26449
|
+
var componentPresets = pgTable89(
|
|
26375
26450
|
"component_presets",
|
|
26376
26451
|
{
|
|
26377
|
-
id:
|
|
26378
|
-
workspaceId:
|
|
26379
|
-
componentId:
|
|
26452
|
+
id: text90("id").primaryKey(),
|
|
26453
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26454
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
26380
26455
|
name: varchar67("name", { length: 255 }).notNull(),
|
|
26381
26456
|
/** ^[a-z0-9-]+$, unique per component — stable across renames. */
|
|
26382
26457
|
slug: varchar67("slug", { length: 255 }).notNull(),
|
|
26383
26458
|
/** Prop key → value. Validated against the component's `props` on every write. */
|
|
26384
|
-
values:
|
|
26385
|
-
position:
|
|
26386
|
-
createdAt:
|
|
26387
|
-
updatedAt:
|
|
26388
|
-
createdBy:
|
|
26389
|
-
updatedBy:
|
|
26459
|
+
values: jsonb50("values").$type().notNull().default({}),
|
|
26460
|
+
position: integer45("position").notNull().default(0),
|
|
26461
|
+
createdAt: timestamp82("created_at").notNull().defaultNow(),
|
|
26462
|
+
updatedAt: timestamp82("updated_at").notNull().defaultNow(),
|
|
26463
|
+
createdBy: text90("created_by"),
|
|
26464
|
+
updatedBy: text90("updated_by")
|
|
26390
26465
|
},
|
|
26391
26466
|
(t) => [
|
|
26392
|
-
|
|
26467
|
+
index77("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
|
|
26393
26468
|
uniqueIndex40("component_presets_component_slug_key").on(t.componentId, t.slug)
|
|
26394
26469
|
]
|
|
26395
26470
|
);
|
|
@@ -26402,13 +26477,13 @@ var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
|
|
|
26402
26477
|
|
|
26403
26478
|
// src/schema/section_zones.ts
|
|
26404
26479
|
import {
|
|
26405
|
-
foreignKey as
|
|
26406
|
-
index as
|
|
26407
|
-
integer as
|
|
26408
|
-
jsonb as
|
|
26409
|
-
pgTable as
|
|
26410
|
-
text as
|
|
26411
|
-
timestamp as
|
|
26480
|
+
foreignKey as foreignKey13,
|
|
26481
|
+
index as index78,
|
|
26482
|
+
integer as integer46,
|
|
26483
|
+
jsonb as jsonb51,
|
|
26484
|
+
pgTable as pgTable90,
|
|
26485
|
+
text as text91,
|
|
26486
|
+
timestamp as timestamp83,
|
|
26412
26487
|
unique as unique12,
|
|
26413
26488
|
uniqueIndex as uniqueIndex41,
|
|
26414
26489
|
varchar as varchar68
|
|
@@ -26422,50 +26497,50 @@ var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
|
|
|
26422
26497
|
"passed",
|
|
26423
26498
|
"failed"
|
|
26424
26499
|
];
|
|
26425
|
-
var sectionDefinitions =
|
|
26500
|
+
var sectionDefinitions = pgTable90(
|
|
26426
26501
|
"section_definitions",
|
|
26427
26502
|
{
|
|
26428
|
-
id:
|
|
26429
|
-
workspaceId:
|
|
26430
|
-
projectId:
|
|
26503
|
+
id: text91("id").primaryKey(),
|
|
26504
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26505
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26431
26506
|
apiId: varchar68("api_id", { length: 100 }).notNull(),
|
|
26432
|
-
firstPublishedAt:
|
|
26433
|
-
archivedAt:
|
|
26507
|
+
firstPublishedAt: timestamp83("first_published_at"),
|
|
26508
|
+
archivedAt: timestamp83("archived_at"),
|
|
26434
26509
|
...auditColumns
|
|
26435
26510
|
},
|
|
26436
26511
|
(table) => [
|
|
26437
|
-
|
|
26512
|
+
foreignKey13({
|
|
26438
26513
|
columns: [table.projectId, table.workspaceId],
|
|
26439
26514
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26440
26515
|
name: "section_definitions_project_workspace_fkey"
|
|
26441
26516
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26442
26517
|
unique12("section_definitions_id_project_unique").on(table.id, table.projectId),
|
|
26443
26518
|
uniqueIndex41("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
|
|
26444
|
-
|
|
26445
|
-
|
|
26519
|
+
index78("section_definitions_workspace_idx").on(table.workspaceId),
|
|
26520
|
+
index78("section_definitions_project_idx").on(table.projectId)
|
|
26446
26521
|
]
|
|
26447
26522
|
);
|
|
26448
|
-
var sectionDefinitionVersions =
|
|
26523
|
+
var sectionDefinitionVersions = pgTable90(
|
|
26449
26524
|
"section_definition_versions",
|
|
26450
26525
|
{
|
|
26451
|
-
id:
|
|
26452
|
-
workspaceId:
|
|
26453
|
-
projectId:
|
|
26454
|
-
sectionDefinitionId:
|
|
26455
|
-
version:
|
|
26526
|
+
id: text91("id").primaryKey(),
|
|
26527
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26528
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26529
|
+
sectionDefinitionId: text91("section_definition_id").notNull(),
|
|
26530
|
+
version: integer46("version").notNull(),
|
|
26456
26531
|
label: varchar68("label", { length: 255 }).notNull(),
|
|
26457
|
-
fields:
|
|
26532
|
+
fields: jsonb51("fields").$type().notNull().default([]),
|
|
26458
26533
|
schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
|
|
26459
|
-
createdBy:
|
|
26460
|
-
createdAt:
|
|
26534
|
+
createdBy: text91("created_by"),
|
|
26535
|
+
createdAt: timestamp83("created_at").notNull().defaultNow()
|
|
26461
26536
|
},
|
|
26462
26537
|
(table) => [
|
|
26463
|
-
|
|
26538
|
+
foreignKey13({
|
|
26464
26539
|
columns: [table.projectId, table.workspaceId],
|
|
26465
26540
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26466
26541
|
name: "section_definition_versions_project_workspace_fkey"
|
|
26467
26542
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26468
|
-
|
|
26543
|
+
foreignKey13({
|
|
26469
26544
|
columns: [table.sectionDefinitionId, table.projectId],
|
|
26470
26545
|
foreignColumns: [sectionDefinitions.id, sectionDefinitions.projectId],
|
|
26471
26546
|
name: "section_definition_versions_definition_project_fkey"
|
|
@@ -26476,63 +26551,63 @@ var sectionDefinitionVersions = pgTable89(
|
|
|
26476
26551
|
table.version,
|
|
26477
26552
|
table.projectId
|
|
26478
26553
|
),
|
|
26479
|
-
|
|
26554
|
+
index78("section_definition_versions_project_idx").on(table.projectId)
|
|
26480
26555
|
]
|
|
26481
26556
|
);
|
|
26482
|
-
var sectionZones =
|
|
26557
|
+
var sectionZones = pgTable90(
|
|
26483
26558
|
"section_zones",
|
|
26484
26559
|
{
|
|
26485
|
-
id:
|
|
26486
|
-
workspaceId:
|
|
26487
|
-
projectId:
|
|
26560
|
+
id: text91("id").primaryKey(),
|
|
26561
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26562
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26488
26563
|
schemaKind: varchar68("schema_kind", { length: 20 }).$type().notNull(),
|
|
26489
|
-
schemaId:
|
|
26564
|
+
schemaId: text91("schema_id").notNull(),
|
|
26490
26565
|
fieldKey: varchar68("field_key", { length: 255 }).notNull(),
|
|
26491
|
-
draftRevision:
|
|
26492
|
-
publishedRevision:
|
|
26566
|
+
draftRevision: integer46("draft_revision").notNull().default(1),
|
|
26567
|
+
publishedRevision: integer46("published_revision"),
|
|
26493
26568
|
...auditColumns
|
|
26494
26569
|
},
|
|
26495
26570
|
(table) => [
|
|
26496
|
-
|
|
26571
|
+
foreignKey13({
|
|
26497
26572
|
columns: [table.projectId, table.workspaceId],
|
|
26498
26573
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26499
26574
|
name: "section_zones_project_workspace_fkey"
|
|
26500
26575
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26501
26576
|
unique12("section_zones_id_project_unique").on(table.id, table.projectId),
|
|
26502
26577
|
uniqueIndex41("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
|
|
26503
|
-
|
|
26578
|
+
index78("section_zones_workspace_idx").on(table.workspaceId)
|
|
26504
26579
|
]
|
|
26505
26580
|
);
|
|
26506
|
-
var sectionZoneAttachments =
|
|
26581
|
+
var sectionZoneAttachments = pgTable90(
|
|
26507
26582
|
"section_zone_attachments",
|
|
26508
26583
|
{
|
|
26509
|
-
id:
|
|
26510
|
-
workspaceId:
|
|
26511
|
-
projectId:
|
|
26512
|
-
zoneId:
|
|
26513
|
-
sectionDefinitionId:
|
|
26514
|
-
draftVersion:
|
|
26515
|
-
publishedVersion:
|
|
26516
|
-
position:
|
|
26584
|
+
id: text91("id").primaryKey(),
|
|
26585
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26586
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26587
|
+
zoneId: text91("zone_id").notNull(),
|
|
26588
|
+
sectionDefinitionId: text91("section_definition_id").notNull(),
|
|
26589
|
+
draftVersion: integer46("draft_version").notNull(),
|
|
26590
|
+
publishedVersion: integer46("published_version"),
|
|
26591
|
+
position: integer46("position").notNull().default(0),
|
|
26517
26592
|
...auditColumns
|
|
26518
26593
|
},
|
|
26519
26594
|
(table) => [
|
|
26520
|
-
|
|
26595
|
+
foreignKey13({
|
|
26521
26596
|
columns: [table.projectId, table.workspaceId],
|
|
26522
26597
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26523
26598
|
name: "section_zone_attachments_project_workspace_fkey"
|
|
26524
26599
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26525
|
-
|
|
26600
|
+
foreignKey13({
|
|
26526
26601
|
columns: [table.zoneId, table.projectId],
|
|
26527
26602
|
foreignColumns: [sectionZones.id, sectionZones.projectId],
|
|
26528
26603
|
name: "section_zone_attachments_zone_project_fkey"
|
|
26529
26604
|
}).onDelete("cascade"),
|
|
26530
|
-
|
|
26605
|
+
foreignKey13({
|
|
26531
26606
|
columns: [table.sectionDefinitionId, table.projectId],
|
|
26532
26607
|
foreignColumns: [sectionDefinitions.id, sectionDefinitions.projectId],
|
|
26533
26608
|
name: "section_zone_attachments_definition_project_fkey"
|
|
26534
26609
|
}).onDelete("restrict"),
|
|
26535
|
-
|
|
26610
|
+
foreignKey13({
|
|
26536
26611
|
columns: [table.sectionDefinitionId, table.draftVersion, table.projectId],
|
|
26537
26612
|
foreignColumns: [
|
|
26538
26613
|
sectionDefinitionVersions.sectionDefinitionId,
|
|
@@ -26541,7 +26616,7 @@ var sectionZoneAttachments = pgTable89(
|
|
|
26541
26616
|
],
|
|
26542
26617
|
name: "section_zone_attachments_draft_version_fkey"
|
|
26543
26618
|
}).onDelete("restrict"),
|
|
26544
|
-
|
|
26619
|
+
foreignKey13({
|
|
26545
26620
|
columns: [table.sectionDefinitionId, table.publishedVersion, table.projectId],
|
|
26546
26621
|
foreignColumns: [
|
|
26547
26622
|
sectionDefinitionVersions.sectionDefinitionId,
|
|
@@ -26551,31 +26626,31 @@ var sectionZoneAttachments = pgTable89(
|
|
|
26551
26626
|
name: "section_zone_attachments_published_version_fkey"
|
|
26552
26627
|
}).onDelete("restrict"),
|
|
26553
26628
|
uniqueIndex41("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
|
|
26554
|
-
|
|
26629
|
+
index78("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
|
|
26555
26630
|
]
|
|
26556
26631
|
);
|
|
26557
|
-
var sectionManifests =
|
|
26632
|
+
var sectionManifests = pgTable90(
|
|
26558
26633
|
"section_manifests",
|
|
26559
26634
|
{
|
|
26560
|
-
id:
|
|
26561
|
-
workspaceId:
|
|
26562
|
-
projectId:
|
|
26563
|
-
sectionDefinitionId:
|
|
26564
|
-
sectionVersion:
|
|
26635
|
+
id: text91("id").primaryKey(),
|
|
26636
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26637
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26638
|
+
sectionDefinitionId: text91("section_definition_id").notNull(),
|
|
26639
|
+
sectionVersion: integer46("section_version").notNull(),
|
|
26565
26640
|
apiId: varchar68("api_id", { length: 100 }).notNull(),
|
|
26566
26641
|
schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
|
|
26567
26642
|
commitSha: varchar68("commit_sha", { length: 64 }).notNull(),
|
|
26568
|
-
manifest:
|
|
26569
|
-
createdBy:
|
|
26570
|
-
createdAt:
|
|
26643
|
+
manifest: jsonb51("manifest").$type().notNull(),
|
|
26644
|
+
createdBy: text91("created_by"),
|
|
26645
|
+
createdAt: timestamp83("created_at").notNull().defaultNow()
|
|
26571
26646
|
},
|
|
26572
26647
|
(table) => [
|
|
26573
|
-
|
|
26648
|
+
foreignKey13({
|
|
26574
26649
|
columns: [table.projectId, table.workspaceId],
|
|
26575
26650
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26576
26651
|
name: "section_manifests_project_workspace_fkey"
|
|
26577
26652
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26578
|
-
|
|
26653
|
+
foreignKey13({
|
|
26579
26654
|
columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
|
|
26580
26655
|
foreignColumns: [
|
|
26581
26656
|
sectionDefinitionVersions.sectionDefinitionId,
|
|
@@ -26585,34 +26660,34 @@ var sectionManifests = pgTable89(
|
|
|
26585
26660
|
name: "section_manifests_definition_version_project_fkey"
|
|
26586
26661
|
}).onDelete("cascade"),
|
|
26587
26662
|
unique12("section_manifests_id_project_unique").on(table.id, table.projectId),
|
|
26588
|
-
|
|
26663
|
+
index78("section_manifests_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
26589
26664
|
]
|
|
26590
26665
|
);
|
|
26591
|
-
var sectionValidationRuns =
|
|
26666
|
+
var sectionValidationRuns = pgTable90(
|
|
26592
26667
|
"section_validation_runs",
|
|
26593
26668
|
{
|
|
26594
|
-
id:
|
|
26595
|
-
workspaceId:
|
|
26596
|
-
projectId:
|
|
26597
|
-
sectionDefinitionId:
|
|
26598
|
-
sectionVersion:
|
|
26599
|
-
manifestId:
|
|
26669
|
+
id: text91("id").primaryKey(),
|
|
26670
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26671
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26672
|
+
sectionDefinitionId: text91("section_definition_id").notNull(),
|
|
26673
|
+
sectionVersion: integer46("section_version").notNull(),
|
|
26674
|
+
manifestId: text91("manifest_id").notNull(),
|
|
26600
26675
|
status: varchar68("status", { length: 20 }).$type().notNull(),
|
|
26601
26676
|
schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
|
|
26602
26677
|
commitSha: varchar68("commit_sha", { length: 64 }).notNull(),
|
|
26603
26678
|
fixtureHash: varchar68("fixture_hash", { length: 64 }).notNull(),
|
|
26604
26679
|
evidenceDigest: varchar68("evidence_digest", { length: 128 }).notNull(),
|
|
26605
|
-
results:
|
|
26606
|
-
createdBy:
|
|
26607
|
-
createdAt:
|
|
26680
|
+
results: jsonb51("results").$type().notNull(),
|
|
26681
|
+
createdBy: text91("created_by"),
|
|
26682
|
+
createdAt: timestamp83("created_at").notNull().defaultNow()
|
|
26608
26683
|
},
|
|
26609
26684
|
(table) => [
|
|
26610
|
-
|
|
26685
|
+
foreignKey13({
|
|
26611
26686
|
columns: [table.projectId, table.workspaceId],
|
|
26612
26687
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26613
26688
|
name: "section_validation_runs_project_workspace_fkey"
|
|
26614
26689
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26615
|
-
|
|
26690
|
+
foreignKey13({
|
|
26616
26691
|
columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
|
|
26617
26692
|
foreignColumns: [
|
|
26618
26693
|
sectionDefinitionVersions.sectionDefinitionId,
|
|
@@ -26621,39 +26696,39 @@ var sectionValidationRuns = pgTable89(
|
|
|
26621
26696
|
],
|
|
26622
26697
|
name: "section_validation_runs_definition_version_project_fkey"
|
|
26623
26698
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26624
|
-
|
|
26699
|
+
foreignKey13({
|
|
26625
26700
|
columns: [table.manifestId, table.projectId],
|
|
26626
26701
|
foreignColumns: [sectionManifests.id, sectionManifests.projectId],
|
|
26627
26702
|
name: "section_validation_runs_manifest_project_fkey"
|
|
26628
26703
|
}).onDelete("restrict"),
|
|
26629
26704
|
unique12("section_validation_runs_id_project_unique").on(table.id, table.projectId),
|
|
26630
|
-
|
|
26705
|
+
index78("section_validation_runs_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
26631
26706
|
]
|
|
26632
26707
|
);
|
|
26633
|
-
var sectionVisualApprovals =
|
|
26708
|
+
var sectionVisualApprovals = pgTable90(
|
|
26634
26709
|
"section_visual_approvals",
|
|
26635
26710
|
{
|
|
26636
|
-
id:
|
|
26637
|
-
workspaceId:
|
|
26638
|
-
projectId:
|
|
26639
|
-
sectionDefinitionId:
|
|
26640
|
-
sectionVersion:
|
|
26641
|
-
manifestId:
|
|
26642
|
-
validationRunId:
|
|
26711
|
+
id: text91("id").primaryKey(),
|
|
26712
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26713
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26714
|
+
sectionDefinitionId: text91("section_definition_id").notNull(),
|
|
26715
|
+
sectionVersion: integer46("section_version").notNull(),
|
|
26716
|
+
manifestId: text91("manifest_id").notNull(),
|
|
26717
|
+
validationRunId: text91("validation_run_id").notNull(),
|
|
26643
26718
|
schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
|
|
26644
26719
|
commitSha: varchar68("commit_sha", { length: 64 }).notNull(),
|
|
26645
26720
|
fixtureHash: varchar68("fixture_hash", { length: 64 }).notNull(),
|
|
26646
26721
|
evidenceDigest: varchar68("evidence_digest", { length: 128 }).notNull(),
|
|
26647
|
-
approvedBy:
|
|
26648
|
-
createdAt:
|
|
26722
|
+
approvedBy: text91("approved_by").notNull(),
|
|
26723
|
+
createdAt: timestamp83("created_at").notNull().defaultNow()
|
|
26649
26724
|
},
|
|
26650
26725
|
(table) => [
|
|
26651
|
-
|
|
26726
|
+
foreignKey13({
|
|
26652
26727
|
columns: [table.projectId, table.workspaceId],
|
|
26653
26728
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26654
26729
|
name: "section_visual_approvals_project_workspace_fkey"
|
|
26655
26730
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26656
|
-
|
|
26731
|
+
foreignKey13({
|
|
26657
26732
|
columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
|
|
26658
26733
|
foreignColumns: [
|
|
26659
26734
|
sectionDefinitionVersions.sectionDefinitionId,
|
|
@@ -26662,54 +26737,54 @@ var sectionVisualApprovals = pgTable89(
|
|
|
26662
26737
|
],
|
|
26663
26738
|
name: "section_visual_approvals_definition_version_project_fkey"
|
|
26664
26739
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26665
|
-
|
|
26740
|
+
foreignKey13({
|
|
26666
26741
|
columns: [table.manifestId, table.projectId],
|
|
26667
26742
|
foreignColumns: [sectionManifests.id, sectionManifests.projectId],
|
|
26668
26743
|
name: "section_visual_approvals_manifest_project_fkey"
|
|
26669
26744
|
}).onDelete("restrict"),
|
|
26670
|
-
|
|
26745
|
+
foreignKey13({
|
|
26671
26746
|
columns: [table.validationRunId, table.projectId],
|
|
26672
26747
|
foreignColumns: [sectionValidationRuns.id, sectionValidationRuns.projectId],
|
|
26673
26748
|
name: "section_visual_approvals_validation_project_fkey"
|
|
26674
26749
|
}).onDelete("restrict"),
|
|
26675
|
-
|
|
26750
|
+
index78("section_visual_approvals_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
26676
26751
|
]
|
|
26677
26752
|
);
|
|
26678
|
-
var sectionImplementationRequests =
|
|
26753
|
+
var sectionImplementationRequests = pgTable90(
|
|
26679
26754
|
"section_implementation_requests",
|
|
26680
26755
|
{
|
|
26681
|
-
id:
|
|
26682
|
-
workspaceId:
|
|
26683
|
-
projectId:
|
|
26684
|
-
sectionDefinitionId:
|
|
26685
|
-
sectionVersion:
|
|
26756
|
+
id: text91("id").primaryKey(),
|
|
26757
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26758
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26759
|
+
sectionDefinitionId: text91("section_definition_id").notNull(),
|
|
26760
|
+
sectionVersion: integer46("section_version").notNull(),
|
|
26686
26761
|
provider: varchar68("provider", { length: 20 }).$type().notNull(),
|
|
26687
26762
|
status: varchar68("status", { length: 20 }).$type().notNull().default("queued"),
|
|
26688
26763
|
schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
|
|
26689
26764
|
targetCommitSha: varchar68("target_commit_sha", { length: 64 }),
|
|
26690
26765
|
providerRunId: varchar68("provider_run_id", { length: 255 }),
|
|
26691
|
-
providerRunUrl:
|
|
26692
|
-
manifestId:
|
|
26693
|
-
validationRunId:
|
|
26766
|
+
providerRunUrl: text91("provider_run_url"),
|
|
26767
|
+
manifestId: text91("manifest_id"),
|
|
26768
|
+
validationRunId: text91("validation_run_id"),
|
|
26694
26769
|
/** SHA-256 of the request-scoped GitHub callback bearer. The plaintext is never persisted. */
|
|
26695
26770
|
callbackTokenHash: varchar68("callback_token_hash", { length: 64 }),
|
|
26696
|
-
requestedBy:
|
|
26697
|
-
claimedBy:
|
|
26771
|
+
requestedBy: text91("requested_by").notNull(),
|
|
26772
|
+
claimedBy: text91("claimed_by"),
|
|
26698
26773
|
errorCode: varchar68("error_code", { length: 100 }),
|
|
26699
|
-
errorMessage:
|
|
26700
|
-
dispatchedAt:
|
|
26701
|
-
startedAt:
|
|
26702
|
-
completedAt:
|
|
26703
|
-
createdAt:
|
|
26704
|
-
updatedAt:
|
|
26774
|
+
errorMessage: text91("error_message"),
|
|
26775
|
+
dispatchedAt: timestamp83("dispatched_at"),
|
|
26776
|
+
startedAt: timestamp83("started_at"),
|
|
26777
|
+
completedAt: timestamp83("completed_at"),
|
|
26778
|
+
createdAt: timestamp83("created_at").notNull().defaultNow(),
|
|
26779
|
+
updatedAt: timestamp83("updated_at").notNull().defaultNow()
|
|
26705
26780
|
},
|
|
26706
26781
|
(table) => [
|
|
26707
|
-
|
|
26782
|
+
foreignKey13({
|
|
26708
26783
|
columns: [table.projectId, table.workspaceId],
|
|
26709
26784
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26710
26785
|
name: "section_implementation_requests_project_workspace_fkey"
|
|
26711
26786
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26712
|
-
|
|
26787
|
+
foreignKey13({
|
|
26713
26788
|
columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
|
|
26714
26789
|
foreignColumns: [
|
|
26715
26790
|
sectionDefinitionVersions.sectionDefinitionId,
|
|
@@ -26718,51 +26793,51 @@ var sectionImplementationRequests = pgTable89(
|
|
|
26718
26793
|
],
|
|
26719
26794
|
name: "section_implementation_requests_definition_version_project_fkey"
|
|
26720
26795
|
}).onDelete("cascade"),
|
|
26721
|
-
|
|
26796
|
+
foreignKey13({
|
|
26722
26797
|
columns: [table.manifestId, table.projectId],
|
|
26723
26798
|
foreignColumns: [sectionManifests.id, sectionManifests.projectId],
|
|
26724
26799
|
name: "section_implementation_requests_manifest_project_fkey"
|
|
26725
26800
|
}).onDelete("restrict"),
|
|
26726
|
-
|
|
26801
|
+
foreignKey13({
|
|
26727
26802
|
columns: [table.validationRunId, table.projectId],
|
|
26728
26803
|
foreignColumns: [sectionValidationRuns.id, sectionValidationRuns.projectId],
|
|
26729
26804
|
name: "section_implementation_requests_validation_project_fkey"
|
|
26730
26805
|
}).onDelete("restrict"),
|
|
26731
26806
|
unique12("section_implementation_requests_id_project_unique").on(table.id, table.projectId),
|
|
26732
26807
|
uniqueIndex41("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql26`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
|
|
26733
|
-
|
|
26808
|
+
index78("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
|
|
26734
26809
|
]
|
|
26735
26810
|
);
|
|
26736
|
-
var sectionZoneReleases =
|
|
26811
|
+
var sectionZoneReleases = pgTable90(
|
|
26737
26812
|
"section_zone_releases",
|
|
26738
26813
|
{
|
|
26739
|
-
id:
|
|
26740
|
-
workspaceId:
|
|
26741
|
-
projectId:
|
|
26742
|
-
zoneId:
|
|
26743
|
-
revision:
|
|
26744
|
-
snapshot:
|
|
26745
|
-
publishedBy:
|
|
26746
|
-
publishedAt:
|
|
26814
|
+
id: text91("id").primaryKey(),
|
|
26815
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
26816
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
26817
|
+
zoneId: text91("zone_id").notNull(),
|
|
26818
|
+
revision: integer46("revision").notNull(),
|
|
26819
|
+
snapshot: jsonb51("snapshot").$type().notNull(),
|
|
26820
|
+
publishedBy: text91("published_by").notNull(),
|
|
26821
|
+
publishedAt: timestamp83("published_at").notNull().defaultNow()
|
|
26747
26822
|
},
|
|
26748
26823
|
(table) => [
|
|
26749
|
-
|
|
26824
|
+
foreignKey13({
|
|
26750
26825
|
columns: [table.projectId, table.workspaceId],
|
|
26751
26826
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
26752
26827
|
name: "section_zone_releases_project_workspace_fkey"
|
|
26753
26828
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
26754
|
-
|
|
26829
|
+
foreignKey13({
|
|
26755
26830
|
columns: [table.zoneId, table.projectId],
|
|
26756
26831
|
foreignColumns: [sectionZones.id, sectionZones.projectId],
|
|
26757
26832
|
name: "section_zone_releases_zone_project_fkey"
|
|
26758
26833
|
}).onDelete("cascade"),
|
|
26759
26834
|
unique12("section_zone_releases_zone_revision_unique").on(table.zoneId, table.revision),
|
|
26760
|
-
|
|
26835
|
+
index78("section_zone_releases_project_published_idx").on(table.projectId, table.publishedAt)
|
|
26761
26836
|
]
|
|
26762
26837
|
);
|
|
26763
26838
|
|
|
26764
26839
|
// src/schema/content_locks.ts
|
|
26765
|
-
import { check as check10, index as
|
|
26840
|
+
import { check as check10, index as index79, jsonb as jsonb52, pgTable as pgTable91, text as text92, timestamp as timestamp84 } from "drizzle-orm/pg-core";
|
|
26766
26841
|
import { sql as sql27 } from "drizzle-orm";
|
|
26767
26842
|
var CONTENT_LOCK_TARGET_KINDS = [
|
|
26768
26843
|
"page",
|
|
@@ -26771,30 +26846,30 @@ var CONTENT_LOCK_TARGET_KINDS = [
|
|
|
26771
26846
|
"component_definition"
|
|
26772
26847
|
];
|
|
26773
26848
|
var CONTENT_LOCK_MODES = ["all", "agents"];
|
|
26774
|
-
var contentLocks =
|
|
26849
|
+
var contentLocks = pgTable91(
|
|
26775
26850
|
"content_locks",
|
|
26776
26851
|
{
|
|
26777
|
-
id:
|
|
26778
|
-
workspaceId:
|
|
26779
|
-
projectId:
|
|
26780
|
-
targetKind:
|
|
26781
|
-
targetId:
|
|
26782
|
-
blockId:
|
|
26852
|
+
id: text92("id").primaryKey(),
|
|
26853
|
+
workspaceId: text92("workspace_id").notNull(),
|
|
26854
|
+
projectId: text92("project_id").notNull(),
|
|
26855
|
+
targetKind: text92("target_kind").$type().notNull(),
|
|
26856
|
+
targetId: text92("target_id").notNull(),
|
|
26857
|
+
blockId: text92("block_id"),
|
|
26783
26858
|
// Deterministic structural path plus block ancestry captured when the lock is created.
|
|
26784
26859
|
// Nullable so Wave 5 remains compatible with locks created before this fingerprint existed.
|
|
26785
|
-
blockFingerprint:
|
|
26786
|
-
fieldPath:
|
|
26787
|
-
mode:
|
|
26788
|
-
reason:
|
|
26789
|
-
createdBy:
|
|
26790
|
-
createdAt:
|
|
26791
|
-
releasedBy:
|
|
26792
|
-
releasedAt:
|
|
26860
|
+
blockFingerprint: jsonb52("block_fingerprint").$type(),
|
|
26861
|
+
fieldPath: text92("field_path").array(),
|
|
26862
|
+
mode: text92("mode").$type().notNull().default("all"),
|
|
26863
|
+
reason: text92("reason"),
|
|
26864
|
+
createdBy: text92("created_by").notNull(),
|
|
26865
|
+
createdAt: timestamp84("created_at").notNull().defaultNow(),
|
|
26866
|
+
releasedBy: text92("released_by"),
|
|
26867
|
+
releasedAt: timestamp84("released_at")
|
|
26793
26868
|
},
|
|
26794
26869
|
(table) => [
|
|
26795
|
-
|
|
26796
|
-
|
|
26797
|
-
|
|
26870
|
+
index79("content_locks_workspace_idx").on(table.workspaceId),
|
|
26871
|
+
index79("content_locks_project_idx").on(table.projectId),
|
|
26872
|
+
index79("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql27`${table.releasedAt} IS NULL`),
|
|
26798
26873
|
check10("content_locks_target_kind_check", sql27`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
|
|
26799
26874
|
check10("content_locks_mode_check", sql27`${table.mode} IN ('all','agents')`)
|
|
26800
26875
|
// `content_locks_shape_check` lives in migration 0192 ONLY: it calls
|
|
@@ -26810,75 +26885,75 @@ var contentLocks = pgTable90(
|
|
|
26810
26885
|
|
|
26811
26886
|
// src/schema/project_transfers.ts
|
|
26812
26887
|
import {
|
|
26813
|
-
pgTable as
|
|
26814
|
-
text as
|
|
26888
|
+
pgTable as pgTable92,
|
|
26889
|
+
text as text93,
|
|
26815
26890
|
varchar as varchar69,
|
|
26816
|
-
timestamp as
|
|
26817
|
-
index as
|
|
26891
|
+
timestamp as timestamp85,
|
|
26892
|
+
index as index80,
|
|
26818
26893
|
uniqueIndex as uniqueIndex42
|
|
26819
26894
|
} from "drizzle-orm/pg-core";
|
|
26820
26895
|
import { sql as sql28 } from "drizzle-orm";
|
|
26821
|
-
var projectTransfers =
|
|
26896
|
+
var projectTransfers = pgTable92(
|
|
26822
26897
|
"project_transfers",
|
|
26823
26898
|
{
|
|
26824
|
-
id:
|
|
26899
|
+
id: text93("id").primaryKey(),
|
|
26825
26900
|
// nanoid
|
|
26826
|
-
token:
|
|
26901
|
+
token: text93("token").notNull(),
|
|
26827
26902
|
// nanoid(32) — recipient handshake / magic link
|
|
26828
26903
|
status: varchar69("status", { length: 20 }).notNull().default("pending"),
|
|
26829
26904
|
// pending | accepted (transient) | completed | declined | cancelled | expired | failed
|
|
26830
|
-
projectId:
|
|
26905
|
+
projectId: text93("project_id").notNull(),
|
|
26831
26906
|
// FK → projects.id (ON DELETE CASCADE, via migration)
|
|
26832
|
-
fromWorkspaceId:
|
|
26907
|
+
fromWorkspaceId: text93("from_workspace_id").notNull(),
|
|
26833
26908
|
// FK → workspaces.id (source)
|
|
26834
|
-
toWorkspaceId:
|
|
26909
|
+
toWorkspaceId: text93("to_workspace_id"),
|
|
26835
26910
|
// FK → workspaces.id — resolved at accept (null while pending)
|
|
26836
|
-
initiatedBy:
|
|
26911
|
+
initiatedBy: text93("initiated_by").notNull(),
|
|
26837
26912
|
// FK → users.id (source owner)
|
|
26838
26913
|
recipientEmail: varchar69("recipient_email", { length: 255 }).notNull(),
|
|
26839
26914
|
// lowercased
|
|
26840
|
-
note:
|
|
26915
|
+
note: text93("note"),
|
|
26841
26916
|
// optional message to the recipient
|
|
26842
|
-
resolvedAt:
|
|
26917
|
+
resolvedAt: timestamp85("resolved_at"),
|
|
26843
26918
|
// set on accept/decline/cancel/expire
|
|
26844
|
-
resolvedBy:
|
|
26919
|
+
resolvedBy: text93("resolved_by"),
|
|
26845
26920
|
// FK → users.id (accepter/decliner/canceller)
|
|
26846
|
-
error:
|
|
26921
|
+
error: text93("error"),
|
|
26847
26922
|
// failure detail when status='failed'
|
|
26848
|
-
expiresAt:
|
|
26923
|
+
expiresAt: timestamp85("expires_at").notNull(),
|
|
26849
26924
|
// createdAt + 7d
|
|
26850
|
-
createdAt:
|
|
26851
|
-
updatedAt:
|
|
26925
|
+
createdAt: timestamp85("created_at").notNull().defaultNow(),
|
|
26926
|
+
updatedAt: timestamp85("updated_at").notNull().defaultNow()
|
|
26852
26927
|
},
|
|
26853
26928
|
(table) => [
|
|
26854
26929
|
// At most one OPEN transfer per project. Partial-unique so completed/declined/
|
|
26855
26930
|
// cancelled/expired/failed rows never wedge a re-initiation.
|
|
26856
26931
|
uniqueIndex42("project_transfers_one_pending_idx").on(table.projectId).where(sql28`${table.status} = 'pending'`),
|
|
26857
26932
|
// Recipient inbox lookup (GET /me/transfers by email + status).
|
|
26858
|
-
|
|
26933
|
+
index80("project_transfers_recipient_idx").on(
|
|
26859
26934
|
table.recipientEmail,
|
|
26860
26935
|
table.status
|
|
26861
26936
|
),
|
|
26862
26937
|
// Source-side list (GET /projects/:id/transfers) + cancel.
|
|
26863
|
-
|
|
26864
|
-
|
|
26938
|
+
index80("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
|
|
26939
|
+
index80("project_transfers_project_idx").on(table.projectId),
|
|
26865
26940
|
// Magic-link resolution.
|
|
26866
26941
|
uniqueIndex42("project_transfers_token_idx").on(table.token),
|
|
26867
26942
|
// Expiry sweep — only pending rows are ever candidates.
|
|
26868
|
-
|
|
26943
|
+
index80("project_transfers_expires_idx").on(table.expiresAt).where(sql28`${table.status} = 'pending'`)
|
|
26869
26944
|
]
|
|
26870
26945
|
);
|
|
26871
26946
|
|
|
26872
26947
|
// src/schema/backups.ts
|
|
26873
26948
|
import {
|
|
26874
|
-
pgTable as
|
|
26875
|
-
text as
|
|
26949
|
+
pgTable as pgTable93,
|
|
26950
|
+
text as text94,
|
|
26876
26951
|
varchar as varchar70,
|
|
26877
|
-
integer as
|
|
26952
|
+
integer as integer47,
|
|
26878
26953
|
bigint as bigint7,
|
|
26879
|
-
jsonb as
|
|
26880
|
-
timestamp as
|
|
26881
|
-
index as
|
|
26954
|
+
jsonb as jsonb53,
|
|
26955
|
+
timestamp as timestamp86,
|
|
26956
|
+
index as index81
|
|
26882
26957
|
} from "drizzle-orm/pg-core";
|
|
26883
26958
|
var FULL_BACKUP_SCOPE = {
|
|
26884
26959
|
content: true,
|
|
@@ -26887,261 +26962,261 @@ var FULL_BACKUP_SCOPE = {
|
|
|
26887
26962
|
submissions: true,
|
|
26888
26963
|
analytics: true
|
|
26889
26964
|
};
|
|
26890
|
-
var backups =
|
|
26965
|
+
var backups = pgTable93(
|
|
26891
26966
|
"backups",
|
|
26892
26967
|
{
|
|
26893
|
-
id:
|
|
26968
|
+
id: text94("id").primaryKey(),
|
|
26894
26969
|
// nanoid
|
|
26895
|
-
workspaceId:
|
|
26970
|
+
workspaceId: text94("workspace_id").notNull(),
|
|
26896
26971
|
// FK → workspaces.id (RLS scope)
|
|
26897
|
-
projectId:
|
|
26972
|
+
projectId: text94("project_id").notNull(),
|
|
26898
26973
|
// FK → projects.id
|
|
26899
26974
|
name: varchar70("name", { length: 255 }).notNull(),
|
|
26900
26975
|
source: varchar70("source", { length: 20 }).notNull().default("manual"),
|
|
26901
26976
|
status: varchar70("status", { length: 20 }).notNull().default("pending"),
|
|
26902
|
-
manifestKey:
|
|
26977
|
+
manifestKey: text94("manifest_key"),
|
|
26903
26978
|
// R2 key of the gzipped manifest; NULL until ready
|
|
26904
|
-
manifestVersion:
|
|
26979
|
+
manifestVersion: integer47("manifest_version").notNull().default(1),
|
|
26905
26980
|
// forward-compat
|
|
26906
26981
|
sizeBytes: bigint7("size_bytes", { mode: "number" }),
|
|
26907
|
-
counts:
|
|
26982
|
+
counts: jsonb53("counts").$type().notNull().default({}),
|
|
26908
26983
|
// R2 object keys this snapshot references. Powers the media-GC hold:
|
|
26909
26984
|
// `list_backup_referenced_media_keys()` keeps these keys alive while the
|
|
26910
26985
|
// backup is live, so a restore never finds a garbage-collected object.
|
|
26911
|
-
mediaKeys:
|
|
26912
|
-
scope:
|
|
26913
|
-
error:
|
|
26914
|
-
createdBy:
|
|
26986
|
+
mediaKeys: jsonb53("media_keys").$type().notNull().default([]),
|
|
26987
|
+
scope: jsonb53("scope").$type().notNull().default(FULL_BACKUP_SCOPE),
|
|
26988
|
+
error: text94("error"),
|
|
26989
|
+
createdBy: text94("created_by"),
|
|
26915
26990
|
// FK → users(id); NULL = system-initiated
|
|
26916
|
-
createdAt:
|
|
26917
|
-
readyAt:
|
|
26918
|
-
expiresAt:
|
|
26991
|
+
createdAt: timestamp86("created_at").notNull().defaultNow(),
|
|
26992
|
+
readyAt: timestamp86("ready_at"),
|
|
26993
|
+
expiresAt: timestamp86("expires_at"),
|
|
26919
26994
|
// retention horizon; NULL = keep until count-pruned
|
|
26920
|
-
deletedAt:
|
|
26995
|
+
deletedAt: timestamp86("deleted_at")
|
|
26921
26996
|
},
|
|
26922
26997
|
(t) => [
|
|
26923
|
-
|
|
26924
|
-
|
|
26998
|
+
index81("backups_project_idx").on(t.projectId, t.createdAt),
|
|
26999
|
+
index81("backups_workspace_idx").on(t.workspaceId)
|
|
26925
27000
|
]
|
|
26926
27001
|
);
|
|
26927
27002
|
|
|
26928
27003
|
// src/schema/backup_jobs.ts
|
|
26929
27004
|
import {
|
|
26930
|
-
pgTable as
|
|
26931
|
-
text as
|
|
27005
|
+
pgTable as pgTable94,
|
|
27006
|
+
text as text95,
|
|
26932
27007
|
varchar as varchar71,
|
|
26933
|
-
integer as
|
|
26934
|
-
jsonb as
|
|
26935
|
-
timestamp as
|
|
26936
|
-
index as
|
|
27008
|
+
integer as integer48,
|
|
27009
|
+
jsonb as jsonb54,
|
|
27010
|
+
timestamp as timestamp87,
|
|
27011
|
+
index as index82
|
|
26937
27012
|
} from "drizzle-orm/pg-core";
|
|
26938
|
-
var backupJobs =
|
|
27013
|
+
var backupJobs = pgTable94(
|
|
26939
27014
|
"backup_jobs",
|
|
26940
27015
|
{
|
|
26941
|
-
id:
|
|
27016
|
+
id: text95("id").primaryKey(),
|
|
26942
27017
|
// nanoid
|
|
26943
|
-
workspaceId:
|
|
26944
|
-
projectId:
|
|
27018
|
+
workspaceId: text95("workspace_id").notNull(),
|
|
27019
|
+
projectId: text95("project_id").notNull(),
|
|
26945
27020
|
// create → the pending backups.id this job fills; restore → the source backup.
|
|
26946
|
-
backupId:
|
|
27021
|
+
backupId: text95("backup_id"),
|
|
26947
27022
|
operation: varchar71("operation", { length: 16 }).notNull(),
|
|
26948
27023
|
status: varchar71("status", { length: 16 }).notNull().default("pending"),
|
|
26949
|
-
progress:
|
|
27024
|
+
progress: integer48("progress").notNull().default(0),
|
|
26950
27025
|
// 0–100
|
|
26951
|
-
workingSince:
|
|
26952
|
-
attempts:
|
|
26953
|
-
error:
|
|
26954
|
-
payload:
|
|
26955
|
-
createdAt:
|
|
26956
|
-
updatedAt:
|
|
27026
|
+
workingSince: timestamp87("working_since", { withTimezone: true }),
|
|
27027
|
+
attempts: integer48("attempts").notNull().default(0),
|
|
27028
|
+
error: text95("error"),
|
|
27029
|
+
payload: jsonb54("payload").$type().notNull().default({}),
|
|
27030
|
+
createdAt: timestamp87("created_at").notNull().defaultNow(),
|
|
27031
|
+
updatedAt: timestamp87("updated_at").notNull().defaultNow()
|
|
26957
27032
|
},
|
|
26958
27033
|
(t) => [
|
|
26959
|
-
|
|
26960
|
-
|
|
27034
|
+
index82("backup_jobs_drain_idx").on(t.status, t.createdAt),
|
|
27035
|
+
index82("backup_jobs_project_idx").on(t.projectId)
|
|
26961
27036
|
]
|
|
26962
27037
|
);
|
|
26963
27038
|
|
|
26964
27039
|
// src/schema/clone_links.ts
|
|
26965
|
-
import { pgTable as
|
|
26966
|
-
var cloneLinks =
|
|
27040
|
+
import { pgTable as pgTable95, text as text96, boolean as boolean30, jsonb as jsonb55, timestamp as timestamp88, index as index83 } from "drizzle-orm/pg-core";
|
|
27041
|
+
var cloneLinks = pgTable95(
|
|
26967
27042
|
"clone_links",
|
|
26968
27043
|
{
|
|
26969
|
-
id:
|
|
27044
|
+
id: text96("id").primaryKey(),
|
|
26970
27045
|
// nanoid
|
|
26971
|
-
workspaceId:
|
|
27046
|
+
workspaceId: text96("workspace_id").notNull(),
|
|
26972
27047
|
// FK → workspaces.id (RLS scope)
|
|
26973
|
-
projectId:
|
|
27048
|
+
projectId: text96("project_id").notNull(),
|
|
26974
27049
|
// FK → projects.id
|
|
26975
|
-
token:
|
|
27050
|
+
token: text96("token").notNull(),
|
|
26976
27051
|
// public share token (nanoid); unique among active links
|
|
26977
27052
|
enabled: boolean30("enabled").notNull().default(true),
|
|
26978
|
-
scope:
|
|
26979
|
-
createdBy:
|
|
27053
|
+
scope: jsonb55("scope").$type().notNull(),
|
|
27054
|
+
createdBy: text96("created_by"),
|
|
26980
27055
|
// FK → users(id); NULL = system-initiated
|
|
26981
|
-
createdAt:
|
|
26982
|
-
updatedAt:
|
|
26983
|
-
revokedAt:
|
|
27056
|
+
createdAt: timestamp88("created_at").notNull().defaultNow(),
|
|
27057
|
+
updatedAt: timestamp88("updated_at").notNull().defaultNow(),
|
|
27058
|
+
revokedAt: timestamp88("revoked_at")
|
|
26984
27059
|
// set when the link is rotated/disabled
|
|
26985
27060
|
},
|
|
26986
27061
|
(t) => [
|
|
26987
|
-
|
|
26988
|
-
|
|
27062
|
+
index83("clone_links_project_idx").on(t.projectId),
|
|
27063
|
+
index83("clone_links_workspace_idx").on(t.workspaceId)
|
|
26989
27064
|
]
|
|
26990
27065
|
);
|
|
26991
27066
|
|
|
26992
27067
|
// src/schema/clone_jobs.ts
|
|
26993
|
-
import { pgTable as
|
|
26994
|
-
var cloneJobs =
|
|
27068
|
+
import { pgTable as pgTable96, text as text97, varchar as varchar72, integer as integer49, jsonb as jsonb56, timestamp as timestamp89, index as index84 } from "drizzle-orm/pg-core";
|
|
27069
|
+
var cloneJobs = pgTable96(
|
|
26995
27070
|
"clone_jobs",
|
|
26996
27071
|
{
|
|
26997
|
-
id:
|
|
27072
|
+
id: text97("id").primaryKey(),
|
|
26998
27073
|
// nanoid
|
|
26999
|
-
workspaceId:
|
|
27074
|
+
workspaceId: text97("workspace_id").notNull(),
|
|
27000
27075
|
// = targetWorkspaceId (RLS scope)
|
|
27001
|
-
sourceProjectId:
|
|
27002
|
-
sourceWorkspaceId:
|
|
27003
|
-
targetProjectId:
|
|
27076
|
+
sourceProjectId: text97("source_project_id").notNull(),
|
|
27077
|
+
sourceWorkspaceId: text97("source_workspace_id").notNull(),
|
|
27078
|
+
targetProjectId: text97("target_project_id"),
|
|
27004
27079
|
// stamped on success
|
|
27005
27080
|
requestedName: varchar72("requested_name", { length: 255 }),
|
|
27006
27081
|
requestedSlug: varchar72("requested_slug", { length: 255 }),
|
|
27007
27082
|
status: varchar72("status", { length: 16 }).notNull().default("pending"),
|
|
27008
|
-
progress:
|
|
27083
|
+
progress: integer49("progress").notNull().default(0),
|
|
27009
27084
|
// 0–100
|
|
27010
|
-
workingSince:
|
|
27011
|
-
attempts:
|
|
27012
|
-
error:
|
|
27013
|
-
payload:
|
|
27014
|
-
initiatedBy:
|
|
27085
|
+
workingSince: timestamp89("working_since", { withTimezone: true }),
|
|
27086
|
+
attempts: integer49("attempts").notNull().default(0),
|
|
27087
|
+
error: text97("error"),
|
|
27088
|
+
payload: jsonb56("payload").$type().notNull().default({}),
|
|
27089
|
+
initiatedBy: text97("initiated_by"),
|
|
27015
27090
|
// FK → users(id); NULL = system/agent
|
|
27016
|
-
createdAt:
|
|
27017
|
-
updatedAt:
|
|
27091
|
+
createdAt: timestamp89("created_at").notNull().defaultNow(),
|
|
27092
|
+
updatedAt: timestamp89("updated_at").notNull().defaultNow()
|
|
27018
27093
|
},
|
|
27019
27094
|
(t) => [
|
|
27020
|
-
|
|
27021
|
-
|
|
27095
|
+
index84("clone_jobs_drain_idx").on(t.status, t.createdAt),
|
|
27096
|
+
index84("clone_jobs_workspace_idx").on(t.workspaceId)
|
|
27022
27097
|
]
|
|
27023
27098
|
);
|
|
27024
27099
|
|
|
27025
27100
|
// src/schema/project_branches.ts
|
|
27026
27101
|
import {
|
|
27027
|
-
pgTable as
|
|
27028
|
-
text as
|
|
27102
|
+
pgTable as pgTable97,
|
|
27103
|
+
text as text98,
|
|
27029
27104
|
varchar as varchar73,
|
|
27030
|
-
timestamp as
|
|
27031
|
-
index as
|
|
27105
|
+
timestamp as timestamp90,
|
|
27106
|
+
index as index85,
|
|
27032
27107
|
uniqueIndex as uniqueIndex43
|
|
27033
27108
|
} from "drizzle-orm/pg-core";
|
|
27034
27109
|
import { sql as sql29 } from "drizzle-orm";
|
|
27035
|
-
var projectBranches =
|
|
27110
|
+
var projectBranches = pgTable97(
|
|
27036
27111
|
"project_branches",
|
|
27037
27112
|
{
|
|
27038
|
-
id:
|
|
27039
|
-
workspaceId:
|
|
27040
|
-
projectId:
|
|
27113
|
+
id: text98("id").primaryKey(),
|
|
27114
|
+
workspaceId: text98("workspace_id").notNull(),
|
|
27115
|
+
projectId: text98("project_id").notNull(),
|
|
27041
27116
|
name: varchar73("name", { length: 80 }).notNull(),
|
|
27042
27117
|
slug: varchar73("slug", { length: 80 }).notNull(),
|
|
27043
|
-
parentBranchId:
|
|
27118
|
+
parentBranchId: text98("parent_branch_id"),
|
|
27044
27119
|
status: varchar73("status", { length: 16 }).$type().notNull().default("open"),
|
|
27045
|
-
appliedAt:
|
|
27046
|
-
abandonedAt:
|
|
27120
|
+
appliedAt: timestamp90("applied_at"),
|
|
27121
|
+
abandonedAt: timestamp90("abandoned_at"),
|
|
27047
27122
|
...auditColumns
|
|
27048
27123
|
},
|
|
27049
27124
|
(t) => [
|
|
27050
|
-
|
|
27125
|
+
index85("project_branches_project_idx").on(t.projectId),
|
|
27051
27126
|
uniqueIndex43("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql29`${t.status} = 'open'`)
|
|
27052
27127
|
]
|
|
27053
27128
|
);
|
|
27054
27129
|
|
|
27055
27130
|
// src/schema/branch_preview_share.ts
|
|
27056
|
-
import { pgTable as
|
|
27057
|
-
var branchPreviewShares =
|
|
27131
|
+
import { pgTable as pgTable98, text as text99, boolean as boolean31, timestamp as timestamp91, index as index86, uniqueIndex as uniqueIndex44 } from "drizzle-orm/pg-core";
|
|
27132
|
+
var branchPreviewShares = pgTable98(
|
|
27058
27133
|
"branch_preview_shares",
|
|
27059
27134
|
{
|
|
27060
|
-
id:
|
|
27061
|
-
workspaceId:
|
|
27062
|
-
projectId:
|
|
27063
|
-
branchId:
|
|
27135
|
+
id: text99("id").primaryKey(),
|
|
27136
|
+
workspaceId: text99("workspace_id").notNull(),
|
|
27137
|
+
projectId: text99("project_id").notNull(),
|
|
27138
|
+
branchId: text99("branch_id").notNull(),
|
|
27064
27139
|
publicEnabled: boolean31("public_enabled").notNull().default(false),
|
|
27065
|
-
publicToken:
|
|
27066
|
-
createdBy:
|
|
27067
|
-
createdAt:
|
|
27068
|
-
updatedAt:
|
|
27140
|
+
publicToken: text99("public_token"),
|
|
27141
|
+
createdBy: text99("created_by"),
|
|
27142
|
+
createdAt: timestamp91("created_at").notNull().defaultNow(),
|
|
27143
|
+
updatedAt: timestamp91("updated_at").notNull().defaultNow()
|
|
27069
27144
|
},
|
|
27070
27145
|
(t) => [
|
|
27071
27146
|
uniqueIndex44("branch_preview_shares_branch_idx").on(t.branchId),
|
|
27072
27147
|
uniqueIndex44("branch_preview_shares_active_token_idx").on(t.publicToken),
|
|
27073
|
-
|
|
27074
|
-
|
|
27148
|
+
index86("branch_preview_shares_project_idx").on(t.projectId),
|
|
27149
|
+
index86("branch_preview_shares_workspace_idx").on(t.workspaceId)
|
|
27075
27150
|
]
|
|
27076
27151
|
);
|
|
27077
|
-
var branchPreviewGrants =
|
|
27152
|
+
var branchPreviewGrants = pgTable98(
|
|
27078
27153
|
"branch_preview_grants",
|
|
27079
27154
|
{
|
|
27080
|
-
id:
|
|
27081
|
-
workspaceId:
|
|
27082
|
-
projectId:
|
|
27083
|
-
branchId:
|
|
27084
|
-
email:
|
|
27085
|
-
invitedBy:
|
|
27086
|
-
createdAt:
|
|
27155
|
+
id: text99("id").primaryKey(),
|
|
27156
|
+
workspaceId: text99("workspace_id").notNull(),
|
|
27157
|
+
projectId: text99("project_id").notNull(),
|
|
27158
|
+
branchId: text99("branch_id").notNull(),
|
|
27159
|
+
email: text99("email").notNull(),
|
|
27160
|
+
invitedBy: text99("invited_by"),
|
|
27161
|
+
createdAt: timestamp91("created_at").notNull().defaultNow()
|
|
27087
27162
|
},
|
|
27088
27163
|
(t) => [
|
|
27089
27164
|
uniqueIndex44("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
|
|
27090
|
-
|
|
27165
|
+
index86("branch_preview_grants_project_idx").on(t.projectId)
|
|
27091
27166
|
]
|
|
27092
27167
|
);
|
|
27093
27168
|
|
|
27094
27169
|
// src/schema/share_links.ts
|
|
27095
|
-
import { pgTable as
|
|
27096
|
-
var shareLinks =
|
|
27170
|
+
import { pgTable as pgTable99, text as text100, boolean as boolean32, timestamp as timestamp92, index as index87 } from "drizzle-orm/pg-core";
|
|
27171
|
+
var shareLinks = pgTable99(
|
|
27097
27172
|
"share_links",
|
|
27098
27173
|
{
|
|
27099
|
-
id:
|
|
27174
|
+
id: text100("id").primaryKey(),
|
|
27100
27175
|
// nanoid
|
|
27101
|
-
workspaceId:
|
|
27176
|
+
workspaceId: text100("workspace_id").notNull(),
|
|
27102
27177
|
// FK → workspaces.id (RLS scope)
|
|
27103
|
-
projectId:
|
|
27178
|
+
projectId: text100("project_id").notNull(),
|
|
27104
27179
|
// FK → projects.id
|
|
27105
|
-
token:
|
|
27180
|
+
token: text100("token").notNull(),
|
|
27106
27181
|
// public share token (nanoid); unique among active links
|
|
27107
27182
|
enabled: boolean32("enabled").notNull().default(true),
|
|
27108
|
-
createdBy:
|
|
27183
|
+
createdBy: text100("created_by"),
|
|
27109
27184
|
// FK → users(id); NULL = system-initiated
|
|
27110
|
-
createdAt:
|
|
27111
|
-
updatedAt:
|
|
27112
|
-
revokedAt:
|
|
27185
|
+
createdAt: timestamp92("created_at").notNull().defaultNow(),
|
|
27186
|
+
updatedAt: timestamp92("updated_at").notNull().defaultNow(),
|
|
27187
|
+
revokedAt: timestamp92("revoked_at")
|
|
27113
27188
|
// set when the link is disabled
|
|
27114
27189
|
},
|
|
27115
27190
|
(t) => [
|
|
27116
|
-
|
|
27117
|
-
|
|
27191
|
+
index87("share_links_project_idx").on(t.projectId),
|
|
27192
|
+
index87("share_links_workspace_idx").on(t.workspaceId)
|
|
27118
27193
|
]
|
|
27119
27194
|
);
|
|
27120
27195
|
|
|
27121
27196
|
// src/schema/templates.ts
|
|
27122
27197
|
import {
|
|
27123
|
-
pgTable as
|
|
27124
|
-
text as
|
|
27198
|
+
pgTable as pgTable100,
|
|
27199
|
+
text as text101,
|
|
27125
27200
|
varchar as varchar74,
|
|
27126
|
-
timestamp as
|
|
27127
|
-
jsonb as
|
|
27128
|
-
integer as
|
|
27129
|
-
index as
|
|
27201
|
+
timestamp as timestamp93,
|
|
27202
|
+
jsonb as jsonb57,
|
|
27203
|
+
integer as integer50,
|
|
27204
|
+
index as index88,
|
|
27130
27205
|
uniqueIndex as uniqueIndex45
|
|
27131
27206
|
} from "drizzle-orm/pg-core";
|
|
27132
27207
|
import { relations as relations17 } from "drizzle-orm/relations";
|
|
27133
27208
|
import { sql as sql30 } from "drizzle-orm";
|
|
27134
|
-
var templates =
|
|
27209
|
+
var templates = pgTable100(
|
|
27135
27210
|
"templates",
|
|
27136
27211
|
{
|
|
27137
|
-
id:
|
|
27212
|
+
id: text101("id").primaryKey(),
|
|
27138
27213
|
// nanoid
|
|
27139
|
-
workspaceId:
|
|
27214
|
+
workspaceId: text101("workspace_id").notNull(),
|
|
27140
27215
|
// FK to workspaces.id (RLS scope / owner)
|
|
27141
27216
|
slug: varchar74("slug", { length: 255 }).notNull(),
|
|
27142
27217
|
// ^[a-z0-9-]+$, unique per workspace
|
|
27143
27218
|
name: varchar74("name", { length: 255 }).notNull(),
|
|
27144
|
-
description:
|
|
27219
|
+
description: text101("description"),
|
|
27145
27220
|
scope: varchar74("scope", { length: 10 }).$type().notNull().default("project"),
|
|
27146
27221
|
// 'demo' ships seed content; 'starter-kit' is the same schema with the content blanked.
|
|
27147
27222
|
// Defaults to 'demo' because a user template is a frozen snapshot of a real project,
|
|
@@ -27152,25 +27227,25 @@ var templates = pgTable99(
|
|
|
27152
27227
|
thumbnail: varchar74("thumbnail", { length: 2048 }),
|
|
27153
27228
|
// Frozen snapshot manifest (stripped snapshot_project output). Never returned in
|
|
27154
27229
|
// list/gallery responses — only read server-side to instantiate.
|
|
27155
|
-
manifest:
|
|
27230
|
+
manifest: jsonb57("manifest").$type().notNull(),
|
|
27156
27231
|
visibility: varchar74("visibility", { length: 10 }).$type().notNull().default("private"),
|
|
27157
|
-
sourceProjectId:
|
|
27232
|
+
sourceProjectId: text101("source_project_id"),
|
|
27158
27233
|
// provenance (nullable — source may be deleted later)
|
|
27159
|
-
createdBy:
|
|
27234
|
+
createdBy: text101("created_by"),
|
|
27160
27235
|
// user id, or null for a management-key create
|
|
27161
|
-
optimisticVersion:
|
|
27162
|
-
createdAt:
|
|
27163
|
-
updatedAt:
|
|
27164
|
-
deletedAt:
|
|
27236
|
+
optimisticVersion: integer50("optimistic_version").notNull().default(0),
|
|
27237
|
+
createdAt: timestamp93("created_at").notNull().defaultNow(),
|
|
27238
|
+
updatedAt: timestamp93("updated_at").notNull().defaultNow(),
|
|
27239
|
+
deletedAt: timestamp93("deleted_at")
|
|
27165
27240
|
// soft-delete
|
|
27166
27241
|
},
|
|
27167
27242
|
(table) => [
|
|
27168
|
-
|
|
27243
|
+
index88("templates_workspace_idx").on(table.workspaceId),
|
|
27169
27244
|
// Partial: only live rows. A soft-deleted template frees its slug (mirrors
|
|
27170
27245
|
// components_ws_proj_slug_idx / migration 0114).
|
|
27171
27246
|
uniqueIndex45("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql30`${table.deletedAt} IS NULL`),
|
|
27172
27247
|
// Public gallery scan (created_at DESC over live public rows).
|
|
27173
|
-
|
|
27248
|
+
index88("templates_public_idx").on(table.visibility).where(sql30`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
|
|
27174
27249
|
]
|
|
27175
27250
|
);
|
|
27176
27251
|
var templatesRelations = relations17(templates, ({ one }) => ({
|
|
@@ -27182,99 +27257,99 @@ var templatesRelations = relations17(templates, ({ one }) => ({
|
|
|
27182
27257
|
|
|
27183
27258
|
// src/schema/payment_records.ts
|
|
27184
27259
|
import {
|
|
27185
|
-
pgTable as
|
|
27186
|
-
text as
|
|
27260
|
+
pgTable as pgTable101,
|
|
27261
|
+
text as text102,
|
|
27187
27262
|
varchar as varchar75,
|
|
27188
|
-
integer as
|
|
27189
|
-
timestamp as
|
|
27190
|
-
index as
|
|
27263
|
+
integer as integer51,
|
|
27264
|
+
timestamp as timestamp94,
|
|
27265
|
+
index as index89
|
|
27191
27266
|
} from "drizzle-orm/pg-core";
|
|
27192
|
-
var paymentRecords =
|
|
27267
|
+
var paymentRecords = pgTable101(
|
|
27193
27268
|
"payment_records",
|
|
27194
27269
|
{
|
|
27195
|
-
id:
|
|
27270
|
+
id: text102("id").primaryKey(),
|
|
27196
27271
|
// nanoid
|
|
27197
|
-
workspaceId:
|
|
27272
|
+
workspaceId: text102("workspace_id").notNull(),
|
|
27198
27273
|
// FK → workspaces.id
|
|
27199
|
-
amountCents:
|
|
27274
|
+
amountCents: integer51("amount_cents").notNull(),
|
|
27200
27275
|
// store money as integer cents
|
|
27201
27276
|
currency: varchar75("currency", { length: 3 }).notNull().default("usd"),
|
|
27202
27277
|
method: varchar75("method", { length: 50 }).notNull().default("manual"),
|
|
27203
27278
|
// manual | stripe | wire | ...
|
|
27204
|
-
note:
|
|
27205
|
-
recordedBy:
|
|
27279
|
+
note: text102("note"),
|
|
27280
|
+
recordedBy: text102("recorded_by"),
|
|
27206
27281
|
// FK → users.id (the admin who entered it)
|
|
27207
|
-
createdAt:
|
|
27282
|
+
createdAt: timestamp94("created_at").notNull().defaultNow()
|
|
27208
27283
|
},
|
|
27209
27284
|
(table) => [
|
|
27210
|
-
|
|
27285
|
+
index89("payment_records_workspace_idx").on(table.workspaceId, table.createdAt)
|
|
27211
27286
|
]
|
|
27212
27287
|
);
|
|
27213
27288
|
|
|
27214
27289
|
// src/schema/plan_changes.ts
|
|
27215
27290
|
import {
|
|
27216
|
-
pgTable as
|
|
27217
|
-
text as
|
|
27218
|
-
timestamp as
|
|
27219
|
-
index as
|
|
27291
|
+
pgTable as pgTable102,
|
|
27292
|
+
text as text103,
|
|
27293
|
+
timestamp as timestamp95,
|
|
27294
|
+
index as index90
|
|
27220
27295
|
} from "drizzle-orm/pg-core";
|
|
27221
|
-
var planChanges =
|
|
27296
|
+
var planChanges = pgTable102(
|
|
27222
27297
|
"plan_changes",
|
|
27223
27298
|
{
|
|
27224
|
-
id:
|
|
27299
|
+
id: text103("id").primaryKey(),
|
|
27225
27300
|
// nanoid
|
|
27226
|
-
workspaceId:
|
|
27301
|
+
workspaceId: text103("workspace_id").notNull(),
|
|
27227
27302
|
// FK → workspaces.id
|
|
27228
|
-
fromPlan:
|
|
27303
|
+
fromPlan: text103("from_plan"),
|
|
27229
27304
|
// plan_limits.id before the change (null if unknown)
|
|
27230
|
-
toPlan:
|
|
27305
|
+
toPlan: text103("to_plan").notNull(),
|
|
27231
27306
|
// plan_limits.id after the change
|
|
27232
|
-
reason:
|
|
27233
|
-
changedBy:
|
|
27307
|
+
reason: text103("reason"),
|
|
27308
|
+
changedBy: text103("changed_by"),
|
|
27234
27309
|
// FK → users.id (the admin)
|
|
27235
|
-
createdAt:
|
|
27310
|
+
createdAt: timestamp95("created_at").notNull().defaultNow()
|
|
27236
27311
|
},
|
|
27237
27312
|
(table) => [
|
|
27238
|
-
|
|
27313
|
+
index90("plan_changes_workspace_idx").on(table.workspaceId, table.createdAt)
|
|
27239
27314
|
]
|
|
27240
27315
|
);
|
|
27241
27316
|
|
|
27242
27317
|
// src/schema/billing_addons.ts
|
|
27243
|
-
import { pgTable as
|
|
27244
|
-
var billingAddons =
|
|
27318
|
+
import { pgTable as pgTable103, text as text104, varchar as varchar76, integer as integer52, boolean as boolean33, jsonb as jsonb58, index as index91 } from "drizzle-orm/pg-core";
|
|
27319
|
+
var billingAddons = pgTable103(
|
|
27245
27320
|
"billing_addons",
|
|
27246
27321
|
{
|
|
27247
|
-
id:
|
|
27322
|
+
id: text104("id").primaryKey(),
|
|
27248
27323
|
// stable slug, e.g. "developer", "ai-1000", "localization"
|
|
27249
27324
|
kind: varchar76("kind", { length: 20 }).notNull(),
|
|
27250
27325
|
// seat_role | ai_credits | localization | ab_testing
|
|
27251
27326
|
name: varchar76("name", { length: 100 }).notNull(),
|
|
27252
|
-
dodoProductId:
|
|
27327
|
+
dodoProductId: text104("dodo_product_id"),
|
|
27253
27328
|
// NULL until the Dodo product is created
|
|
27254
|
-
unitPriceCents:
|
|
27329
|
+
unitPriceCents: integer52("unit_price_cents").notNull(),
|
|
27255
27330
|
currency: varchar76("currency", { length: 8 }).notNull().default("usd"),
|
|
27256
|
-
credits:
|
|
27331
|
+
credits: integer52("credits"),
|
|
27257
27332
|
// ai_credits packs only: credits granted per unit
|
|
27258
27333
|
recurring: boolean33("recurring").notNull().default(false),
|
|
27259
27334
|
// seats/localization/AB = true; credit packs = false
|
|
27260
|
-
metadata:
|
|
27335
|
+
metadata: jsonb58("metadata").$type().default({})
|
|
27261
27336
|
},
|
|
27262
|
-
(t) => [
|
|
27337
|
+
(t) => [index91("billing_addons_kind_idx").on(t.kind)]
|
|
27263
27338
|
);
|
|
27264
27339
|
|
|
27265
27340
|
// src/schema/billing_customers.ts
|
|
27266
|
-
import { pgTable as
|
|
27267
|
-
var billingCustomers =
|
|
27341
|
+
import { pgTable as pgTable104, text as text105, varchar as varchar77, timestamp as timestamp96, uniqueIndex as uniqueIndex46 } from "drizzle-orm/pg-core";
|
|
27342
|
+
var billingCustomers = pgTable104(
|
|
27268
27343
|
"billing_customers",
|
|
27269
27344
|
{
|
|
27270
|
-
id:
|
|
27345
|
+
id: text105("id").primaryKey(),
|
|
27271
27346
|
// nanoid
|
|
27272
|
-
workspaceId:
|
|
27347
|
+
workspaceId: text105("workspace_id").notNull(),
|
|
27273
27348
|
// FK → workspaces.id (RLS scope)
|
|
27274
|
-
dodoCustomerId:
|
|
27349
|
+
dodoCustomerId: text105("dodo_customer_id").notNull(),
|
|
27275
27350
|
email: varchar77("email", { length: 255 }),
|
|
27276
|
-
createdAt:
|
|
27277
|
-
updatedAt:
|
|
27351
|
+
createdAt: timestamp96("created_at").notNull().defaultNow(),
|
|
27352
|
+
updatedAt: timestamp96("updated_at").notNull().defaultNow()
|
|
27278
27353
|
},
|
|
27279
27354
|
(t) => [
|
|
27280
27355
|
uniqueIndex46("billing_customers_workspace_idx").on(t.workspaceId),
|
|
@@ -27283,34 +27358,34 @@ var billingCustomers = pgTable103(
|
|
|
27283
27358
|
);
|
|
27284
27359
|
|
|
27285
27360
|
// src/schema/subscriptions.ts
|
|
27286
|
-
import { pgTable as
|
|
27361
|
+
import { pgTable as pgTable105, text as text106, varchar as varchar78, boolean as boolean34, timestamp as timestamp97, index as index92, uniqueIndex as uniqueIndex47 } from "drizzle-orm/pg-core";
|
|
27287
27362
|
import { sql as sql31 } from "drizzle-orm";
|
|
27288
|
-
var subscriptions =
|
|
27363
|
+
var subscriptions = pgTable105(
|
|
27289
27364
|
"subscriptions",
|
|
27290
27365
|
{
|
|
27291
|
-
id:
|
|
27366
|
+
id: text106("id").primaryKey(),
|
|
27292
27367
|
// nanoid
|
|
27293
|
-
workspaceId:
|
|
27368
|
+
workspaceId: text106("workspace_id").notNull(),
|
|
27294
27369
|
// FK → workspaces.id (RLS scope)
|
|
27295
|
-
projectId:
|
|
27370
|
+
projectId: text106("project_id"),
|
|
27296
27371
|
// NULL = workspace plan; set = site plan (FK → projects.id)
|
|
27297
|
-
planId:
|
|
27372
|
+
planId: text106("plan_id").notNull(),
|
|
27298
27373
|
// FK → plan_limits.id
|
|
27299
|
-
dodoSubscriptionId:
|
|
27300
|
-
dodoCustomerId:
|
|
27374
|
+
dodoSubscriptionId: text106("dodo_subscription_id"),
|
|
27375
|
+
dodoCustomerId: text106("dodo_customer_id"),
|
|
27301
27376
|
status: varchar78("status", { length: 20 }).notNull().default("active"),
|
|
27302
27377
|
// active | on_hold | cancelled | expired | pending
|
|
27303
27378
|
// Which of plan_limits' two prices this row is billed at. Without it the bill cannot tell
|
|
27304
27379
|
// whether the owner pays price_cents or price_cents_yearly (0147).
|
|
27305
27380
|
interval: varchar78("interval", { length: 10 }).notNull().default("month"),
|
|
27306
27381
|
// month | year
|
|
27307
|
-
currentPeriodEnd:
|
|
27382
|
+
currentPeriodEnd: timestamp97("current_period_end"),
|
|
27308
27383
|
cancelAtPeriodEnd: boolean34("cancel_at_period_end").notNull().default(false),
|
|
27309
|
-
createdAt:
|
|
27310
|
-
updatedAt:
|
|
27384
|
+
createdAt: timestamp97("created_at").notNull().defaultNow(),
|
|
27385
|
+
updatedAt: timestamp97("updated_at").notNull().defaultNow()
|
|
27311
27386
|
},
|
|
27312
27387
|
(t) => [
|
|
27313
|
-
|
|
27388
|
+
index92("subscriptions_workspace_idx").on(t.workspaceId),
|
|
27314
27389
|
uniqueIndex47("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql31`${t.dodoSubscriptionId} IS NOT NULL`),
|
|
27315
27390
|
// At most one workspace-level subscription per workspace.
|
|
27316
27391
|
uniqueIndex47("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql31`${t.projectId} IS NULL`),
|
|
@@ -27320,116 +27395,142 @@ var subscriptions = pgTable104(
|
|
|
27320
27395
|
);
|
|
27321
27396
|
|
|
27322
27397
|
// src/schema/subscription_addons.ts
|
|
27323
|
-
import { pgTable as
|
|
27398
|
+
import { pgTable as pgTable106, text as text107, varchar as varchar79, integer as integer53, timestamp as timestamp98, index as index93, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
|
|
27324
27399
|
import { sql as sql32 } from "drizzle-orm";
|
|
27325
|
-
var subscriptionAddons =
|
|
27400
|
+
var subscriptionAddons = pgTable106(
|
|
27326
27401
|
"subscription_addons",
|
|
27327
27402
|
{
|
|
27328
|
-
id:
|
|
27403
|
+
id: text107("id").primaryKey(),
|
|
27329
27404
|
// nanoid
|
|
27330
|
-
workspaceId:
|
|
27405
|
+
workspaceId: text107("workspace_id").notNull(),
|
|
27331
27406
|
// FK → workspaces.id (RLS scope)
|
|
27332
|
-
addonId:
|
|
27407
|
+
addonId: text107("addon_id").notNull(),
|
|
27333
27408
|
// FK → billing_addons.id
|
|
27334
|
-
quantity:
|
|
27335
|
-
dodoSubscriptionId:
|
|
27409
|
+
quantity: integer53("quantity").notNull().default(1),
|
|
27410
|
+
dodoSubscriptionId: text107("dodo_subscription_id"),
|
|
27336
27411
|
// NULL for a manual/admin grant
|
|
27337
27412
|
status: varchar79("status", { length: 20 }).notNull().default("active"),
|
|
27338
27413
|
// active | cancelled | expired
|
|
27339
|
-
createdAt:
|
|
27340
|
-
updatedAt:
|
|
27414
|
+
createdAt: timestamp98("created_at").notNull().defaultNow(),
|
|
27415
|
+
updatedAt: timestamp98("updated_at").notNull().defaultNow()
|
|
27341
27416
|
},
|
|
27342
27417
|
(t) => [
|
|
27343
|
-
|
|
27418
|
+
index93("subscription_addons_workspace_idx").on(t.workspaceId),
|
|
27344
27419
|
uniqueIndex48("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql32`${t.dodoSubscriptionId} IS NOT NULL`)
|
|
27345
27420
|
]
|
|
27346
27421
|
);
|
|
27347
27422
|
|
|
27423
|
+
// src/schema/billing_alerts.ts
|
|
27424
|
+
import { pgTable as pgTable107, text as text108, varchar as varchar80, timestamp as timestamp99, index as index94, uniqueIndex as uniqueIndex49 } from "drizzle-orm/pg-core";
|
|
27425
|
+
var billingAlerts = pgTable107(
|
|
27426
|
+
"billing_alerts",
|
|
27427
|
+
{
|
|
27428
|
+
id: text108("id").primaryKey(),
|
|
27429
|
+
// nanoid
|
|
27430
|
+
workspaceId: text108("workspace_id").notNull(),
|
|
27431
|
+
// FK → workspaces.id (internal table, no RLS)
|
|
27432
|
+
kind: varchar80("kind", { length: 32 }).notNull(),
|
|
27433
|
+
// renewal_due | bandwidth_80 | bandwidth_100
|
|
27434
|
+
/**
|
|
27435
|
+
* What "already sent" means for this alert, built by the caller (alerts.ts owns the spellings).
|
|
27436
|
+
* Renewals key on the subscription + its period end, so one reminder per period survives a
|
|
27437
|
+
* period-end change. Bandwidth keys on the threshold + calendar month, matching the window
|
|
27438
|
+
* getUsage() measures — so the counter resetting on the 1st re-arms the alert.
|
|
27439
|
+
*/
|
|
27440
|
+
dedupeKey: text108("dedupe_key").notNull(),
|
|
27441
|
+
sentAt: timestamp99("sent_at", { withTimezone: true }).notNull().defaultNow()
|
|
27442
|
+
},
|
|
27443
|
+
(t) => [
|
|
27444
|
+
uniqueIndex49("billing_alerts_dedupe_idx").on(t.dedupeKey),
|
|
27445
|
+
index94("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
|
|
27446
|
+
]
|
|
27447
|
+
);
|
|
27448
|
+
|
|
27348
27449
|
// src/schema/ai_credit_ledger.ts
|
|
27349
|
-
import { pgTable as
|
|
27350
|
-
var aiCreditLedger =
|
|
27450
|
+
import { pgTable as pgTable108, text as text109, varchar as varchar81, integer as integer54, timestamp as timestamp100, index as index95 } from "drizzle-orm/pg-core";
|
|
27451
|
+
var aiCreditLedger = pgTable108(
|
|
27351
27452
|
"ai_credit_ledger",
|
|
27352
27453
|
{
|
|
27353
|
-
id:
|
|
27454
|
+
id: text109("id").primaryKey(),
|
|
27354
27455
|
// nanoid
|
|
27355
|
-
workspaceId:
|
|
27456
|
+
workspaceId: text109("workspace_id").notNull(),
|
|
27356
27457
|
// FK → workspaces.id (RLS scope)
|
|
27357
|
-
delta:
|
|
27458
|
+
delta: integer54("delta").notNull(),
|
|
27358
27459
|
// signed: +purchase/grant, -consume/expire
|
|
27359
|
-
reason:
|
|
27460
|
+
reason: varchar81("reason", { length: 20 }).notNull(),
|
|
27360
27461
|
// purchase | consume | grant | expire
|
|
27361
|
-
dodoPaymentId:
|
|
27462
|
+
dodoPaymentId: text109("dodo_payment_id"),
|
|
27362
27463
|
// set for purchases
|
|
27363
|
-
note:
|
|
27364
|
-
createdAt:
|
|
27464
|
+
note: text109("note"),
|
|
27465
|
+
createdAt: timestamp100("created_at").notNull().defaultNow()
|
|
27365
27466
|
},
|
|
27366
|
-
(t) => [
|
|
27467
|
+
(t) => [index95("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt)]
|
|
27367
27468
|
);
|
|
27368
27469
|
|
|
27369
27470
|
// src/schema/support_tickets.ts
|
|
27370
27471
|
import {
|
|
27371
|
-
pgTable as
|
|
27372
|
-
text as
|
|
27373
|
-
varchar as
|
|
27374
|
-
timestamp as
|
|
27472
|
+
pgTable as pgTable109,
|
|
27473
|
+
text as text110,
|
|
27474
|
+
varchar as varchar82,
|
|
27475
|
+
timestamp as timestamp101,
|
|
27375
27476
|
boolean as boolean35,
|
|
27376
|
-
jsonb as
|
|
27377
|
-
index as
|
|
27477
|
+
jsonb as jsonb59,
|
|
27478
|
+
index as index96
|
|
27378
27479
|
} from "drizzle-orm/pg-core";
|
|
27379
|
-
var supportTickets =
|
|
27480
|
+
var supportTickets = pgTable109(
|
|
27380
27481
|
"support_tickets",
|
|
27381
27482
|
{
|
|
27382
|
-
id:
|
|
27483
|
+
id: text110("id").primaryKey(),
|
|
27383
27484
|
// nanoid
|
|
27384
|
-
workspaceId:
|
|
27485
|
+
workspaceId: text110("workspace_id"),
|
|
27385
27486
|
// FK → workspaces.id (nullable: account-level tickets)
|
|
27386
27487
|
// FK → users.id (the customer). NULL for a ticket Plain created: an email or Slack
|
|
27387
27488
|
// sender has no BetterCMS account. visibleTicketWhere() compares this to the session
|
|
27388
27489
|
// user, and NULL never matches, so those tickets stay invisible to every customer —
|
|
27389
27490
|
// which is correct, since there is no dashboard reply transport for them.
|
|
27390
|
-
userId:
|
|
27491
|
+
userId: text110("user_id"),
|
|
27391
27492
|
// The only identity a Plain-origin ticket has. The staff list coalesces it with
|
|
27392
27493
|
// users.email; NULL whenever userId is set.
|
|
27393
|
-
customerEmail:
|
|
27394
|
-
customerName:
|
|
27395
|
-
subject:
|
|
27396
|
-
body:
|
|
27397
|
-
status:
|
|
27494
|
+
customerEmail: text110("customer_email"),
|
|
27495
|
+
customerName: text110("customer_name"),
|
|
27496
|
+
subject: varchar82("subject", { length: 255 }).notNull(),
|
|
27497
|
+
body: text110("body").notNull(),
|
|
27498
|
+
status: varchar82("status", { length: 20 }).notNull().default("open"),
|
|
27398
27499
|
// open | pending | closed
|
|
27399
|
-
priority:
|
|
27500
|
+
priority: varchar82("priority", { length: 20 }).notNull().default("normal"),
|
|
27400
27501
|
// low | normal | high | urgent
|
|
27401
|
-
assigneeId:
|
|
27502
|
+
assigneeId: text110("assignee_id"),
|
|
27402
27503
|
// FK → users.id (staff member handling it)
|
|
27403
27504
|
// Plain's ThreadChannel, lowercased. 'api' is a ticket opened in the dashboard; the
|
|
27404
27505
|
// rest arrive from Plain. The staff reply path branches on this: 'api' threads deliver
|
|
27405
27506
|
// nothing to the customer so we send the email ourselves, every other channel is
|
|
27406
27507
|
// delivered by Plain.
|
|
27407
|
-
channel:
|
|
27508
|
+
channel: text110("channel").notNull().default("api"),
|
|
27408
27509
|
// The Plain thread this ticket mirrors. NULL until the first outbound sync succeeds,
|
|
27409
27510
|
// hence the partial unique index rather than a unique column.
|
|
27410
|
-
plainThreadId:
|
|
27511
|
+
plainThreadId: text110("plain_thread_id"),
|
|
27411
27512
|
// Files attached when the case was opened, before any message row exists.
|
|
27412
|
-
attachments:
|
|
27413
|
-
createdAt:
|
|
27414
|
-
updatedAt:
|
|
27513
|
+
attachments: jsonb59("attachments").$type().notNull().default([]),
|
|
27514
|
+
createdAt: timestamp101("created_at").notNull().defaultNow(),
|
|
27515
|
+
updatedAt: timestamp101("updated_at").notNull().defaultNow()
|
|
27415
27516
|
},
|
|
27416
27517
|
(table) => [
|
|
27417
|
-
|
|
27418
|
-
|
|
27419
|
-
|
|
27420
|
-
|
|
27518
|
+
index96("support_tickets_status_idx").on(table.status, table.updatedAt),
|
|
27519
|
+
index96("support_tickets_workspace_idx").on(table.workspaceId),
|
|
27520
|
+
index96("support_tickets_user_idx").on(table.userId),
|
|
27521
|
+
index96("support_tickets_channel_idx").on(table.channel, table.updatedAt)
|
|
27421
27522
|
]
|
|
27422
27523
|
);
|
|
27423
|
-
var supportTicketMessages =
|
|
27524
|
+
var supportTicketMessages = pgTable109(
|
|
27424
27525
|
"support_ticket_messages",
|
|
27425
27526
|
{
|
|
27426
|
-
id:
|
|
27527
|
+
id: text110("id").primaryKey(),
|
|
27427
27528
|
// nanoid
|
|
27428
|
-
ticketId:
|
|
27529
|
+
ticketId: text110("ticket_id").notNull(),
|
|
27429
27530
|
// FK → support_tickets.id
|
|
27430
|
-
authorId:
|
|
27531
|
+
authorId: text110("author_id"),
|
|
27431
27532
|
// FK → users.id (staff or customer)
|
|
27432
|
-
body:
|
|
27533
|
+
body: text110("body").notNull(),
|
|
27433
27534
|
isStaff: boolean35("is_staff").notNull().default(false),
|
|
27434
27535
|
// true = team reply
|
|
27435
27536
|
// Staff-only triage note. NEVER leaves the platform-admin lane: the customer read
|
|
@@ -27439,99 +27540,99 @@ var supportTicketMessages = pgTable107(
|
|
|
27439
27540
|
// at-least-once webhook. NULL for anything Plain never saw, and for our own replies on
|
|
27440
27541
|
// channels whose mutation returns no entry id — replyToThread returns only an error
|
|
27441
27542
|
// slot, which is why the echo check keys on the actor and this is the backstop.
|
|
27442
|
-
plainMessageId:
|
|
27443
|
-
attachments:
|
|
27444
|
-
createdAt:
|
|
27543
|
+
plainMessageId: text110("plain_message_id"),
|
|
27544
|
+
attachments: jsonb59("attachments").$type().notNull().default([]),
|
|
27545
|
+
createdAt: timestamp101("created_at").notNull().defaultNow()
|
|
27445
27546
|
},
|
|
27446
27547
|
(table) => [
|
|
27447
|
-
|
|
27548
|
+
index96("support_ticket_messages_ticket_idx").on(table.ticketId, table.createdAt)
|
|
27448
27549
|
]
|
|
27449
27550
|
);
|
|
27450
27551
|
|
|
27451
27552
|
// src/schema/admin_action_logs.ts
|
|
27452
27553
|
import {
|
|
27453
|
-
pgTable as
|
|
27454
|
-
text as
|
|
27455
|
-
varchar as
|
|
27456
|
-
jsonb as
|
|
27457
|
-
timestamp as
|
|
27458
|
-
index as
|
|
27554
|
+
pgTable as pgTable110,
|
|
27555
|
+
text as text111,
|
|
27556
|
+
varchar as varchar83,
|
|
27557
|
+
jsonb as jsonb60,
|
|
27558
|
+
timestamp as timestamp102,
|
|
27559
|
+
index as index97
|
|
27459
27560
|
} from "drizzle-orm/pg-core";
|
|
27460
|
-
var adminActionLogs =
|
|
27561
|
+
var adminActionLogs = pgTable110(
|
|
27461
27562
|
"admin_action_logs",
|
|
27462
27563
|
{
|
|
27463
|
-
id:
|
|
27564
|
+
id: text111("id").primaryKey(),
|
|
27464
27565
|
// nanoid
|
|
27465
|
-
actorId:
|
|
27566
|
+
actorId: text111("actor_id"),
|
|
27466
27567
|
// FK → users.id (the staff member)
|
|
27467
|
-
actorEmail:
|
|
27568
|
+
actorEmail: varchar83("actor_email", { length: 320 }),
|
|
27468
27569
|
// denormalized for display
|
|
27469
|
-
actorRole:
|
|
27570
|
+
actorRole: varchar83("actor_role", { length: 40 }),
|
|
27470
27571
|
// admin_role at action time
|
|
27471
|
-
action:
|
|
27572
|
+
action: varchar83("action", { length: 80 }).notNull(),
|
|
27472
27573
|
// e.g. workspace.plan_change
|
|
27473
|
-
targetType:
|
|
27574
|
+
targetType: varchar83("target_type", { length: 40 }),
|
|
27474
27575
|
// workspace | user | plan | ticket
|
|
27475
|
-
targetId:
|
|
27476
|
-
reason:
|
|
27477
|
-
metadata:
|
|
27478
|
-
ipAddress:
|
|
27479
|
-
createdAt:
|
|
27576
|
+
targetId: text111("target_id"),
|
|
27577
|
+
reason: text111("reason"),
|
|
27578
|
+
metadata: jsonb60("metadata").$type().notNull().default({}),
|
|
27579
|
+
ipAddress: text111("ip_address"),
|
|
27580
|
+
createdAt: timestamp102("created_at").notNull().defaultNow()
|
|
27480
27581
|
},
|
|
27481
27582
|
(table) => [
|
|
27482
|
-
|
|
27483
|
-
|
|
27583
|
+
index97("admin_action_logs_created_idx").on(table.createdAt),
|
|
27584
|
+
index97("admin_action_logs_action_idx").on(table.action, table.createdAt)
|
|
27484
27585
|
]
|
|
27485
27586
|
);
|
|
27486
27587
|
|
|
27487
27588
|
// src/schema/admin_notes.ts
|
|
27488
|
-
import { pgTable as
|
|
27489
|
-
var adminNotes =
|
|
27589
|
+
import { pgTable as pgTable111, text as text112, varchar as varchar84, boolean as boolean36, timestamp as timestamp103, index as index98 } from "drizzle-orm/pg-core";
|
|
27590
|
+
var adminNotes = pgTable111(
|
|
27490
27591
|
"admin_notes",
|
|
27491
27592
|
{
|
|
27492
|
-
id:
|
|
27593
|
+
id: text112("id").primaryKey(),
|
|
27493
27594
|
// nanoid
|
|
27494
|
-
targetType:
|
|
27595
|
+
targetType: varchar84("target_type", { length: 20 }).notNull(),
|
|
27495
27596
|
// user | workspace | project
|
|
27496
|
-
targetId:
|
|
27497
|
-
body:
|
|
27498
|
-
authorId:
|
|
27597
|
+
targetId: text112("target_id").notNull(),
|
|
27598
|
+
body: text112("body").notNull(),
|
|
27599
|
+
authorId: text112("author_id"),
|
|
27499
27600
|
// FK → users.id (the staff member)
|
|
27500
|
-
authorEmail:
|
|
27601
|
+
authorEmail: varchar84("author_email", { length: 320 }),
|
|
27501
27602
|
// denormalized for display
|
|
27502
27603
|
pinned: boolean36("pinned").notNull().default(false),
|
|
27503
|
-
createdAt:
|
|
27504
|
-
updatedAt:
|
|
27604
|
+
createdAt: timestamp103("created_at").notNull().defaultNow(),
|
|
27605
|
+
updatedAt: timestamp103("updated_at").notNull().defaultNow()
|
|
27505
27606
|
},
|
|
27506
27607
|
(t) => [
|
|
27507
27608
|
// Pinned first, then newest — the exact order the tab renders.
|
|
27508
|
-
|
|
27609
|
+
index98("admin_notes_target_idx").on(t.targetType, t.targetId, t.pinned, t.createdAt)
|
|
27509
27610
|
]
|
|
27510
27611
|
);
|
|
27511
27612
|
|
|
27512
27613
|
// src/schema/admin_agent_sessions.ts
|
|
27513
|
-
import { pgTable as
|
|
27514
|
-
var adminAgentSessions =
|
|
27614
|
+
import { pgTable as pgTable112, text as text113, varchar as varchar85, doublePrecision as doublePrecision2, timestamp as timestamp104, index as index99 } from "drizzle-orm/pg-core";
|
|
27615
|
+
var adminAgentSessions = pgTable112(
|
|
27515
27616
|
"admin_agent_sessions",
|
|
27516
27617
|
{
|
|
27517
|
-
id:
|
|
27618
|
+
id: text113("id").primaryKey(),
|
|
27518
27619
|
// nanoid
|
|
27519
|
-
actorId:
|
|
27620
|
+
actorId: text113("actor_id").notNull(),
|
|
27520
27621
|
// FK → users.id (the staff member)
|
|
27521
|
-
actorEmail:
|
|
27522
|
-
title:
|
|
27523
|
-
status:
|
|
27622
|
+
actorEmail: varchar85("actor_email", { length: 320 }),
|
|
27623
|
+
title: varchar85("title", { length: 200 }),
|
|
27624
|
+
status: varchar85("status", { length: 20 }).notNull().default("active"),
|
|
27524
27625
|
// active | error
|
|
27525
27626
|
costUsd: doublePrecision2("cost_usd").notNull().default(0),
|
|
27526
|
-
createdAt:
|
|
27527
|
-
updatedAt:
|
|
27528
|
-
lastActiveAt:
|
|
27627
|
+
createdAt: timestamp104("created_at").notNull().defaultNow(),
|
|
27628
|
+
updatedAt: timestamp104("updated_at").notNull().defaultNow(),
|
|
27629
|
+
lastActiveAt: timestamp104("last_active_at").notNull().defaultNow()
|
|
27529
27630
|
},
|
|
27530
|
-
(t) => [
|
|
27631
|
+
(t) => [index99("admin_agent_sessions_actor_idx").on(t.actorId, t.lastActiveAt)]
|
|
27531
27632
|
);
|
|
27532
27633
|
|
|
27533
27634
|
// src/schema/crm_deals.ts
|
|
27534
|
-
import { pgTable as
|
|
27635
|
+
import { pgTable as pgTable113, text as text114, varchar as varchar86, integer as integer55, timestamp as timestamp105, index as index100, unique as unique13 } from "drizzle-orm/pg-core";
|
|
27535
27636
|
var CRM_STAGES = [
|
|
27536
27637
|
"qualified",
|
|
27537
27638
|
"conversation",
|
|
@@ -27539,136 +27640,210 @@ var CRM_STAGES = [
|
|
|
27539
27640
|
"customer",
|
|
27540
27641
|
"at_risk"
|
|
27541
27642
|
];
|
|
27542
|
-
var crmDeals =
|
|
27643
|
+
var crmDeals = pgTable113(
|
|
27543
27644
|
"crm_deals",
|
|
27544
27645
|
{
|
|
27545
|
-
id:
|
|
27646
|
+
id: text114("id").primaryKey(),
|
|
27546
27647
|
// nanoid
|
|
27547
|
-
workspaceId:
|
|
27648
|
+
workspaceId: text114("workspace_id").notNull(),
|
|
27548
27649
|
// FK → workspaces.id
|
|
27549
|
-
stage:
|
|
27550
|
-
valueCents:
|
|
27650
|
+
stage: varchar86("stage", { length: 20 }).notNull().default("qualified").$type(),
|
|
27651
|
+
valueCents: integer55("value_cents"),
|
|
27551
27652
|
// annual contract value the rep is working toward
|
|
27552
|
-
ownerId:
|
|
27653
|
+
ownerId: text114("owner_id"),
|
|
27553
27654
|
// FK → users.id (the staff member on the account)
|
|
27554
|
-
nextStep:
|
|
27555
|
-
notes:
|
|
27556
|
-
lastTouchAt:
|
|
27557
|
-
createdAt:
|
|
27558
|
-
updatedAt:
|
|
27655
|
+
nextStep: text114("next_step"),
|
|
27656
|
+
notes: text114("notes"),
|
|
27657
|
+
lastTouchAt: timestamp105("last_touch_at"),
|
|
27658
|
+
createdAt: timestamp105("created_at").notNull().defaultNow(),
|
|
27659
|
+
updatedAt: timestamp105("updated_at").notNull().defaultNow()
|
|
27559
27660
|
},
|
|
27560
27661
|
(t) => [
|
|
27561
27662
|
unique13("crm_deals_workspace_id_key").on(t.workspaceId),
|
|
27562
|
-
|
|
27563
|
-
|
|
27663
|
+
index100("crm_deals_stage_idx").on(t.stage, t.lastTouchAt),
|
|
27664
|
+
index100("crm_deals_owner_idx").on(t.ownerId)
|
|
27564
27665
|
]
|
|
27565
27666
|
);
|
|
27566
27667
|
|
|
27567
27668
|
// src/schema/project_env_vars.ts
|
|
27568
27669
|
import {
|
|
27569
|
-
pgTable as
|
|
27570
|
-
text as
|
|
27571
|
-
varchar as
|
|
27572
|
-
timestamp as
|
|
27573
|
-
index as
|
|
27574
|
-
uniqueIndex as
|
|
27670
|
+
pgTable as pgTable114,
|
|
27671
|
+
text as text115,
|
|
27672
|
+
varchar as varchar87,
|
|
27673
|
+
timestamp as timestamp106,
|
|
27674
|
+
index as index101,
|
|
27675
|
+
uniqueIndex as uniqueIndex50
|
|
27575
27676
|
} from "drizzle-orm/pg-core";
|
|
27576
27677
|
var ENV_VAR_SCOPES = ["production", "preview", "development"];
|
|
27577
|
-
var projectEnvVars =
|
|
27678
|
+
var projectEnvVars = pgTable114(
|
|
27578
27679
|
"project_env_vars",
|
|
27579
27680
|
{
|
|
27580
|
-
id:
|
|
27681
|
+
id: text115("id").primaryKey(),
|
|
27581
27682
|
// nanoid
|
|
27582
|
-
projectId:
|
|
27683
|
+
projectId: text115("project_id").notNull(),
|
|
27583
27684
|
// FK to projects.id
|
|
27584
|
-
workspaceId:
|
|
27685
|
+
workspaceId: text115("workspace_id").notNull(),
|
|
27585
27686
|
// FK to workspaces.id — RLS scope
|
|
27586
|
-
key:
|
|
27587
|
-
valueEnc:
|
|
27687
|
+
key: varchar87("key", { length: 128 }).notNull(),
|
|
27688
|
+
valueEnc: text115("value_enc").notNull(),
|
|
27588
27689
|
// AES-256-GCM, `iv:tag:ciphertext` hex
|
|
27589
|
-
scope:
|
|
27590
|
-
updatedBy:
|
|
27690
|
+
scope: varchar87("scope", { length: 16 }).$type().notNull(),
|
|
27691
|
+
updatedBy: text115("updated_by"),
|
|
27591
27692
|
// FK to users.id, nullable
|
|
27592
|
-
updatedAt:
|
|
27593
|
-
createdAt:
|
|
27693
|
+
updatedAt: timestamp106("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27694
|
+
createdAt: timestamp106("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
27594
27695
|
},
|
|
27595
27696
|
(table) => [
|
|
27596
27697
|
// One value per key per scope — the same key MAY exist in production and preview.
|
|
27597
|
-
|
|
27698
|
+
uniqueIndex50("project_env_vars_project_key_scope_idx").on(
|
|
27598
27699
|
table.projectId,
|
|
27599
27700
|
table.key,
|
|
27600
27701
|
table.scope
|
|
27601
27702
|
),
|
|
27602
|
-
|
|
27703
|
+
index101("project_env_vars_project_idx").on(table.projectId)
|
|
27603
27704
|
]
|
|
27604
27705
|
);
|
|
27605
27706
|
|
|
27606
27707
|
// src/schema/mcp_connections.ts
|
|
27607
|
-
import { pgTable as
|
|
27708
|
+
import { pgTable as pgTable115, text as text116, varchar as varchar88, jsonb as jsonb61, timestamp as timestamp107, index as index102, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
|
|
27608
27709
|
import { sql as sql33 } from "drizzle-orm";
|
|
27609
|
-
var mcpConnections =
|
|
27710
|
+
var mcpConnections = pgTable115(
|
|
27610
27711
|
"mcp_connections",
|
|
27611
27712
|
{
|
|
27612
|
-
id:
|
|
27713
|
+
id: text116("id").primaryKey(),
|
|
27613
27714
|
// nanoid
|
|
27614
|
-
workspaceId:
|
|
27715
|
+
workspaceId: text116("workspace_id").notNull(),
|
|
27615
27716
|
// FK → workspaces.id (RLS scope)
|
|
27616
|
-
projectId:
|
|
27717
|
+
projectId: text116("project_id").notNull(),
|
|
27617
27718
|
// FK → projects.id (application-enforced)
|
|
27618
27719
|
/** Catalog slug (`notion` | `linear` | `hubspot` | `figma`) or `custom` for a user-added server. */
|
|
27619
|
-
providerSlug:
|
|
27720
|
+
providerSlug: varchar88("provider_slug", { length: 32 }).notNull(),
|
|
27620
27721
|
/** Where tools come from. See the header note — NOT interchangeable with authMode. */
|
|
27621
|
-
kind:
|
|
27722
|
+
kind: varchar88("kind", { length: 16 }).notNull().$type(),
|
|
27622
27723
|
/** How the credential is obtained. See the header note. */
|
|
27623
|
-
authMode:
|
|
27724
|
+
authMode: varchar88("auth_mode", { length: 24 }).notNull().$type(),
|
|
27624
27725
|
/** Display name. The catalog's name for a known provider; user-supplied for a custom one. */
|
|
27625
|
-
name:
|
|
27726
|
+
name: varchar88("name", { length: 120 }).notNull(),
|
|
27626
27727
|
/** Remote Streamable-HTTP endpoint. NULL for `kind: 'rest'`, which has no MCP server. */
|
|
27627
|
-
serverUrl:
|
|
27728
|
+
serverUrl: text116("server_url"),
|
|
27628
27729
|
/** Display only — the connected Notion workspace / Linear org / Figma account. */
|
|
27629
|
-
accountLabel:
|
|
27630
|
-
accessTokenEnc:
|
|
27631
|
-
refreshTokenEnc:
|
|
27632
|
-
expiresAt:
|
|
27730
|
+
accountLabel: varchar88("account_label", { length: 255 }),
|
|
27731
|
+
accessTokenEnc: text116("access_token_enc"),
|
|
27732
|
+
refreshTokenEnc: text116("refresh_token_enc"),
|
|
27733
|
+
expiresAt: timestamp107("expires_at", { withTimezone: true }),
|
|
27633
27734
|
/** `custom_headers` mode only: the encrypted header map a gateway requires on every call. */
|
|
27634
|
-
headersEnc:
|
|
27735
|
+
headersEnc: text116("headers_enc"),
|
|
27635
27736
|
/** DCR-issued or statically configured — the same two columns serve both, deliberately. */
|
|
27636
|
-
oauthClientId:
|
|
27637
|
-
oauthClientSecretEnc:
|
|
27737
|
+
oauthClientId: varchar88("oauth_client_id", { length: 255 }),
|
|
27738
|
+
oauthClientSecretEnc: text116("oauth_client_secret_enc"),
|
|
27638
27739
|
/** Both cleared on a successful exchange; see the header note on why they must exist at all. */
|
|
27639
|
-
oauthState:
|
|
27640
|
-
pkceVerifierEnc:
|
|
27740
|
+
oauthState: text116("oauth_state"),
|
|
27741
|
+
pkceVerifierEnc: text116("pkce_verifier_enc"),
|
|
27641
27742
|
/** Discovery output: authorization server metadata, token endpoint, RFC 8707 resource. */
|
|
27642
|
-
authMetadata:
|
|
27643
|
-
scopes:
|
|
27743
|
+
authMetadata: jsonb61("auth_metadata").$type(),
|
|
27744
|
+
scopes: text116("scopes").array().$type(),
|
|
27644
27745
|
/**
|
|
27645
27746
|
* Full descriptors (name, description, inputSchema, annotations) — NOT just names. The
|
|
27646
27747
|
* read-only boundary is decided from `annotations.readOnlyHint`, so the names alone would
|
|
27647
27748
|
* force a live listTools on the turn path to answer a governance question.
|
|
27648
27749
|
*/
|
|
27649
|
-
toolsCache:
|
|
27650
|
-
toolsCachedAt:
|
|
27750
|
+
toolsCache: jsonb61("tools_cache").$type().notNull().default([]),
|
|
27751
|
+
toolsCachedAt: timestamp107("tools_cached_at", { withTimezone: true }),
|
|
27651
27752
|
/**
|
|
27652
27753
|
* pending | ok | invalid | revoked. `pending` is the pre-consent row; `invalid` is set on a
|
|
27653
27754
|
* provider 401 or a decrypt failure so the UI can say "reconnect" instead of replaying the
|
|
27654
27755
|
* same auth error on every turn forever.
|
|
27655
27756
|
*/
|
|
27656
|
-
status:
|
|
27757
|
+
status: varchar88("status", { length: 16 }).notNull().default("pending").$type(),
|
|
27657
27758
|
/** Machine-readable companion to `status`, e.g. `decrypt_failed`, `provider_401`. */
|
|
27658
|
-
statusReason:
|
|
27659
|
-
lastError:
|
|
27660
|
-
lastUsedAt:
|
|
27661
|
-
connectedBy:
|
|
27759
|
+
statusReason: varchar88("status_reason", { length: 64 }),
|
|
27760
|
+
lastError: text116("last_error"),
|
|
27761
|
+
lastUsedAt: timestamp107("last_used_at", { withTimezone: true }),
|
|
27762
|
+
connectedBy: text116("connected_by"),
|
|
27662
27763
|
// FK → users(id), added in migration
|
|
27663
27764
|
...auditColumns,
|
|
27664
27765
|
...softDeleteColumn
|
|
27665
27766
|
},
|
|
27666
27767
|
(t) => [
|
|
27667
|
-
|
|
27668
|
-
|
|
27768
|
+
index102("mcp_connections_workspace_idx").on(t.workspaceId),
|
|
27769
|
+
index102("mcp_connections_project_idx").on(t.projectId),
|
|
27669
27770
|
// Reconnecting a catalog provider UPDATEs rather than accumulating a second live credential.
|
|
27670
27771
|
// Custom connectors are excluded: a project may legitimately add many distinct MCP servers.
|
|
27671
|
-
|
|
27772
|
+
uniqueIndex51("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql33`deleted_at IS NULL AND provider_slug <> 'custom'`)
|
|
27773
|
+
]
|
|
27774
|
+
);
|
|
27775
|
+
|
|
27776
|
+
// src/schema/crm_connections.ts
|
|
27777
|
+
import {
|
|
27778
|
+
pgTable as pgTable116,
|
|
27779
|
+
text as text117,
|
|
27780
|
+
timestamp as timestamp108,
|
|
27781
|
+
boolean as boolean37,
|
|
27782
|
+
jsonb as jsonb62,
|
|
27783
|
+
integer as integer56,
|
|
27784
|
+
uniqueIndex as uniqueIndex52
|
|
27785
|
+
} from "drizzle-orm/pg-core";
|
|
27786
|
+
var crmConnections = pgTable116(
|
|
27787
|
+
"crm_connections",
|
|
27788
|
+
{
|
|
27789
|
+
id: text117("id").primaryKey(),
|
|
27790
|
+
workspaceId: text117("workspace_id").notNull(),
|
|
27791
|
+
provider: text117("provider").$type().notNull(),
|
|
27792
|
+
accountId: text117("account_id").notNull(),
|
|
27793
|
+
accountName: text117("account_name").notNull(),
|
|
27794
|
+
instanceUrl: text117("instance_url").notNull(),
|
|
27795
|
+
sandbox: boolean37("sandbox").notNull().default(false),
|
|
27796
|
+
status: text117("status").notNull().default("connected"),
|
|
27797
|
+
accessToken: text117("access_token").notNull(),
|
|
27798
|
+
refreshToken: text117("refresh_token").notNull(),
|
|
27799
|
+
expiresAt: timestamp108("expires_at").notNull(),
|
|
27800
|
+
createdAt: timestamp108("created_at").notNull().defaultNow(),
|
|
27801
|
+
updatedAt: timestamp108("updated_at").notNull().defaultNow()
|
|
27802
|
+
},
|
|
27803
|
+
(t) => [
|
|
27804
|
+
uniqueIndex52("crm_connection_account_uq").on(
|
|
27805
|
+
t.workspaceId,
|
|
27806
|
+
t.provider,
|
|
27807
|
+
t.accountId
|
|
27808
|
+
)
|
|
27809
|
+
]
|
|
27810
|
+
);
|
|
27811
|
+
var crmOauthStates = pgTable116("crm_oauth_states", {
|
|
27812
|
+
id: text117("id").primaryKey(),
|
|
27813
|
+
workspaceId: text117("workspace_id").notNull(),
|
|
27814
|
+
userId: text117("user_id").notNull(),
|
|
27815
|
+
provider: text117("provider").notNull(),
|
|
27816
|
+
verifier: text117("verifier").notNull(),
|
|
27817
|
+
returnPath: text117("return_path").notNull(),
|
|
27818
|
+
sandbox: boolean37("sandbox").notNull(),
|
|
27819
|
+
expiresAt: timestamp108("expires_at").notNull()
|
|
27820
|
+
});
|
|
27821
|
+
var formIntegrationDeliveries = pgTable116(
|
|
27822
|
+
"form_integration_deliveries",
|
|
27823
|
+
{
|
|
27824
|
+
id: text117("id").primaryKey(),
|
|
27825
|
+
workspaceId: text117("workspace_id").notNull(),
|
|
27826
|
+
formId: text117("form_id").notNull(),
|
|
27827
|
+
integrationId: text117("integration_id").notNull(),
|
|
27828
|
+
eventId: text117("event_id").notNull(),
|
|
27829
|
+
submissionId: text117("submission_id").notNull(),
|
|
27830
|
+
snapshot: jsonb62("snapshot").$type().notNull(),
|
|
27831
|
+
data: jsonb62("data").$type().notNull(),
|
|
27832
|
+
status: text117("status").notNull().default("queued"),
|
|
27833
|
+
attempts: integer56("attempts").notNull().default(0),
|
|
27834
|
+
lastError: text117("last_error"),
|
|
27835
|
+
remoteRecordId: text117("remote_record_id"),
|
|
27836
|
+
nextAttemptAt: timestamp108("next_attempt_at").notNull().defaultNow(),
|
|
27837
|
+
leaseUntil: timestamp108("lease_until"),
|
|
27838
|
+
createdAt: timestamp108("created_at").notNull().defaultNow(),
|
|
27839
|
+
updatedAt: timestamp108("updated_at").notNull().defaultNow()
|
|
27840
|
+
},
|
|
27841
|
+
(t) => [
|
|
27842
|
+
uniqueIndex52("crm_delivery_event_uq").on(
|
|
27843
|
+
t.workspaceId,
|
|
27844
|
+
t.eventId,
|
|
27845
|
+
t.integrationId
|
|
27846
|
+
)
|
|
27672
27847
|
]
|
|
27673
27848
|
);
|
|
27674
27849
|
|
|
@@ -28236,6 +28411,7 @@ export {
|
|
|
28236
28411
|
bcmsMigrationFlags,
|
|
28237
28412
|
betaWaitlist,
|
|
28238
28413
|
billingAddons,
|
|
28414
|
+
billingAlerts,
|
|
28239
28415
|
billingCustomers,
|
|
28240
28416
|
branchColumns,
|
|
28241
28417
|
branchPreviewGrants,
|
|
@@ -28272,10 +28448,13 @@ export {
|
|
|
28272
28448
|
contentLocks,
|
|
28273
28449
|
contentModels,
|
|
28274
28450
|
contentModelsRelations,
|
|
28451
|
+
contentNavigation,
|
|
28275
28452
|
contentVersions,
|
|
28276
28453
|
conversionBriefsIssued,
|
|
28277
28454
|
conversionProposals,
|
|
28455
|
+
crmConnections,
|
|
28278
28456
|
crmDeals,
|
|
28457
|
+
crmOauthStates,
|
|
28279
28458
|
customDomains,
|
|
28280
28459
|
db,
|
|
28281
28460
|
deployTargets,
|
|
@@ -28290,6 +28469,7 @@ export {
|
|
|
28290
28469
|
foldersRelations,
|
|
28291
28470
|
formContacts,
|
|
28292
28471
|
formContactsRelations,
|
|
28472
|
+
formIntegrationDeliveries,
|
|
28293
28473
|
formIntegrations,
|
|
28294
28474
|
formIntegrationsRelations,
|
|
28295
28475
|
formSubmissions,
|