@bettercms-ai/db 0.12.6 → 0.13.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 +665 -3
- package/dist/index.js +1392 -1317
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11654,18 +11654,18 @@ var require_common = __commonJS({
|
|
|
11654
11654
|
if (typeof args[0] !== "string") {
|
|
11655
11655
|
args.unshift("%O");
|
|
11656
11656
|
}
|
|
11657
|
-
let
|
|
11657
|
+
let index120 = 0;
|
|
11658
11658
|
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
11659
11659
|
if (match === "%%") {
|
|
11660
11660
|
return "%";
|
|
11661
11661
|
}
|
|
11662
|
-
|
|
11662
|
+
index120++;
|
|
11663
11663
|
const formatter = createDebug.formatters[format];
|
|
11664
11664
|
if (typeof formatter === "function") {
|
|
11665
|
-
const val = args[
|
|
11665
|
+
const val = args[index120];
|
|
11666
11666
|
match = formatter.call(self2, val);
|
|
11667
|
-
args.splice(
|
|
11668
|
-
|
|
11667
|
+
args.splice(index120, 1);
|
|
11668
|
+
index120--;
|
|
11669
11669
|
}
|
|
11670
11670
|
return match;
|
|
11671
11671
|
});
|
|
@@ -11901,15 +11901,15 @@ var require_browser = __commonJS({
|
|
|
11901
11901
|
}
|
|
11902
11902
|
const c = "color: " + this.color;
|
|
11903
11903
|
args.splice(1, 0, c, "color: inherit");
|
|
11904
|
-
let
|
|
11904
|
+
let index120 = 0;
|
|
11905
11905
|
let lastC = 0;
|
|
11906
11906
|
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
11907
11907
|
if (match === "%%") {
|
|
11908
11908
|
return;
|
|
11909
11909
|
}
|
|
11910
|
-
|
|
11910
|
+
index120++;
|
|
11911
11911
|
if (match === "%c") {
|
|
11912
|
-
lastC =
|
|
11912
|
+
lastC = index120;
|
|
11913
11913
|
}
|
|
11914
11914
|
});
|
|
11915
11915
|
args.splice(lastC, 0, c);
|
|
@@ -14470,10 +14470,10 @@ var require_axios = __commonJS({
|
|
|
14470
14470
|
value = stringifyWithDepthLimit(value, 1);
|
|
14471
14471
|
} else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
|
|
14472
14472
|
key = removeBrackets(key);
|
|
14473
|
-
arr.forEach(function each(el,
|
|
14473
|
+
arr.forEach(function each(el, index120) {
|
|
14474
14474
|
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
14475
14475
|
// eslint-disable-next-line no-nested-ternary
|
|
14476
|
-
indexes === true ? renderKey([key],
|
|
14476
|
+
indexes === true ? renderKey([key], index120, dots) : indexes === null ? key : key + "[]",
|
|
14477
14477
|
convertValue(el)
|
|
14478
14478
|
);
|
|
14479
14479
|
});
|
|
@@ -14774,9 +14774,9 @@ var require_axios = __commonJS({
|
|
|
14774
14774
|
});
|
|
14775
14775
|
}
|
|
14776
14776
|
var MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
|
|
14777
|
-
function throwIfDepthExceeded(
|
|
14778
|
-
if (
|
|
14779
|
-
throw new AxiosError("FormData field is too deeply nested (" +
|
|
14777
|
+
function throwIfDepthExceeded(index120) {
|
|
14778
|
+
if (index120 > MAX_DEPTH) {
|
|
14779
|
+
throw new AxiosError("FormData field is too deeply nested (" + index120 + " levels). Max depth: " + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
|
|
14780
14780
|
}
|
|
14781
14781
|
}
|
|
14782
14782
|
function parsePropPath(name) {
|
|
@@ -14802,12 +14802,12 @@ var require_axios = __commonJS({
|
|
|
14802
14802
|
return obj;
|
|
14803
14803
|
}
|
|
14804
14804
|
function formDataToJSON(formData) {
|
|
14805
|
-
function buildPath(path2, value, target,
|
|
14806
|
-
throwIfDepthExceeded(
|
|
14807
|
-
let name = path2[
|
|
14805
|
+
function buildPath(path2, value, target, index120) {
|
|
14806
|
+
throwIfDepthExceeded(index120);
|
|
14807
|
+
let name = path2[index120++];
|
|
14808
14808
|
if (name === "__proto__") return true;
|
|
14809
14809
|
const isNumericKey = Number.isFinite(+name);
|
|
14810
|
-
const isLast =
|
|
14810
|
+
const isLast = index120 >= path2.length;
|
|
14811
14811
|
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
14812
14812
|
if (isLast) {
|
|
14813
14813
|
if (utils$1.hasOwnProp(target, name)) {
|
|
@@ -14820,7 +14820,7 @@ var require_axios = __commonJS({
|
|
|
14820
14820
|
if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|
14821
14821
|
target[name] = [];
|
|
14822
14822
|
}
|
|
14823
|
-
const result = buildPath(path2, value, target[name],
|
|
14823
|
+
const result = buildPath(path2, value, target[name], index120);
|
|
14824
14824
|
if (result && utils$1.isArray(target[name])) {
|
|
14825
14825
|
target[name] = arrayToObject(target[name]);
|
|
14826
14826
|
}
|
|
@@ -15489,20 +15489,20 @@ var require_axios = __commonJS({
|
|
|
15489
15489
|
if (parts[0] !== "127") return false;
|
|
15490
15490
|
return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
15491
15491
|
};
|
|
15492
|
-
var parseIPv4Octet = (
|
|
15493
|
-
if (/^0[xX][0-9a-fA-F]+$/.test(
|
|
15494
|
-
const n = parseInt(
|
|
15492
|
+
var parseIPv4Octet = (text136) => {
|
|
15493
|
+
if (/^0[xX][0-9a-fA-F]+$/.test(text136)) {
|
|
15494
|
+
const n = parseInt(text136.slice(2), 16);
|
|
15495
15495
|
return Number.isFinite(n) ? n : null;
|
|
15496
15496
|
}
|
|
15497
|
-
if (
|
|
15498
|
-
const n = parseInt(
|
|
15497
|
+
if (text136.length > 1 && /^0[0-7]+$/.test(text136)) {
|
|
15498
|
+
const n = parseInt(text136, 8);
|
|
15499
15499
|
return Number.isFinite(n) ? n : null;
|
|
15500
15500
|
}
|
|
15501
|
-
if (
|
|
15501
|
+
if (text136.length > 1 && /^0[0-9]+$/.test(text136)) {
|
|
15502
15502
|
return null;
|
|
15503
15503
|
}
|
|
15504
|
-
if (/^[0-9]+$/.test(
|
|
15505
|
-
const n = parseInt(
|
|
15504
|
+
if (/^[0-9]+$/.test(text136)) {
|
|
15505
|
+
const n = parseInt(text136, 10);
|
|
15506
15506
|
return Number.isFinite(n) ? n : null;
|
|
15507
15507
|
}
|
|
15508
15508
|
return null;
|
|
@@ -15840,12 +15840,12 @@ var require_axios = __commonJS({
|
|
|
15840
15840
|
};
|
|
15841
15841
|
}
|
|
15842
15842
|
function throttle(fn, freq) {
|
|
15843
|
-
let
|
|
15843
|
+
let timestamp127 = 0;
|
|
15844
15844
|
let threshold = 1e3 / freq;
|
|
15845
15845
|
let lastArgs;
|
|
15846
15846
|
let timer;
|
|
15847
15847
|
const invoke = (args, now = Date.now()) => {
|
|
15848
|
-
|
|
15848
|
+
timestamp127 = now;
|
|
15849
15849
|
lastArgs = null;
|
|
15850
15850
|
if (timer) {
|
|
15851
15851
|
clearTimeout(timer);
|
|
@@ -15855,7 +15855,7 @@ var require_axios = __commonJS({
|
|
|
15855
15855
|
};
|
|
15856
15856
|
const throttled = (...args) => {
|
|
15857
15857
|
const now = Date.now();
|
|
15858
|
-
const passed = now -
|
|
15858
|
+
const passed = now - timestamp127;
|
|
15859
15859
|
if (passed >= threshold) {
|
|
15860
15860
|
invoke(args, now);
|
|
15861
15861
|
} else {
|
|
@@ -18242,9 +18242,9 @@ var require_axios = __commonJS({
|
|
|
18242
18242
|
if (!this._listeners) {
|
|
18243
18243
|
return;
|
|
18244
18244
|
}
|
|
18245
|
-
const
|
|
18246
|
-
if (
|
|
18247
|
-
this._listeners.splice(
|
|
18245
|
+
const index120 = this._listeners.indexOf(listener);
|
|
18246
|
+
if (index120 !== -1) {
|
|
18247
|
+
this._listeners.splice(index120, 1);
|
|
18248
18248
|
}
|
|
18249
18249
|
}
|
|
18250
18250
|
toAbortSignal() {
|
|
@@ -22036,6 +22036,8 @@ __export(index_exports, {
|
|
|
22036
22036
|
customDomains: () => customDomains,
|
|
22037
22037
|
deployTargets: () => deployTargets,
|
|
22038
22038
|
deviceAuthorizations: () => deviceAuthorizations,
|
|
22039
|
+
dockUiSourceVersions: () => dockUiSourceVersions,
|
|
22040
|
+
dockUiSources: () => dockUiSources,
|
|
22039
22041
|
emailSuppressions: () => emailSuppressions,
|
|
22040
22042
|
entrySlotModels: () => entrySlotModels,
|
|
22041
22043
|
externalDeployments: () => externalDeployments,
|
|
@@ -22838,6 +22840,13 @@ var contentModels = pgTable4(
|
|
|
22838
22840
|
listPreview: jsonb5("list_preview").$type(),
|
|
22839
22841
|
/** The entries list order when the request sends no `sort`. */
|
|
22840
22842
|
defaultSort: jsonb5("default_sort").$type(),
|
|
22843
|
+
/**
|
|
22844
|
+
* V2 kit facets with no native column (0503; @bettercms-ai/types ContentModelV2): shape,
|
|
22845
|
+
* placement, category, variant chrome. No published copy: a model has none. Null = unset.
|
|
22846
|
+
*/
|
|
22847
|
+
v2: jsonb5("v2").$type(),
|
|
22848
|
+
/** "v<N>:<sha256 hex>" over the canonical definition (0503). Written by the services; null until then. */
|
|
22849
|
+
schemaHash: text5("schema_hash"),
|
|
22841
22850
|
branchId: text5("branch_id"),
|
|
22842
22851
|
originId: text5("origin_id"),
|
|
22843
22852
|
createdAt: timestamp5("created_at").notNull().defaultNow(),
|
|
@@ -26911,6 +26920,16 @@ var componentVariantGroups = pgTable82(
|
|
|
26911
26920
|
* reads as unset, and the first member stands in.
|
|
26912
26921
|
*/
|
|
26913
26922
|
defaultComponentId: text83("default_component_id"),
|
|
26923
|
+
/**
|
|
26924
|
+
* V2 kit variant chrome (0503; @bettercms-ai/types VariantGroupV2): `{ variants: [{ componentId,
|
|
26925
|
+
* icon?, description? }] }`, ORDER the array index. The live copy is taken by
|
|
26926
|
+
* publish_component_family_contract with `published_canonical_inputs`. Null = unset.
|
|
26927
|
+
*/
|
|
26928
|
+
v2: jsonb44("v2").$type(),
|
|
26929
|
+
publishedV2: jsonb44("published_v2").$type(),
|
|
26930
|
+
/** "v<N>:<sha256 hex>" over the canonical family definition (0503), and its live copy. */
|
|
26931
|
+
schemaHash: text83("schema_hash"),
|
|
26932
|
+
publishedSchemaHash: text83("published_schema_hash"),
|
|
26914
26933
|
...writeGovernanceColumns,
|
|
26915
26934
|
...auditColumns,
|
|
26916
26935
|
...softDeleteColumn
|
|
@@ -26976,7 +26995,8 @@ var components = pgTable84(
|
|
|
26976
26995
|
baseVariantName: varchar64("base_variant_name", { length: 255 }).notNull().default("Default"),
|
|
26977
26996
|
slug: varchar64("slug", { length: 255 }).notNull(),
|
|
26978
26997
|
// ^[a-z0-9-]+$, unique per (workspace, project)
|
|
26979
|
-
|
|
26998
|
+
// 32 since 0503: the kit catalogue's categories are stored verbatim ("Features & storytelling").
|
|
26999
|
+
category: varchar64("category", { length: 32 }).$type().notNull().default("custom"),
|
|
26980
27000
|
// Section library (migration 0156_component_section_type.sql): the family this component
|
|
26981
27001
|
// is a LAYOUT of, e.g. "Hero". `name` is the layout label ("Centered"), so rows sharing a
|
|
26982
27002
|
// sectionType are selectable variants of one section. NULL = an ordinary component, not
|
|
@@ -27077,6 +27097,14 @@ var components = pgTable84(
|
|
|
27077
27097
|
// props[].target.blockId/path — a live tree paired with draft prop-defs mis-targets.
|
|
27078
27098
|
publishedBlockJson: jsonb45("published_block_json").$type(),
|
|
27079
27099
|
publishedProps: jsonb45("published_props").$type(),
|
|
27100
|
+
// V2 kit facets with no native column (migration 0503; @bettercms-ai/types ComponentV2). The
|
|
27101
|
+
// draft, and its live copy taken by the same publish statements as `props`. Null = unset.
|
|
27102
|
+
v2: jsonb45("v2").$type(),
|
|
27103
|
+
publishedV2: jsonb45("published_v2").$type(),
|
|
27104
|
+
// "v<N>:<sha256 hex>" over the canonical definition (0503). Written by the services; null until
|
|
27105
|
+
// then. Its live copy rides the publish with `publishedV2`.
|
|
27106
|
+
schemaHash: text85("schema_hash"),
|
|
27107
|
+
publishedSchemaHash: text85("published_schema_hash"),
|
|
27080
27108
|
status: varchar64("status", { length: 20 }).$type().notNull().default("draft"),
|
|
27081
27109
|
publishedAt: timestamp77("published_at"),
|
|
27082
27110
|
// WHEN the live copy last changed: every publish, where `publishedAt` keeps the first (0454,
|
|
@@ -27552,30 +27580,75 @@ var schemaChangeSets = pgTable93(
|
|
|
27552
27580
|
]
|
|
27553
27581
|
);
|
|
27554
27582
|
|
|
27583
|
+
// src/schema/dock_ui_sources.ts
|
|
27584
|
+
import { index as index82, integer as integer47, jsonb as jsonb53, pgTable as pgTable94, text as text95, timestamp as timestamp87, uniqueIndex as uniqueIndex40, varchar as varchar70 } from "drizzle-orm/pg-core";
|
|
27585
|
+
var dockUiSources = pgTable94(
|
|
27586
|
+
"dock_ui_sources",
|
|
27587
|
+
{
|
|
27588
|
+
id: text95("id").primaryKey(),
|
|
27589
|
+
workspaceId: text95("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27590
|
+
projectId: text95("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27591
|
+
name: varchar70("name", { length: 64 }).notNull(),
|
|
27592
|
+
scope: text95("scope").$type().notNull(),
|
|
27593
|
+
kind: text95("kind").$type().notNull(),
|
|
27594
|
+
target: jsonb53("target").$type().notNull().default({}),
|
|
27595
|
+
headVersion: integer47("head_version").notNull().default(0),
|
|
27596
|
+
publishedVersion: integer47("published_version"),
|
|
27597
|
+
status: text95("status").$type().notNull().default("draft"),
|
|
27598
|
+
approvedBy: text95("approved_by").references(() => users.id, { onDelete: "set null" }),
|
|
27599
|
+
approvedAt: timestamp87("approved_at", { withTimezone: true }),
|
|
27600
|
+
buildReceipt: jsonb53("build_receipt").$type(),
|
|
27601
|
+
createdAt: timestamp87("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27602
|
+
updatedAt: timestamp87("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27603
|
+
},
|
|
27604
|
+
(t) => [
|
|
27605
|
+
uniqueIndex40("dock_ui_sources_project_name_idx").on(t.projectId, t.name),
|
|
27606
|
+
index82("dock_ui_sources_workspace_idx").on(t.workspaceId)
|
|
27607
|
+
]
|
|
27608
|
+
);
|
|
27609
|
+
var dockUiSourceVersions = pgTable94(
|
|
27610
|
+
"dock_ui_source_versions",
|
|
27611
|
+
{
|
|
27612
|
+
id: text95("id").primaryKey(),
|
|
27613
|
+
workspaceId: text95("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27614
|
+
sourceId: text95("source_id").notNull().references(() => dockUiSources.id, { onDelete: "cascade" }),
|
|
27615
|
+
version: integer47("version").notNull(),
|
|
27616
|
+
sourceText: text95("source_text").notNull(),
|
|
27617
|
+
sourceSha: text95("source_sha").notNull(),
|
|
27618
|
+
actorId: text95("actor_id").references(() => users.id, { onDelete: "set null" }),
|
|
27619
|
+
origin: text95("origin").$type().notNull().default("dashboard"),
|
|
27620
|
+
createdAt: timestamp87("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
27621
|
+
},
|
|
27622
|
+
(t) => [
|
|
27623
|
+
uniqueIndex40("dock_ui_source_versions_source_version_idx").on(t.sourceId, t.version),
|
|
27624
|
+
index82("dock_ui_source_versions_workspace_idx").on(t.workspaceId)
|
|
27625
|
+
]
|
|
27626
|
+
);
|
|
27627
|
+
|
|
27555
27628
|
// src/schema/component_variants.ts
|
|
27556
27629
|
import {
|
|
27557
|
-
pgTable as
|
|
27558
|
-
text as
|
|
27559
|
-
varchar as
|
|
27560
|
-
timestamp as
|
|
27561
|
-
jsonb as
|
|
27562
|
-
integer as
|
|
27563
|
-
index as
|
|
27630
|
+
pgTable as pgTable95,
|
|
27631
|
+
text as text96,
|
|
27632
|
+
varchar as varchar71,
|
|
27633
|
+
timestamp as timestamp88,
|
|
27634
|
+
jsonb as jsonb54,
|
|
27635
|
+
integer as integer48,
|
|
27636
|
+
index as index83,
|
|
27564
27637
|
unique as unique4,
|
|
27565
|
-
uniqueIndex as
|
|
27638
|
+
uniqueIndex as uniqueIndex41
|
|
27566
27639
|
} from "drizzle-orm/pg-core";
|
|
27567
27640
|
import { relations as relations15 } from "drizzle-orm/relations";
|
|
27568
27641
|
import { sql as sql22 } from "drizzle-orm";
|
|
27569
|
-
var componentVariants =
|
|
27642
|
+
var componentVariants = pgTable95(
|
|
27570
27643
|
"component_variants",
|
|
27571
27644
|
{
|
|
27572
|
-
id:
|
|
27573
|
-
workspaceId:
|
|
27574
|
-
componentId:
|
|
27575
|
-
name:
|
|
27645
|
+
id: text96("id").primaryKey(),
|
|
27646
|
+
workspaceId: text96("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27647
|
+
componentId: text96("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27648
|
+
name: varchar71("name", { length: 255 }).notNull(),
|
|
27576
27649
|
// `<component-root>-<variant-name>`, e.g. `footer-compact`.
|
|
27577
|
-
key:
|
|
27578
|
-
delta:
|
|
27650
|
+
key: varchar71("key", { length: 356 }).notNull(),
|
|
27651
|
+
delta: jsonb54("delta").$type().notNull().default({
|
|
27579
27652
|
fieldOverrides: [],
|
|
27580
27653
|
addedProps: [],
|
|
27581
27654
|
removedFieldKeys: [],
|
|
@@ -27583,13 +27656,13 @@ var componentVariants = pgTable94(
|
|
|
27583
27656
|
valueOverrides: {},
|
|
27584
27657
|
addedBlocks: []
|
|
27585
27658
|
}),
|
|
27586
|
-
publishedDelta:
|
|
27587
|
-
status:
|
|
27588
|
-
publishedAt:
|
|
27589
|
-
optimisticVersion:
|
|
27590
|
-
createdAt:
|
|
27591
|
-
updatedAt:
|
|
27592
|
-
deletedAt:
|
|
27659
|
+
publishedDelta: jsonb54("published_delta").$type(),
|
|
27660
|
+
status: varchar71("status", { length: 20 }).$type().notNull().default("draft"),
|
|
27661
|
+
publishedAt: timestamp88("published_at"),
|
|
27662
|
+
optimisticVersion: integer48("optimistic_version").notNull().default(0),
|
|
27663
|
+
createdAt: timestamp88("created_at").notNull().defaultNow(),
|
|
27664
|
+
updatedAt: timestamp88("updated_at").notNull().defaultNow(),
|
|
27665
|
+
deletedAt: timestamp88("deleted_at")
|
|
27593
27666
|
},
|
|
27594
27667
|
(table) => [
|
|
27595
27668
|
unique4("component_variants_id_workspace_component_unique").on(
|
|
@@ -27597,9 +27670,9 @@ var componentVariants = pgTable94(
|
|
|
27597
27670
|
table.workspaceId,
|
|
27598
27671
|
table.componentId
|
|
27599
27672
|
),
|
|
27600
|
-
|
|
27601
|
-
|
|
27602
|
-
|
|
27673
|
+
index83("component_variants_workspace_idx").on(table.workspaceId),
|
|
27674
|
+
index83("component_variants_component_idx").on(table.componentId),
|
|
27675
|
+
uniqueIndex41("component_variants_component_key_unique").on(table.componentId, table.key).where(sql22`${table.deletedAt} IS NULL`)
|
|
27603
27676
|
]
|
|
27604
27677
|
);
|
|
27605
27678
|
var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
|
|
@@ -27617,37 +27690,37 @@ var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
|
|
|
27617
27690
|
import {
|
|
27618
27691
|
bigint as bigint6,
|
|
27619
27692
|
foreignKey as foreignKey6,
|
|
27620
|
-
index as
|
|
27621
|
-
integer as
|
|
27622
|
-
jsonb as
|
|
27623
|
-
pgTable as
|
|
27624
|
-
text as
|
|
27625
|
-
timestamp as
|
|
27693
|
+
index as index84,
|
|
27694
|
+
integer as integer49,
|
|
27695
|
+
jsonb as jsonb55,
|
|
27696
|
+
pgTable as pgTable96,
|
|
27697
|
+
text as text97,
|
|
27698
|
+
timestamp as timestamp89,
|
|
27626
27699
|
unique as unique5,
|
|
27627
|
-
uniqueIndex as
|
|
27700
|
+
uniqueIndex as uniqueIndex42,
|
|
27628
27701
|
uuid as uuid2,
|
|
27629
|
-
varchar as
|
|
27702
|
+
varchar as varchar72
|
|
27630
27703
|
} from "drizzle-orm/pg-core";
|
|
27631
27704
|
import { sql as sql23 } from "drizzle-orm";
|
|
27632
|
-
var componentImplementationCandidates =
|
|
27705
|
+
var componentImplementationCandidates = pgTable96(
|
|
27633
27706
|
"component_implementation_candidates",
|
|
27634
27707
|
{
|
|
27635
|
-
id:
|
|
27636
|
-
workspaceId:
|
|
27637
|
-
projectId:
|
|
27638
|
-
componentId:
|
|
27639
|
-
variantGroupId:
|
|
27640
|
-
familyKey:
|
|
27641
|
-
familyContractHash:
|
|
27708
|
+
id: text97("id").primaryKey(),
|
|
27709
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27710
|
+
projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27711
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27712
|
+
variantGroupId: text97("variant_group_id"),
|
|
27713
|
+
familyKey: text97("family_key").notNull(),
|
|
27714
|
+
familyContractHash: varchar72("family_contract_hash", { length: 64 }).notNull(),
|
|
27642
27715
|
// Exact value-bearing family contract. Unlike `contract.canonicalInputs` (the
|
|
27643
27716
|
// renderer/schema projection), this snapshot deliberately retains defaults because it
|
|
27644
27717
|
// becomes the immutable public-input source pinned by each published variant.
|
|
27645
|
-
familyContract:
|
|
27646
|
-
schemaHash:
|
|
27647
|
-
brandContractHash:
|
|
27648
|
-
contract:
|
|
27649
|
-
createdBy:
|
|
27650
|
-
createdAt:
|
|
27718
|
+
familyContract: jsonb55("family_contract").$type(),
|
|
27719
|
+
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
27720
|
+
brandContractHash: varchar72("brand_contract_hash", { length: 64 }).notNull(),
|
|
27721
|
+
contract: jsonb55("contract").$type().notNull(),
|
|
27722
|
+
createdBy: text97("created_by"),
|
|
27723
|
+
createdAt: timestamp89("created_at").notNull().defaultNow()
|
|
27651
27724
|
},
|
|
27652
27725
|
(table) => [
|
|
27653
27726
|
foreignKey6({
|
|
@@ -27658,7 +27731,7 @@ var componentImplementationCandidates = pgTable95(
|
|
|
27658
27731
|
// v1 candidates (created before 0263) have no exact family-contract bytes. They must not
|
|
27659
27732
|
// occupy the v2 tuple: validation needs to append an exact candidate beside the legacy
|
|
27660
27733
|
// row instead of either mutating it or selecting it by matching hashes alone.
|
|
27661
|
-
|
|
27734
|
+
uniqueIndex42("component_implementation_candidate_exact_tuple_unique").on(
|
|
27662
27735
|
table.projectId,
|
|
27663
27736
|
table.componentId,
|
|
27664
27737
|
table.schemaHash,
|
|
@@ -27666,26 +27739,26 @@ var componentImplementationCandidates = pgTable95(
|
|
|
27666
27739
|
table.familyContractHash
|
|
27667
27740
|
).where(sql23`${table.familyContract} IS NOT NULL`),
|
|
27668
27741
|
unique5("component_implementation_candidate_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27669
|
-
|
|
27742
|
+
index84("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
|
|
27670
27743
|
]
|
|
27671
27744
|
);
|
|
27672
|
-
var componentFamilyManifests =
|
|
27745
|
+
var componentFamilyManifests = pgTable96(
|
|
27673
27746
|
"component_family_manifests",
|
|
27674
27747
|
{
|
|
27675
|
-
id:
|
|
27676
|
-
workspaceId:
|
|
27677
|
-
projectId:
|
|
27678
|
-
familyKey:
|
|
27679
|
-
familyContractHash:
|
|
27680
|
-
familyContract:
|
|
27681
|
-
commitSha:
|
|
27682
|
-
adapterHash:
|
|
27683
|
-
manifestHash:
|
|
27684
|
-
previewOrigin:
|
|
27685
|
-
nativeViewports:
|
|
27686
|
-
adapter:
|
|
27687
|
-
createdBy:
|
|
27688
|
-
createdAt:
|
|
27748
|
+
id: text97("id").primaryKey(),
|
|
27749
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27750
|
+
projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27751
|
+
familyKey: text97("family_key").notNull(),
|
|
27752
|
+
familyContractHash: varchar72("family_contract_hash", { length: 64 }).notNull(),
|
|
27753
|
+
familyContract: jsonb55("family_contract").$type(),
|
|
27754
|
+
commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
|
|
27755
|
+
adapterHash: varchar72("adapter_hash", { length: 64 }).notNull(),
|
|
27756
|
+
manifestHash: varchar72("manifest_hash", { length: 64 }).notNull(),
|
|
27757
|
+
previewOrigin: text97("preview_origin").notNull(),
|
|
27758
|
+
nativeViewports: jsonb55("native_viewports").$type().notNull(),
|
|
27759
|
+
adapter: jsonb55("adapter").$type().notNull(),
|
|
27760
|
+
createdBy: text97("created_by"),
|
|
27761
|
+
createdAt: timestamp89("created_at").notNull().defaultNow()
|
|
27689
27762
|
},
|
|
27690
27763
|
(table) => [
|
|
27691
27764
|
foreignKey6({
|
|
@@ -27696,48 +27769,48 @@ var componentFamilyManifests = pgTable95(
|
|
|
27696
27769
|
unique5("component_family_manifests_scope_unique").on(table.id, table.projectId, table.familyKey),
|
|
27697
27770
|
unique5("component_family_manifests_id_project_unique").on(table.id, table.projectId),
|
|
27698
27771
|
unique5("component_family_manifests_evidence_unique").on(table.id, table.projectId, table.manifestHash),
|
|
27699
|
-
|
|
27700
|
-
|
|
27772
|
+
uniqueIndex42("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
|
|
27773
|
+
index84("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
|
|
27701
27774
|
]
|
|
27702
27775
|
);
|
|
27703
|
-
var componentImplementationRequests =
|
|
27776
|
+
var componentImplementationRequests = pgTable96(
|
|
27704
27777
|
"component_implementation_requests",
|
|
27705
27778
|
{
|
|
27706
|
-
id:
|
|
27707
|
-
workspaceId:
|
|
27708
|
-
projectId:
|
|
27709
|
-
componentId:
|
|
27710
|
-
candidateId:
|
|
27711
|
-
componentVersion:
|
|
27712
|
-
provider:
|
|
27713
|
-
status:
|
|
27714
|
-
familyKey:
|
|
27715
|
-
familyContractHash:
|
|
27716
|
-
schemaHash:
|
|
27717
|
-
brandContractHash:
|
|
27718
|
-
dependenciesHash:
|
|
27719
|
-
commitSha:
|
|
27720
|
-
adapterHash:
|
|
27721
|
-
familyManifestHash:
|
|
27722
|
-
previewOrigin:
|
|
27723
|
-
nativeViewports:
|
|
27724
|
-
adapter:
|
|
27725
|
-
providerProvenance:
|
|
27726
|
-
claimedByApiKeyId:
|
|
27727
|
-
claimCredentialHash:
|
|
27728
|
-
claimCredentialExpiresAt:
|
|
27729
|
-
claimCredentialConsumedAt:
|
|
27730
|
-
completionHash:
|
|
27731
|
-
evidenceId:
|
|
27732
|
-
errorCode:
|
|
27733
|
-
errorMessage:
|
|
27734
|
-
requestedBy:
|
|
27735
|
-
createdAt:
|
|
27736
|
-
expiresAt:
|
|
27737
|
-
claimedAt:
|
|
27738
|
-
completedAt:
|
|
27739
|
-
failedAt:
|
|
27740
|
-
updatedAt:
|
|
27779
|
+
id: text97("id").primaryKey(),
|
|
27780
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27781
|
+
projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27782
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27783
|
+
candidateId: text97("candidate_id").notNull(),
|
|
27784
|
+
componentVersion: integer49("component_version").notNull(),
|
|
27785
|
+
provider: varchar72("provider", { length: 20 }).$type().notNull(),
|
|
27786
|
+
status: varchar72("status", { length: 20 }).$type().notNull(),
|
|
27787
|
+
familyKey: text97("family_key").notNull(),
|
|
27788
|
+
familyContractHash: varchar72("family_contract_hash", { length: 64 }).notNull(),
|
|
27789
|
+
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
27790
|
+
brandContractHash: varchar72("brand_contract_hash", { length: 64 }).notNull(),
|
|
27791
|
+
dependenciesHash: varchar72("dependencies_hash", { length: 64 }).notNull(),
|
|
27792
|
+
commitSha: varchar72("commit_sha", { length: 64 }),
|
|
27793
|
+
adapterHash: varchar72("adapter_hash", { length: 64 }),
|
|
27794
|
+
familyManifestHash: varchar72("family_manifest_hash", { length: 64 }),
|
|
27795
|
+
previewOrigin: text97("preview_origin"),
|
|
27796
|
+
nativeViewports: jsonb55("native_viewports").$type(),
|
|
27797
|
+
adapter: jsonb55("adapter").$type(),
|
|
27798
|
+
providerProvenance: jsonb55("provider_provenance").$type(),
|
|
27799
|
+
claimedByApiKeyId: text97("claimed_by_api_key_id"),
|
|
27800
|
+
claimCredentialHash: varchar72("claim_credential_hash", { length: 64 }),
|
|
27801
|
+
claimCredentialExpiresAt: timestamp89("claim_credential_expires_at", { withTimezone: true }),
|
|
27802
|
+
claimCredentialConsumedAt: timestamp89("claim_credential_consumed_at", { withTimezone: true }),
|
|
27803
|
+
completionHash: varchar72("completion_hash", { length: 64 }),
|
|
27804
|
+
evidenceId: text97("evidence_id"),
|
|
27805
|
+
errorCode: text97("error_code"),
|
|
27806
|
+
errorMessage: text97("error_message"),
|
|
27807
|
+
requestedBy: text97("requested_by"),
|
|
27808
|
+
createdAt: timestamp89("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27809
|
+
expiresAt: timestamp89("expires_at", { withTimezone: true }).notNull(),
|
|
27810
|
+
claimedAt: timestamp89("claimed_at", { withTimezone: true }),
|
|
27811
|
+
completedAt: timestamp89("completed_at", { withTimezone: true }),
|
|
27812
|
+
failedAt: timestamp89("failed_at", { withTimezone: true }),
|
|
27813
|
+
updatedAt: timestamp89("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27741
27814
|
},
|
|
27742
27815
|
(table) => [
|
|
27743
27816
|
foreignKey6({
|
|
@@ -27751,36 +27824,36 @@ var componentImplementationRequests = pgTable95(
|
|
|
27751
27824
|
name: "component_implementation_requests_candidate_fkey"
|
|
27752
27825
|
}).onDelete("cascade"),
|
|
27753
27826
|
unique5("component_implementation_requests_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27754
|
-
|
|
27755
|
-
|
|
27827
|
+
uniqueIndex42("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql23`${table.status} IN ('pending', 'claimed')`),
|
|
27828
|
+
index84("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
|
|
27756
27829
|
]
|
|
27757
27830
|
);
|
|
27758
|
-
var componentImplementationEvidence =
|
|
27831
|
+
var componentImplementationEvidence = pgTable96(
|
|
27759
27832
|
"component_implementation_evidence",
|
|
27760
27833
|
{
|
|
27761
|
-
id:
|
|
27762
|
-
workspaceId:
|
|
27763
|
-
projectId:
|
|
27764
|
-
componentId:
|
|
27765
|
-
candidateId:
|
|
27766
|
-
familyManifestId:
|
|
27767
|
-
familyManifestHash:
|
|
27768
|
-
variantBindingHash:
|
|
27769
|
-
variantBinding:
|
|
27770
|
-
requestId:
|
|
27771
|
-
schemaHash:
|
|
27772
|
-
brandContractHash:
|
|
27773
|
-
commitSha:
|
|
27774
|
-
adapterHash:
|
|
27775
|
-
previewOrigin:
|
|
27776
|
-
nativeViewports:
|
|
27777
|
-
adapter:
|
|
27778
|
-
status:
|
|
27779
|
-
checks:
|
|
27780
|
-
evidenceDigest:
|
|
27781
|
-
evidenceTupleHash:
|
|
27782
|
-
createdBy:
|
|
27783
|
-
createdAt:
|
|
27834
|
+
id: text97("id").primaryKey(),
|
|
27835
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27836
|
+
projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27837
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27838
|
+
candidateId: text97("candidate_id").notNull(),
|
|
27839
|
+
familyManifestId: text97("family_manifest_id").notNull(),
|
|
27840
|
+
familyManifestHash: varchar72("family_manifest_hash", { length: 64 }).notNull(),
|
|
27841
|
+
variantBindingHash: varchar72("variant_binding_hash", { length: 64 }).notNull(),
|
|
27842
|
+
variantBinding: jsonb55("variant_binding").$type().notNull(),
|
|
27843
|
+
requestId: text97("request_id"),
|
|
27844
|
+
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
27845
|
+
brandContractHash: varchar72("brand_contract_hash", { length: 64 }).notNull(),
|
|
27846
|
+
commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
|
|
27847
|
+
adapterHash: varchar72("adapter_hash", { length: 64 }).notNull(),
|
|
27848
|
+
previewOrigin: text97("preview_origin").notNull(),
|
|
27849
|
+
nativeViewports: jsonb55("native_viewports").$type().notNull(),
|
|
27850
|
+
adapter: jsonb55("adapter").$type().notNull(),
|
|
27851
|
+
status: varchar72("status", { length: 20 }).$type().notNull(),
|
|
27852
|
+
checks: jsonb55("checks").$type().notNull(),
|
|
27853
|
+
evidenceDigest: varchar72("evidence_digest", { length: 128 }).notNull(),
|
|
27854
|
+
evidenceTupleHash: varchar72("evidence_tuple_hash", { length: 64 }).notNull(),
|
|
27855
|
+
createdBy: text97("created_by"),
|
|
27856
|
+
createdAt: timestamp89("created_at").notNull().defaultNow()
|
|
27784
27857
|
},
|
|
27785
27858
|
(table) => [
|
|
27786
27859
|
foreignKey6({
|
|
@@ -27803,23 +27876,23 @@ var componentImplementationEvidence = pgTable95(
|
|
|
27803
27876
|
foreignColumns: [componentImplementationRequests.id, componentImplementationRequests.projectId, componentImplementationRequests.componentId],
|
|
27804
27877
|
name: "component_implementation_evidence_request_fkey"
|
|
27805
27878
|
}).onDelete("restrict"),
|
|
27806
|
-
|
|
27807
|
-
|
|
27879
|
+
uniqueIndex42("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
|
|
27880
|
+
uniqueIndex42("component_implementation_evidence_request_unique").on(table.requestId).where(sql23`${table.requestId} IS NOT NULL`),
|
|
27808
27881
|
unique5("component_implementation_evidence_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27809
|
-
|
|
27882
|
+
index84("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
|
|
27810
27883
|
]
|
|
27811
27884
|
);
|
|
27812
|
-
var componentImplementationApprovals =
|
|
27885
|
+
var componentImplementationApprovals = pgTable96(
|
|
27813
27886
|
"component_implementation_approvals",
|
|
27814
27887
|
{
|
|
27815
|
-
id:
|
|
27816
|
-
workspaceId:
|
|
27817
|
-
projectId:
|
|
27818
|
-
componentId:
|
|
27819
|
-
candidateId:
|
|
27820
|
-
evidenceId:
|
|
27821
|
-
approvedBy:
|
|
27822
|
-
approvedAt:
|
|
27888
|
+
id: text97("id").primaryKey(),
|
|
27889
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27890
|
+
projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27891
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27892
|
+
candidateId: text97("candidate_id").notNull(),
|
|
27893
|
+
evidenceId: text97("evidence_id").notNull(),
|
|
27894
|
+
approvedBy: text97("approved_by").notNull(),
|
|
27895
|
+
approvedAt: timestamp89("approved_at").notNull().defaultNow()
|
|
27823
27896
|
},
|
|
27824
27897
|
(table) => [
|
|
27825
27898
|
foreignKey6({
|
|
@@ -27837,12 +27910,12 @@ var componentImplementationApprovals = pgTable95(
|
|
|
27837
27910
|
foreignColumns: [componentImplementationEvidence.id, componentImplementationEvidence.projectId, componentImplementationEvidence.componentId],
|
|
27838
27911
|
name: "component_implementation_approvals_evidence_fkey"
|
|
27839
27912
|
}).onDelete("cascade"),
|
|
27840
|
-
|
|
27913
|
+
uniqueIndex42("component_implementation_approval_evidence_unique").on(table.evidenceId),
|
|
27841
27914
|
unique5("component_implementation_approval_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27842
|
-
|
|
27915
|
+
index84("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
|
|
27843
27916
|
]
|
|
27844
27917
|
);
|
|
27845
|
-
var componentImplementationAdapters =
|
|
27918
|
+
var componentImplementationAdapters = pgTable96(
|
|
27846
27919
|
"component_implementation_adapters",
|
|
27847
27920
|
{
|
|
27848
27921
|
// uuid generated BY THE DATABASE, unlike this file's older `text` ids with app-side prefixes.
|
|
@@ -27850,15 +27923,15 @@ var componentImplementationAdapters = pgTable95(
|
|
|
27850
27923
|
// (project_id, component_id), which is unique — so there is nothing for a readable prefix to
|
|
27851
27924
|
// help with, and one fewer identifier for a writer to have to mint correctly.
|
|
27852
27925
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
27853
|
-
workspaceId:
|
|
27854
|
-
projectId:
|
|
27855
|
-
componentId:
|
|
27856
|
-
adapter:
|
|
27857
|
-
adapterHash:
|
|
27858
|
-
source:
|
|
27859
|
-
declaredBy:
|
|
27860
|
-
declaredAt:
|
|
27861
|
-
updatedAt:
|
|
27926
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27927
|
+
projectId: text97("project_id").notNull(),
|
|
27928
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27929
|
+
adapter: jsonb55("adapter").$type().notNull(),
|
|
27930
|
+
adapterHash: varchar72("adapter_hash", { length: 64 }).notNull(),
|
|
27931
|
+
source: varchar72("source", { length: 24 }).$type().notNull(),
|
|
27932
|
+
declaredBy: text97("declared_by"),
|
|
27933
|
+
declaredAt: timestamp89("declared_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27934
|
+
updatedAt: timestamp89("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27862
27935
|
},
|
|
27863
27936
|
(table) => [
|
|
27864
27937
|
foreignKey6({
|
|
@@ -27867,30 +27940,30 @@ var componentImplementationAdapters = pgTable95(
|
|
|
27867
27940
|
name: "component_implementation_adapters_scope_fkey"
|
|
27868
27941
|
}).onDelete("cascade"),
|
|
27869
27942
|
unique5("component_implementation_adapters_component_unique").on(table.projectId, table.componentId),
|
|
27870
|
-
|
|
27943
|
+
index84("component_implementation_adapters_project_idx").on(table.projectId, table.componentId)
|
|
27871
27944
|
]
|
|
27872
27945
|
);
|
|
27873
|
-
var componentImplementationStates =
|
|
27946
|
+
var componentImplementationStates = pgTable96(
|
|
27874
27947
|
"component_implementation_states",
|
|
27875
27948
|
{
|
|
27876
|
-
id:
|
|
27877
|
-
workspaceId:
|
|
27878
|
-
projectId:
|
|
27879
|
-
componentId:
|
|
27880
|
-
selectedCandidateId:
|
|
27881
|
-
selectedEvidenceId:
|
|
27882
|
-
selectedApprovalId:
|
|
27883
|
-
publishedCandidateId:
|
|
27884
|
-
publishedEvidenceId:
|
|
27885
|
-
publishedApprovalId:
|
|
27886
|
-
requestId:
|
|
27887
|
-
requestProvider:
|
|
27888
|
-
requestStatus:
|
|
27889
|
-
requestErrorCode:
|
|
27890
|
-
requestErrorMessage:
|
|
27891
|
-
requestedBy:
|
|
27892
|
-
requestedAt:
|
|
27893
|
-
updatedAt:
|
|
27949
|
+
id: text97("id").primaryKey(),
|
|
27950
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27951
|
+
projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27952
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27953
|
+
selectedCandidateId: text97("selected_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
|
|
27954
|
+
selectedEvidenceId: text97("selected_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
|
|
27955
|
+
selectedApprovalId: text97("selected_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
|
|
27956
|
+
publishedCandidateId: text97("published_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
|
|
27957
|
+
publishedEvidenceId: text97("published_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
|
|
27958
|
+
publishedApprovalId: text97("published_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
|
|
27959
|
+
requestId: text97("request_id"),
|
|
27960
|
+
requestProvider: varchar72("request_provider", { length: 20 }).$type(),
|
|
27961
|
+
requestStatus: varchar72("request_status", { length: 20 }).$type().notNull().default("not-requested"),
|
|
27962
|
+
requestErrorCode: text97("request_error_code"),
|
|
27963
|
+
requestErrorMessage: text97("request_error_message"),
|
|
27964
|
+
requestedBy: text97("requested_by"),
|
|
27965
|
+
requestedAt: timestamp89("requested_at"),
|
|
27966
|
+
updatedAt: timestamp89("updated_at").notNull().defaultNow()
|
|
27894
27967
|
},
|
|
27895
27968
|
(table) => [
|
|
27896
27969
|
foreignKey6({
|
|
@@ -27898,25 +27971,25 @@ var componentImplementationStates = pgTable95(
|
|
|
27898
27971
|
foreignColumns: [projects.id, projects.workspaceId],
|
|
27899
27972
|
name: "component_implementation_states_project_workspace_fkey"
|
|
27900
27973
|
}).onDelete("cascade"),
|
|
27901
|
-
|
|
27902
|
-
|
|
27974
|
+
uniqueIndex42("component_implementation_states_component_unique").on(table.projectId, table.componentId),
|
|
27975
|
+
index84("component_implementation_states_workspace_idx").on(table.workspaceId)
|
|
27903
27976
|
]
|
|
27904
27977
|
);
|
|
27905
|
-
var componentPreviewSources =
|
|
27978
|
+
var componentPreviewSources = pgTable96(
|
|
27906
27979
|
"component_preview_sources",
|
|
27907
27980
|
{
|
|
27908
27981
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
27909
|
-
workspaceId:
|
|
27910
|
-
projectId:
|
|
27911
|
-
componentId:
|
|
27912
|
-
sourcePath:
|
|
27913
|
-
sourceExport:
|
|
27982
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27983
|
+
projectId: text97("project_id").notNull(),
|
|
27984
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27985
|
+
sourcePath: text97("source_path").notNull(),
|
|
27986
|
+
sourceExport: varchar72("source_export", { length: 128 }).notNull().default("default"),
|
|
27914
27987
|
/** `file`: props are the component's fields. `section`: codemod-extracted, props `{ blockId, bind, overrides, page }` (0321). */
|
|
27915
|
-
sourceKind:
|
|
27916
|
-
recordedBy:
|
|
27917
|
-
updatedBy:
|
|
27918
|
-
createdAt:
|
|
27919
|
-
updatedAt:
|
|
27988
|
+
sourceKind: varchar72("source_kind", { length: 16 }).$type().notNull().default("file"),
|
|
27989
|
+
recordedBy: varchar72("recorded_by", { length: 24 }).$type().notNull().default("agent"),
|
|
27990
|
+
updatedBy: text97("updated_by"),
|
|
27991
|
+
createdAt: timestamp89("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27992
|
+
updatedAt: timestamp89("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27920
27993
|
},
|
|
27921
27994
|
(table) => [
|
|
27922
27995
|
foreignKey6({
|
|
@@ -27925,28 +27998,28 @@ var componentPreviewSources = pgTable95(
|
|
|
27925
27998
|
name: "component_preview_sources_scope_fkey"
|
|
27926
27999
|
}).onDelete("cascade"),
|
|
27927
28000
|
unique5("component_preview_sources_component_unique").on(table.projectId, table.componentId),
|
|
27928
|
-
|
|
28001
|
+
index84("component_preview_sources_project_idx").on(table.projectId)
|
|
27929
28002
|
]
|
|
27930
28003
|
);
|
|
27931
|
-
var componentPreviewBundles =
|
|
28004
|
+
var componentPreviewBundles = pgTable96(
|
|
27932
28005
|
"component_preview_bundles",
|
|
27933
28006
|
{
|
|
27934
28007
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
27935
|
-
workspaceId:
|
|
27936
|
-
projectId:
|
|
27937
|
-
commitSha:
|
|
27938
|
-
artifactKey:
|
|
27939
|
-
checksum:
|
|
28008
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28009
|
+
projectId: text97("project_id").notNull(),
|
|
28010
|
+
commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
|
|
28011
|
+
artifactKey: text97("artifact_key").notNull(),
|
|
28012
|
+
checksum: varchar72("checksum", { length: 80 }).notNull(),
|
|
27940
28013
|
sizeBytes: bigint6("size_bytes", { mode: "number" }).notNull(),
|
|
27941
|
-
createdAt:
|
|
28014
|
+
createdAt: timestamp89("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27942
28015
|
/** The preview-runtime version that built this bundle (0330); null from a runner before 0.5.0. */
|
|
27943
|
-
runtimeVersion:
|
|
28016
|
+
runtimeVersion: text97("runtime_version"),
|
|
27944
28017
|
/** The latest runtime refresh of this commit: rebuilt with a newer runner without re-validating (0330). */
|
|
27945
28018
|
refreshId: uuid2("refresh_id"),
|
|
27946
|
-
refreshStatus:
|
|
27947
|
-
refreshErrorCode:
|
|
27948
|
-
refreshErrorMessage:
|
|
27949
|
-
refreshDispatchedAt:
|
|
28019
|
+
refreshStatus: text97("refresh_status"),
|
|
28020
|
+
refreshErrorCode: text97("refresh_error_code"),
|
|
28021
|
+
refreshErrorMessage: text97("refresh_error_message"),
|
|
28022
|
+
refreshDispatchedAt: timestamp89("refresh_dispatched_at", { withTimezone: true })
|
|
27950
28023
|
},
|
|
27951
28024
|
(table) => [
|
|
27952
28025
|
foreignKey6({
|
|
@@ -27955,7 +28028,7 @@ var componentPreviewBundles = pgTable95(
|
|
|
27955
28028
|
name: "component_preview_bundles_scope_fkey"
|
|
27956
28029
|
}).onDelete("cascade"),
|
|
27957
28030
|
unique5("component_preview_bundles_commit_unique").on(table.projectId, table.commitSha),
|
|
27958
|
-
|
|
28031
|
+
index84("component_preview_bundles_project_idx").on(table.projectId, table.createdAt)
|
|
27959
28032
|
]
|
|
27960
28033
|
);
|
|
27961
28034
|
|
|
@@ -27964,17 +28037,17 @@ import { sql as sql24 } from "drizzle-orm";
|
|
|
27964
28037
|
import {
|
|
27965
28038
|
check as check5,
|
|
27966
28039
|
foreignKey as foreignKey7,
|
|
27967
|
-
index as
|
|
27968
|
-
integer as
|
|
27969
|
-
jsonb as
|
|
27970
|
-
pgTable as
|
|
28040
|
+
index as index85,
|
|
28041
|
+
integer as integer50,
|
|
28042
|
+
jsonb as jsonb56,
|
|
28043
|
+
pgTable as pgTable97,
|
|
27971
28044
|
primaryKey as primaryKey10,
|
|
27972
|
-
text as
|
|
27973
|
-
timestamp as
|
|
28045
|
+
text as text98,
|
|
28046
|
+
timestamp as timestamp90,
|
|
27974
28047
|
unique as unique6,
|
|
27975
|
-
uniqueIndex as
|
|
28048
|
+
uniqueIndex as uniqueIndex43,
|
|
27976
28049
|
uuid as uuid3,
|
|
27977
|
-
varchar as
|
|
28050
|
+
varchar as varchar73
|
|
27978
28051
|
} from "drizzle-orm/pg-core";
|
|
27979
28052
|
var ORCHESTRATION_RUN_STATUSES = [
|
|
27980
28053
|
"open",
|
|
@@ -27984,15 +28057,15 @@ var ORCHESTRATION_RUN_STATUSES = [
|
|
|
27984
28057
|
"completed",
|
|
27985
28058
|
"abandoned"
|
|
27986
28059
|
];
|
|
27987
|
-
var projectOrchestrationStates =
|
|
28060
|
+
var projectOrchestrationStates = pgTable97(
|
|
27988
28061
|
"project_orchestration_states",
|
|
27989
28062
|
{
|
|
27990
|
-
projectId:
|
|
27991
|
-
workspaceId:
|
|
27992
|
-
generation:
|
|
27993
|
-
enabledBy:
|
|
27994
|
-
enabledAt:
|
|
27995
|
-
updatedAt:
|
|
28063
|
+
projectId: text98("project_id").primaryKey().references(() => projects.id, { onDelete: "cascade" }),
|
|
28064
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28065
|
+
generation: integer50("generation").notNull().default(2),
|
|
28066
|
+
enabledBy: text98("enabled_by").notNull(),
|
|
28067
|
+
enabledAt: timestamp90("enabled_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28068
|
+
updatedAt: timestamp90("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27996
28069
|
},
|
|
27997
28070
|
(table) => [
|
|
27998
28071
|
foreignKey7({
|
|
@@ -28002,31 +28075,31 @@ var projectOrchestrationStates = pgTable96(
|
|
|
28002
28075
|
}).onDelete("cascade"),
|
|
28003
28076
|
unique6("project_orchestration_states_scope_unique").on(table.projectId, table.workspaceId),
|
|
28004
28077
|
check5("project_orchestration_states_generation_check", sql24`${table.generation} >= 2`),
|
|
28005
|
-
|
|
28078
|
+
index85("project_orchestration_states_workspace_idx").on(table.workspaceId)
|
|
28006
28079
|
]
|
|
28007
28080
|
);
|
|
28008
|
-
var orchestrationRuns =
|
|
28081
|
+
var orchestrationRuns = pgTable97(
|
|
28009
28082
|
"orchestration_runs",
|
|
28010
28083
|
{
|
|
28011
28084
|
id: uuid3("id").primaryKey().defaultRandom(),
|
|
28012
|
-
workspaceId:
|
|
28013
|
-
projectId:
|
|
28014
|
-
projectGeneration:
|
|
28015
|
-
startIdempotencyKey:
|
|
28016
|
-
targetKind:
|
|
28017
|
-
targetId:
|
|
28018
|
-
targetVariantId:
|
|
28019
|
-
targetMetadata:
|
|
28020
|
-
status:
|
|
28021
|
-
activeStage:
|
|
28022
|
-
version:
|
|
28023
|
-
preferredExecutorId:
|
|
28024
|
-
cancellationRequestedAt:
|
|
28025
|
-
cancellationRequestedBy:
|
|
28026
|
-
createdBy:
|
|
28027
|
-
policyVersion:
|
|
28028
|
-
createdAt:
|
|
28029
|
-
updatedAt:
|
|
28085
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28086
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28087
|
+
projectGeneration: integer50("project_generation").notNull(),
|
|
28088
|
+
startIdempotencyKey: text98("start_idempotency_key").notNull(),
|
|
28089
|
+
targetKind: varchar73("target_kind", { length: 32 }).$type().notNull().default("component-variant"),
|
|
28090
|
+
targetId: text98("target_id").notNull().references(() => components.id, { onDelete: "no action" }),
|
|
28091
|
+
targetVariantId: text98("target_variant_id"),
|
|
28092
|
+
targetMetadata: jsonb56("target_metadata").$type().notNull(),
|
|
28093
|
+
status: varchar73("status", { length: 20 }).$type().notNull().default("open"),
|
|
28094
|
+
activeStage: varchar73("active_stage", { length: 64 }).notNull().default("awaiting-executor"),
|
|
28095
|
+
version: integer50("version").notNull().default(1),
|
|
28096
|
+
preferredExecutorId: text98("preferred_executor_id"),
|
|
28097
|
+
cancellationRequestedAt: timestamp90("cancellation_requested_at", { withTimezone: true }),
|
|
28098
|
+
cancellationRequestedBy: text98("cancellation_requested_by"),
|
|
28099
|
+
createdBy: text98("created_by").notNull(),
|
|
28100
|
+
policyVersion: varchar73("policy_version", { length: 64 }).notNull().default("orchestration-v2"),
|
|
28101
|
+
createdAt: timestamp90("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28102
|
+
updatedAt: timestamp90("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28030
28103
|
},
|
|
28031
28104
|
(table) => [
|
|
28032
28105
|
foreignKey7({
|
|
@@ -28049,15 +28122,15 @@ var orchestrationRuns = pgTable96(
|
|
|
28049
28122
|
table.projectId,
|
|
28050
28123
|
table.startIdempotencyKey
|
|
28051
28124
|
),
|
|
28052
|
-
|
|
28053
|
-
|
|
28125
|
+
uniqueIndex43("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql24`${table.status} IN ('open', 'paused', 'cancelling')`),
|
|
28126
|
+
index85("orchestration_runs_project_target_idx").on(
|
|
28054
28127
|
table.projectId,
|
|
28055
28128
|
table.targetKind,
|
|
28056
28129
|
table.targetId,
|
|
28057
28130
|
table.targetVariantId,
|
|
28058
28131
|
table.createdAt
|
|
28059
28132
|
),
|
|
28060
|
-
|
|
28133
|
+
index85("orchestration_runs_workspace_status_idx").on(
|
|
28061
28134
|
table.workspaceId,
|
|
28062
28135
|
table.status,
|
|
28063
28136
|
table.updatedAt
|
|
@@ -28144,14 +28217,14 @@ var orchestrationRuns = pgTable96(
|
|
|
28144
28217
|
check5("orchestration_runs_timestamps_check", sql24`${table.updatedAt} >= ${table.createdAt}`)
|
|
28145
28218
|
]
|
|
28146
28219
|
);
|
|
28147
|
-
var orchestrationRunStartKeys =
|
|
28220
|
+
var orchestrationRunStartKeys = pgTable97(
|
|
28148
28221
|
"orchestration_run_start_keys",
|
|
28149
28222
|
{
|
|
28150
|
-
workspaceId:
|
|
28151
|
-
projectId:
|
|
28152
|
-
idempotencyKey:
|
|
28223
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28224
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28225
|
+
idempotencyKey: text98("idempotency_key").notNull(),
|
|
28153
28226
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28154
|
-
createdAt:
|
|
28227
|
+
createdAt: timestamp90("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28155
28228
|
},
|
|
28156
28229
|
(table) => [
|
|
28157
28230
|
primaryKey10({ columns: [table.projectId, table.idempotencyKey] }),
|
|
@@ -28160,33 +28233,33 @@ var orchestrationRunStartKeys = pgTable96(
|
|
|
28160
28233
|
foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
|
|
28161
28234
|
name: "orchestration_run_start_keys_run_scope_fkey"
|
|
28162
28235
|
}).onDelete("cascade"),
|
|
28163
|
-
|
|
28236
|
+
index85("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
|
|
28164
28237
|
check5(
|
|
28165
28238
|
"orchestration_run_start_keys_idempotency_key_check",
|
|
28166
28239
|
sql24`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
|
|
28167
28240
|
)
|
|
28168
28241
|
]
|
|
28169
28242
|
);
|
|
28170
|
-
var orchestrationRunEvents =
|
|
28243
|
+
var orchestrationRunEvents = pgTable97(
|
|
28171
28244
|
"orchestration_run_events",
|
|
28172
28245
|
{
|
|
28173
28246
|
id: uuid3("id").primaryKey().defaultRandom(),
|
|
28174
28247
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28175
|
-
workspaceId:
|
|
28176
|
-
projectId:
|
|
28177
|
-
sequence:
|
|
28178
|
-
schemaVersion:
|
|
28179
|
-
idempotencyKey:
|
|
28180
|
-
type:
|
|
28181
|
-
actorType:
|
|
28182
|
-
actorId:
|
|
28183
|
-
causationId:
|
|
28184
|
-
correlationId:
|
|
28185
|
-
payload:
|
|
28186
|
-
payloadDigest:
|
|
28248
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28249
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28250
|
+
sequence: integer50("sequence").notNull(),
|
|
28251
|
+
schemaVersion: integer50("schema_version").notNull().default(1),
|
|
28252
|
+
idempotencyKey: text98("idempotency_key").notNull(),
|
|
28253
|
+
type: varchar73("type", { length: 100 }).notNull(),
|
|
28254
|
+
actorType: varchar73("actor_type", { length: 32 }).notNull(),
|
|
28255
|
+
actorId: text98("actor_id").notNull(),
|
|
28256
|
+
causationId: text98("causation_id"),
|
|
28257
|
+
correlationId: text98("correlation_id"),
|
|
28258
|
+
payload: jsonb56("payload").$type().notNull().default({}),
|
|
28259
|
+
payloadDigest: varchar73("payload_digest", { length: 71 }).generatedAlwaysAs(
|
|
28187
28260
|
sql24`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
|
|
28188
28261
|
),
|
|
28189
|
-
createdAt:
|
|
28262
|
+
createdAt: timestamp90("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28190
28263
|
},
|
|
28191
28264
|
(table) => [
|
|
28192
28265
|
foreignKey7({
|
|
@@ -28196,7 +28269,7 @@ var orchestrationRunEvents = pgTable96(
|
|
|
28196
28269
|
}).onDelete("cascade"),
|
|
28197
28270
|
unique6("orchestration_run_events_sequence_unique").on(table.runId, table.sequence),
|
|
28198
28271
|
unique6("orchestration_run_events_idempotency_unique").on(table.runId, table.idempotencyKey),
|
|
28199
|
-
|
|
28272
|
+
index85("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
|
|
28200
28273
|
check5("orchestration_run_events_sequence_check", sql24`${table.sequence} >= 1`),
|
|
28201
28274
|
check5("orchestration_run_events_schema_version_check", sql24`${table.schemaVersion} >= 1`),
|
|
28202
28275
|
check5(
|
|
@@ -28212,20 +28285,20 @@ var orchestrationRunEvents = pgTable96(
|
|
|
28212
28285
|
)
|
|
28213
28286
|
]
|
|
28214
28287
|
);
|
|
28215
|
-
var orchestrationRunCommandResults =
|
|
28288
|
+
var orchestrationRunCommandResults = pgTable97(
|
|
28216
28289
|
"orchestration_run_command_results",
|
|
28217
28290
|
{
|
|
28218
28291
|
commandId: uuid3("command_id").primaryKey(),
|
|
28219
|
-
workspaceId:
|
|
28220
|
-
projectId:
|
|
28292
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28293
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28221
28294
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28222
|
-
command:
|
|
28223
|
-
expectedVersion:
|
|
28224
|
-
resultingVersion:
|
|
28225
|
-
actorId:
|
|
28295
|
+
command: varchar73("command", { length: 20 }).$type().notNull(),
|
|
28296
|
+
expectedVersion: integer50("expected_version").notNull(),
|
|
28297
|
+
resultingVersion: integer50("resulting_version").notNull(),
|
|
28298
|
+
actorId: text98("actor_id").notNull(),
|
|
28226
28299
|
eventId: uuid3("event_id").notNull().references(() => orchestrationRunEvents.id, { onDelete: "cascade" }),
|
|
28227
|
-
resultPayload:
|
|
28228
|
-
createdAt:
|
|
28300
|
+
resultPayload: jsonb56("result_payload").$type().notNull(),
|
|
28301
|
+
createdAt: timestamp90("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28229
28302
|
},
|
|
28230
28303
|
(table) => [
|
|
28231
28304
|
foreignKey7({
|
|
@@ -28233,8 +28306,8 @@ var orchestrationRunCommandResults = pgTable96(
|
|
|
28233
28306
|
foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
|
|
28234
28307
|
name: "orchestration_run_command_results_run_scope_fkey"
|
|
28235
28308
|
}).onDelete("cascade"),
|
|
28236
|
-
|
|
28237
|
-
|
|
28309
|
+
index85("orchestration_run_command_results_run_created_idx").on(table.runId, table.createdAt),
|
|
28310
|
+
index85("orchestration_run_command_results_project_created_idx").on(
|
|
28238
28311
|
table.projectId,
|
|
28239
28312
|
table.createdAt
|
|
28240
28313
|
),
|
|
@@ -28268,16 +28341,16 @@ import {
|
|
|
28268
28341
|
boolean as boolean32,
|
|
28269
28342
|
check as check6,
|
|
28270
28343
|
foreignKey as foreignKey8,
|
|
28271
|
-
index as
|
|
28272
|
-
integer as
|
|
28273
|
-
jsonb as
|
|
28274
|
-
pgTable as
|
|
28275
|
-
text as
|
|
28276
|
-
timestamp as
|
|
28344
|
+
index as index86,
|
|
28345
|
+
integer as integer51,
|
|
28346
|
+
jsonb as jsonb57,
|
|
28347
|
+
pgTable as pgTable98,
|
|
28348
|
+
text as text99,
|
|
28349
|
+
timestamp as timestamp91,
|
|
28277
28350
|
unique as unique7,
|
|
28278
|
-
uniqueIndex as
|
|
28351
|
+
uniqueIndex as uniqueIndex44,
|
|
28279
28352
|
uuid as uuid4,
|
|
28280
|
-
varchar as
|
|
28353
|
+
varchar as varchar74
|
|
28281
28354
|
} from "drizzle-orm/pg-core";
|
|
28282
28355
|
var EXECUTOR_KINDS = ["dashboard-agent", "native-bridge"];
|
|
28283
28356
|
var EXECUTOR_INSTALLATION_STATUSES = ["active", "revoked", "incompatible"];
|
|
@@ -28318,20 +28391,20 @@ var EXECUTOR_COMMAND_KINDS = [
|
|
|
28318
28391
|
"cancel",
|
|
28319
28392
|
"handoff"
|
|
28320
28393
|
];
|
|
28321
|
-
var orchestrationExecutorInstallations =
|
|
28394
|
+
var orchestrationExecutorInstallations = pgTable98(
|
|
28322
28395
|
"orchestration_executor_installations",
|
|
28323
28396
|
{
|
|
28324
28397
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28325
|
-
workspaceId:
|
|
28326
|
-
projectId:
|
|
28327
|
-
kind:
|
|
28328
|
-
grantId:
|
|
28329
|
-
protocolVersion:
|
|
28330
|
-
capabilityDigest:
|
|
28331
|
-
repositoryClaim:
|
|
28332
|
-
status:
|
|
28333
|
-
createdAt:
|
|
28334
|
-
updatedAt:
|
|
28398
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28399
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28400
|
+
kind: varchar74("kind", { length: 24 }).$type().notNull(),
|
|
28401
|
+
grantId: text99("grant_id").references(() => deviceAuthorizations.id, { onDelete: "cascade" }),
|
|
28402
|
+
protocolVersion: varchar74("protocol_version", { length: 16 }).notNull(),
|
|
28403
|
+
capabilityDigest: text99("capability_digest").notNull(),
|
|
28404
|
+
repositoryClaim: jsonb57("repository_claim").$type().notNull().default({}),
|
|
28405
|
+
status: varchar74("status", { length: 20 }).$type().notNull().default("active"),
|
|
28406
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28407
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28335
28408
|
},
|
|
28336
28409
|
(table) => [
|
|
28337
28410
|
foreignKey8({
|
|
@@ -28344,12 +28417,12 @@ var orchestrationExecutorInstallations = pgTable97(
|
|
|
28344
28417
|
table.workspaceId,
|
|
28345
28418
|
table.projectId
|
|
28346
28419
|
),
|
|
28347
|
-
|
|
28420
|
+
index86("orchestration_executor_installations_project_status_idx").on(
|
|
28348
28421
|
table.projectId,
|
|
28349
28422
|
table.status
|
|
28350
28423
|
),
|
|
28351
|
-
|
|
28352
|
-
|
|
28424
|
+
uniqueIndex44("orchestration_executor_installations_grant_unique").on(table.projectId, table.grantId).where(sql25`${table.grantId} IS NOT NULL AND ${table.status} = 'active'`),
|
|
28425
|
+
uniqueIndex44("orchestration_executor_installations_dashboard_unique").on(table.projectId).where(sql25`${table.kind} = 'dashboard-agent' AND ${table.status} = 'active'`),
|
|
28353
28426
|
check6(
|
|
28354
28427
|
"orchestration_executor_installations_kind_check",
|
|
28355
28428
|
sql25`${table.kind} IN ('dashboard-agent', 'native-bridge')`
|
|
@@ -28381,24 +28454,24 @@ var orchestrationExecutorInstallations = pgTable97(
|
|
|
28381
28454
|
)
|
|
28382
28455
|
]
|
|
28383
28456
|
);
|
|
28384
|
-
var orchestrationExecutorSessions =
|
|
28457
|
+
var orchestrationExecutorSessions = pgTable98(
|
|
28385
28458
|
"orchestration_executor_sessions",
|
|
28386
28459
|
{
|
|
28387
28460
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28388
|
-
workspaceId:
|
|
28389
|
-
projectId:
|
|
28461
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28462
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28390
28463
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
28391
|
-
sessionEpoch:
|
|
28392
|
-
credentialAudience:
|
|
28393
|
-
state:
|
|
28464
|
+
sessionEpoch: integer51("session_epoch").notNull().default(1),
|
|
28465
|
+
credentialAudience: varchar74("credential_audience", { length: 64 }).notNull(),
|
|
28466
|
+
state: varchar74("state", { length: 20 }).$type().notNull().default("open"),
|
|
28394
28467
|
clientCursor: bigint7("client_cursor", { mode: "number" }).notNull().default(0),
|
|
28395
28468
|
serverCursor: bigint7("server_cursor", { mode: "number" }).notNull().default(0),
|
|
28396
|
-
connectedAt:
|
|
28397
|
-
lastHeartbeatAt:
|
|
28398
|
-
serverReceivedAt:
|
|
28399
|
-
closedAt:
|
|
28400
|
-
createdAt:
|
|
28401
|
-
updatedAt:
|
|
28469
|
+
connectedAt: timestamp91("connected_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28470
|
+
lastHeartbeatAt: timestamp91("last_heartbeat_at", { withTimezone: true }),
|
|
28471
|
+
serverReceivedAt: timestamp91("server_received_at", { withTimezone: true }),
|
|
28472
|
+
closedAt: timestamp91("closed_at", { withTimezone: true }),
|
|
28473
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28474
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28402
28475
|
},
|
|
28403
28476
|
(table) => [
|
|
28404
28477
|
foreignKey8({
|
|
@@ -28419,11 +28492,11 @@ var orchestrationExecutorSessions = pgTable97(
|
|
|
28419
28492
|
table.installationId,
|
|
28420
28493
|
table.sessionEpoch
|
|
28421
28494
|
),
|
|
28422
|
-
|
|
28495
|
+
index86("orchestration_executor_sessions_installation_state_idx").on(
|
|
28423
28496
|
table.installationId,
|
|
28424
28497
|
table.state
|
|
28425
28498
|
),
|
|
28426
|
-
|
|
28499
|
+
index86("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql25`${table.state} = 'open'`),
|
|
28427
28500
|
check6("orchestration_executor_sessions_epoch_check", sql25`${table.sessionEpoch} >= 1`),
|
|
28428
28501
|
check6(
|
|
28429
28502
|
"orchestration_executor_sessions_state_check",
|
|
@@ -28447,39 +28520,39 @@ var orchestrationExecutorSessions = pgTable97(
|
|
|
28447
28520
|
)
|
|
28448
28521
|
]
|
|
28449
28522
|
);
|
|
28450
|
-
var orchestrationImplementationAttempts =
|
|
28523
|
+
var orchestrationImplementationAttempts = pgTable98(
|
|
28451
28524
|
"orchestration_implementation_attempts",
|
|
28452
28525
|
{
|
|
28453
28526
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28454
|
-
workspaceId:
|
|
28455
|
-
projectId:
|
|
28527
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28528
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28456
28529
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28457
28530
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
28458
|
-
attemptNumber:
|
|
28459
|
-
targetKind:
|
|
28460
|
-
targetId:
|
|
28461
|
-
targetBindingDigest:
|
|
28531
|
+
attemptNumber: integer51("attempt_number").notNull(),
|
|
28532
|
+
targetKind: varchar74("target_kind", { length: 32 }).notNull().default("component-variant"),
|
|
28533
|
+
targetId: text99("target_id").notNull(),
|
|
28534
|
+
targetBindingDigest: text99("target_binding_digest").notNull(),
|
|
28462
28535
|
repositoryId: bigint7("repository_id", { mode: "number" }),
|
|
28463
|
-
baseBranch:
|
|
28464
|
-
baseSha:
|
|
28536
|
+
baseBranch: varchar74("base_branch", { length: 255 }),
|
|
28537
|
+
baseSha: varchar74("base_sha", { length: 64 }),
|
|
28465
28538
|
/**
|
|
28466
28539
|
* The branch this attempt created, recorded BEFORE the first write lands on it. This is the
|
|
28467
28540
|
* crash-safety line: if the process dies holding a branch, cancellation and reconciliation can
|
|
28468
28541
|
* still find it. Null until the branch exists. Shape-checked to run branches only (0278).
|
|
28469
28542
|
*/
|
|
28470
|
-
createdRef:
|
|
28471
|
-
status:
|
|
28543
|
+
createdRef: text99("created_ref"),
|
|
28544
|
+
status: varchar74("status", { length: 24 }).$type().notNull().default("preflight"),
|
|
28472
28545
|
supersededBy: uuid4("superseded_by"),
|
|
28473
28546
|
/**
|
|
28474
28547
|
* Withdrawal (0284): the three facts travel together or not at all, enforced by a CHECK. A
|
|
28475
28548
|
* withdrawn attempt's pull request is kept BY URL, so a reader of the run never has to
|
|
28476
28549
|
* discover from GitHub that one used to exist here.
|
|
28477
28550
|
*/
|
|
28478
|
-
withdrawnAt:
|
|
28479
|
-
withdrawnBy:
|
|
28480
|
-
withdrawnPullRequestUrl:
|
|
28481
|
-
createdAt:
|
|
28482
|
-
updatedAt:
|
|
28551
|
+
withdrawnAt: timestamp91("withdrawn_at", { withTimezone: true }),
|
|
28552
|
+
withdrawnBy: text99("withdrawn_by"),
|
|
28553
|
+
withdrawnPullRequestUrl: text99("withdrawn_pull_request_url"),
|
|
28554
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28555
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28483
28556
|
},
|
|
28484
28557
|
(table) => [
|
|
28485
28558
|
foreignKey8({
|
|
@@ -28514,7 +28587,7 @@ var orchestrationImplementationAttempts = pgTable97(
|
|
|
28514
28587
|
table.runId,
|
|
28515
28588
|
table.attemptNumber
|
|
28516
28589
|
),
|
|
28517
|
-
|
|
28590
|
+
index86("orchestration_implementation_attempts_run_created_idx").on(
|
|
28518
28591
|
table.runId,
|
|
28519
28592
|
table.createdAt
|
|
28520
28593
|
),
|
|
@@ -28545,135 +28618,135 @@ var orchestrationImplementationAttempts = pgTable97(
|
|
|
28545
28618
|
)
|
|
28546
28619
|
]
|
|
28547
28620
|
);
|
|
28548
|
-
var orchestrationPlanSnapshots =
|
|
28621
|
+
var orchestrationPlanSnapshots = pgTable98(
|
|
28549
28622
|
"orchestration_plan_snapshots",
|
|
28550
28623
|
{
|
|
28551
|
-
planDigest:
|
|
28552
|
-
workspaceId:
|
|
28553
|
-
projectId:
|
|
28554
|
-
baseHeadOid:
|
|
28555
|
-
budget:
|
|
28556
|
-
files:
|
|
28557
|
-
fileCount:
|
|
28624
|
+
planDigest: text99("plan_digest").primaryKey(),
|
|
28625
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28626
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28627
|
+
baseHeadOid: varchar74("base_head_oid", { length: 64 }).notNull(),
|
|
28628
|
+
budget: jsonb57("budget").notNull(),
|
|
28629
|
+
files: jsonb57("files").notNull(),
|
|
28630
|
+
fileCount: integer51("file_count").notNull(),
|
|
28558
28631
|
byteCount: bigint7("byte_count", { mode: "number" }).notNull(),
|
|
28559
|
-
createdAt:
|
|
28632
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28560
28633
|
},
|
|
28561
|
-
(table) => [
|
|
28634
|
+
(table) => [index86("orchestration_plan_snapshots_project_idx").on(table.workspaceId, table.projectId, table.createdAt)]
|
|
28562
28635
|
);
|
|
28563
|
-
var orchestrationVisualApprovals =
|
|
28636
|
+
var orchestrationVisualApprovals = pgTable98(
|
|
28564
28637
|
"orchestration_visual_approvals",
|
|
28565
28638
|
{
|
|
28566
28639
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28567
|
-
workspaceId:
|
|
28568
|
-
projectId:
|
|
28640
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28641
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28569
28642
|
runId: uuid4("run_id").notNull(),
|
|
28570
28643
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28571
|
-
headSha:
|
|
28644
|
+
headSha: varchar74("head_sha", { length: 64 }).notNull(),
|
|
28572
28645
|
evidenceId: uuid4("evidence_id").notNull(),
|
|
28573
|
-
authorizedBy:
|
|
28574
|
-
idempotencyKey:
|
|
28575
|
-
expiresAt:
|
|
28576
|
-
consumedAt:
|
|
28577
|
-
consumedByRef:
|
|
28578
|
-
createdAt:
|
|
28579
|
-
updatedAt:
|
|
28646
|
+
authorizedBy: text99("authorized_by").notNull(),
|
|
28647
|
+
idempotencyKey: text99("idempotency_key").notNull(),
|
|
28648
|
+
expiresAt: timestamp91("expires_at", { withTimezone: true }).notNull(),
|
|
28649
|
+
consumedAt: timestamp91("consumed_at", { withTimezone: true }),
|
|
28650
|
+
consumedByRef: text99("consumed_by_ref"),
|
|
28651
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28652
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28580
28653
|
}
|
|
28581
28654
|
);
|
|
28582
|
-
var orchestrationMergeAuthorizations =
|
|
28655
|
+
var orchestrationMergeAuthorizations = pgTable98(
|
|
28583
28656
|
"orchestration_merge_authorizations",
|
|
28584
28657
|
{
|
|
28585
28658
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28586
|
-
workspaceId:
|
|
28587
|
-
projectId:
|
|
28659
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28660
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28588
28661
|
runId: uuid4("run_id").notNull(),
|
|
28589
28662
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28590
|
-
pullRequestNumber:
|
|
28591
|
-
expectedHeadSha:
|
|
28663
|
+
pullRequestNumber: integer51("pull_request_number").notNull(),
|
|
28664
|
+
expectedHeadSha: varchar74("expected_head_sha", { length: 64 }).notNull(),
|
|
28592
28665
|
visualApprovalId: uuid4("visual_approval_id").notNull(),
|
|
28593
28666
|
/**
|
|
28594
28667
|
* 0285. A void is a first-class END, not a consumption with a special ref: consumption records
|
|
28595
28668
|
* what an authorization BOUGHT, and a void bought nothing. A CHECK keeps the three together and
|
|
28596
28669
|
* forbids a row that is both spent and voided.
|
|
28597
28670
|
*/
|
|
28598
|
-
voidedAt:
|
|
28599
|
-
voidedBy:
|
|
28600
|
-
voidReason:
|
|
28601
|
-
authorizedBy:
|
|
28602
|
-
idempotencyKey:
|
|
28603
|
-
expiresAt:
|
|
28604
|
-
consumedAt:
|
|
28605
|
-
consumedByRef:
|
|
28606
|
-
createdAt:
|
|
28607
|
-
updatedAt:
|
|
28671
|
+
voidedAt: timestamp91("voided_at", { withTimezone: true }),
|
|
28672
|
+
voidedBy: text99("voided_by"),
|
|
28673
|
+
voidReason: text99("void_reason"),
|
|
28674
|
+
authorizedBy: text99("authorized_by").notNull(),
|
|
28675
|
+
idempotencyKey: text99("idempotency_key").notNull(),
|
|
28676
|
+
expiresAt: timestamp91("expires_at", { withTimezone: true }).notNull(),
|
|
28677
|
+
consumedAt: timestamp91("consumed_at", { withTimezone: true }),
|
|
28678
|
+
consumedByRef: text99("consumed_by_ref"),
|
|
28679
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28680
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28608
28681
|
}
|
|
28609
28682
|
);
|
|
28610
|
-
var orchestrationDeploymentAuthorizations =
|
|
28683
|
+
var orchestrationDeploymentAuthorizations = pgTable98(
|
|
28611
28684
|
"orchestration_deployment_authorizations",
|
|
28612
28685
|
{
|
|
28613
28686
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28614
|
-
workspaceId:
|
|
28615
|
-
projectId:
|
|
28687
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28688
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28616
28689
|
runId: uuid4("run_id").notNull(),
|
|
28617
28690
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28618
|
-
mergeSha:
|
|
28619
|
-
artifactChecksum:
|
|
28691
|
+
mergeSha: varchar74("merge_sha", { length: 64 }).notNull(),
|
|
28692
|
+
artifactChecksum: varchar74("artifact_checksum", { length: 80 }).notNull(),
|
|
28620
28693
|
mergeAuthorizationId: uuid4("merge_authorization_id").notNull(),
|
|
28621
|
-
authorizedBy:
|
|
28622
|
-
idempotencyKey:
|
|
28623
|
-
expiresAt:
|
|
28624
|
-
consumedAt:
|
|
28625
|
-
consumedByRef:
|
|
28626
|
-
createdAt:
|
|
28627
|
-
updatedAt:
|
|
28694
|
+
authorizedBy: text99("authorized_by").notNull(),
|
|
28695
|
+
idempotencyKey: text99("idempotency_key").notNull(),
|
|
28696
|
+
expiresAt: timestamp91("expires_at", { withTimezone: true }).notNull(),
|
|
28697
|
+
consumedAt: timestamp91("consumed_at", { withTimezone: true }),
|
|
28698
|
+
consumedByRef: text99("consumed_by_ref"),
|
|
28699
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28700
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28628
28701
|
}
|
|
28629
28702
|
);
|
|
28630
|
-
var orchestrationDeploymentRequests =
|
|
28703
|
+
var orchestrationDeploymentRequests = pgTable98(
|
|
28631
28704
|
"orchestration_deployment_requests",
|
|
28632
28705
|
{
|
|
28633
28706
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28634
|
-
workspaceId:
|
|
28635
|
-
projectId:
|
|
28707
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28708
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28636
28709
|
runId: uuid4("run_id").notNull(),
|
|
28637
28710
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28638
28711
|
authorizationId: uuid4("authorization_id").notNull(),
|
|
28639
|
-
expectedMergeSha:
|
|
28640
|
-
artifactChecksum:
|
|
28641
|
-
state:
|
|
28642
|
-
voidReason:
|
|
28643
|
-
releaseId:
|
|
28644
|
-
createdAt:
|
|
28645
|
-
updatedAt:
|
|
28712
|
+
expectedMergeSha: varchar74("expected_merge_sha", { length: 64 }).notNull(),
|
|
28713
|
+
artifactChecksum: varchar74("artifact_checksum", { length: 80 }).notNull(),
|
|
28714
|
+
state: varchar74("state", { length: 12 }).$type().notNull().default("live"),
|
|
28715
|
+
voidReason: text99("void_reason"),
|
|
28716
|
+
releaseId: text99("release_id"),
|
|
28717
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28718
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28646
28719
|
}
|
|
28647
28720
|
);
|
|
28648
|
-
var orchestrationExecutionApprovals =
|
|
28721
|
+
var orchestrationExecutionApprovals = pgTable98(
|
|
28649
28722
|
"orchestration_execution_approvals",
|
|
28650
28723
|
{
|
|
28651
28724
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28652
|
-
workspaceId:
|
|
28653
|
-
projectId:
|
|
28725
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28726
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28654
28727
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28655
28728
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28656
28729
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
28657
|
-
idempotencyKey:
|
|
28658
|
-
approvedBy:
|
|
28659
|
-
targetKind:
|
|
28660
|
-
targetId:
|
|
28661
|
-
targetBindingDigest:
|
|
28730
|
+
idempotencyKey: text99("idempotency_key").notNull(),
|
|
28731
|
+
approvedBy: text99("approved_by").notNull(),
|
|
28732
|
+
targetKind: varchar74("target_kind", { length: 32 }).notNull().default("component-variant"),
|
|
28733
|
+
targetId: text99("target_id").notNull(),
|
|
28734
|
+
targetBindingDigest: text99("target_binding_digest").notNull(),
|
|
28662
28735
|
repositoryId: bigint7("repository_id", { mode: "number" }),
|
|
28663
|
-
baseBranch:
|
|
28664
|
-
baseSha:
|
|
28736
|
+
baseBranch: varchar74("base_branch", { length: 255 }),
|
|
28737
|
+
baseSha: varchar74("base_sha", { length: 64 }),
|
|
28665
28738
|
/** Set when the approval is spent. 0274 grants UPDATE on THESE TWO COLUMNS ONLY, so every
|
|
28666
28739
|
* other field on a row a human signed stays as unwritable as it was before. */
|
|
28667
|
-
consumedAt:
|
|
28740
|
+
consumedAt: timestamp91("consumed_at", { withTimezone: true }),
|
|
28668
28741
|
consumedByAttemptId: uuid4("consumed_by_attempt_id"),
|
|
28669
|
-
pathPolicy:
|
|
28670
|
-
operationClasses:
|
|
28671
|
-
mutationBudget:
|
|
28672
|
-
planDigest:
|
|
28673
|
-
capabilityDigest:
|
|
28674
|
-
validationDigest:
|
|
28675
|
-
expiresAt:
|
|
28676
|
-
createdAt:
|
|
28742
|
+
pathPolicy: jsonb57("path_policy").$type().notNull().default({}),
|
|
28743
|
+
operationClasses: jsonb57("operation_classes").$type().notNull().default([]),
|
|
28744
|
+
mutationBudget: jsonb57("mutation_budget").$type().notNull().default({}),
|
|
28745
|
+
planDigest: text99("plan_digest").notNull(),
|
|
28746
|
+
capabilityDigest: text99("capability_digest").notNull(),
|
|
28747
|
+
validationDigest: text99("validation_digest").notNull(),
|
|
28748
|
+
expiresAt: timestamp91("expires_at", { withTimezone: true }).notNull(),
|
|
28749
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28677
28750
|
},
|
|
28678
28751
|
(table) => [
|
|
28679
28752
|
foreignKey8({
|
|
@@ -28710,7 +28783,7 @@ var orchestrationExecutionApprovals = pgTable97(
|
|
|
28710
28783
|
// One approval per attempt. A running implementation never introduces a second approval; a
|
|
28711
28784
|
// changed binding requires a NEW attempt, which is what makes the authority auditable.
|
|
28712
28785
|
unique7("orchestration_execution_approvals_attempt_unique").on(table.attemptId),
|
|
28713
|
-
|
|
28786
|
+
index86("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
|
|
28714
28787
|
check6(
|
|
28715
28788
|
"orchestration_execution_approvals_idempotency_key_check",
|
|
28716
28789
|
sql25`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
|
|
@@ -28757,23 +28830,23 @@ var orchestrationExecutionApprovals = pgTable97(
|
|
|
28757
28830
|
)
|
|
28758
28831
|
]
|
|
28759
28832
|
);
|
|
28760
|
-
var orchestrationExecutorLeases =
|
|
28833
|
+
var orchestrationExecutorLeases = pgTable98(
|
|
28761
28834
|
"orchestration_executor_leases",
|
|
28762
28835
|
{
|
|
28763
28836
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28764
|
-
workspaceId:
|
|
28765
|
-
projectId:
|
|
28837
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28838
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28766
28839
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28767
28840
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28768
28841
|
sessionId: uuid4("session_id").notNull().references(() => orchestrationExecutorSessions.id, { onDelete: "cascade" }),
|
|
28769
|
-
leaseEpoch:
|
|
28770
|
-
state:
|
|
28771
|
-
heartbeatDeadline:
|
|
28772
|
-
acquiredAt:
|
|
28773
|
-
releasedAt:
|
|
28774
|
-
releaseReason:
|
|
28775
|
-
createdAt:
|
|
28776
|
-
updatedAt:
|
|
28842
|
+
leaseEpoch: integer51("lease_epoch").notNull().default(1),
|
|
28843
|
+
state: varchar74("state", { length: 20 }).$type().notNull().default("active"),
|
|
28844
|
+
heartbeatDeadline: timestamp91("heartbeat_deadline", { withTimezone: true }).notNull(),
|
|
28845
|
+
acquiredAt: timestamp91("acquired_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28846
|
+
releasedAt: timestamp91("released_at", { withTimezone: true }),
|
|
28847
|
+
releaseReason: varchar74("release_reason", { length: 32 }).$type(),
|
|
28848
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28849
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28777
28850
|
},
|
|
28778
28851
|
(table) => [
|
|
28779
28852
|
foreignKey8({
|
|
@@ -28810,8 +28883,8 @@ var orchestrationExecutorLeases = pgTable97(
|
|
|
28810
28883
|
),
|
|
28811
28884
|
unique7("orchestration_executor_leases_epoch_unique").on(table.attemptId, table.leaseEpoch),
|
|
28812
28885
|
// Plan invariant 6, enforced in the database: a run has at most one active executor lease.
|
|
28813
|
-
|
|
28814
|
-
|
|
28886
|
+
uniqueIndex44("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql25`${table.state} = 'active'`),
|
|
28887
|
+
index86("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql25`${table.state} = 'active'`),
|
|
28815
28888
|
check6("orchestration_executor_leases_epoch_check", sql25`${table.leaseEpoch} >= 1`),
|
|
28816
28889
|
check6(
|
|
28817
28890
|
"orchestration_executor_leases_state_check",
|
|
@@ -28831,32 +28904,32 @@ var orchestrationExecutorLeases = pgTable97(
|
|
|
28831
28904
|
)
|
|
28832
28905
|
]
|
|
28833
28906
|
);
|
|
28834
|
-
var orchestrationExecutorCommands =
|
|
28907
|
+
var orchestrationExecutorCommands = pgTable98(
|
|
28835
28908
|
"orchestration_executor_commands",
|
|
28836
28909
|
{
|
|
28837
28910
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28838
|
-
workspaceId:
|
|
28839
|
-
projectId:
|
|
28911
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28912
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28840
28913
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28841
28914
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28842
28915
|
leaseId: uuid4("lease_id").references(() => orchestrationExecutorLeases.id, {
|
|
28843
28916
|
onDelete: "set null"
|
|
28844
28917
|
}),
|
|
28845
|
-
leaseEpoch:
|
|
28918
|
+
leaseEpoch: integer51("lease_epoch"),
|
|
28846
28919
|
approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
|
|
28847
28920
|
onDelete: "set null"
|
|
28848
28921
|
}),
|
|
28849
28922
|
sequence: bigint7("sequence", { mode: "number" }).notNull(),
|
|
28850
|
-
kind:
|
|
28851
|
-
idempotencyKey:
|
|
28852
|
-
expectedRunVersion:
|
|
28853
|
-
payload:
|
|
28854
|
-
payloadDigest:
|
|
28923
|
+
kind: varchar74("kind", { length: 32 }).$type().notNull(),
|
|
28924
|
+
idempotencyKey: text99("idempotency_key").notNull(),
|
|
28925
|
+
expectedRunVersion: integer51("expected_run_version").notNull(),
|
|
28926
|
+
payload: jsonb57("payload").$type().notNull().default({}),
|
|
28927
|
+
payloadDigest: varchar74("payload_digest", { length: 71 }).generatedAlwaysAs(
|
|
28855
28928
|
sql25`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
|
|
28856
28929
|
),
|
|
28857
|
-
deliveredAt:
|
|
28858
|
-
acknowledgedAt:
|
|
28859
|
-
createdAt:
|
|
28930
|
+
deliveredAt: timestamp91("delivered_at", { withTimezone: true }),
|
|
28931
|
+
acknowledgedAt: timestamp91("acknowledged_at", { withTimezone: true }),
|
|
28932
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28860
28933
|
},
|
|
28861
28934
|
(table) => [
|
|
28862
28935
|
foreignKey8({
|
|
@@ -28882,9 +28955,9 @@ var orchestrationExecutorCommands = pgTable97(
|
|
|
28882
28955
|
table.runId,
|
|
28883
28956
|
table.idempotencyKey
|
|
28884
28957
|
),
|
|
28885
|
-
|
|
28958
|
+
index86("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
|
|
28886
28959
|
// The long-poll cursor read: unacknowledged commands for a run, in order.
|
|
28887
|
-
|
|
28960
|
+
index86("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql25`${table.acknowledgedAt} IS NULL`),
|
|
28888
28961
|
check6("orchestration_executor_commands_sequence_check", sql25`${table.sequence} >= 1`),
|
|
28889
28962
|
check6(
|
|
28890
28963
|
"orchestration_executor_commands_kind_check",
|
|
@@ -28914,25 +28987,25 @@ var orchestrationExecutorCommands = pgTable97(
|
|
|
28914
28987
|
]
|
|
28915
28988
|
);
|
|
28916
28989
|
var PATCH_OPERATIONS = ["create", "update", "delete"];
|
|
28917
|
-
var orchestrationPatchManifests =
|
|
28990
|
+
var orchestrationPatchManifests = pgTable98(
|
|
28918
28991
|
"orchestration_patch_manifests",
|
|
28919
28992
|
{
|
|
28920
28993
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28921
|
-
workspaceId:
|
|
28922
|
-
projectId:
|
|
28994
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28995
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28923
28996
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28924
28997
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28925
28998
|
approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
|
|
28926
28999
|
onDelete: "set null"
|
|
28927
29000
|
}),
|
|
28928
|
-
sequence:
|
|
28929
|
-
path:
|
|
28930
|
-
operation:
|
|
28931
|
-
fileMode:
|
|
28932
|
-
expectedBefore:
|
|
28933
|
-
resultingBlobSha:
|
|
29001
|
+
sequence: integer51("sequence").notNull(),
|
|
29002
|
+
path: text99("path").notNull(),
|
|
29003
|
+
operation: varchar74("operation", { length: 16 }).$type().notNull(),
|
|
29004
|
+
fileMode: varchar74("file_mode", { length: 6 }).notNull().default("100644"),
|
|
29005
|
+
expectedBefore: varchar74("expected_before", { length: 64 }),
|
|
29006
|
+
resultingBlobSha: varchar74("resulting_blob_sha", { length: 64 }),
|
|
28934
29007
|
byteCount: bigint7("byte_count", { mode: "number" }).notNull().default(0),
|
|
28935
|
-
createdAt:
|
|
29008
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28936
29009
|
},
|
|
28937
29010
|
(table) => [
|
|
28938
29011
|
foreignKey8({
|
|
@@ -28955,7 +29028,7 @@ var orchestrationPatchManifests = pgTable97(
|
|
|
28955
29028
|
}).onDelete("cascade"),
|
|
28956
29029
|
unique7("orchestration_patch_manifests_sequence_unique").on(table.attemptId, table.sequence),
|
|
28957
29030
|
unique7("orchestration_patch_manifests_path_unique").on(table.attemptId, table.path),
|
|
28958
|
-
|
|
29031
|
+
index86("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
|
|
28959
29032
|
check6("orchestration_patch_manifests_sequence_check", sql25`${table.sequence} >= 1`),
|
|
28960
29033
|
check6(
|
|
28961
29034
|
"orchestration_patch_manifests_operation_check",
|
|
@@ -28981,30 +29054,30 @@ var orchestrationPatchManifests = pgTable97(
|
|
|
28981
29054
|
check6("orchestration_patch_manifests_byte_count_check", sql25`${table.byteCount} >= 0`)
|
|
28982
29055
|
]
|
|
28983
29056
|
);
|
|
28984
|
-
var orchestrationPullRequestReceipts =
|
|
29057
|
+
var orchestrationPullRequestReceipts = pgTable98(
|
|
28985
29058
|
"orchestration_pull_request_receipts",
|
|
28986
29059
|
{
|
|
28987
29060
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28988
|
-
workspaceId:
|
|
28989
|
-
projectId:
|
|
29061
|
+
workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29062
|
+
projectId: text99("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28990
29063
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28991
29064
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28992
29065
|
repositoryId: bigint7("repository_id", { mode: "number" }).notNull(),
|
|
28993
29066
|
installationId: bigint7("installation_id", { mode: "number" }),
|
|
28994
29067
|
pullRequestId: bigint7("pull_request_id", { mode: "number" }).notNull(),
|
|
28995
|
-
pullRequestNumber:
|
|
28996
|
-
pullRequestUrl:
|
|
28997
|
-
baseRef:
|
|
28998
|
-
baseSha:
|
|
28999
|
-
headRef:
|
|
29000
|
-
headSha:
|
|
29068
|
+
pullRequestNumber: integer51("pull_request_number").notNull(),
|
|
29069
|
+
pullRequestUrl: text99("pull_request_url").notNull(),
|
|
29070
|
+
baseRef: varchar74("base_ref", { length: 255 }).notNull(),
|
|
29071
|
+
baseSha: varchar74("base_sha", { length: 64 }).notNull(),
|
|
29072
|
+
headRef: varchar74("head_ref", { length: 255 }).notNull(),
|
|
29073
|
+
headSha: varchar74("head_sha", { length: 64 }).notNull(),
|
|
29001
29074
|
/** True when BetterCMS created and owns the head branch. A head we do not own is observable
|
|
29002
29075
|
* but never advanceable by the adapter. */
|
|
29003
29076
|
branchOwned: boolean32("branch_owned").notNull().default(true),
|
|
29004
|
-
generation:
|
|
29077
|
+
generation: integer51("generation").notNull().default(1),
|
|
29005
29078
|
isDraft: boolean32("is_draft").notNull().default(true),
|
|
29006
|
-
createdAt:
|
|
29007
|
-
updatedAt:
|
|
29079
|
+
createdAt: timestamp91("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
29080
|
+
updatedAt: timestamp91("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
29008
29081
|
},
|
|
29009
29082
|
(table) => [
|
|
29010
29083
|
foreignKey8({
|
|
@@ -29029,11 +29102,11 @@ var orchestrationPullRequestReceipts = pgTable97(
|
|
|
29029
29102
|
table.attemptId,
|
|
29030
29103
|
table.generation
|
|
29031
29104
|
),
|
|
29032
|
-
|
|
29105
|
+
index86("orchestration_pull_request_receipts_attempt_generation_idx").on(
|
|
29033
29106
|
table.attemptId,
|
|
29034
29107
|
table.generation
|
|
29035
29108
|
),
|
|
29036
|
-
|
|
29109
|
+
index86("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
|
|
29037
29110
|
check6("orchestration_pull_request_receipts_generation_check", sql25`${table.generation} >= 1`),
|
|
29038
29111
|
check6("orchestration_pull_request_receipts_number_check", sql25`${table.pullRequestNumber} >= 1`),
|
|
29039
29112
|
check6(
|
|
@@ -29062,24 +29135,24 @@ var orchestrationPullRequestReceipts = pgTable97(
|
|
|
29062
29135
|
|
|
29063
29136
|
// src/schema/conversion_proposals.ts
|
|
29064
29137
|
import { sql as sql26 } from "drizzle-orm";
|
|
29065
|
-
import { check as check7, foreignKey as foreignKey9, index as
|
|
29138
|
+
import { check as check7, foreignKey as foreignKey9, index as index87, integer as integer52, jsonb as jsonb58, pgTable as pgTable99, text as text100, timestamp as timestamp92, unique as unique8, uuid as uuid5, varchar as varchar75 } from "drizzle-orm/pg-core";
|
|
29066
29139
|
var CONVERSION_PROPOSAL_STATUSES = ["draft", "approved", "superseded"];
|
|
29067
|
-
var conversionProposals =
|
|
29140
|
+
var conversionProposals = pgTable99(
|
|
29068
29141
|
"conversion_proposals",
|
|
29069
29142
|
{
|
|
29070
29143
|
id: uuid5("id").primaryKey().defaultRandom(),
|
|
29071
|
-
workspaceId:
|
|
29072
|
-
projectId:
|
|
29144
|
+
workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29145
|
+
projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29073
29146
|
/** The plan snapshot holding the proposed file contents. */
|
|
29074
|
-
planDigest:
|
|
29147
|
+
planDigest: text100("plan_digest").notNull().references(() => orchestrationPlanSnapshots.planDigest),
|
|
29075
29148
|
/** sha256 of the canonical brief — what the CMS held when this was proposed. */
|
|
29076
|
-
briefDigest:
|
|
29077
|
-
baseHeadOid:
|
|
29078
|
-
baseBranch:
|
|
29149
|
+
briefDigest: text100("brief_digest").notNull(),
|
|
29150
|
+
baseHeadOid: varchar75("base_head_oid", { length: 64 }).notNull(),
|
|
29151
|
+
baseBranch: text100("base_branch").notNull(),
|
|
29079
29152
|
/** Brief paths whose `original` was not found in any source file. */
|
|
29080
|
-
unlocated:
|
|
29153
|
+
unlocated: jsonb58("unlocated").notNull().default(sql26`'[]'::jsonb`),
|
|
29081
29154
|
/** Files that matched a brief original but fell outside the acquisition caps. */
|
|
29082
|
-
omittedByCap:
|
|
29155
|
+
omittedByCap: jsonb58("omitted_by_cap").notNull().default(sql26`'[]'::jsonb`),
|
|
29083
29156
|
/**
|
|
29084
29157
|
* The codemod's receipt (migration 0296) — every path it bound, and every one it could not.
|
|
29085
29158
|
*
|
|
@@ -29087,25 +29160,25 @@ var conversionProposals = pgTable98(
|
|
|
29087
29160
|
* pending list for those, which is exactly the silent "nothing left to do" this lane refuses.
|
|
29088
29161
|
* Informative: `proposeConversion` re-derives every claim it acts on from the proposed files.
|
|
29089
29162
|
*/
|
|
29090
|
-
receipt:
|
|
29091
|
-
status:
|
|
29092
|
-
version:
|
|
29093
|
-
idempotencyKey:
|
|
29163
|
+
receipt: jsonb58("receipt"),
|
|
29164
|
+
status: text100("status").notNull().default("draft"),
|
|
29165
|
+
version: integer52("version").notNull().default(1),
|
|
29166
|
+
idempotencyKey: text100("idempotency_key").notNull(),
|
|
29094
29167
|
/**
|
|
29095
29168
|
* The key of the transition that put this row in its CURRENT terminal state — the approve, or
|
|
29096
29169
|
* the manual supersede. Separate from `idempotencyKey`, which belongs to the create: a client
|
|
29097
29170
|
* retrying one act must never be answered with the result of another.
|
|
29098
29171
|
*/
|
|
29099
|
-
transitionIdempotencyKey:
|
|
29100
|
-
createdBy:
|
|
29101
|
-
createdAt:
|
|
29102
|
-
approvedBy:
|
|
29103
|
-
approvedAt:
|
|
29104
|
-
supersededAt:
|
|
29105
|
-
supersededReason:
|
|
29172
|
+
transitionIdempotencyKey: text100("transition_idempotency_key"),
|
|
29173
|
+
createdBy: text100("created_by").notNull(),
|
|
29174
|
+
createdAt: timestamp92("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
29175
|
+
approvedBy: text100("approved_by"),
|
|
29176
|
+
approvedAt: timestamp92("approved_at", { withTimezone: true }),
|
|
29177
|
+
supersededAt: timestamp92("superseded_at", { withTimezone: true }),
|
|
29178
|
+
supersededReason: text100("superseded_reason")
|
|
29106
29179
|
},
|
|
29107
29180
|
(table) => [
|
|
29108
|
-
|
|
29181
|
+
index87("conversion_proposals_project_idx").on(table.workspaceId, table.projectId, table.createdAt),
|
|
29109
29182
|
unique8("conversion_proposals_idempotency_unique").on(table.projectId, table.idempotencyKey),
|
|
29110
29183
|
foreignKey9({
|
|
29111
29184
|
columns: [table.projectId, table.workspaceId],
|
|
@@ -29123,28 +29196,28 @@ var conversionProposals = pgTable98(
|
|
|
29123
29196
|
|
|
29124
29197
|
// src/schema/conversion_briefs_issued.ts
|
|
29125
29198
|
import { sql as sql27 } from "drizzle-orm";
|
|
29126
|
-
import { check as check8, foreignKey as foreignKey10, index as
|
|
29127
|
-
var conversionBriefsIssued =
|
|
29199
|
+
import { check as check8, foreignKey as foreignKey10, index as index88, jsonb as jsonb59, pgTable as pgTable100, text as text101, timestamp as timestamp93, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
|
|
29200
|
+
var conversionBriefsIssued = pgTable100(
|
|
29128
29201
|
"conversion_briefs_issued",
|
|
29129
29202
|
{
|
|
29130
29203
|
id: uuid6("id").primaryKey().defaultRandom(),
|
|
29131
|
-
workspaceId:
|
|
29132
|
-
projectId:
|
|
29204
|
+
workspaceId: text101("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29205
|
+
projectId: text101("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29133
29206
|
/** sha256 of the canonical brief — `briefDigest`, computed identically by the codemod. */
|
|
29134
|
-
briefDigest:
|
|
29207
|
+
briefDigest: text101("brief_digest").notNull(),
|
|
29135
29208
|
/** `[{ route, scope, path, kind, locator? }]` — every bindable path the brief listed. */
|
|
29136
|
-
paths:
|
|
29209
|
+
paths: jsonb59("paths").notNull().default(sql27`'[]'::jsonb`),
|
|
29137
29210
|
/**
|
|
29138
29211
|
* The codemod's account of the run against THIS digest (`submit_conversion_receipt`): which
|
|
29139
29212
|
* paths it rewrote, which it could not, and why. Null until one is submitted — a hand
|
|
29140
29213
|
* conversion never submits one and still counts toward coverage.
|
|
29141
29214
|
*/
|
|
29142
|
-
receipt:
|
|
29215
|
+
receipt: jsonb59("receipt"),
|
|
29143
29216
|
/** The LAST time this pin was issued. What a retention sweep keys on. */
|
|
29144
|
-
issuedAt:
|
|
29217
|
+
issuedAt: timestamp93("issued_at", { withTimezone: true }).notNull().defaultNow()
|
|
29145
29218
|
},
|
|
29146
29219
|
(table) => [
|
|
29147
|
-
|
|
29220
|
+
index88("conversion_briefs_issued_project_issued_idx").on(table.projectId, table.issuedAt),
|
|
29148
29221
|
unique9("conversion_briefs_issued_digest_unique").on(table.projectId, table.briefDigest),
|
|
29149
29222
|
foreignKey10({
|
|
29150
29223
|
columns: [table.projectId, table.workspaceId],
|
|
@@ -29158,40 +29231,40 @@ var conversionBriefsIssued = pgTable99(
|
|
|
29158
29231
|
|
|
29159
29232
|
// src/schema/binding_decisions.ts
|
|
29160
29233
|
import { sql as sql28 } from "drizzle-orm";
|
|
29161
|
-
import { index as
|
|
29234
|
+
import { index as index89, jsonb as jsonb60, pgTable as pgTable101, smallint as smallint2, text as text102, timestamp as timestamp94, uniqueIndex as uniqueIndex45, uuid as uuid7 } from "drizzle-orm/pg-core";
|
|
29162
29235
|
var BINDING_DECISION_OPS = ["bind", "code", "reject"];
|
|
29163
29236
|
var BINDING_DECISION_STATES = ["stored", "materialized", "proven", "live", "lost"];
|
|
29164
|
-
var bindingDecisions =
|
|
29237
|
+
var bindingDecisions = pgTable101(
|
|
29165
29238
|
"binding_decisions",
|
|
29166
29239
|
{
|
|
29167
29240
|
id: uuid7("id").primaryKey().defaultRandom(),
|
|
29168
|
-
workspaceId:
|
|
29169
|
-
projectId:
|
|
29241
|
+
workspaceId: text102("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29242
|
+
projectId: text102("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29170
29243
|
/** `current` | `staging` (CHECK in the migration): the slot the decision's release lands in. */
|
|
29171
|
-
slot:
|
|
29172
|
-
target:
|
|
29244
|
+
slot: text102("slot").notNull(),
|
|
29245
|
+
target: text102("target").notNull(),
|
|
29173
29246
|
/** `bind` | `code` | `reject` | `rule` (CHECK; `rule` since 0467, archive sites), and the editable plan's answers since 0495 (`logo`, `chrome`, `reserved-input`, `kit-entry`, `brand-kit`, `body`). An `accept` is stored as the op it expands to. */
|
|
29174
|
-
op:
|
|
29175
|
-
payload:
|
|
29247
|
+
op: text102("op").notNull(),
|
|
29248
|
+
payload: jsonb60("payload").$type().notNull().default(sql28`'{}'::jsonb`),
|
|
29176
29249
|
/** `person` | `ai` (CHECK), from the request's write origin only. */
|
|
29177
|
-
byKind:
|
|
29178
|
-
by:
|
|
29250
|
+
byKind: text102("by_kind").notNull(),
|
|
29251
|
+
by: text102("by"),
|
|
29179
29252
|
/** `stored` | `materialized` | `proven` | `live` | `lost` (CHECK). */
|
|
29180
|
-
state:
|
|
29253
|
+
state: text102("state").notNull().default("stored"),
|
|
29181
29254
|
/** The `force` reason an AI gave over a person's decision. */
|
|
29182
|
-
reason:
|
|
29255
|
+
reason: text102("reason"),
|
|
29183
29256
|
receiptsSeen: smallint2("receipts_seen").notNull().default(0),
|
|
29184
|
-
materializedSha:
|
|
29185
|
-
provenSha:
|
|
29257
|
+
materializedSha: text102("materialized_sha"),
|
|
29258
|
+
provenSha: text102("proven_sha"),
|
|
29186
29259
|
/** Non-null: no longer live (replaced, overridden or cleared), kept as the record. */
|
|
29187
|
-
supersededReason:
|
|
29188
|
-
createdAt:
|
|
29189
|
-
updatedAt:
|
|
29260
|
+
supersededReason: text102("superseded_reason"),
|
|
29261
|
+
createdAt: timestamp94("created_at").notNull().defaultNow(),
|
|
29262
|
+
updatedAt: timestamp94("updated_at").notNull().defaultNow()
|
|
29190
29263
|
},
|
|
29191
29264
|
(t) => [
|
|
29192
|
-
|
|
29193
|
-
|
|
29194
|
-
|
|
29265
|
+
uniqueIndex45("binding_decisions_target_op_unique").on(t.projectId, t.slot, t.target, t.op),
|
|
29266
|
+
uniqueIndex45("binding_decisions_live_target_unique").on(t.projectId, t.slot, t.target).where(sql28`superseded_reason IS NULL`),
|
|
29267
|
+
index89("binding_decisions_project_slot_state_idx").on(t.projectId, t.slot, t.state)
|
|
29195
29268
|
]
|
|
29196
29269
|
);
|
|
29197
29270
|
|
|
@@ -29201,16 +29274,16 @@ import {
|
|
|
29201
29274
|
bigint as bigint8,
|
|
29202
29275
|
check as check9,
|
|
29203
29276
|
foreignKey as foreignKey11,
|
|
29204
|
-
index as
|
|
29205
|
-
integer as
|
|
29206
|
-
jsonb as
|
|
29207
|
-
pgTable as
|
|
29208
|
-
text as
|
|
29209
|
-
timestamp as
|
|
29277
|
+
index as index90,
|
|
29278
|
+
integer as integer53,
|
|
29279
|
+
jsonb as jsonb61,
|
|
29280
|
+
pgTable as pgTable102,
|
|
29281
|
+
text as text103,
|
|
29282
|
+
timestamp as timestamp95,
|
|
29210
29283
|
unique as unique10,
|
|
29211
|
-
uniqueIndex as
|
|
29284
|
+
uniqueIndex as uniqueIndex46,
|
|
29212
29285
|
uuid as uuid8,
|
|
29213
|
-
varchar as
|
|
29286
|
+
varchar as varchar76
|
|
29214
29287
|
} from "drizzle-orm/pg-core";
|
|
29215
29288
|
var VALIDATION_ENVELOPE_STATUSES = [
|
|
29216
29289
|
"queued",
|
|
@@ -29223,51 +29296,51 @@ var VALIDATION_ENVELOPE_STATUSES = [
|
|
|
29223
29296
|
"cancelled"
|
|
29224
29297
|
];
|
|
29225
29298
|
var VALIDATION_LIVE_STATUSES = ["queued", "dispatched", "action_required"];
|
|
29226
|
-
var orchestrationValidationEnvelopes =
|
|
29299
|
+
var orchestrationValidationEnvelopes = pgTable102(
|
|
29227
29300
|
"orchestration_validation_envelopes",
|
|
29228
29301
|
{
|
|
29229
29302
|
id: uuid8("id").primaryKey().defaultRandom(),
|
|
29230
|
-
workspaceId:
|
|
29231
|
-
projectId:
|
|
29303
|
+
workspaceId: text103("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29304
|
+
projectId: text103("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29232
29305
|
runId: uuid8("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
29233
29306
|
attemptId: uuid8("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
29234
29307
|
/** Null until a receipt writer exists (Phase 6). The head below is pinned regardless. */
|
|
29235
29308
|
receiptId: uuid8("receipt_id").references(() => orchestrationPullRequestReceipts.id, {
|
|
29236
29309
|
onDelete: "set null"
|
|
29237
29310
|
}),
|
|
29238
|
-
receiptGeneration:
|
|
29311
|
+
receiptGeneration: integer53("receipt_generation").notNull().default(1),
|
|
29239
29312
|
// The pinned tuple. Every field here is compared against returned evidence, and each mismatch
|
|
29240
29313
|
// has its own error code — "wrong repository" and "wrong head" are different recoveries.
|
|
29241
29314
|
repositoryId: bigint8("repository_id", { mode: "number" }).notNull(),
|
|
29242
29315
|
pullRequestId: bigint8("pull_request_id", { mode: "number" }).notNull(),
|
|
29243
|
-
pullRequestNumber:
|
|
29316
|
+
pullRequestNumber: integer53("pull_request_number").notNull(),
|
|
29244
29317
|
/** The exact commit this validation is about. A validation proves nothing about any other. */
|
|
29245
|
-
headSha:
|
|
29246
|
-
baseSha:
|
|
29247
|
-
bindingDigest:
|
|
29248
|
-
schemaHash:
|
|
29249
|
-
brandContractHash:
|
|
29250
|
-
baselineDigest:
|
|
29251
|
-
toolchainHash:
|
|
29252
|
-
validatorVersion:
|
|
29253
|
-
workflowSha256:
|
|
29318
|
+
headSha: varchar76("head_sha", { length: 64 }).notNull(),
|
|
29319
|
+
baseSha: varchar76("base_sha", { length: 64 }).notNull(),
|
|
29320
|
+
bindingDigest: varchar76("binding_digest", { length: 71 }).notNull(),
|
|
29321
|
+
schemaHash: varchar76("schema_hash", { length: 64 }).notNull(),
|
|
29322
|
+
brandContractHash: varchar76("brand_contract_hash", { length: 64 }).notNull(),
|
|
29323
|
+
baselineDigest: varchar76("baseline_digest", { length: 71 }).notNull(),
|
|
29324
|
+
toolchainHash: varchar76("toolchain_hash", { length: 64 }).notNull(),
|
|
29325
|
+
validatorVersion: text103("validator_version").notNull(),
|
|
29326
|
+
workflowSha256: varchar76("workflow_sha256", { length: 64 }).notNull(),
|
|
29254
29327
|
/** Digest only. The single-use credential itself is handed to the validator and never stored. */
|
|
29255
|
-
nonceHash:
|
|
29256
|
-
nonceExpiresAt:
|
|
29257
|
-
nonceConsumedAt:
|
|
29258
|
-
status:
|
|
29259
|
-
errorCode:
|
|
29260
|
-
errorMessage:
|
|
29328
|
+
nonceHash: varchar76("nonce_hash", { length: 64 }).notNull(),
|
|
29329
|
+
nonceExpiresAt: timestamp95("nonce_expires_at", { withTimezone: true }).notNull(),
|
|
29330
|
+
nonceConsumedAt: timestamp95("nonce_consumed_at", { withTimezone: true }),
|
|
29331
|
+
status: varchar76("status", { length: 20 }).notNull().default("queued"),
|
|
29332
|
+
errorCode: text103("error_code"),
|
|
29333
|
+
errorMessage: text103("error_message"),
|
|
29261
29334
|
/** Composite-FK'd to (evidence.id, evidence.envelope_id) in 0273, so an envelope cannot be
|
|
29262
29335
|
* marked passed while pointing at a DIFFERENT envelope's evidence. */
|
|
29263
29336
|
evidenceId: uuid8("evidence_id"),
|
|
29264
29337
|
/** Written on pass, read by nothing. The unlock that consumes it is a later phase. */
|
|
29265
|
-
attestationDigest:
|
|
29266
|
-
dispatchedAt:
|
|
29338
|
+
attestationDigest: varchar76("attestation_digest", { length: 71 }),
|
|
29339
|
+
dispatchedAt: timestamp95("dispatched_at", { withTimezone: true }),
|
|
29267
29340
|
/** A retry is a NEW row with a NEW nonce, linked back — never a status reset on this one. */
|
|
29268
29341
|
retryOf: uuid8("retry_of"),
|
|
29269
|
-
createdAt:
|
|
29270
|
-
updatedAt:
|
|
29342
|
+
createdAt: timestamp95("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
29343
|
+
updatedAt: timestamp95("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
29271
29344
|
},
|
|
29272
29345
|
(table) => [
|
|
29273
29346
|
unique10("orchestration_validation_envelopes_scope_unique").on(
|
|
@@ -29291,12 +29364,12 @@ var orchestrationValidationEnvelopes = pgTable101(
|
|
|
29291
29364
|
}).onDelete("set null"),
|
|
29292
29365
|
// One live envelope per (attempt, head): two validators can never both be authoritative for
|
|
29293
29366
|
// the same commit. The index arbitrates, so no read-then-write can lose the race.
|
|
29294
|
-
|
|
29295
|
-
|
|
29367
|
+
uniqueIndex46("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql29`status IN ('queued', 'dispatched', 'action_required')`),
|
|
29368
|
+
index90("orchestration_validation_envelopes_attempt_idx").on(
|
|
29296
29369
|
table.attemptId,
|
|
29297
29370
|
table.createdAt.desc()
|
|
29298
29371
|
),
|
|
29299
|
-
|
|
29372
|
+
index90("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql29`status IN ('queued', 'dispatched')`),
|
|
29300
29373
|
check9(
|
|
29301
29374
|
"orchestration_validation_envelopes_status_check",
|
|
29302
29375
|
sql29`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
|
|
@@ -29312,28 +29385,28 @@ var orchestrationValidationEnvelopes = pgTable101(
|
|
|
29312
29385
|
)
|
|
29313
29386
|
]
|
|
29314
29387
|
);
|
|
29315
|
-
var orchestrationValidationEvidence =
|
|
29388
|
+
var orchestrationValidationEvidence = pgTable102(
|
|
29316
29389
|
"orchestration_validation_evidence",
|
|
29317
29390
|
{
|
|
29318
29391
|
id: uuid8("id").primaryKey().defaultRandom(),
|
|
29319
|
-
workspaceId:
|
|
29320
|
-
projectId:
|
|
29392
|
+
workspaceId: text103("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29393
|
+
projectId: text103("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29321
29394
|
runId: uuid8("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
29322
29395
|
attemptId: uuid8("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
29323
29396
|
envelopeId: uuid8("envelope_id").notNull().references(() => orchestrationValidationEnvelopes.id, { onDelete: "cascade" }),
|
|
29324
|
-
headSha:
|
|
29325
|
-
evidenceDigest:
|
|
29326
|
-
artifactDigest:
|
|
29327
|
-
validatorVersion:
|
|
29397
|
+
headSha: varchar76("head_sha", { length: 64 }).notNull(),
|
|
29398
|
+
evidenceDigest: varchar76("evidence_digest", { length: 71 }).notNull(),
|
|
29399
|
+
artifactDigest: varchar76("artifact_digest", { length: 71 }).notNull(),
|
|
29400
|
+
validatorVersion: text103("validator_version").notNull(),
|
|
29328
29401
|
/** The BrandKit contract this evidence is filed under. 0273 ties it to
|
|
29329
29402
|
* `checks->brandKit->contractHash`, so a payload cannot claim a different one. Comparing it
|
|
29330
29403
|
* against the ENVELOPE's hash is an ingest check — a CHECK cannot reach another table. */
|
|
29331
|
-
brandContractHash:
|
|
29332
|
-
status:
|
|
29404
|
+
brandContractHash: varchar76("brand_contract_hash", { length: 64 }).notNull(),
|
|
29405
|
+
status: varchar76("status", { length: 10 }).notNull(),
|
|
29333
29406
|
/** brandKit / runtime / visual. The shape is enforced by CHECK in 0273, not by the writer. */
|
|
29334
|
-
checks:
|
|
29335
|
-
createdBy:
|
|
29336
|
-
createdAt:
|
|
29407
|
+
checks: jsonb61("checks").notNull(),
|
|
29408
|
+
createdBy: text103("created_by"),
|
|
29409
|
+
createdAt: timestamp95("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
29337
29410
|
},
|
|
29338
29411
|
(table) => [
|
|
29339
29412
|
unique10("orchestration_validation_evidence_scope_unique").on(
|
|
@@ -29360,7 +29433,7 @@ var orchestrationValidationEvidence = pgTable101(
|
|
|
29360
29433
|
table.attemptId,
|
|
29361
29434
|
table.evidenceDigest
|
|
29362
29435
|
),
|
|
29363
|
-
|
|
29436
|
+
index90("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
|
|
29364
29437
|
check9(
|
|
29365
29438
|
"orchestration_validation_evidence_status_check",
|
|
29366
29439
|
sql29`${table.status} IN ('passed', 'failed')`
|
|
@@ -29370,27 +29443,27 @@ var orchestrationValidationEvidence = pgTable101(
|
|
|
29370
29443
|
|
|
29371
29444
|
// src/schema/orchestration_executor_grants.ts
|
|
29372
29445
|
import { sql as sql30 } from "drizzle-orm";
|
|
29373
|
-
import { check as check10, foreignKey as foreignKey12, index as
|
|
29446
|
+
import { check as check10, foreignKey as foreignKey12, index as index91, integer as integer54, pgTable as pgTable103, text as text104, timestamp as timestamp96, unique as unique11, uniqueIndex as uniqueIndex47, uuid as uuid9, varchar as varchar77 } from "drizzle-orm/pg-core";
|
|
29374
29447
|
var EXECUTOR_GRANT_STATUSES = ["active", "revoked", "expired"];
|
|
29375
|
-
var orchestrationExecutorGrants =
|
|
29448
|
+
var orchestrationExecutorGrants = pgTable103(
|
|
29376
29449
|
"orchestration_executor_grants",
|
|
29377
29450
|
{
|
|
29378
|
-
id:
|
|
29379
|
-
workspaceId:
|
|
29380
|
-
projectId:
|
|
29451
|
+
id: text104("id").primaryKey().default(sql30`gen_random_uuid()`),
|
|
29452
|
+
workspaceId: text104("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29453
|
+
projectId: text104("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29381
29454
|
installationId: uuid9("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
29382
29455
|
/** Digest only. The credential is returned once at mint and never stored. */
|
|
29383
|
-
credentialHash:
|
|
29384
|
-
credentialAudience:
|
|
29385
|
-
credentialExpiresAt:
|
|
29456
|
+
credentialHash: varchar77("credential_hash", { length: 64 }).notNull(),
|
|
29457
|
+
credentialAudience: text104("credential_audience").notNull(),
|
|
29458
|
+
credentialExpiresAt: timestamp96("credential_expires_at", { withTimezone: true }).notNull(),
|
|
29386
29459
|
/** The epoch this credential is valid for. A fenced session's credential dies before it expires. */
|
|
29387
|
-
sessionEpoch:
|
|
29388
|
-
status:
|
|
29389
|
-
revokedAt:
|
|
29390
|
-
revokedBy:
|
|
29391
|
-
createdBy:
|
|
29392
|
-
createdAt:
|
|
29393
|
-
updatedAt:
|
|
29460
|
+
sessionEpoch: integer54("session_epoch").notNull(),
|
|
29461
|
+
status: varchar77("status", { length: 16 }).notNull().default("active"),
|
|
29462
|
+
revokedAt: timestamp96("revoked_at", { withTimezone: true }),
|
|
29463
|
+
revokedBy: text104("revoked_by"),
|
|
29464
|
+
createdBy: text104("created_by"),
|
|
29465
|
+
createdAt: timestamp96("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
29466
|
+
updatedAt: timestamp96("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
29394
29467
|
},
|
|
29395
29468
|
(table) => [
|
|
29396
29469
|
unique11("orchestration_executor_grants_scope_unique").on(
|
|
@@ -29409,8 +29482,8 @@ var orchestrationExecutorGrants = pgTable102(
|
|
|
29409
29482
|
}).onDelete("cascade"),
|
|
29410
29483
|
// One live credential per installation. Two would mean two processes can each present a valid
|
|
29411
29484
|
// one, and the exclusion argument collapses before the lease layer is reached.
|
|
29412
|
-
|
|
29413
|
-
|
|
29485
|
+
uniqueIndex47("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql30`status = 'active'`),
|
|
29486
|
+
index91("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql30`status = 'active'`),
|
|
29414
29487
|
check10(
|
|
29415
29488
|
"orchestration_executor_grants_status_check",
|
|
29416
29489
|
sql30`${table.status} IN ('active', 'revoked', 'expired')`
|
|
@@ -29423,28 +29496,28 @@ var orchestrationExecutorGrants = pgTable102(
|
|
|
29423
29496
|
);
|
|
29424
29497
|
|
|
29425
29498
|
// src/schema/component_presets.ts
|
|
29426
|
-
import { pgTable as
|
|
29499
|
+
import { pgTable as pgTable104, text as text105, varchar as varchar78, timestamp as timestamp97, jsonb as jsonb62, integer as integer55, index as index92, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
|
|
29427
29500
|
import { relations as relations16 } from "drizzle-orm";
|
|
29428
|
-
var componentPresets =
|
|
29501
|
+
var componentPresets = pgTable104(
|
|
29429
29502
|
"component_presets",
|
|
29430
29503
|
{
|
|
29431
|
-
id:
|
|
29432
|
-
workspaceId:
|
|
29433
|
-
componentId:
|
|
29434
|
-
name:
|
|
29504
|
+
id: text105("id").primaryKey(),
|
|
29505
|
+
workspaceId: text105("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29506
|
+
componentId: text105("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
29507
|
+
name: varchar78("name", { length: 255 }).notNull(),
|
|
29435
29508
|
/** ^[a-z0-9-]+$, unique per component — stable across renames. */
|
|
29436
|
-
slug:
|
|
29509
|
+
slug: varchar78("slug", { length: 255 }).notNull(),
|
|
29437
29510
|
/** Prop key → value. Validated against the component's `props` on every write. */
|
|
29438
|
-
values:
|
|
29439
|
-
position:
|
|
29440
|
-
createdAt:
|
|
29441
|
-
updatedAt:
|
|
29442
|
-
createdBy:
|
|
29443
|
-
updatedBy:
|
|
29511
|
+
values: jsonb62("values").$type().notNull().default({}),
|
|
29512
|
+
position: integer55("position").notNull().default(0),
|
|
29513
|
+
createdAt: timestamp97("created_at").notNull().defaultNow(),
|
|
29514
|
+
updatedAt: timestamp97("updated_at").notNull().defaultNow(),
|
|
29515
|
+
createdBy: text105("created_by"),
|
|
29516
|
+
updatedBy: text105("updated_by")
|
|
29444
29517
|
},
|
|
29445
29518
|
(t) => [
|
|
29446
|
-
|
|
29447
|
-
|
|
29519
|
+
index92("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
|
|
29520
|
+
uniqueIndex48("component_presets_component_slug_key").on(t.componentId, t.slug)
|
|
29448
29521
|
]
|
|
29449
29522
|
);
|
|
29450
29523
|
var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
|
|
@@ -29457,15 +29530,15 @@ var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
|
|
|
29457
29530
|
// src/schema/section_zones.ts
|
|
29458
29531
|
import {
|
|
29459
29532
|
foreignKey as foreignKey13,
|
|
29460
|
-
index as
|
|
29461
|
-
integer as
|
|
29462
|
-
jsonb as
|
|
29463
|
-
pgTable as
|
|
29464
|
-
text as
|
|
29465
|
-
timestamp as
|
|
29533
|
+
index as index93,
|
|
29534
|
+
integer as integer56,
|
|
29535
|
+
jsonb as jsonb63,
|
|
29536
|
+
pgTable as pgTable105,
|
|
29537
|
+
text as text106,
|
|
29538
|
+
timestamp as timestamp98,
|
|
29466
29539
|
unique as unique12,
|
|
29467
|
-
uniqueIndex as
|
|
29468
|
-
varchar as
|
|
29540
|
+
uniqueIndex as uniqueIndex49,
|
|
29541
|
+
varchar as varchar79
|
|
29469
29542
|
} from "drizzle-orm/pg-core";
|
|
29470
29543
|
import { sql as sql31 } from "drizzle-orm";
|
|
29471
29544
|
var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
|
|
@@ -29476,15 +29549,15 @@ var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
|
|
|
29476
29549
|
"passed",
|
|
29477
29550
|
"failed"
|
|
29478
29551
|
];
|
|
29479
|
-
var sectionDefinitions =
|
|
29552
|
+
var sectionDefinitions = pgTable105(
|
|
29480
29553
|
"section_definitions",
|
|
29481
29554
|
{
|
|
29482
|
-
id:
|
|
29483
|
-
workspaceId:
|
|
29484
|
-
projectId:
|
|
29485
|
-
apiId:
|
|
29486
|
-
firstPublishedAt:
|
|
29487
|
-
archivedAt:
|
|
29555
|
+
id: text106("id").primaryKey(),
|
|
29556
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29557
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29558
|
+
apiId: varchar79("api_id", { length: 100 }).notNull(),
|
|
29559
|
+
firstPublishedAt: timestamp98("first_published_at"),
|
|
29560
|
+
archivedAt: timestamp98("archived_at"),
|
|
29488
29561
|
...auditColumns
|
|
29489
29562
|
},
|
|
29490
29563
|
(table) => [
|
|
@@ -29494,24 +29567,24 @@ var sectionDefinitions = pgTable104(
|
|
|
29494
29567
|
name: "section_definitions_project_workspace_fkey"
|
|
29495
29568
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
29496
29569
|
unique12("section_definitions_id_project_unique").on(table.id, table.projectId),
|
|
29497
|
-
|
|
29498
|
-
|
|
29499
|
-
|
|
29570
|
+
uniqueIndex49("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
|
|
29571
|
+
index93("section_definitions_workspace_idx").on(table.workspaceId),
|
|
29572
|
+
index93("section_definitions_project_idx").on(table.projectId)
|
|
29500
29573
|
]
|
|
29501
29574
|
);
|
|
29502
|
-
var sectionDefinitionVersions =
|
|
29575
|
+
var sectionDefinitionVersions = pgTable105(
|
|
29503
29576
|
"section_definition_versions",
|
|
29504
29577
|
{
|
|
29505
|
-
id:
|
|
29506
|
-
workspaceId:
|
|
29507
|
-
projectId:
|
|
29508
|
-
sectionDefinitionId:
|
|
29509
|
-
version:
|
|
29510
|
-
label:
|
|
29511
|
-
fields:
|
|
29512
|
-
schemaHash:
|
|
29513
|
-
createdBy:
|
|
29514
|
-
createdAt:
|
|
29578
|
+
id: text106("id").primaryKey(),
|
|
29579
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29580
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29581
|
+
sectionDefinitionId: text106("section_definition_id").notNull(),
|
|
29582
|
+
version: integer56("version").notNull(),
|
|
29583
|
+
label: varchar79("label", { length: 255 }).notNull(),
|
|
29584
|
+
fields: jsonb63("fields").$type().notNull().default([]),
|
|
29585
|
+
schemaHash: varchar79("schema_hash", { length: 64 }).notNull(),
|
|
29586
|
+
createdBy: text106("created_by"),
|
|
29587
|
+
createdAt: timestamp98("created_at").notNull().defaultNow()
|
|
29515
29588
|
},
|
|
29516
29589
|
(table) => [
|
|
29517
29590
|
foreignKey13({
|
|
@@ -29530,20 +29603,20 @@ var sectionDefinitionVersions = pgTable104(
|
|
|
29530
29603
|
table.version,
|
|
29531
29604
|
table.projectId
|
|
29532
29605
|
),
|
|
29533
|
-
|
|
29606
|
+
index93("section_definition_versions_project_idx").on(table.projectId)
|
|
29534
29607
|
]
|
|
29535
29608
|
);
|
|
29536
|
-
var sectionZones =
|
|
29609
|
+
var sectionZones = pgTable105(
|
|
29537
29610
|
"section_zones",
|
|
29538
29611
|
{
|
|
29539
|
-
id:
|
|
29540
|
-
workspaceId:
|
|
29541
|
-
projectId:
|
|
29542
|
-
schemaKind:
|
|
29543
|
-
schemaId:
|
|
29544
|
-
fieldKey:
|
|
29545
|
-
draftRevision:
|
|
29546
|
-
publishedRevision:
|
|
29612
|
+
id: text106("id").primaryKey(),
|
|
29613
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29614
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29615
|
+
schemaKind: varchar79("schema_kind", { length: 20 }).$type().notNull(),
|
|
29616
|
+
schemaId: text106("schema_id").notNull(),
|
|
29617
|
+
fieldKey: varchar79("field_key", { length: 255 }).notNull(),
|
|
29618
|
+
draftRevision: integer56("draft_revision").notNull().default(1),
|
|
29619
|
+
publishedRevision: integer56("published_revision"),
|
|
29547
29620
|
...auditColumns
|
|
29548
29621
|
},
|
|
29549
29622
|
(table) => [
|
|
@@ -29553,21 +29626,21 @@ var sectionZones = pgTable104(
|
|
|
29553
29626
|
name: "section_zones_project_workspace_fkey"
|
|
29554
29627
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
29555
29628
|
unique12("section_zones_id_project_unique").on(table.id, table.projectId),
|
|
29556
|
-
|
|
29557
|
-
|
|
29629
|
+
uniqueIndex49("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
|
|
29630
|
+
index93("section_zones_workspace_idx").on(table.workspaceId)
|
|
29558
29631
|
]
|
|
29559
29632
|
);
|
|
29560
|
-
var sectionZoneAttachments =
|
|
29633
|
+
var sectionZoneAttachments = pgTable105(
|
|
29561
29634
|
"section_zone_attachments",
|
|
29562
29635
|
{
|
|
29563
|
-
id:
|
|
29564
|
-
workspaceId:
|
|
29565
|
-
projectId:
|
|
29566
|
-
zoneId:
|
|
29567
|
-
sectionDefinitionId:
|
|
29568
|
-
draftVersion:
|
|
29569
|
-
publishedVersion:
|
|
29570
|
-
position:
|
|
29636
|
+
id: text106("id").primaryKey(),
|
|
29637
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29638
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29639
|
+
zoneId: text106("zone_id").notNull(),
|
|
29640
|
+
sectionDefinitionId: text106("section_definition_id").notNull(),
|
|
29641
|
+
draftVersion: integer56("draft_version").notNull(),
|
|
29642
|
+
publishedVersion: integer56("published_version"),
|
|
29643
|
+
position: integer56("position").notNull().default(0),
|
|
29571
29644
|
...auditColumns
|
|
29572
29645
|
},
|
|
29573
29646
|
(table) => [
|
|
@@ -29604,24 +29677,24 @@ var sectionZoneAttachments = pgTable104(
|
|
|
29604
29677
|
],
|
|
29605
29678
|
name: "section_zone_attachments_published_version_fkey"
|
|
29606
29679
|
}).onDelete("restrict"),
|
|
29607
|
-
|
|
29608
|
-
|
|
29680
|
+
uniqueIndex49("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
|
|
29681
|
+
index93("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
|
|
29609
29682
|
]
|
|
29610
29683
|
);
|
|
29611
|
-
var sectionManifests =
|
|
29684
|
+
var sectionManifests = pgTable105(
|
|
29612
29685
|
"section_manifests",
|
|
29613
29686
|
{
|
|
29614
|
-
id:
|
|
29615
|
-
workspaceId:
|
|
29616
|
-
projectId:
|
|
29617
|
-
sectionDefinitionId:
|
|
29618
|
-
sectionVersion:
|
|
29619
|
-
apiId:
|
|
29620
|
-
schemaHash:
|
|
29621
|
-
commitSha:
|
|
29622
|
-
manifest:
|
|
29623
|
-
createdBy:
|
|
29624
|
-
createdAt:
|
|
29687
|
+
id: text106("id").primaryKey(),
|
|
29688
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29689
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29690
|
+
sectionDefinitionId: text106("section_definition_id").notNull(),
|
|
29691
|
+
sectionVersion: integer56("section_version").notNull(),
|
|
29692
|
+
apiId: varchar79("api_id", { length: 100 }).notNull(),
|
|
29693
|
+
schemaHash: varchar79("schema_hash", { length: 64 }).notNull(),
|
|
29694
|
+
commitSha: varchar79("commit_sha", { length: 64 }).notNull(),
|
|
29695
|
+
manifest: jsonb63("manifest").$type().notNull(),
|
|
29696
|
+
createdBy: text106("created_by"),
|
|
29697
|
+
createdAt: timestamp98("created_at").notNull().defaultNow()
|
|
29625
29698
|
},
|
|
29626
29699
|
(table) => [
|
|
29627
29700
|
foreignKey13({
|
|
@@ -29639,26 +29712,26 @@ var sectionManifests = pgTable104(
|
|
|
29639
29712
|
name: "section_manifests_definition_version_project_fkey"
|
|
29640
29713
|
}).onDelete("cascade"),
|
|
29641
29714
|
unique12("section_manifests_id_project_unique").on(table.id, table.projectId),
|
|
29642
|
-
|
|
29715
|
+
index93("section_manifests_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
29643
29716
|
]
|
|
29644
29717
|
);
|
|
29645
|
-
var sectionValidationRuns =
|
|
29718
|
+
var sectionValidationRuns = pgTable105(
|
|
29646
29719
|
"section_validation_runs",
|
|
29647
29720
|
{
|
|
29648
|
-
id:
|
|
29649
|
-
workspaceId:
|
|
29650
|
-
projectId:
|
|
29651
|
-
sectionDefinitionId:
|
|
29652
|
-
sectionVersion:
|
|
29653
|
-
manifestId:
|
|
29654
|
-
status:
|
|
29655
|
-
schemaHash:
|
|
29656
|
-
commitSha:
|
|
29657
|
-
fixtureHash:
|
|
29658
|
-
evidenceDigest:
|
|
29659
|
-
results:
|
|
29660
|
-
createdBy:
|
|
29661
|
-
createdAt:
|
|
29721
|
+
id: text106("id").primaryKey(),
|
|
29722
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29723
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29724
|
+
sectionDefinitionId: text106("section_definition_id").notNull(),
|
|
29725
|
+
sectionVersion: integer56("section_version").notNull(),
|
|
29726
|
+
manifestId: text106("manifest_id").notNull(),
|
|
29727
|
+
status: varchar79("status", { length: 20 }).$type().notNull(),
|
|
29728
|
+
schemaHash: varchar79("schema_hash", { length: 64 }).notNull(),
|
|
29729
|
+
commitSha: varchar79("commit_sha", { length: 64 }).notNull(),
|
|
29730
|
+
fixtureHash: varchar79("fixture_hash", { length: 64 }).notNull(),
|
|
29731
|
+
evidenceDigest: varchar79("evidence_digest", { length: 128 }).notNull(),
|
|
29732
|
+
results: jsonb63("results").$type().notNull(),
|
|
29733
|
+
createdBy: text106("created_by"),
|
|
29734
|
+
createdAt: timestamp98("created_at").notNull().defaultNow()
|
|
29662
29735
|
},
|
|
29663
29736
|
(table) => [
|
|
29664
29737
|
foreignKey13({
|
|
@@ -29681,25 +29754,25 @@ var sectionValidationRuns = pgTable104(
|
|
|
29681
29754
|
name: "section_validation_runs_manifest_project_fkey"
|
|
29682
29755
|
}).onDelete("restrict"),
|
|
29683
29756
|
unique12("section_validation_runs_id_project_unique").on(table.id, table.projectId),
|
|
29684
|
-
|
|
29757
|
+
index93("section_validation_runs_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
29685
29758
|
]
|
|
29686
29759
|
);
|
|
29687
|
-
var sectionVisualApprovals =
|
|
29760
|
+
var sectionVisualApprovals = pgTable105(
|
|
29688
29761
|
"section_visual_approvals",
|
|
29689
29762
|
{
|
|
29690
|
-
id:
|
|
29691
|
-
workspaceId:
|
|
29692
|
-
projectId:
|
|
29693
|
-
sectionDefinitionId:
|
|
29694
|
-
sectionVersion:
|
|
29695
|
-
manifestId:
|
|
29696
|
-
validationRunId:
|
|
29697
|
-
schemaHash:
|
|
29698
|
-
commitSha:
|
|
29699
|
-
fixtureHash:
|
|
29700
|
-
evidenceDigest:
|
|
29701
|
-
approvedBy:
|
|
29702
|
-
createdAt:
|
|
29763
|
+
id: text106("id").primaryKey(),
|
|
29764
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29765
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29766
|
+
sectionDefinitionId: text106("section_definition_id").notNull(),
|
|
29767
|
+
sectionVersion: integer56("section_version").notNull(),
|
|
29768
|
+
manifestId: text106("manifest_id").notNull(),
|
|
29769
|
+
validationRunId: text106("validation_run_id").notNull(),
|
|
29770
|
+
schemaHash: varchar79("schema_hash", { length: 64 }).notNull(),
|
|
29771
|
+
commitSha: varchar79("commit_sha", { length: 64 }).notNull(),
|
|
29772
|
+
fixtureHash: varchar79("fixture_hash", { length: 64 }).notNull(),
|
|
29773
|
+
evidenceDigest: varchar79("evidence_digest", { length: 128 }).notNull(),
|
|
29774
|
+
approvedBy: text106("approved_by").notNull(),
|
|
29775
|
+
createdAt: timestamp98("created_at").notNull().defaultNow()
|
|
29703
29776
|
},
|
|
29704
29777
|
(table) => [
|
|
29705
29778
|
foreignKey13({
|
|
@@ -29726,36 +29799,36 @@ var sectionVisualApprovals = pgTable104(
|
|
|
29726
29799
|
foreignColumns: [sectionValidationRuns.id, sectionValidationRuns.projectId],
|
|
29727
29800
|
name: "section_visual_approvals_validation_project_fkey"
|
|
29728
29801
|
}).onDelete("restrict"),
|
|
29729
|
-
|
|
29802
|
+
index93("section_visual_approvals_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
29730
29803
|
]
|
|
29731
29804
|
);
|
|
29732
|
-
var sectionImplementationRequests =
|
|
29805
|
+
var sectionImplementationRequests = pgTable105(
|
|
29733
29806
|
"section_implementation_requests",
|
|
29734
29807
|
{
|
|
29735
|
-
id:
|
|
29736
|
-
workspaceId:
|
|
29737
|
-
projectId:
|
|
29738
|
-
sectionDefinitionId:
|
|
29739
|
-
sectionVersion:
|
|
29740
|
-
provider:
|
|
29741
|
-
status:
|
|
29742
|
-
schemaHash:
|
|
29743
|
-
targetCommitSha:
|
|
29744
|
-
providerRunId:
|
|
29745
|
-
providerRunUrl:
|
|
29746
|
-
manifestId:
|
|
29747
|
-
validationRunId:
|
|
29808
|
+
id: text106("id").primaryKey(),
|
|
29809
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29810
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29811
|
+
sectionDefinitionId: text106("section_definition_id").notNull(),
|
|
29812
|
+
sectionVersion: integer56("section_version").notNull(),
|
|
29813
|
+
provider: varchar79("provider", { length: 20 }).$type().notNull(),
|
|
29814
|
+
status: varchar79("status", { length: 20 }).$type().notNull().default("queued"),
|
|
29815
|
+
schemaHash: varchar79("schema_hash", { length: 64 }).notNull(),
|
|
29816
|
+
targetCommitSha: varchar79("target_commit_sha", { length: 64 }),
|
|
29817
|
+
providerRunId: varchar79("provider_run_id", { length: 255 }),
|
|
29818
|
+
providerRunUrl: text106("provider_run_url"),
|
|
29819
|
+
manifestId: text106("manifest_id"),
|
|
29820
|
+
validationRunId: text106("validation_run_id"),
|
|
29748
29821
|
/** SHA-256 of the request-scoped GitHub callback bearer. The plaintext is never persisted. */
|
|
29749
|
-
callbackTokenHash:
|
|
29750
|
-
requestedBy:
|
|
29751
|
-
claimedBy:
|
|
29752
|
-
errorCode:
|
|
29753
|
-
errorMessage:
|
|
29754
|
-
dispatchedAt:
|
|
29755
|
-
startedAt:
|
|
29756
|
-
completedAt:
|
|
29757
|
-
createdAt:
|
|
29758
|
-
updatedAt:
|
|
29822
|
+
callbackTokenHash: varchar79("callback_token_hash", { length: 64 }),
|
|
29823
|
+
requestedBy: text106("requested_by").notNull(),
|
|
29824
|
+
claimedBy: text106("claimed_by"),
|
|
29825
|
+
errorCode: varchar79("error_code", { length: 100 }),
|
|
29826
|
+
errorMessage: text106("error_message"),
|
|
29827
|
+
dispatchedAt: timestamp98("dispatched_at"),
|
|
29828
|
+
startedAt: timestamp98("started_at"),
|
|
29829
|
+
completedAt: timestamp98("completed_at"),
|
|
29830
|
+
createdAt: timestamp98("created_at").notNull().defaultNow(),
|
|
29831
|
+
updatedAt: timestamp98("updated_at").notNull().defaultNow()
|
|
29759
29832
|
},
|
|
29760
29833
|
(table) => [
|
|
29761
29834
|
foreignKey13({
|
|
@@ -29783,21 +29856,21 @@ var sectionImplementationRequests = pgTable104(
|
|
|
29783
29856
|
name: "section_implementation_requests_validation_project_fkey"
|
|
29784
29857
|
}).onDelete("restrict"),
|
|
29785
29858
|
unique12("section_implementation_requests_id_project_unique").on(table.id, table.projectId),
|
|
29786
|
-
|
|
29787
|
-
|
|
29859
|
+
uniqueIndex49("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql31`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
|
|
29860
|
+
index93("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
|
|
29788
29861
|
]
|
|
29789
29862
|
);
|
|
29790
|
-
var sectionZoneReleases =
|
|
29863
|
+
var sectionZoneReleases = pgTable105(
|
|
29791
29864
|
"section_zone_releases",
|
|
29792
29865
|
{
|
|
29793
|
-
id:
|
|
29794
|
-
workspaceId:
|
|
29795
|
-
projectId:
|
|
29796
|
-
zoneId:
|
|
29797
|
-
revision:
|
|
29798
|
-
snapshot:
|
|
29799
|
-
publishedBy:
|
|
29800
|
-
publishedAt:
|
|
29866
|
+
id: text106("id").primaryKey(),
|
|
29867
|
+
workspaceId: text106("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29868
|
+
projectId: text106("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29869
|
+
zoneId: text106("zone_id").notNull(),
|
|
29870
|
+
revision: integer56("revision").notNull(),
|
|
29871
|
+
snapshot: jsonb63("snapshot").$type().notNull(),
|
|
29872
|
+
publishedBy: text106("published_by").notNull(),
|
|
29873
|
+
publishedAt: timestamp98("published_at").notNull().defaultNow()
|
|
29801
29874
|
},
|
|
29802
29875
|
(table) => [
|
|
29803
29876
|
foreignKey13({
|
|
@@ -29811,12 +29884,12 @@ var sectionZoneReleases = pgTable104(
|
|
|
29811
29884
|
name: "section_zone_releases_zone_project_fkey"
|
|
29812
29885
|
}).onDelete("cascade"),
|
|
29813
29886
|
unique12("section_zone_releases_zone_revision_unique").on(table.zoneId, table.revision),
|
|
29814
|
-
|
|
29887
|
+
index93("section_zone_releases_project_published_idx").on(table.projectId, table.publishedAt)
|
|
29815
29888
|
]
|
|
29816
29889
|
);
|
|
29817
29890
|
|
|
29818
29891
|
// src/schema/content_locks.ts
|
|
29819
|
-
import { check as check11, index as
|
|
29892
|
+
import { check as check11, index as index94, jsonb as jsonb64, pgTable as pgTable106, text as text107, timestamp as timestamp99 } from "drizzle-orm/pg-core";
|
|
29820
29893
|
import { sql as sql32 } from "drizzle-orm";
|
|
29821
29894
|
var CONTENT_LOCK_TARGET_KINDS = [
|
|
29822
29895
|
"page",
|
|
@@ -29825,30 +29898,30 @@ var CONTENT_LOCK_TARGET_KINDS = [
|
|
|
29825
29898
|
"component_definition"
|
|
29826
29899
|
];
|
|
29827
29900
|
var CONTENT_LOCK_MODES = ["all", "agents"];
|
|
29828
|
-
var contentLocks =
|
|
29901
|
+
var contentLocks = pgTable106(
|
|
29829
29902
|
"content_locks",
|
|
29830
29903
|
{
|
|
29831
|
-
id:
|
|
29832
|
-
workspaceId:
|
|
29833
|
-
projectId:
|
|
29834
|
-
targetKind:
|
|
29835
|
-
targetId:
|
|
29836
|
-
blockId:
|
|
29904
|
+
id: text107("id").primaryKey(),
|
|
29905
|
+
workspaceId: text107("workspace_id").notNull(),
|
|
29906
|
+
projectId: text107("project_id").notNull(),
|
|
29907
|
+
targetKind: text107("target_kind").$type().notNull(),
|
|
29908
|
+
targetId: text107("target_id").notNull(),
|
|
29909
|
+
blockId: text107("block_id"),
|
|
29837
29910
|
// Deterministic structural path plus block ancestry captured when the lock is created.
|
|
29838
29911
|
// Nullable so Wave 5 remains compatible with locks created before this fingerprint existed.
|
|
29839
|
-
blockFingerprint:
|
|
29840
|
-
fieldPath:
|
|
29841
|
-
mode:
|
|
29842
|
-
reason:
|
|
29843
|
-
createdBy:
|
|
29844
|
-
createdAt:
|
|
29845
|
-
releasedBy:
|
|
29846
|
-
releasedAt:
|
|
29912
|
+
blockFingerprint: jsonb64("block_fingerprint").$type(),
|
|
29913
|
+
fieldPath: text107("field_path").array(),
|
|
29914
|
+
mode: text107("mode").$type().notNull().default("all"),
|
|
29915
|
+
reason: text107("reason"),
|
|
29916
|
+
createdBy: text107("created_by").notNull(),
|
|
29917
|
+
createdAt: timestamp99("created_at").notNull().defaultNow(),
|
|
29918
|
+
releasedBy: text107("released_by"),
|
|
29919
|
+
releasedAt: timestamp99("released_at")
|
|
29847
29920
|
},
|
|
29848
29921
|
(table) => [
|
|
29849
|
-
|
|
29850
|
-
|
|
29851
|
-
|
|
29922
|
+
index94("content_locks_workspace_idx").on(table.workspaceId),
|
|
29923
|
+
index94("content_locks_project_idx").on(table.projectId),
|
|
29924
|
+
index94("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql32`${table.releasedAt} IS NULL`),
|
|
29852
29925
|
check11("content_locks_target_kind_check", sql32`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
|
|
29853
29926
|
check11("content_locks_mode_check", sql32`${table.mode} IN ('all','agents')`)
|
|
29854
29927
|
// `content_locks_shape_check` lives in migration 0192 ONLY: it calls
|
|
@@ -29864,75 +29937,75 @@ var contentLocks = pgTable105(
|
|
|
29864
29937
|
|
|
29865
29938
|
// src/schema/project_transfers.ts
|
|
29866
29939
|
import {
|
|
29867
|
-
pgTable as
|
|
29868
|
-
text as
|
|
29869
|
-
varchar as
|
|
29870
|
-
timestamp as
|
|
29871
|
-
index as
|
|
29872
|
-
uniqueIndex as
|
|
29940
|
+
pgTable as pgTable107,
|
|
29941
|
+
text as text108,
|
|
29942
|
+
varchar as varchar80,
|
|
29943
|
+
timestamp as timestamp100,
|
|
29944
|
+
index as index95,
|
|
29945
|
+
uniqueIndex as uniqueIndex50
|
|
29873
29946
|
} from "drizzle-orm/pg-core";
|
|
29874
29947
|
import { sql as sql33 } from "drizzle-orm";
|
|
29875
|
-
var projectTransfers =
|
|
29948
|
+
var projectTransfers = pgTable107(
|
|
29876
29949
|
"project_transfers",
|
|
29877
29950
|
{
|
|
29878
|
-
id:
|
|
29951
|
+
id: text108("id").primaryKey(),
|
|
29879
29952
|
// nanoid
|
|
29880
|
-
token:
|
|
29953
|
+
token: text108("token").notNull(),
|
|
29881
29954
|
// nanoid(32) — recipient handshake / magic link
|
|
29882
|
-
status:
|
|
29955
|
+
status: varchar80("status", { length: 20 }).notNull().default("pending"),
|
|
29883
29956
|
// pending | accepted (transient) | completed | declined | cancelled | expired | failed
|
|
29884
|
-
projectId:
|
|
29957
|
+
projectId: text108("project_id").notNull(),
|
|
29885
29958
|
// FK → projects.id (ON DELETE CASCADE, via migration)
|
|
29886
|
-
fromWorkspaceId:
|
|
29959
|
+
fromWorkspaceId: text108("from_workspace_id").notNull(),
|
|
29887
29960
|
// FK → workspaces.id (source)
|
|
29888
|
-
toWorkspaceId:
|
|
29961
|
+
toWorkspaceId: text108("to_workspace_id"),
|
|
29889
29962
|
// FK → workspaces.id — resolved at accept (null while pending)
|
|
29890
|
-
initiatedBy:
|
|
29963
|
+
initiatedBy: text108("initiated_by").notNull(),
|
|
29891
29964
|
// FK → users.id (source owner)
|
|
29892
|
-
recipientEmail:
|
|
29965
|
+
recipientEmail: varchar80("recipient_email", { length: 255 }).notNull(),
|
|
29893
29966
|
// lowercased
|
|
29894
|
-
note:
|
|
29967
|
+
note: text108("note"),
|
|
29895
29968
|
// optional message to the recipient
|
|
29896
|
-
resolvedAt:
|
|
29969
|
+
resolvedAt: timestamp100("resolved_at"),
|
|
29897
29970
|
// set on accept/decline/cancel/expire
|
|
29898
|
-
resolvedBy:
|
|
29971
|
+
resolvedBy: text108("resolved_by"),
|
|
29899
29972
|
// FK → users.id (accepter/decliner/canceller)
|
|
29900
|
-
error:
|
|
29973
|
+
error: text108("error"),
|
|
29901
29974
|
// failure detail when status='failed'
|
|
29902
|
-
expiresAt:
|
|
29975
|
+
expiresAt: timestamp100("expires_at").notNull(),
|
|
29903
29976
|
// createdAt + 7d
|
|
29904
|
-
createdAt:
|
|
29905
|
-
updatedAt:
|
|
29977
|
+
createdAt: timestamp100("created_at").notNull().defaultNow(),
|
|
29978
|
+
updatedAt: timestamp100("updated_at").notNull().defaultNow()
|
|
29906
29979
|
},
|
|
29907
29980
|
(table) => [
|
|
29908
29981
|
// At most one OPEN transfer per project. Partial-unique so completed/declined/
|
|
29909
29982
|
// cancelled/expired/failed rows never wedge a re-initiation.
|
|
29910
|
-
|
|
29983
|
+
uniqueIndex50("project_transfers_one_pending_idx").on(table.projectId).where(sql33`${table.status} = 'pending'`),
|
|
29911
29984
|
// Recipient inbox lookup (GET /me/transfers by email + status).
|
|
29912
|
-
|
|
29985
|
+
index95("project_transfers_recipient_idx").on(
|
|
29913
29986
|
table.recipientEmail,
|
|
29914
29987
|
table.status
|
|
29915
29988
|
),
|
|
29916
29989
|
// Source-side list (GET /projects/:id/transfers) + cancel.
|
|
29917
|
-
|
|
29918
|
-
|
|
29990
|
+
index95("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
|
|
29991
|
+
index95("project_transfers_project_idx").on(table.projectId),
|
|
29919
29992
|
// Magic-link resolution.
|
|
29920
|
-
|
|
29993
|
+
uniqueIndex50("project_transfers_token_idx").on(table.token),
|
|
29921
29994
|
// Expiry sweep — only pending rows are ever candidates.
|
|
29922
|
-
|
|
29995
|
+
index95("project_transfers_expires_idx").on(table.expiresAt).where(sql33`${table.status} = 'pending'`)
|
|
29923
29996
|
]
|
|
29924
29997
|
);
|
|
29925
29998
|
|
|
29926
29999
|
// src/schema/backups.ts
|
|
29927
30000
|
import {
|
|
29928
|
-
pgTable as
|
|
29929
|
-
text as
|
|
29930
|
-
varchar as
|
|
29931
|
-
integer as
|
|
30001
|
+
pgTable as pgTable108,
|
|
30002
|
+
text as text109,
|
|
30003
|
+
varchar as varchar81,
|
|
30004
|
+
integer as integer57,
|
|
29932
30005
|
bigint as bigint9,
|
|
29933
|
-
jsonb as
|
|
29934
|
-
timestamp as
|
|
29935
|
-
index as
|
|
30006
|
+
jsonb as jsonb65,
|
|
30007
|
+
timestamp as timestamp101,
|
|
30008
|
+
index as index96
|
|
29936
30009
|
} from "drizzle-orm/pg-core";
|
|
29937
30010
|
var FULL_BACKUP_SCOPE = {
|
|
29938
30011
|
content: true,
|
|
@@ -29941,315 +30014,315 @@ var FULL_BACKUP_SCOPE = {
|
|
|
29941
30014
|
submissions: true,
|
|
29942
30015
|
analytics: true
|
|
29943
30016
|
};
|
|
29944
|
-
var backups =
|
|
30017
|
+
var backups = pgTable108(
|
|
29945
30018
|
"backups",
|
|
29946
30019
|
{
|
|
29947
|
-
id:
|
|
30020
|
+
id: text109("id").primaryKey(),
|
|
29948
30021
|
// nanoid
|
|
29949
|
-
workspaceId:
|
|
30022
|
+
workspaceId: text109("workspace_id").notNull(),
|
|
29950
30023
|
// FK → workspaces.id (RLS scope)
|
|
29951
|
-
projectId:
|
|
30024
|
+
projectId: text109("project_id").notNull(),
|
|
29952
30025
|
// FK → projects.id
|
|
29953
|
-
name:
|
|
29954
|
-
source:
|
|
29955
|
-
status:
|
|
29956
|
-
manifestKey:
|
|
30026
|
+
name: varchar81("name", { length: 255 }).notNull(),
|
|
30027
|
+
source: varchar81("source", { length: 20 }).notNull().default("manual"),
|
|
30028
|
+
status: varchar81("status", { length: 20 }).notNull().default("pending"),
|
|
30029
|
+
manifestKey: text109("manifest_key"),
|
|
29957
30030
|
// R2 key of the gzipped manifest; NULL until ready
|
|
29958
|
-
manifestVersion:
|
|
30031
|
+
manifestVersion: integer57("manifest_version").notNull().default(1),
|
|
29959
30032
|
// forward-compat
|
|
29960
30033
|
sizeBytes: bigint9("size_bytes", { mode: "number" }),
|
|
29961
|
-
counts:
|
|
30034
|
+
counts: jsonb65("counts").$type().notNull().default({}),
|
|
29962
30035
|
// R2 object keys this snapshot references. Powers the media-GC hold:
|
|
29963
30036
|
// `list_backup_referenced_media_keys()` keeps these keys alive while the
|
|
29964
30037
|
// backup is live, so a restore never finds a garbage-collected object.
|
|
29965
|
-
mediaKeys:
|
|
29966
|
-
scope:
|
|
29967
|
-
error:
|
|
29968
|
-
createdBy:
|
|
30038
|
+
mediaKeys: jsonb65("media_keys").$type().notNull().default([]),
|
|
30039
|
+
scope: jsonb65("scope").$type().notNull().default(FULL_BACKUP_SCOPE),
|
|
30040
|
+
error: text109("error"),
|
|
30041
|
+
createdBy: text109("created_by"),
|
|
29969
30042
|
// FK → users(id); NULL = system-initiated
|
|
29970
|
-
createdAt:
|
|
29971
|
-
readyAt:
|
|
29972
|
-
expiresAt:
|
|
30043
|
+
createdAt: timestamp101("created_at").notNull().defaultNow(),
|
|
30044
|
+
readyAt: timestamp101("ready_at"),
|
|
30045
|
+
expiresAt: timestamp101("expires_at"),
|
|
29973
30046
|
// retention horizon; NULL = keep until count-pruned
|
|
29974
|
-
deletedAt:
|
|
30047
|
+
deletedAt: timestamp101("deleted_at")
|
|
29975
30048
|
},
|
|
29976
30049
|
(t) => [
|
|
29977
|
-
|
|
29978
|
-
|
|
30050
|
+
index96("backups_project_idx").on(t.projectId, t.createdAt),
|
|
30051
|
+
index96("backups_workspace_idx").on(t.workspaceId)
|
|
29979
30052
|
]
|
|
29980
30053
|
);
|
|
29981
30054
|
|
|
29982
30055
|
// src/schema/backup_jobs.ts
|
|
29983
30056
|
import {
|
|
29984
|
-
pgTable as
|
|
29985
|
-
text as
|
|
29986
|
-
varchar as
|
|
29987
|
-
integer as
|
|
29988
|
-
jsonb as
|
|
29989
|
-
timestamp as
|
|
29990
|
-
index as
|
|
30057
|
+
pgTable as pgTable109,
|
|
30058
|
+
text as text110,
|
|
30059
|
+
varchar as varchar82,
|
|
30060
|
+
integer as integer58,
|
|
30061
|
+
jsonb as jsonb66,
|
|
30062
|
+
timestamp as timestamp102,
|
|
30063
|
+
index as index97
|
|
29991
30064
|
} from "drizzle-orm/pg-core";
|
|
29992
|
-
var backupJobs =
|
|
30065
|
+
var backupJobs = pgTable109(
|
|
29993
30066
|
"backup_jobs",
|
|
29994
30067
|
{
|
|
29995
|
-
id:
|
|
30068
|
+
id: text110("id").primaryKey(),
|
|
29996
30069
|
// nanoid
|
|
29997
|
-
workspaceId:
|
|
29998
|
-
projectId:
|
|
30070
|
+
workspaceId: text110("workspace_id").notNull(),
|
|
30071
|
+
projectId: text110("project_id").notNull(),
|
|
29999
30072
|
// create → the pending backups.id this job fills; restore → the source backup.
|
|
30000
|
-
backupId:
|
|
30001
|
-
operation:
|
|
30002
|
-
status:
|
|
30003
|
-
progress:
|
|
30073
|
+
backupId: text110("backup_id"),
|
|
30074
|
+
operation: varchar82("operation", { length: 16 }).notNull(),
|
|
30075
|
+
status: varchar82("status", { length: 16 }).notNull().default("pending"),
|
|
30076
|
+
progress: integer58("progress").notNull().default(0),
|
|
30004
30077
|
// 0–100
|
|
30005
|
-
workingSince:
|
|
30006
|
-
attempts:
|
|
30007
|
-
error:
|
|
30008
|
-
payload:
|
|
30009
|
-
createdAt:
|
|
30010
|
-
updatedAt:
|
|
30078
|
+
workingSince: timestamp102("working_since", { withTimezone: true }),
|
|
30079
|
+
attempts: integer58("attempts").notNull().default(0),
|
|
30080
|
+
error: text110("error"),
|
|
30081
|
+
payload: jsonb66("payload").$type().notNull().default({}),
|
|
30082
|
+
createdAt: timestamp102("created_at").notNull().defaultNow(),
|
|
30083
|
+
updatedAt: timestamp102("updated_at").notNull().defaultNow()
|
|
30011
30084
|
},
|
|
30012
30085
|
(t) => [
|
|
30013
|
-
|
|
30014
|
-
|
|
30086
|
+
index97("backup_jobs_drain_idx").on(t.status, t.createdAt),
|
|
30087
|
+
index97("backup_jobs_project_idx").on(t.projectId)
|
|
30015
30088
|
]
|
|
30016
30089
|
);
|
|
30017
30090
|
|
|
30018
30091
|
// src/schema/clone_links.ts
|
|
30019
|
-
import { pgTable as
|
|
30020
|
-
var cloneLinks =
|
|
30092
|
+
import { pgTable as pgTable110, text as text111, boolean as boolean33, jsonb as jsonb67, timestamp as timestamp103, index as index98 } from "drizzle-orm/pg-core";
|
|
30093
|
+
var cloneLinks = pgTable110(
|
|
30021
30094
|
"clone_links",
|
|
30022
30095
|
{
|
|
30023
|
-
id:
|
|
30096
|
+
id: text111("id").primaryKey(),
|
|
30024
30097
|
// nanoid
|
|
30025
|
-
workspaceId:
|
|
30098
|
+
workspaceId: text111("workspace_id").notNull(),
|
|
30026
30099
|
// FK → workspaces.id (RLS scope)
|
|
30027
|
-
projectId:
|
|
30100
|
+
projectId: text111("project_id").notNull(),
|
|
30028
30101
|
// FK → projects.id
|
|
30029
|
-
token:
|
|
30102
|
+
token: text111("token").notNull(),
|
|
30030
30103
|
// public share token (nanoid); unique among active links
|
|
30031
30104
|
enabled: boolean33("enabled").notNull().default(true),
|
|
30032
|
-
scope:
|
|
30033
|
-
createdBy:
|
|
30105
|
+
scope: jsonb67("scope").$type().notNull(),
|
|
30106
|
+
createdBy: text111("created_by"),
|
|
30034
30107
|
// FK → users(id); NULL = system-initiated
|
|
30035
|
-
createdAt:
|
|
30036
|
-
updatedAt:
|
|
30037
|
-
revokedAt:
|
|
30108
|
+
createdAt: timestamp103("created_at").notNull().defaultNow(),
|
|
30109
|
+
updatedAt: timestamp103("updated_at").notNull().defaultNow(),
|
|
30110
|
+
revokedAt: timestamp103("revoked_at")
|
|
30038
30111
|
// set when the link is rotated/disabled
|
|
30039
30112
|
},
|
|
30040
30113
|
(t) => [
|
|
30041
|
-
|
|
30042
|
-
|
|
30114
|
+
index98("clone_links_project_idx").on(t.projectId),
|
|
30115
|
+
index98("clone_links_workspace_idx").on(t.workspaceId)
|
|
30043
30116
|
]
|
|
30044
30117
|
);
|
|
30045
30118
|
|
|
30046
30119
|
// src/schema/clone_jobs.ts
|
|
30047
|
-
import { pgTable as
|
|
30120
|
+
import { pgTable as pgTable111, text as text112, varchar as varchar83, integer as integer59, jsonb as jsonb68, timestamp as timestamp104, index as index99, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
|
|
30048
30121
|
import { sql as sql34 } from "drizzle-orm";
|
|
30049
|
-
var cloneJobs =
|
|
30122
|
+
var cloneJobs = pgTable111(
|
|
30050
30123
|
"clone_jobs",
|
|
30051
30124
|
{
|
|
30052
|
-
id:
|
|
30125
|
+
id: text112("id").primaryKey(),
|
|
30053
30126
|
// nanoid
|
|
30054
|
-
workspaceId:
|
|
30127
|
+
workspaceId: text112("workspace_id").notNull(),
|
|
30055
30128
|
// = targetWorkspaceId (RLS scope)
|
|
30056
|
-
sourceProjectId:
|
|
30057
|
-
sourceWorkspaceId:
|
|
30058
|
-
targetProjectId:
|
|
30129
|
+
sourceProjectId: text112("source_project_id").notNull(),
|
|
30130
|
+
sourceWorkspaceId: text112("source_workspace_id").notNull(),
|
|
30131
|
+
targetProjectId: text112("target_project_id"),
|
|
30059
30132
|
// stamped on success
|
|
30060
|
-
requestedName:
|
|
30061
|
-
requestedSlug:
|
|
30062
|
-
status:
|
|
30063
|
-
progress:
|
|
30133
|
+
requestedName: varchar83("requested_name", { length: 255 }),
|
|
30134
|
+
requestedSlug: varchar83("requested_slug", { length: 255 }),
|
|
30135
|
+
status: varchar83("status", { length: 16 }).notNull().default("pending"),
|
|
30136
|
+
progress: integer59("progress").notNull().default(0),
|
|
30064
30137
|
// 0–100
|
|
30065
|
-
workingSince:
|
|
30066
|
-
attempts:
|
|
30067
|
-
error:
|
|
30068
|
-
payload:
|
|
30138
|
+
workingSince: timestamp104("working_since", { withTimezone: true }),
|
|
30139
|
+
attempts: integer59("attempts").notNull().default(0),
|
|
30140
|
+
error: text112("error"),
|
|
30141
|
+
payload: jsonb68("payload").$type().notNull().default({}),
|
|
30069
30142
|
// Which post-clone work the drain owes a finished job. 'clone' = none, today's behaviour.
|
|
30070
30143
|
// Migration 0343.
|
|
30071
|
-
purpose:
|
|
30072
|
-
initiatedBy:
|
|
30144
|
+
purpose: varchar83("purpose", { length: 32 }).notNull().default("clone"),
|
|
30145
|
+
initiatedBy: text112("initiated_by"),
|
|
30073
30146
|
// FK → users(id); NULL = system/agent
|
|
30074
|
-
createdAt:
|
|
30075
|
-
updatedAt:
|
|
30147
|
+
createdAt: timestamp104("created_at").notNull().defaultNow(),
|
|
30148
|
+
updatedAt: timestamp104("updated_at").notNull().defaultNow()
|
|
30076
30149
|
},
|
|
30077
30150
|
(t) => [
|
|
30078
|
-
|
|
30079
|
-
|
|
30151
|
+
index99("clone_jobs_drain_idx").on(t.status, t.createdAt),
|
|
30152
|
+
index99("clone_jobs_workspace_idx").on(t.workspaceId),
|
|
30080
30153
|
// One unfinished hybrid→headless switch per source (0343). The route maps its 23505 to
|
|
30081
30154
|
// SWITCH_ALREADY_PENDING.
|
|
30082
|
-
|
|
30155
|
+
uniqueIndex51("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql34`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
|
|
30083
30156
|
]
|
|
30084
30157
|
);
|
|
30085
30158
|
|
|
30086
30159
|
// src/schema/project_branches.ts
|
|
30087
30160
|
import {
|
|
30088
30161
|
primaryKey as primaryKey11,
|
|
30089
|
-
pgTable as
|
|
30090
|
-
text as
|
|
30091
|
-
varchar as
|
|
30092
|
-
timestamp as
|
|
30093
|
-
index as
|
|
30094
|
-
uniqueIndex as
|
|
30162
|
+
pgTable as pgTable112,
|
|
30163
|
+
text as text113,
|
|
30164
|
+
varchar as varchar84,
|
|
30165
|
+
timestamp as timestamp105,
|
|
30166
|
+
index as index100,
|
|
30167
|
+
uniqueIndex as uniqueIndex52
|
|
30095
30168
|
} from "drizzle-orm/pg-core";
|
|
30096
30169
|
import { sql as sql35 } from "drizzle-orm";
|
|
30097
|
-
var projectBranches =
|
|
30170
|
+
var projectBranches = pgTable112(
|
|
30098
30171
|
"project_branches",
|
|
30099
30172
|
{
|
|
30100
|
-
id:
|
|
30101
|
-
workspaceId:
|
|
30102
|
-
projectId:
|
|
30103
|
-
name:
|
|
30104
|
-
slug:
|
|
30105
|
-
parentBranchId:
|
|
30106
|
-
status:
|
|
30107
|
-
appliedAt:
|
|
30108
|
-
abandonedAt:
|
|
30173
|
+
id: text113("id").primaryKey(),
|
|
30174
|
+
workspaceId: text113("workspace_id").notNull(),
|
|
30175
|
+
projectId: text113("project_id").notNull(),
|
|
30176
|
+
name: varchar84("name", { length: 80 }).notNull(),
|
|
30177
|
+
slug: varchar84("slug", { length: 80 }).notNull(),
|
|
30178
|
+
parentBranchId: text113("parent_branch_id"),
|
|
30179
|
+
status: varchar84("status", { length: 16 }).$type().notNull().default("open"),
|
|
30180
|
+
appliedAt: timestamp105("applied_at"),
|
|
30181
|
+
abandonedAt: timestamp105("abandoned_at"),
|
|
30109
30182
|
/** Set while an Apply/Pull runs (0374); a second one is refused. Stale after five minutes. */
|
|
30110
|
-
applyingAt:
|
|
30183
|
+
applyingAt: timestamp105("applying_at"),
|
|
30111
30184
|
...auditColumns
|
|
30112
30185
|
},
|
|
30113
30186
|
(t) => [
|
|
30114
|
-
|
|
30115
|
-
|
|
30187
|
+
index100("project_branches_project_idx").on(t.projectId),
|
|
30188
|
+
uniqueIndex52("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql35`${t.status} = 'open'`)
|
|
30116
30189
|
]
|
|
30117
30190
|
);
|
|
30118
|
-
var branchRowSyncs =
|
|
30191
|
+
var branchRowSyncs = pgTable112(
|
|
30119
30192
|
"branch_row_syncs",
|
|
30120
30193
|
{
|
|
30121
|
-
workspaceId:
|
|
30122
|
-
projectId:
|
|
30123
|
-
branchId:
|
|
30124
|
-
kind:
|
|
30125
|
-
parentRowId:
|
|
30126
|
-
syncedAt:
|
|
30194
|
+
workspaceId: text113("workspace_id").notNull(),
|
|
30195
|
+
projectId: text113("project_id").notNull(),
|
|
30196
|
+
branchId: text113("branch_id").notNull(),
|
|
30197
|
+
kind: text113("kind").notNull(),
|
|
30198
|
+
parentRowId: text113("parent_row_id").notNull(),
|
|
30199
|
+
syncedAt: timestamp105("synced_at").notNull().defaultNow()
|
|
30127
30200
|
},
|
|
30128
30201
|
(t) => [
|
|
30129
30202
|
primaryKey11({ columns: [t.branchId, t.kind, t.parentRowId] }),
|
|
30130
|
-
|
|
30203
|
+
index100("branch_row_syncs_project_idx").on(t.projectId)
|
|
30131
30204
|
]
|
|
30132
30205
|
);
|
|
30133
30206
|
|
|
30134
30207
|
// src/schema/branch_preview_share.ts
|
|
30135
|
-
import { pgTable as
|
|
30136
|
-
var branchPreviewShares =
|
|
30208
|
+
import { pgTable as pgTable113, text as text114, boolean as boolean34, timestamp as timestamp106, index as index101, uniqueIndex as uniqueIndex53 } from "drizzle-orm/pg-core";
|
|
30209
|
+
var branchPreviewShares = pgTable113(
|
|
30137
30210
|
"branch_preview_shares",
|
|
30138
30211
|
{
|
|
30139
|
-
id:
|
|
30140
|
-
workspaceId:
|
|
30141
|
-
projectId:
|
|
30142
|
-
branchId:
|
|
30212
|
+
id: text114("id").primaryKey(),
|
|
30213
|
+
workspaceId: text114("workspace_id").notNull(),
|
|
30214
|
+
projectId: text114("project_id").notNull(),
|
|
30215
|
+
branchId: text114("branch_id").notNull(),
|
|
30143
30216
|
publicEnabled: boolean34("public_enabled").notNull().default(false),
|
|
30144
|
-
publicToken:
|
|
30145
|
-
createdBy:
|
|
30146
|
-
createdAt:
|
|
30147
|
-
updatedAt:
|
|
30217
|
+
publicToken: text114("public_token"),
|
|
30218
|
+
createdBy: text114("created_by"),
|
|
30219
|
+
createdAt: timestamp106("created_at").notNull().defaultNow(),
|
|
30220
|
+
updatedAt: timestamp106("updated_at").notNull().defaultNow()
|
|
30148
30221
|
},
|
|
30149
30222
|
(t) => [
|
|
30150
|
-
|
|
30151
|
-
|
|
30152
|
-
|
|
30153
|
-
|
|
30223
|
+
uniqueIndex53("branch_preview_shares_branch_idx").on(t.branchId),
|
|
30224
|
+
uniqueIndex53("branch_preview_shares_active_token_idx").on(t.publicToken),
|
|
30225
|
+
index101("branch_preview_shares_project_idx").on(t.projectId),
|
|
30226
|
+
index101("branch_preview_shares_workspace_idx").on(t.workspaceId)
|
|
30154
30227
|
]
|
|
30155
30228
|
);
|
|
30156
|
-
var branchPreviewGrants =
|
|
30229
|
+
var branchPreviewGrants = pgTable113(
|
|
30157
30230
|
"branch_preview_grants",
|
|
30158
30231
|
{
|
|
30159
|
-
id:
|
|
30160
|
-
workspaceId:
|
|
30161
|
-
projectId:
|
|
30162
|
-
branchId:
|
|
30163
|
-
email:
|
|
30164
|
-
invitedBy:
|
|
30165
|
-
createdAt:
|
|
30232
|
+
id: text114("id").primaryKey(),
|
|
30233
|
+
workspaceId: text114("workspace_id").notNull(),
|
|
30234
|
+
projectId: text114("project_id").notNull(),
|
|
30235
|
+
branchId: text114("branch_id").notNull(),
|
|
30236
|
+
email: text114("email").notNull(),
|
|
30237
|
+
invitedBy: text114("invited_by"),
|
|
30238
|
+
createdAt: timestamp106("created_at").notNull().defaultNow()
|
|
30166
30239
|
},
|
|
30167
30240
|
(t) => [
|
|
30168
|
-
|
|
30169
|
-
|
|
30241
|
+
uniqueIndex53("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
|
|
30242
|
+
index101("branch_preview_grants_project_idx").on(t.projectId)
|
|
30170
30243
|
]
|
|
30171
30244
|
);
|
|
30172
30245
|
|
|
30173
30246
|
// src/schema/share_links.ts
|
|
30174
|
-
import { pgTable as
|
|
30175
|
-
var shareLinks =
|
|
30247
|
+
import { pgTable as pgTable114, text as text115, boolean as boolean35, timestamp as timestamp107, index as index102 } from "drizzle-orm/pg-core";
|
|
30248
|
+
var shareLinks = pgTable114(
|
|
30176
30249
|
"share_links",
|
|
30177
30250
|
{
|
|
30178
|
-
id:
|
|
30251
|
+
id: text115("id").primaryKey(),
|
|
30179
30252
|
// nanoid
|
|
30180
|
-
workspaceId:
|
|
30253
|
+
workspaceId: text115("workspace_id").notNull(),
|
|
30181
30254
|
// FK → workspaces.id (RLS scope)
|
|
30182
|
-
projectId:
|
|
30255
|
+
projectId: text115("project_id").notNull(),
|
|
30183
30256
|
// FK → projects.id
|
|
30184
|
-
token:
|
|
30257
|
+
token: text115("token").notNull(),
|
|
30185
30258
|
// public share token (nanoid); unique among active links
|
|
30186
30259
|
enabled: boolean35("enabled").notNull().default(true),
|
|
30187
|
-
createdBy:
|
|
30260
|
+
createdBy: text115("created_by"),
|
|
30188
30261
|
// FK → users(id); NULL = system-initiated
|
|
30189
|
-
createdAt:
|
|
30190
|
-
updatedAt:
|
|
30191
|
-
revokedAt:
|
|
30262
|
+
createdAt: timestamp107("created_at").notNull().defaultNow(),
|
|
30263
|
+
updatedAt: timestamp107("updated_at").notNull().defaultNow(),
|
|
30264
|
+
revokedAt: timestamp107("revoked_at")
|
|
30192
30265
|
// set when the link is disabled
|
|
30193
30266
|
},
|
|
30194
30267
|
(t) => [
|
|
30195
|
-
|
|
30196
|
-
|
|
30268
|
+
index102("share_links_project_idx").on(t.projectId),
|
|
30269
|
+
index102("share_links_workspace_idx").on(t.workspaceId)
|
|
30197
30270
|
]
|
|
30198
30271
|
);
|
|
30199
30272
|
|
|
30200
30273
|
// src/schema/templates.ts
|
|
30201
30274
|
import {
|
|
30202
|
-
pgTable as
|
|
30203
|
-
text as
|
|
30204
|
-
varchar as
|
|
30205
|
-
timestamp as
|
|
30206
|
-
jsonb as
|
|
30207
|
-
integer as
|
|
30208
|
-
index as
|
|
30209
|
-
uniqueIndex as
|
|
30275
|
+
pgTable as pgTable115,
|
|
30276
|
+
text as text116,
|
|
30277
|
+
varchar as varchar85,
|
|
30278
|
+
timestamp as timestamp108,
|
|
30279
|
+
jsonb as jsonb69,
|
|
30280
|
+
integer as integer60,
|
|
30281
|
+
index as index103,
|
|
30282
|
+
uniqueIndex as uniqueIndex54
|
|
30210
30283
|
} from "drizzle-orm/pg-core";
|
|
30211
30284
|
import { relations as relations17 } from "drizzle-orm/relations";
|
|
30212
30285
|
import { sql as sql36 } from "drizzle-orm";
|
|
30213
|
-
var templates =
|
|
30286
|
+
var templates = pgTable115(
|
|
30214
30287
|
"templates",
|
|
30215
30288
|
{
|
|
30216
|
-
id:
|
|
30289
|
+
id: text116("id").primaryKey(),
|
|
30217
30290
|
// nanoid
|
|
30218
|
-
workspaceId:
|
|
30291
|
+
workspaceId: text116("workspace_id").notNull(),
|
|
30219
30292
|
// FK to workspaces.id (RLS scope / owner)
|
|
30220
|
-
slug:
|
|
30293
|
+
slug: varchar85("slug", { length: 255 }).notNull(),
|
|
30221
30294
|
// ^[a-z0-9-]+$, unique per workspace
|
|
30222
|
-
name:
|
|
30223
|
-
description:
|
|
30224
|
-
scope:
|
|
30295
|
+
name: varchar85("name", { length: 255 }).notNull(),
|
|
30296
|
+
description: text116("description"),
|
|
30297
|
+
scope: varchar85("scope", { length: 10 }).$type().notNull().default("project"),
|
|
30225
30298
|
// 'demo' ships seed content; 'starter-kit' is the same schema with the content blanked.
|
|
30226
30299
|
// Defaults to 'demo' because a user template is a frozen snapshot of a real project,
|
|
30227
30300
|
// which always carries its source's content. Migration 0187.
|
|
30228
|
-
category:
|
|
30229
|
-
framework:
|
|
30301
|
+
category: varchar85("category", { length: 20 }).$type().notNull().default("demo"),
|
|
30302
|
+
framework: varchar85("framework", { length: 20 }).$type(),
|
|
30230
30303
|
// metadata hint
|
|
30231
|
-
thumbnail:
|
|
30304
|
+
thumbnail: varchar85("thumbnail", { length: 2048 }),
|
|
30232
30305
|
// Frozen snapshot manifest (stripped snapshot_project output). Never returned in
|
|
30233
30306
|
// list/gallery responses — only read server-side to instantiate.
|
|
30234
|
-
manifest:
|
|
30235
|
-
visibility:
|
|
30236
|
-
sourceProjectId:
|
|
30307
|
+
manifest: jsonb69("manifest").$type().notNull(),
|
|
30308
|
+
visibility: varchar85("visibility", { length: 10 }).$type().notNull().default("private"),
|
|
30309
|
+
sourceProjectId: text116("source_project_id"),
|
|
30237
30310
|
// provenance (nullable — source may be deleted later)
|
|
30238
|
-
createdBy:
|
|
30311
|
+
createdBy: text116("created_by"),
|
|
30239
30312
|
// user id, or null for a management-key create
|
|
30240
|
-
optimisticVersion:
|
|
30241
|
-
createdAt:
|
|
30242
|
-
updatedAt:
|
|
30243
|
-
deletedAt:
|
|
30313
|
+
optimisticVersion: integer60("optimistic_version").notNull().default(0),
|
|
30314
|
+
createdAt: timestamp108("created_at").notNull().defaultNow(),
|
|
30315
|
+
updatedAt: timestamp108("updated_at").notNull().defaultNow(),
|
|
30316
|
+
deletedAt: timestamp108("deleted_at")
|
|
30244
30317
|
// soft-delete
|
|
30245
30318
|
},
|
|
30246
30319
|
(table) => [
|
|
30247
|
-
|
|
30320
|
+
index103("templates_workspace_idx").on(table.workspaceId),
|
|
30248
30321
|
// Partial: only live rows. A soft-deleted template frees its slug (mirrors
|
|
30249
30322
|
// components_ws_proj_slug_idx / migration 0114).
|
|
30250
|
-
|
|
30323
|
+
uniqueIndex54("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql36`${table.deletedAt} IS NULL`),
|
|
30251
30324
|
// Public gallery scan (created_at DESC over live public rows).
|
|
30252
|
-
|
|
30325
|
+
index103("templates_public_idx").on(table.visibility).where(sql36`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
|
|
30253
30326
|
]
|
|
30254
30327
|
);
|
|
30255
30328
|
var templatesRelations = relations17(templates, ({ one }) => ({
|
|
@@ -30261,186 +30334,186 @@ var templatesRelations = relations17(templates, ({ one }) => ({
|
|
|
30261
30334
|
|
|
30262
30335
|
// src/schema/payment_records.ts
|
|
30263
30336
|
import {
|
|
30264
|
-
pgTable as
|
|
30265
|
-
text as
|
|
30266
|
-
varchar as
|
|
30267
|
-
integer as
|
|
30268
|
-
timestamp as
|
|
30269
|
-
index as
|
|
30337
|
+
pgTable as pgTable116,
|
|
30338
|
+
text as text117,
|
|
30339
|
+
varchar as varchar86,
|
|
30340
|
+
integer as integer61,
|
|
30341
|
+
timestamp as timestamp109,
|
|
30342
|
+
index as index104
|
|
30270
30343
|
} from "drizzle-orm/pg-core";
|
|
30271
|
-
var paymentRecords =
|
|
30344
|
+
var paymentRecords = pgTable116(
|
|
30272
30345
|
"payment_records",
|
|
30273
30346
|
{
|
|
30274
|
-
id:
|
|
30347
|
+
id: text117("id").primaryKey(),
|
|
30275
30348
|
// nanoid
|
|
30276
|
-
workspaceId:
|
|
30349
|
+
workspaceId: text117("workspace_id").notNull(),
|
|
30277
30350
|
// FK → workspaces.id
|
|
30278
|
-
amountCents:
|
|
30351
|
+
amountCents: integer61("amount_cents").notNull(),
|
|
30279
30352
|
// store money as integer cents
|
|
30280
|
-
currency:
|
|
30281
|
-
method:
|
|
30353
|
+
currency: varchar86("currency", { length: 3 }).notNull().default("usd"),
|
|
30354
|
+
method: varchar86("method", { length: 50 }).notNull().default("manual"),
|
|
30282
30355
|
// manual | stripe | wire | ...
|
|
30283
|
-
note:
|
|
30284
|
-
recordedBy:
|
|
30356
|
+
note: text117("note"),
|
|
30357
|
+
recordedBy: text117("recorded_by"),
|
|
30285
30358
|
// FK → users.id (the admin who entered it)
|
|
30286
|
-
createdAt:
|
|
30359
|
+
createdAt: timestamp109("created_at").notNull().defaultNow()
|
|
30287
30360
|
},
|
|
30288
30361
|
(table) => [
|
|
30289
|
-
|
|
30362
|
+
index104("payment_records_workspace_idx").on(table.workspaceId, table.createdAt)
|
|
30290
30363
|
]
|
|
30291
30364
|
);
|
|
30292
30365
|
|
|
30293
30366
|
// src/schema/plan_changes.ts
|
|
30294
30367
|
import {
|
|
30295
|
-
pgTable as
|
|
30296
|
-
text as
|
|
30297
|
-
timestamp as
|
|
30298
|
-
index as
|
|
30368
|
+
pgTable as pgTable117,
|
|
30369
|
+
text as text118,
|
|
30370
|
+
timestamp as timestamp110,
|
|
30371
|
+
index as index105
|
|
30299
30372
|
} from "drizzle-orm/pg-core";
|
|
30300
|
-
var planChanges =
|
|
30373
|
+
var planChanges = pgTable117(
|
|
30301
30374
|
"plan_changes",
|
|
30302
30375
|
{
|
|
30303
|
-
id:
|
|
30376
|
+
id: text118("id").primaryKey(),
|
|
30304
30377
|
// nanoid
|
|
30305
|
-
workspaceId:
|
|
30378
|
+
workspaceId: text118("workspace_id").notNull(),
|
|
30306
30379
|
// FK → workspaces.id
|
|
30307
|
-
fromPlan:
|
|
30380
|
+
fromPlan: text118("from_plan"),
|
|
30308
30381
|
// plan_limits.id before the change (null if unknown)
|
|
30309
|
-
toPlan:
|
|
30382
|
+
toPlan: text118("to_plan").notNull(),
|
|
30310
30383
|
// plan_limits.id after the change
|
|
30311
|
-
reason:
|
|
30312
|
-
changedBy:
|
|
30384
|
+
reason: text118("reason"),
|
|
30385
|
+
changedBy: text118("changed_by"),
|
|
30313
30386
|
// FK → users.id (the admin)
|
|
30314
|
-
createdAt:
|
|
30387
|
+
createdAt: timestamp110("created_at").notNull().defaultNow()
|
|
30315
30388
|
},
|
|
30316
30389
|
(table) => [
|
|
30317
|
-
|
|
30390
|
+
index105("plan_changes_workspace_idx").on(table.workspaceId, table.createdAt)
|
|
30318
30391
|
]
|
|
30319
30392
|
);
|
|
30320
30393
|
|
|
30321
30394
|
// src/schema/billing_addons.ts
|
|
30322
|
-
import { pgTable as
|
|
30323
|
-
var billingAddons =
|
|
30395
|
+
import { pgTable as pgTable118, text as text119, varchar as varchar87, integer as integer62, boolean as boolean36, jsonb as jsonb70, index as index106 } from "drizzle-orm/pg-core";
|
|
30396
|
+
var billingAddons = pgTable118(
|
|
30324
30397
|
"billing_addons",
|
|
30325
30398
|
{
|
|
30326
|
-
id:
|
|
30399
|
+
id: text119("id").primaryKey(),
|
|
30327
30400
|
// stable slug, e.g. "developer", "ai-1000", "localization"
|
|
30328
|
-
kind:
|
|
30401
|
+
kind: varchar87("kind", { length: 20 }).notNull(),
|
|
30329
30402
|
// seat_role | ai_credits | localization | ab_testing
|
|
30330
|
-
name:
|
|
30331
|
-
dodoProductId:
|
|
30403
|
+
name: varchar87("name", { length: 100 }).notNull(),
|
|
30404
|
+
dodoProductId: text119("dodo_product_id"),
|
|
30332
30405
|
// NULL until the Dodo product is created
|
|
30333
|
-
unitPriceCents:
|
|
30334
|
-
currency:
|
|
30335
|
-
credits:
|
|
30406
|
+
unitPriceCents: integer62("unit_price_cents").notNull(),
|
|
30407
|
+
currency: varchar87("currency", { length: 8 }).notNull().default("usd"),
|
|
30408
|
+
credits: integer62("credits"),
|
|
30336
30409
|
// ai_credits packs only: credits granted per unit
|
|
30337
30410
|
recurring: boolean36("recurring").notNull().default(false),
|
|
30338
30411
|
// seats/localization/AB = true; credit packs = false
|
|
30339
|
-
metadata:
|
|
30412
|
+
metadata: jsonb70("metadata").$type().default({}),
|
|
30340
30413
|
// Pricing v3 (0489): site (bought for one website) | workspace (members, credit packs).
|
|
30341
|
-
scope:
|
|
30342
|
-
visibility:
|
|
30414
|
+
scope: varchar87("scope", { length: 12 }).notNull().default("workspace"),
|
|
30415
|
+
visibility: varchar87("visibility", { length: 8 }).notNull().default("public")
|
|
30343
30416
|
},
|
|
30344
|
-
(t) => [
|
|
30417
|
+
(t) => [index106("billing_addons_kind_idx").on(t.kind)]
|
|
30345
30418
|
);
|
|
30346
30419
|
|
|
30347
30420
|
// src/schema/billing_customers.ts
|
|
30348
|
-
import { pgTable as
|
|
30349
|
-
var billingCustomers =
|
|
30421
|
+
import { pgTable as pgTable119, text as text120, varchar as varchar88, timestamp as timestamp111, uniqueIndex as uniqueIndex55 } from "drizzle-orm/pg-core";
|
|
30422
|
+
var billingCustomers = pgTable119(
|
|
30350
30423
|
"billing_customers",
|
|
30351
30424
|
{
|
|
30352
|
-
id:
|
|
30425
|
+
id: text120("id").primaryKey(),
|
|
30353
30426
|
// nanoid
|
|
30354
|
-
workspaceId:
|
|
30427
|
+
workspaceId: text120("workspace_id").notNull(),
|
|
30355
30428
|
// FK → workspaces.id (RLS scope)
|
|
30356
|
-
dodoCustomerId:
|
|
30357
|
-
email:
|
|
30358
|
-
createdAt:
|
|
30359
|
-
updatedAt:
|
|
30429
|
+
dodoCustomerId: text120("dodo_customer_id").notNull(),
|
|
30430
|
+
email: varchar88("email", { length: 255 }),
|
|
30431
|
+
createdAt: timestamp111("created_at").notNull().defaultNow(),
|
|
30432
|
+
updatedAt: timestamp111("updated_at").notNull().defaultNow()
|
|
30360
30433
|
},
|
|
30361
30434
|
(t) => [
|
|
30362
|
-
|
|
30363
|
-
|
|
30435
|
+
uniqueIndex55("billing_customers_workspace_idx").on(t.workspaceId),
|
|
30436
|
+
uniqueIndex55("billing_customers_dodo_idx").on(t.dodoCustomerId)
|
|
30364
30437
|
]
|
|
30365
30438
|
);
|
|
30366
30439
|
|
|
30367
30440
|
// src/schema/subscriptions.ts
|
|
30368
|
-
import { pgTable as
|
|
30441
|
+
import { pgTable as pgTable120, text as text121, varchar as varchar89, boolean as boolean37, timestamp as timestamp112, index as index107, uniqueIndex as uniqueIndex56 } from "drizzle-orm/pg-core";
|
|
30369
30442
|
import { sql as sql37 } from "drizzle-orm";
|
|
30370
|
-
var subscriptions =
|
|
30443
|
+
var subscriptions = pgTable120(
|
|
30371
30444
|
"subscriptions",
|
|
30372
30445
|
{
|
|
30373
|
-
id:
|
|
30446
|
+
id: text121("id").primaryKey(),
|
|
30374
30447
|
// nanoid
|
|
30375
|
-
workspaceId:
|
|
30448
|
+
workspaceId: text121("workspace_id").notNull(),
|
|
30376
30449
|
// FK → workspaces.id (RLS scope)
|
|
30377
|
-
projectId:
|
|
30450
|
+
projectId: text121("project_id"),
|
|
30378
30451
|
// NULL = workspace plan; set = site plan (FK → projects.id)
|
|
30379
|
-
planId:
|
|
30452
|
+
planId: text121("plan_id").notNull(),
|
|
30380
30453
|
// FK → plan_limits.id
|
|
30381
|
-
dodoSubscriptionId:
|
|
30382
|
-
dodoCustomerId:
|
|
30383
|
-
status:
|
|
30454
|
+
dodoSubscriptionId: text121("dodo_subscription_id"),
|
|
30455
|
+
dodoCustomerId: text121("dodo_customer_id"),
|
|
30456
|
+
status: varchar89("status", { length: 20 }).notNull().default("active"),
|
|
30384
30457
|
// active | on_hold | cancelled | expired | pending
|
|
30385
30458
|
// Which of plan_limits' two prices this row is billed at. Without it the bill cannot tell
|
|
30386
30459
|
// whether the owner pays price_cents or price_cents_yearly (0147).
|
|
30387
|
-
interval:
|
|
30460
|
+
interval: varchar89("interval", { length: 10 }).notNull().default("month"),
|
|
30388
30461
|
// month | year
|
|
30389
|
-
currentPeriodEnd:
|
|
30462
|
+
currentPeriodEnd: timestamp112("current_period_end"),
|
|
30390
30463
|
cancelAtPeriodEnd: boolean37("cancel_at_period_end").notNull().default(false),
|
|
30391
|
-
foundingUntil:
|
|
30464
|
+
foundingUntil: timestamp112("founding_until", { withTimezone: true }),
|
|
30392
30465
|
// founding price until (Pricing v3 §16)
|
|
30393
|
-
createdAt:
|
|
30394
|
-
updatedAt:
|
|
30466
|
+
createdAt: timestamp112("created_at").notNull().defaultNow(),
|
|
30467
|
+
updatedAt: timestamp112("updated_at").notNull().defaultNow()
|
|
30395
30468
|
},
|
|
30396
30469
|
(t) => [
|
|
30397
|
-
|
|
30398
|
-
|
|
30470
|
+
index107("subscriptions_workspace_idx").on(t.workspaceId),
|
|
30471
|
+
uniqueIndex56("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql37`${t.dodoSubscriptionId} IS NOT NULL`),
|
|
30399
30472
|
// At most one workspace-level subscription per workspace.
|
|
30400
|
-
|
|
30473
|
+
uniqueIndex56("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql37`${t.projectId} IS NULL`),
|
|
30401
30474
|
// At most one subscription per site.
|
|
30402
|
-
|
|
30475
|
+
uniqueIndex56("subscriptions_project_unique").on(t.projectId).where(sql37`${t.projectId} IS NOT NULL`)
|
|
30403
30476
|
]
|
|
30404
30477
|
);
|
|
30405
30478
|
|
|
30406
30479
|
// src/schema/subscription_addons.ts
|
|
30407
|
-
import { pgTable as
|
|
30480
|
+
import { pgTable as pgTable121, text as text122, varchar as varchar90, integer as integer63, timestamp as timestamp113, index as index108, uniqueIndex as uniqueIndex57 } from "drizzle-orm/pg-core";
|
|
30408
30481
|
import { sql as sql38 } from "drizzle-orm";
|
|
30409
|
-
var subscriptionAddons =
|
|
30482
|
+
var subscriptionAddons = pgTable121(
|
|
30410
30483
|
"subscription_addons",
|
|
30411
30484
|
{
|
|
30412
|
-
id:
|
|
30485
|
+
id: text122("id").primaryKey(),
|
|
30413
30486
|
// nanoid
|
|
30414
|
-
workspaceId:
|
|
30487
|
+
workspaceId: text122("workspace_id").notNull(),
|
|
30415
30488
|
// FK → workspaces.id (RLS scope)
|
|
30416
|
-
addonId:
|
|
30489
|
+
addonId: text122("addon_id").notNull(),
|
|
30417
30490
|
// FK → billing_addons.id
|
|
30418
|
-
projectId:
|
|
30491
|
+
projectId: text122("project_id"),
|
|
30419
30492
|
// the website a site add-on belongs to (Pricing v3); NULL = workspace-wide
|
|
30420
|
-
quantity:
|
|
30421
|
-
dodoSubscriptionId:
|
|
30493
|
+
quantity: integer63("quantity").notNull().default(1),
|
|
30494
|
+
dodoSubscriptionId: text122("dodo_subscription_id"),
|
|
30422
30495
|
// NULL for a manual/admin grant
|
|
30423
|
-
status:
|
|
30496
|
+
status: varchar90("status", { length: 20 }).notNull().default("active"),
|
|
30424
30497
|
// active | cancelled | expired
|
|
30425
|
-
createdAt:
|
|
30426
|
-
updatedAt:
|
|
30498
|
+
createdAt: timestamp113("created_at").notNull().defaultNow(),
|
|
30499
|
+
updatedAt: timestamp113("updated_at").notNull().defaultNow()
|
|
30427
30500
|
},
|
|
30428
30501
|
(t) => [
|
|
30429
|
-
|
|
30430
|
-
|
|
30502
|
+
index108("subscription_addons_workspace_idx").on(t.workspaceId),
|
|
30503
|
+
uniqueIndex57("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql38`${t.dodoSubscriptionId} IS NOT NULL`)
|
|
30431
30504
|
]
|
|
30432
30505
|
);
|
|
30433
30506
|
|
|
30434
30507
|
// src/schema/billing_alerts.ts
|
|
30435
|
-
import { pgTable as
|
|
30436
|
-
var billingAlerts =
|
|
30508
|
+
import { pgTable as pgTable122, text as text123, varchar as varchar91, timestamp as timestamp114, index as index109, uniqueIndex as uniqueIndex58 } from "drizzle-orm/pg-core";
|
|
30509
|
+
var billingAlerts = pgTable122(
|
|
30437
30510
|
"billing_alerts",
|
|
30438
30511
|
{
|
|
30439
|
-
id:
|
|
30512
|
+
id: text123("id").primaryKey(),
|
|
30440
30513
|
// nanoid
|
|
30441
|
-
workspaceId:
|
|
30514
|
+
workspaceId: text123("workspace_id").notNull(),
|
|
30442
30515
|
// FK → workspaces.id (internal table, no RLS)
|
|
30443
|
-
kind:
|
|
30516
|
+
kind: varchar91("kind", { length: 32 }).notNull(),
|
|
30444
30517
|
// renewal_due | bandwidth_80 | bandwidth_100
|
|
30445
30518
|
/**
|
|
30446
30519
|
* What "already sent" means for this alert, built by the caller (alerts.ts owns the spellings).
|
|
@@ -30448,104 +30521,104 @@ var billingAlerts = pgTable121(
|
|
|
30448
30521
|
* period-end change. Bandwidth keys on the threshold + calendar month, matching the window
|
|
30449
30522
|
* getUsage() measures — so the counter resetting on the 1st re-arms the alert.
|
|
30450
30523
|
*/
|
|
30451
|
-
dedupeKey:
|
|
30452
|
-
sentAt:
|
|
30524
|
+
dedupeKey: text123("dedupe_key").notNull(),
|
|
30525
|
+
sentAt: timestamp114("sent_at", { withTimezone: true }).notNull().defaultNow()
|
|
30453
30526
|
},
|
|
30454
30527
|
(t) => [
|
|
30455
|
-
|
|
30456
|
-
|
|
30528
|
+
uniqueIndex58("billing_alerts_dedupe_idx").on(t.dedupeKey),
|
|
30529
|
+
index109("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
|
|
30457
30530
|
]
|
|
30458
30531
|
);
|
|
30459
30532
|
|
|
30460
30533
|
// src/schema/ai_credit_ledger.ts
|
|
30461
|
-
import { pgTable as
|
|
30534
|
+
import { pgTable as pgTable123, text as text124, varchar as varchar92, integer as integer64, timestamp as timestamp115, index as index110, uniqueIndex as uniqueIndex59 } from "drizzle-orm/pg-core";
|
|
30462
30535
|
import { sql as sql39 } from "drizzle-orm";
|
|
30463
|
-
var aiCreditLedger =
|
|
30536
|
+
var aiCreditLedger = pgTable123(
|
|
30464
30537
|
"ai_credit_ledger",
|
|
30465
30538
|
{
|
|
30466
|
-
id:
|
|
30539
|
+
id: text124("id").primaryKey(),
|
|
30467
30540
|
// nanoid
|
|
30468
|
-
workspaceId:
|
|
30541
|
+
workspaceId: text124("workspace_id").notNull(),
|
|
30469
30542
|
// FK → workspaces.id (RLS scope)
|
|
30470
|
-
delta:
|
|
30543
|
+
delta: integer64("delta").notNull(),
|
|
30471
30544
|
// signed: +purchase/grant, -consume/expire
|
|
30472
|
-
reason:
|
|
30545
|
+
reason: varchar92("reason", { length: 20 }).notNull(),
|
|
30473
30546
|
// purchase | consume | grant | expire
|
|
30474
|
-
dodoPaymentId:
|
|
30547
|
+
dodoPaymentId: text124("dodo_payment_id"),
|
|
30475
30548
|
// set for purchases
|
|
30476
|
-
note:
|
|
30477
|
-
createdAt:
|
|
30549
|
+
note: text124("note"),
|
|
30550
|
+
createdAt: timestamp115("created_at").notNull().defaultNow()
|
|
30478
30551
|
},
|
|
30479
30552
|
(t) => [
|
|
30480
|
-
|
|
30481
|
-
|
|
30553
|
+
index110("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt),
|
|
30554
|
+
uniqueIndex59("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql39`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
|
|
30482
30555
|
]
|
|
30483
30556
|
);
|
|
30484
30557
|
|
|
30485
30558
|
// src/schema/support_tickets.ts
|
|
30486
30559
|
import {
|
|
30487
|
-
pgTable as
|
|
30488
|
-
text as
|
|
30489
|
-
varchar as
|
|
30490
|
-
timestamp as
|
|
30560
|
+
pgTable as pgTable124,
|
|
30561
|
+
text as text125,
|
|
30562
|
+
varchar as varchar93,
|
|
30563
|
+
timestamp as timestamp116,
|
|
30491
30564
|
boolean as boolean38,
|
|
30492
|
-
jsonb as
|
|
30493
|
-
index as
|
|
30565
|
+
jsonb as jsonb71,
|
|
30566
|
+
index as index111
|
|
30494
30567
|
} from "drizzle-orm/pg-core";
|
|
30495
|
-
var supportTickets =
|
|
30568
|
+
var supportTickets = pgTable124(
|
|
30496
30569
|
"support_tickets",
|
|
30497
30570
|
{
|
|
30498
|
-
id:
|
|
30571
|
+
id: text125("id").primaryKey(),
|
|
30499
30572
|
// nanoid
|
|
30500
|
-
workspaceId:
|
|
30573
|
+
workspaceId: text125("workspace_id"),
|
|
30501
30574
|
// FK → workspaces.id (nullable: account-level tickets)
|
|
30502
30575
|
// FK → users.id (the customer). NULL for a ticket Plain created: an email or Slack
|
|
30503
30576
|
// sender has no BetterCMS account. visibleTicketWhere() compares this to the session
|
|
30504
30577
|
// user, and NULL never matches, so those tickets stay invisible to every customer —
|
|
30505
30578
|
// which is correct, since there is no dashboard reply transport for them.
|
|
30506
|
-
userId:
|
|
30579
|
+
userId: text125("user_id"),
|
|
30507
30580
|
// The only identity a Plain-origin ticket has. The staff list coalesces it with
|
|
30508
30581
|
// users.email; NULL whenever userId is set.
|
|
30509
|
-
customerEmail:
|
|
30510
|
-
customerName:
|
|
30511
|
-
subject:
|
|
30512
|
-
body:
|
|
30513
|
-
status:
|
|
30582
|
+
customerEmail: text125("customer_email"),
|
|
30583
|
+
customerName: text125("customer_name"),
|
|
30584
|
+
subject: varchar93("subject", { length: 255 }).notNull(),
|
|
30585
|
+
body: text125("body").notNull(),
|
|
30586
|
+
status: varchar93("status", { length: 20 }).notNull().default("open"),
|
|
30514
30587
|
// open | pending | closed
|
|
30515
|
-
priority:
|
|
30588
|
+
priority: varchar93("priority", { length: 20 }).notNull().default("normal"),
|
|
30516
30589
|
// low | normal | high | urgent
|
|
30517
|
-
assigneeId:
|
|
30590
|
+
assigneeId: text125("assignee_id"),
|
|
30518
30591
|
// FK → users.id (staff member handling it)
|
|
30519
30592
|
// Plain's ThreadChannel, lowercased. 'api' is a ticket opened in the dashboard; the
|
|
30520
30593
|
// rest arrive from Plain. The staff reply path branches on this: 'api' threads deliver
|
|
30521
30594
|
// nothing to the customer so we send the email ourselves, every other channel is
|
|
30522
30595
|
// delivered by Plain.
|
|
30523
|
-
channel:
|
|
30596
|
+
channel: text125("channel").notNull().default("api"),
|
|
30524
30597
|
// The Plain thread this ticket mirrors. NULL until the first outbound sync succeeds,
|
|
30525
30598
|
// hence the partial unique index rather than a unique column.
|
|
30526
|
-
plainThreadId:
|
|
30599
|
+
plainThreadId: text125("plain_thread_id"),
|
|
30527
30600
|
// Files attached when the case was opened, before any message row exists.
|
|
30528
|
-
attachments:
|
|
30529
|
-
createdAt:
|
|
30530
|
-
updatedAt:
|
|
30601
|
+
attachments: jsonb71("attachments").$type().notNull().default([]),
|
|
30602
|
+
createdAt: timestamp116("created_at").notNull().defaultNow(),
|
|
30603
|
+
updatedAt: timestamp116("updated_at").notNull().defaultNow()
|
|
30531
30604
|
},
|
|
30532
30605
|
(table) => [
|
|
30533
|
-
|
|
30534
|
-
|
|
30535
|
-
|
|
30536
|
-
|
|
30606
|
+
index111("support_tickets_status_idx").on(table.status, table.updatedAt),
|
|
30607
|
+
index111("support_tickets_workspace_idx").on(table.workspaceId),
|
|
30608
|
+
index111("support_tickets_user_idx").on(table.userId),
|
|
30609
|
+
index111("support_tickets_channel_idx").on(table.channel, table.updatedAt)
|
|
30537
30610
|
]
|
|
30538
30611
|
);
|
|
30539
|
-
var supportTicketMessages =
|
|
30612
|
+
var supportTicketMessages = pgTable124(
|
|
30540
30613
|
"support_ticket_messages",
|
|
30541
30614
|
{
|
|
30542
|
-
id:
|
|
30615
|
+
id: text125("id").primaryKey(),
|
|
30543
30616
|
// nanoid
|
|
30544
|
-
ticketId:
|
|
30617
|
+
ticketId: text125("ticket_id").notNull(),
|
|
30545
30618
|
// FK → support_tickets.id
|
|
30546
|
-
authorId:
|
|
30619
|
+
authorId: text125("author_id"),
|
|
30547
30620
|
// FK → users.id (staff or customer)
|
|
30548
|
-
body:
|
|
30621
|
+
body: text125("body").notNull(),
|
|
30549
30622
|
isStaff: boolean38("is_staff").notNull().default(false),
|
|
30550
30623
|
// true = team reply
|
|
30551
30624
|
// Staff-only triage note. NEVER leaves the platform-admin lane: the customer read
|
|
@@ -30555,99 +30628,99 @@ var supportTicketMessages = pgTable123(
|
|
|
30555
30628
|
// at-least-once webhook. NULL for anything Plain never saw, and for our own replies on
|
|
30556
30629
|
// channels whose mutation returns no entry id — replyToThread returns only an error
|
|
30557
30630
|
// slot, which is why the echo check keys on the actor and this is the backstop.
|
|
30558
|
-
plainMessageId:
|
|
30559
|
-
attachments:
|
|
30560
|
-
createdAt:
|
|
30631
|
+
plainMessageId: text125("plain_message_id"),
|
|
30632
|
+
attachments: jsonb71("attachments").$type().notNull().default([]),
|
|
30633
|
+
createdAt: timestamp116("created_at").notNull().defaultNow()
|
|
30561
30634
|
},
|
|
30562
30635
|
(table) => [
|
|
30563
|
-
|
|
30636
|
+
index111("support_ticket_messages_ticket_idx").on(table.ticketId, table.createdAt)
|
|
30564
30637
|
]
|
|
30565
30638
|
);
|
|
30566
30639
|
|
|
30567
30640
|
// src/schema/admin_action_logs.ts
|
|
30568
30641
|
import {
|
|
30569
|
-
pgTable as
|
|
30570
|
-
text as
|
|
30571
|
-
varchar as
|
|
30572
|
-
jsonb as
|
|
30573
|
-
timestamp as
|
|
30574
|
-
index as
|
|
30642
|
+
pgTable as pgTable125,
|
|
30643
|
+
text as text126,
|
|
30644
|
+
varchar as varchar94,
|
|
30645
|
+
jsonb as jsonb72,
|
|
30646
|
+
timestamp as timestamp117,
|
|
30647
|
+
index as index112
|
|
30575
30648
|
} from "drizzle-orm/pg-core";
|
|
30576
|
-
var adminActionLogs =
|
|
30649
|
+
var adminActionLogs = pgTable125(
|
|
30577
30650
|
"admin_action_logs",
|
|
30578
30651
|
{
|
|
30579
|
-
id:
|
|
30652
|
+
id: text126("id").primaryKey(),
|
|
30580
30653
|
// nanoid
|
|
30581
|
-
actorId:
|
|
30654
|
+
actorId: text126("actor_id"),
|
|
30582
30655
|
// FK → users.id (the staff member)
|
|
30583
|
-
actorEmail:
|
|
30656
|
+
actorEmail: varchar94("actor_email", { length: 320 }),
|
|
30584
30657
|
// denormalized for display
|
|
30585
|
-
actorRole:
|
|
30658
|
+
actorRole: varchar94("actor_role", { length: 40 }),
|
|
30586
30659
|
// admin_role at action time
|
|
30587
|
-
action:
|
|
30660
|
+
action: varchar94("action", { length: 80 }).notNull(),
|
|
30588
30661
|
// e.g. workspace.plan_change
|
|
30589
|
-
targetType:
|
|
30662
|
+
targetType: varchar94("target_type", { length: 40 }),
|
|
30590
30663
|
// workspace | user | plan | ticket
|
|
30591
|
-
targetId:
|
|
30592
|
-
reason:
|
|
30593
|
-
metadata:
|
|
30594
|
-
ipAddress:
|
|
30595
|
-
createdAt:
|
|
30664
|
+
targetId: text126("target_id"),
|
|
30665
|
+
reason: text126("reason"),
|
|
30666
|
+
metadata: jsonb72("metadata").$type().notNull().default({}),
|
|
30667
|
+
ipAddress: text126("ip_address"),
|
|
30668
|
+
createdAt: timestamp117("created_at").notNull().defaultNow()
|
|
30596
30669
|
},
|
|
30597
30670
|
(table) => [
|
|
30598
|
-
|
|
30599
|
-
|
|
30671
|
+
index112("admin_action_logs_created_idx").on(table.createdAt),
|
|
30672
|
+
index112("admin_action_logs_action_idx").on(table.action, table.createdAt)
|
|
30600
30673
|
]
|
|
30601
30674
|
);
|
|
30602
30675
|
|
|
30603
30676
|
// src/schema/admin_notes.ts
|
|
30604
|
-
import { pgTable as
|
|
30605
|
-
var adminNotes =
|
|
30677
|
+
import { pgTable as pgTable126, text as text127, varchar as varchar95, boolean as boolean39, timestamp as timestamp118, index as index113 } from "drizzle-orm/pg-core";
|
|
30678
|
+
var adminNotes = pgTable126(
|
|
30606
30679
|
"admin_notes",
|
|
30607
30680
|
{
|
|
30608
|
-
id:
|
|
30681
|
+
id: text127("id").primaryKey(),
|
|
30609
30682
|
// nanoid
|
|
30610
|
-
targetType:
|
|
30683
|
+
targetType: varchar95("target_type", { length: 20 }).notNull(),
|
|
30611
30684
|
// user | workspace | project
|
|
30612
|
-
targetId:
|
|
30613
|
-
body:
|
|
30614
|
-
authorId:
|
|
30685
|
+
targetId: text127("target_id").notNull(),
|
|
30686
|
+
body: text127("body").notNull(),
|
|
30687
|
+
authorId: text127("author_id"),
|
|
30615
30688
|
// FK → users.id (the staff member)
|
|
30616
|
-
authorEmail:
|
|
30689
|
+
authorEmail: varchar95("author_email", { length: 320 }),
|
|
30617
30690
|
// denormalized for display
|
|
30618
30691
|
pinned: boolean39("pinned").notNull().default(false),
|
|
30619
|
-
createdAt:
|
|
30620
|
-
updatedAt:
|
|
30692
|
+
createdAt: timestamp118("created_at").notNull().defaultNow(),
|
|
30693
|
+
updatedAt: timestamp118("updated_at").notNull().defaultNow()
|
|
30621
30694
|
},
|
|
30622
30695
|
(t) => [
|
|
30623
30696
|
// Pinned first, then newest — the exact order the tab renders.
|
|
30624
|
-
|
|
30697
|
+
index113("admin_notes_target_idx").on(t.targetType, t.targetId, t.pinned, t.createdAt)
|
|
30625
30698
|
]
|
|
30626
30699
|
);
|
|
30627
30700
|
|
|
30628
30701
|
// src/schema/admin_agent_sessions.ts
|
|
30629
|
-
import { pgTable as
|
|
30630
|
-
var adminAgentSessions =
|
|
30702
|
+
import { pgTable as pgTable127, text as text128, varchar as varchar96, doublePrecision as doublePrecision2, timestamp as timestamp119, index as index114 } from "drizzle-orm/pg-core";
|
|
30703
|
+
var adminAgentSessions = pgTable127(
|
|
30631
30704
|
"admin_agent_sessions",
|
|
30632
30705
|
{
|
|
30633
|
-
id:
|
|
30706
|
+
id: text128("id").primaryKey(),
|
|
30634
30707
|
// nanoid
|
|
30635
|
-
actorId:
|
|
30708
|
+
actorId: text128("actor_id").notNull(),
|
|
30636
30709
|
// FK → users.id (the staff member)
|
|
30637
|
-
actorEmail:
|
|
30638
|
-
title:
|
|
30639
|
-
status:
|
|
30710
|
+
actorEmail: varchar96("actor_email", { length: 320 }),
|
|
30711
|
+
title: varchar96("title", { length: 200 }),
|
|
30712
|
+
status: varchar96("status", { length: 20 }).notNull().default("active"),
|
|
30640
30713
|
// active | error
|
|
30641
30714
|
costUsd: doublePrecision2("cost_usd").notNull().default(0),
|
|
30642
|
-
createdAt:
|
|
30643
|
-
updatedAt:
|
|
30644
|
-
lastActiveAt:
|
|
30715
|
+
createdAt: timestamp119("created_at").notNull().defaultNow(),
|
|
30716
|
+
updatedAt: timestamp119("updated_at").notNull().defaultNow(),
|
|
30717
|
+
lastActiveAt: timestamp119("last_active_at").notNull().defaultNow()
|
|
30645
30718
|
},
|
|
30646
|
-
(t) => [
|
|
30719
|
+
(t) => [index114("admin_agent_sessions_actor_idx").on(t.actorId, t.lastActiveAt)]
|
|
30647
30720
|
);
|
|
30648
30721
|
|
|
30649
30722
|
// src/schema/crm_deals.ts
|
|
30650
|
-
import { pgTable as
|
|
30723
|
+
import { pgTable as pgTable128, text as text129, varchar as varchar97, integer as integer65, timestamp as timestamp120, index as index115, unique as unique13 } from "drizzle-orm/pg-core";
|
|
30651
30724
|
var CRM_STAGES = [
|
|
30652
30725
|
"qualified",
|
|
30653
30726
|
"conversation",
|
|
@@ -30655,212 +30728,212 @@ var CRM_STAGES = [
|
|
|
30655
30728
|
"customer",
|
|
30656
30729
|
"at_risk"
|
|
30657
30730
|
];
|
|
30658
|
-
var crmDeals =
|
|
30731
|
+
var crmDeals = pgTable128(
|
|
30659
30732
|
"crm_deals",
|
|
30660
30733
|
{
|
|
30661
|
-
id:
|
|
30734
|
+
id: text129("id").primaryKey(),
|
|
30662
30735
|
// nanoid
|
|
30663
|
-
workspaceId:
|
|
30736
|
+
workspaceId: text129("workspace_id").notNull(),
|
|
30664
30737
|
// FK → workspaces.id
|
|
30665
|
-
stage:
|
|
30666
|
-
valueCents:
|
|
30738
|
+
stage: varchar97("stage", { length: 20 }).notNull().default("qualified").$type(),
|
|
30739
|
+
valueCents: integer65("value_cents"),
|
|
30667
30740
|
// annual contract value the rep is working toward
|
|
30668
|
-
ownerId:
|
|
30741
|
+
ownerId: text129("owner_id"),
|
|
30669
30742
|
// FK → users.id (the staff member on the account)
|
|
30670
|
-
nextStep:
|
|
30671
|
-
notes:
|
|
30672
|
-
lastTouchAt:
|
|
30673
|
-
createdAt:
|
|
30674
|
-
updatedAt:
|
|
30743
|
+
nextStep: text129("next_step"),
|
|
30744
|
+
notes: text129("notes"),
|
|
30745
|
+
lastTouchAt: timestamp120("last_touch_at"),
|
|
30746
|
+
createdAt: timestamp120("created_at").notNull().defaultNow(),
|
|
30747
|
+
updatedAt: timestamp120("updated_at").notNull().defaultNow()
|
|
30675
30748
|
},
|
|
30676
30749
|
(t) => [
|
|
30677
30750
|
unique13("crm_deals_workspace_id_key").on(t.workspaceId),
|
|
30678
|
-
|
|
30679
|
-
|
|
30751
|
+
index115("crm_deals_stage_idx").on(t.stage, t.lastTouchAt),
|
|
30752
|
+
index115("crm_deals_owner_idx").on(t.ownerId)
|
|
30680
30753
|
]
|
|
30681
30754
|
);
|
|
30682
30755
|
|
|
30683
30756
|
// src/schema/project_env_vars.ts
|
|
30684
30757
|
import {
|
|
30685
|
-
pgTable as
|
|
30686
|
-
text as
|
|
30687
|
-
varchar as
|
|
30688
|
-
timestamp as
|
|
30689
|
-
index as
|
|
30690
|
-
uniqueIndex as
|
|
30758
|
+
pgTable as pgTable129,
|
|
30759
|
+
text as text130,
|
|
30760
|
+
varchar as varchar98,
|
|
30761
|
+
timestamp as timestamp121,
|
|
30762
|
+
index as index116,
|
|
30763
|
+
uniqueIndex as uniqueIndex60
|
|
30691
30764
|
} from "drizzle-orm/pg-core";
|
|
30692
30765
|
var ENV_VAR_SCOPES = ["production", "preview", "development"];
|
|
30693
|
-
var projectEnvVars =
|
|
30766
|
+
var projectEnvVars = pgTable129(
|
|
30694
30767
|
"project_env_vars",
|
|
30695
30768
|
{
|
|
30696
|
-
id:
|
|
30769
|
+
id: text130("id").primaryKey(),
|
|
30697
30770
|
// nanoid
|
|
30698
|
-
projectId:
|
|
30771
|
+
projectId: text130("project_id").notNull(),
|
|
30699
30772
|
// FK to projects.id
|
|
30700
|
-
workspaceId:
|
|
30773
|
+
workspaceId: text130("workspace_id").notNull(),
|
|
30701
30774
|
// FK to workspaces.id — RLS scope
|
|
30702
|
-
key:
|
|
30703
|
-
valueEnc:
|
|
30775
|
+
key: varchar98("key", { length: 128 }).notNull(),
|
|
30776
|
+
valueEnc: text130("value_enc").notNull(),
|
|
30704
30777
|
// AES-256-GCM, `iv:tag:ciphertext` hex
|
|
30705
|
-
scope:
|
|
30706
|
-
updatedBy:
|
|
30778
|
+
scope: varchar98("scope", { length: 16 }).$type().notNull(),
|
|
30779
|
+
updatedBy: text130("updated_by"),
|
|
30707
30780
|
// FK to users.id, nullable
|
|
30708
|
-
updatedAt:
|
|
30709
|
-
createdAt:
|
|
30781
|
+
updatedAt: timestamp121("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30782
|
+
createdAt: timestamp121("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30710
30783
|
/** Last read by an integration's vendor call (0473; written at most hourly). */
|
|
30711
|
-
lastUsedAt:
|
|
30784
|
+
lastUsedAt: timestamp121("last_used_at", { withTimezone: true }),
|
|
30712
30785
|
/** Rotation (0473): the value before the last rotate, accepted until `previousExpiresAt` only
|
|
30713
30786
|
* where a vendor signs with it (webhook verification). Outbound calls use the current value. */
|
|
30714
|
-
previousValueEnc:
|
|
30715
|
-
previousExpiresAt:
|
|
30787
|
+
previousValueEnc: text130("previous_value_enc"),
|
|
30788
|
+
previousExpiresAt: timestamp121("previous_expires_at", { withTimezone: true })
|
|
30716
30789
|
},
|
|
30717
30790
|
(table) => [
|
|
30718
30791
|
// One value per key per scope — the same key MAY exist in production and preview.
|
|
30719
|
-
|
|
30792
|
+
uniqueIndex60("project_env_vars_project_key_scope_idx").on(
|
|
30720
30793
|
table.projectId,
|
|
30721
30794
|
table.key,
|
|
30722
30795
|
table.scope
|
|
30723
30796
|
),
|
|
30724
|
-
|
|
30797
|
+
index116("project_env_vars_project_idx").on(table.projectId)
|
|
30725
30798
|
]
|
|
30726
30799
|
);
|
|
30727
30800
|
|
|
30728
30801
|
// src/schema/mcp_connections.ts
|
|
30729
|
-
import { pgTable as
|
|
30802
|
+
import { pgTable as pgTable130, text as text131, varchar as varchar99, jsonb as jsonb73, timestamp as timestamp122, index as index117, uniqueIndex as uniqueIndex61 } from "drizzle-orm/pg-core";
|
|
30730
30803
|
import { sql as sql40 } from "drizzle-orm";
|
|
30731
|
-
var mcpConnections =
|
|
30804
|
+
var mcpConnections = pgTable130(
|
|
30732
30805
|
"mcp_connections",
|
|
30733
30806
|
{
|
|
30734
|
-
id:
|
|
30807
|
+
id: text131("id").primaryKey(),
|
|
30735
30808
|
// nanoid
|
|
30736
|
-
workspaceId:
|
|
30809
|
+
workspaceId: text131("workspace_id").notNull(),
|
|
30737
30810
|
// FK → workspaces.id (RLS scope)
|
|
30738
|
-
projectId:
|
|
30811
|
+
projectId: text131("project_id").notNull(),
|
|
30739
30812
|
// FK → projects.id (application-enforced)
|
|
30740
30813
|
/** Catalog slug (`notion` | `linear` | `hubspot` | `figma`) or `custom` for a user-added server. */
|
|
30741
|
-
providerSlug:
|
|
30814
|
+
providerSlug: varchar99("provider_slug", { length: 32 }).notNull(),
|
|
30742
30815
|
/** Where tools come from. See the header note — NOT interchangeable with authMode. */
|
|
30743
|
-
kind:
|
|
30816
|
+
kind: varchar99("kind", { length: 16 }).notNull().$type(),
|
|
30744
30817
|
/** How the credential is obtained. See the header note. */
|
|
30745
|
-
authMode:
|
|
30818
|
+
authMode: varchar99("auth_mode", { length: 24 }).notNull().$type(),
|
|
30746
30819
|
/** Display name. The catalog's name for a known provider; user-supplied for a custom one. */
|
|
30747
|
-
name:
|
|
30820
|
+
name: varchar99("name", { length: 120 }).notNull(),
|
|
30748
30821
|
/** Remote Streamable-HTTP endpoint. NULL for `kind: 'rest'`, which has no MCP server. */
|
|
30749
|
-
serverUrl:
|
|
30822
|
+
serverUrl: text131("server_url"),
|
|
30750
30823
|
/** Display only — the connected Notion workspace / Linear org / Figma account. */
|
|
30751
|
-
accountLabel:
|
|
30752
|
-
accessTokenEnc:
|
|
30753
|
-
refreshTokenEnc:
|
|
30754
|
-
expiresAt:
|
|
30824
|
+
accountLabel: varchar99("account_label", { length: 255 }),
|
|
30825
|
+
accessTokenEnc: text131("access_token_enc"),
|
|
30826
|
+
refreshTokenEnc: text131("refresh_token_enc"),
|
|
30827
|
+
expiresAt: timestamp122("expires_at", { withTimezone: true }),
|
|
30755
30828
|
/** `custom_headers` mode only: the encrypted header map a gateway requires on every call. */
|
|
30756
|
-
headersEnc:
|
|
30829
|
+
headersEnc: text131("headers_enc"),
|
|
30757
30830
|
/** DCR-issued or statically configured — the same two columns serve both, deliberately. */
|
|
30758
|
-
oauthClientId:
|
|
30759
|
-
oauthClientSecretEnc:
|
|
30831
|
+
oauthClientId: varchar99("oauth_client_id", { length: 255 }),
|
|
30832
|
+
oauthClientSecretEnc: text131("oauth_client_secret_enc"),
|
|
30760
30833
|
/** Both cleared on a successful exchange; see the header note on why they must exist at all. */
|
|
30761
|
-
oauthState:
|
|
30762
|
-
pkceVerifierEnc:
|
|
30834
|
+
oauthState: text131("oauth_state"),
|
|
30835
|
+
pkceVerifierEnc: text131("pkce_verifier_enc"),
|
|
30763
30836
|
/** Discovery output: authorization server metadata, token endpoint, RFC 8707 resource. */
|
|
30764
|
-
authMetadata:
|
|
30765
|
-
scopes:
|
|
30837
|
+
authMetadata: jsonb73("auth_metadata").$type(),
|
|
30838
|
+
scopes: text131("scopes").array().$type(),
|
|
30766
30839
|
/**
|
|
30767
30840
|
* Full descriptors (name, description, inputSchema, annotations) — NOT just names. The
|
|
30768
30841
|
* read-only boundary is decided from `annotations.readOnlyHint`, so the names alone would
|
|
30769
30842
|
* force a live listTools on the turn path to answer a governance question.
|
|
30770
30843
|
*/
|
|
30771
|
-
toolsCache:
|
|
30772
|
-
toolsCachedAt:
|
|
30844
|
+
toolsCache: jsonb73("tools_cache").$type().notNull().default([]),
|
|
30845
|
+
toolsCachedAt: timestamp122("tools_cached_at", { withTimezone: true }),
|
|
30773
30846
|
/**
|
|
30774
30847
|
* pending | ok | invalid | revoked. `pending` is the pre-consent row; `invalid` is set on a
|
|
30775
30848
|
* provider 401 or a decrypt failure so the UI can say "reconnect" instead of replaying the
|
|
30776
30849
|
* same auth error on every turn forever.
|
|
30777
30850
|
*/
|
|
30778
|
-
status:
|
|
30851
|
+
status: varchar99("status", { length: 16 }).notNull().default("pending").$type(),
|
|
30779
30852
|
/** Machine-readable companion to `status`, e.g. `decrypt_failed`, `provider_401`. */
|
|
30780
|
-
statusReason:
|
|
30781
|
-
lastError:
|
|
30782
|
-
lastUsedAt:
|
|
30783
|
-
connectedBy:
|
|
30853
|
+
statusReason: varchar99("status_reason", { length: 64 }),
|
|
30854
|
+
lastError: text131("last_error"),
|
|
30855
|
+
lastUsedAt: timestamp122("last_used_at", { withTimezone: true }),
|
|
30856
|
+
connectedBy: text131("connected_by"),
|
|
30784
30857
|
// FK → users(id), added in migration
|
|
30785
30858
|
...auditColumns,
|
|
30786
30859
|
...softDeleteColumn
|
|
30787
30860
|
},
|
|
30788
30861
|
(t) => [
|
|
30789
|
-
|
|
30790
|
-
|
|
30862
|
+
index117("mcp_connections_workspace_idx").on(t.workspaceId),
|
|
30863
|
+
index117("mcp_connections_project_idx").on(t.projectId),
|
|
30791
30864
|
// Reconnecting a catalog provider UPDATEs rather than accumulating a second live credential.
|
|
30792
30865
|
// Custom connectors are excluded: a project may legitimately add many distinct MCP servers.
|
|
30793
|
-
|
|
30866
|
+
uniqueIndex61("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql40`deleted_at IS NULL AND provider_slug <> 'custom'`)
|
|
30794
30867
|
]
|
|
30795
30868
|
);
|
|
30796
30869
|
|
|
30797
30870
|
// src/schema/crm_connections.ts
|
|
30798
30871
|
import {
|
|
30799
|
-
pgTable as
|
|
30800
|
-
text as
|
|
30801
|
-
timestamp as
|
|
30872
|
+
pgTable as pgTable131,
|
|
30873
|
+
text as text132,
|
|
30874
|
+
timestamp as timestamp123,
|
|
30802
30875
|
boolean as boolean40,
|
|
30803
|
-
jsonb as
|
|
30804
|
-
integer as
|
|
30805
|
-
uniqueIndex as
|
|
30876
|
+
jsonb as jsonb74,
|
|
30877
|
+
integer as integer66,
|
|
30878
|
+
uniqueIndex as uniqueIndex62
|
|
30806
30879
|
} from "drizzle-orm/pg-core";
|
|
30807
|
-
var crmConnections =
|
|
30880
|
+
var crmConnections = pgTable131(
|
|
30808
30881
|
"crm_connections",
|
|
30809
30882
|
{
|
|
30810
|
-
id:
|
|
30811
|
-
workspaceId:
|
|
30812
|
-
provider:
|
|
30813
|
-
accountId:
|
|
30814
|
-
accountName:
|
|
30815
|
-
instanceUrl:
|
|
30883
|
+
id: text132("id").primaryKey(),
|
|
30884
|
+
workspaceId: text132("workspace_id").notNull(),
|
|
30885
|
+
provider: text132("provider").$type().notNull(),
|
|
30886
|
+
accountId: text132("account_id").notNull(),
|
|
30887
|
+
accountName: text132("account_name").notNull(),
|
|
30888
|
+
instanceUrl: text132("instance_url").notNull(),
|
|
30816
30889
|
sandbox: boolean40("sandbox").notNull().default(false),
|
|
30817
|
-
status:
|
|
30818
|
-
accessToken:
|
|
30819
|
-
refreshToken:
|
|
30820
|
-
expiresAt:
|
|
30821
|
-
createdAt:
|
|
30822
|
-
updatedAt:
|
|
30890
|
+
status: text132("status").notNull().default("connected"),
|
|
30891
|
+
accessToken: text132("access_token").notNull(),
|
|
30892
|
+
refreshToken: text132("refresh_token").notNull(),
|
|
30893
|
+
expiresAt: timestamp123("expires_at").notNull(),
|
|
30894
|
+
createdAt: timestamp123("created_at").notNull().defaultNow(),
|
|
30895
|
+
updatedAt: timestamp123("updated_at").notNull().defaultNow()
|
|
30823
30896
|
},
|
|
30824
30897
|
(t) => [
|
|
30825
|
-
|
|
30898
|
+
uniqueIndex62("crm_connection_account_uq").on(
|
|
30826
30899
|
t.workspaceId,
|
|
30827
30900
|
t.provider,
|
|
30828
30901
|
t.accountId
|
|
30829
30902
|
)
|
|
30830
30903
|
]
|
|
30831
30904
|
);
|
|
30832
|
-
var crmOauthStates =
|
|
30833
|
-
id:
|
|
30834
|
-
workspaceId:
|
|
30835
|
-
userId:
|
|
30836
|
-
provider:
|
|
30837
|
-
verifier:
|
|
30838
|
-
returnPath:
|
|
30905
|
+
var crmOauthStates = pgTable131("crm_oauth_states", {
|
|
30906
|
+
id: text132("id").primaryKey(),
|
|
30907
|
+
workspaceId: text132("workspace_id").notNull(),
|
|
30908
|
+
userId: text132("user_id").notNull(),
|
|
30909
|
+
provider: text132("provider").notNull(),
|
|
30910
|
+
verifier: text132("verifier").notNull(),
|
|
30911
|
+
returnPath: text132("return_path").notNull(),
|
|
30839
30912
|
sandbox: boolean40("sandbox").notNull(),
|
|
30840
|
-
expiresAt:
|
|
30913
|
+
expiresAt: timestamp123("expires_at").notNull()
|
|
30841
30914
|
});
|
|
30842
|
-
var formIntegrationDeliveries =
|
|
30915
|
+
var formIntegrationDeliveries = pgTable131(
|
|
30843
30916
|
"form_integration_deliveries",
|
|
30844
30917
|
{
|
|
30845
|
-
id:
|
|
30846
|
-
workspaceId:
|
|
30847
|
-
formId:
|
|
30848
|
-
integrationId:
|
|
30849
|
-
eventId:
|
|
30850
|
-
submissionId:
|
|
30851
|
-
snapshot:
|
|
30852
|
-
data:
|
|
30853
|
-
status:
|
|
30854
|
-
attempts:
|
|
30855
|
-
lastError:
|
|
30856
|
-
remoteRecordId:
|
|
30857
|
-
nextAttemptAt:
|
|
30858
|
-
leaseUntil:
|
|
30859
|
-
createdAt:
|
|
30860
|
-
updatedAt:
|
|
30918
|
+
id: text132("id").primaryKey(),
|
|
30919
|
+
workspaceId: text132("workspace_id").notNull(),
|
|
30920
|
+
formId: text132("form_id").notNull(),
|
|
30921
|
+
integrationId: text132("integration_id").notNull(),
|
|
30922
|
+
eventId: text132("event_id").notNull(),
|
|
30923
|
+
submissionId: text132("submission_id").notNull(),
|
|
30924
|
+
snapshot: jsonb74("snapshot").$type().notNull(),
|
|
30925
|
+
data: jsonb74("data").$type().notNull(),
|
|
30926
|
+
status: text132("status").notNull().default("queued"),
|
|
30927
|
+
attempts: integer66("attempts").notNull().default(0),
|
|
30928
|
+
lastError: text132("last_error"),
|
|
30929
|
+
remoteRecordId: text132("remote_record_id"),
|
|
30930
|
+
nextAttemptAt: timestamp123("next_attempt_at").notNull().defaultNow(),
|
|
30931
|
+
leaseUntil: timestamp123("lease_until"),
|
|
30932
|
+
createdAt: timestamp123("created_at").notNull().defaultNow(),
|
|
30933
|
+
updatedAt: timestamp123("updated_at").notNull().defaultNow()
|
|
30861
30934
|
},
|
|
30862
30935
|
(t) => [
|
|
30863
|
-
|
|
30936
|
+
uniqueIndex62("crm_delivery_event_uq").on(
|
|
30864
30937
|
t.workspaceId,
|
|
30865
30938
|
t.eventId,
|
|
30866
30939
|
t.integrationId
|
|
@@ -30869,101 +30942,101 @@ var formIntegrationDeliveries = pgTable130(
|
|
|
30869
30942
|
);
|
|
30870
30943
|
|
|
30871
30944
|
// src/schema/platform_incidents.ts
|
|
30872
|
-
import { check as check12, integer as
|
|
30945
|
+
import { check as check12, integer as integer67, pgTable as pgTable132, smallint as smallint3, text as text133, timestamp as timestamp124, index as index118 } from "drizzle-orm/pg-core";
|
|
30873
30946
|
import { sql as sql41 } from "drizzle-orm";
|
|
30874
30947
|
var STATUS_IN = sql41.raw("('investigating', 'identified', 'monitoring', 'resolved')");
|
|
30875
|
-
var platformIncidents =
|
|
30948
|
+
var platformIncidents = pgTable132(
|
|
30876
30949
|
"platform_incidents",
|
|
30877
30950
|
{
|
|
30878
|
-
id:
|
|
30879
|
-
number:
|
|
30880
|
-
title:
|
|
30951
|
+
id: text133("id").primaryKey(),
|
|
30952
|
+
number: integer67("number").generatedAlwaysAsIdentity().notNull().unique("platform_incidents_number_key"),
|
|
30953
|
+
title: text133("title").notNull(),
|
|
30881
30954
|
severity: smallint3("severity").notNull(),
|
|
30882
30955
|
// 1 (worst) … 4
|
|
30883
|
-
status:
|
|
30956
|
+
status: text133("status").notNull().default("investigating"),
|
|
30884
30957
|
// investigating | identified | monitoring | resolved
|
|
30885
|
-
services:
|
|
30886
|
-
commanderId:
|
|
30887
|
-
startedAt:
|
|
30888
|
-
resolvedAt:
|
|
30889
|
-
createdBy:
|
|
30890
|
-
createdAt:
|
|
30891
|
-
updatedAt:
|
|
30958
|
+
services: text133("services").array().notNull().default([]),
|
|
30959
|
+
commanderId: text133("commander_id"),
|
|
30960
|
+
startedAt: timestamp124("started_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30961
|
+
resolvedAt: timestamp124("resolved_at", { withTimezone: true }),
|
|
30962
|
+
createdBy: text133("created_by"),
|
|
30963
|
+
createdAt: timestamp124("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30964
|
+
updatedAt: timestamp124("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
30892
30965
|
},
|
|
30893
30966
|
// Mirrors 0375 exactly: drizzle-kit push builds fresh DBs before the migration runs.
|
|
30894
30967
|
(t) => [
|
|
30895
|
-
|
|
30968
|
+
index118("platform_incidents_started_idx").on(t.startedAt.desc()),
|
|
30896
30969
|
check12("platform_incidents_severity_check", sql41`${t.severity} BETWEEN 1 AND 4`),
|
|
30897
30970
|
check12("platform_incidents_status_check", sql41`${t.status} IN ${STATUS_IN}`)
|
|
30898
30971
|
]
|
|
30899
30972
|
);
|
|
30900
|
-
var platformIncidentUpdates =
|
|
30973
|
+
var platformIncidentUpdates = pgTable132(
|
|
30901
30974
|
"platform_incident_updates",
|
|
30902
30975
|
{
|
|
30903
|
-
id:
|
|
30904
|
-
incidentId:
|
|
30905
|
-
status:
|
|
30906
|
-
note:
|
|
30907
|
-
createdBy:
|
|
30908
|
-
createdAt:
|
|
30976
|
+
id: text133("id").primaryKey(),
|
|
30977
|
+
incidentId: text133("incident_id").notNull().references(() => platformIncidents.id, { onDelete: "cascade" }),
|
|
30978
|
+
status: text133("status").notNull(),
|
|
30979
|
+
note: text133("note").notNull(),
|
|
30980
|
+
createdBy: text133("created_by"),
|
|
30981
|
+
createdAt: timestamp124("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
30909
30982
|
},
|
|
30910
30983
|
(t) => [
|
|
30911
|
-
|
|
30984
|
+
index118("platform_incident_updates_incident_idx").on(t.incidentId, t.createdAt),
|
|
30912
30985
|
check12("platform_incident_updates_status_check", sql41`${t.status} IN ${STATUS_IN}`)
|
|
30913
30986
|
]
|
|
30914
30987
|
);
|
|
30915
30988
|
|
|
30916
30989
|
// src/schema/platform_vendors.ts
|
|
30917
|
-
import { date as date4, integer as
|
|
30918
|
-
var platformVendors =
|
|
30919
|
-
id:
|
|
30920
|
-
name:
|
|
30921
|
-
category:
|
|
30922
|
-
billingCycle:
|
|
30990
|
+
import { date as date4, integer as integer68, pgTable as pgTable133, text as text134, timestamp as timestamp125, varchar as varchar100 } from "drizzle-orm/pg-core";
|
|
30991
|
+
var platformVendors = pgTable133("platform_vendors", {
|
|
30992
|
+
id: text134("id").primaryKey(),
|
|
30993
|
+
name: text134("name").notNull(),
|
|
30994
|
+
category: text134("category").notNull(),
|
|
30995
|
+
billingCycle: text134("billing_cycle").notNull().default("monthly"),
|
|
30923
30996
|
// monthly | yearly | usage
|
|
30924
|
-
monthlyCents:
|
|
30997
|
+
monthlyCents: integer68("monthly_cents").notNull().default(0),
|
|
30925
30998
|
// normalised monthly cost
|
|
30926
|
-
currency:
|
|
30999
|
+
currency: varchar100("currency", { length: 3 }).notNull().default("usd"),
|
|
30927
31000
|
renewsOn: date4("renews_on"),
|
|
30928
31001
|
// YYYY-MM-DD
|
|
30929
|
-
status:
|
|
31002
|
+
status: text134("status").notNull().default("active"),
|
|
30930
31003
|
// active | trial | cancelling | unused
|
|
30931
|
-
ownerEmail:
|
|
30932
|
-
notes:
|
|
30933
|
-
createdBy:
|
|
30934
|
-
createdAt:
|
|
30935
|
-
updatedAt:
|
|
31004
|
+
ownerEmail: text134("owner_email"),
|
|
31005
|
+
notes: text134("notes"),
|
|
31006
|
+
createdBy: text134("created_by"),
|
|
31007
|
+
createdAt: timestamp125("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
31008
|
+
updatedAt: timestamp125("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
30936
31009
|
});
|
|
30937
31010
|
|
|
30938
31011
|
// src/schema/platform_tasks.ts
|
|
30939
|
-
import { check as check13, date as date5, pgTable as
|
|
31012
|
+
import { check as check13, date as date5, pgTable as pgTable134, text as text135, timestamp as timestamp126, index as index119 } from "drizzle-orm/pg-core";
|
|
30940
31013
|
import { sql as sql42 } from "drizzle-orm";
|
|
30941
|
-
var platformTasks =
|
|
31014
|
+
var platformTasks = pgTable134(
|
|
30942
31015
|
"platform_tasks",
|
|
30943
31016
|
{
|
|
30944
|
-
id:
|
|
30945
|
-
title:
|
|
30946
|
-
description:
|
|
30947
|
-
status:
|
|
31017
|
+
id: text135("id").primaryKey(),
|
|
31018
|
+
title: text135("title").notNull(),
|
|
31019
|
+
description: text135("description"),
|
|
31020
|
+
status: text135("status").notNull().default("open"),
|
|
30948
31021
|
// open | in_progress | done
|
|
30949
|
-
priority:
|
|
31022
|
+
priority: text135("priority").notNull().default("medium"),
|
|
30950
31023
|
// low | medium | high | urgent
|
|
30951
|
-
assigneeId:
|
|
31024
|
+
assigneeId: text135("assignee_id"),
|
|
30952
31025
|
dueOn: date5("due_on"),
|
|
30953
31026
|
// YYYY-MM-DD
|
|
30954
|
-
entityType:
|
|
31027
|
+
entityType: text135("entity_type"),
|
|
30955
31028
|
// user | workspace | incident | deal
|
|
30956
|
-
entityId:
|
|
30957
|
-
entityLabel:
|
|
30958
|
-
completedAt:
|
|
30959
|
-
createdBy:
|
|
30960
|
-
createdAt:
|
|
30961
|
-
updatedAt:
|
|
31029
|
+
entityId: text135("entity_id"),
|
|
31030
|
+
entityLabel: text135("entity_label"),
|
|
31031
|
+
completedAt: timestamp126("completed_at", { withTimezone: true }),
|
|
31032
|
+
createdBy: text135("created_by"),
|
|
31033
|
+
createdAt: timestamp126("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
31034
|
+
updatedAt: timestamp126("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
30962
31035
|
},
|
|
30963
31036
|
// Mirrors 0377 exactly: drizzle-kit push builds fresh DBs before the migration runs.
|
|
30964
31037
|
(t) => [
|
|
30965
|
-
|
|
30966
|
-
|
|
31038
|
+
index119("platform_tasks_open_idx").on(t.status, t.dueOn),
|
|
31039
|
+
index119("platform_tasks_entity_idx").on(t.entityType, t.entityId),
|
|
30967
31040
|
check13("platform_tasks_status_check", sql42`${t.status} IN ('open', 'in_progress', 'done')`),
|
|
30968
31041
|
check13("platform_tasks_priority_check", sql42`${t.priority} IN ('low', 'medium', 'high', 'urgent')`),
|
|
30969
31042
|
check13("platform_tasks_entity_type_check", sql42`${t.entityType} IN ('user', 'workspace', 'incident', 'deal')`),
|
|
@@ -31646,6 +31719,8 @@ export {
|
|
|
31646
31719
|
db,
|
|
31647
31720
|
deployTargets,
|
|
31648
31721
|
deviceAuthorizations,
|
|
31722
|
+
dockUiSourceVersions,
|
|
31723
|
+
dockUiSources,
|
|
31649
31724
|
emailSuppressions,
|
|
31650
31725
|
ensureCollection,
|
|
31651
31726
|
ensureDefaultWorkspace,
|