@bettercms-ai/db 0.8.3 → 0.10.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 +375 -6
- package/dist/index.js +1086 -1044
- 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 index111 = 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
|
+
index111++;
|
|
11663
11663
|
const formatter = createDebug.formatters[format];
|
|
11664
11664
|
if (typeof formatter === "function") {
|
|
11665
|
-
const val = args[
|
|
11665
|
+
const val = args[index111];
|
|
11666
11666
|
match = formatter.call(self2, val);
|
|
11667
|
-
args.splice(
|
|
11668
|
-
|
|
11667
|
+
args.splice(index111, 1);
|
|
11668
|
+
index111--;
|
|
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 index111 = 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
|
+
index111++;
|
|
11911
11911
|
if (match === "%c") {
|
|
11912
|
-
lastC =
|
|
11912
|
+
lastC = index111;
|
|
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, index111) {
|
|
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], index111, 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(index111) {
|
|
14778
|
+
if (index111 > MAX_DEPTH) {
|
|
14779
|
+
throw new AxiosError("FormData field is too deeply nested (" + index111 + " 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, index111) {
|
|
14806
|
+
throwIfDepthExceeded(index111);
|
|
14807
|
+
let name = path2[index111++];
|
|
14808
14808
|
if (name === "__proto__") return true;
|
|
14809
14809
|
const isNumericKey = Number.isFinite(+name);
|
|
14810
|
-
const isLast =
|
|
14810
|
+
const isLast = index111 >= 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], index111);
|
|
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 = (text128) => {
|
|
15493
|
+
if (/^0[xX][0-9a-fA-F]+$/.test(text128)) {
|
|
15494
|
+
const n = parseInt(text128.slice(2), 16);
|
|
15495
15495
|
return Number.isFinite(n) ? n : null;
|
|
15496
15496
|
}
|
|
15497
|
-
if (
|
|
15498
|
-
const n = parseInt(
|
|
15497
|
+
if (text128.length > 1 && /^0[0-7]+$/.test(text128)) {
|
|
15498
|
+
const n = parseInt(text128, 8);
|
|
15499
15499
|
return Number.isFinite(n) ? n : null;
|
|
15500
15500
|
}
|
|
15501
|
-
if (
|
|
15501
|
+
if (text128.length > 1 && /^0[0-9]+$/.test(text128)) {
|
|
15502
15502
|
return null;
|
|
15503
15503
|
}
|
|
15504
|
-
if (/^[0-9]+$/.test(
|
|
15505
|
-
const n = parseInt(
|
|
15504
|
+
if (/^[0-9]+$/.test(text128)) {
|
|
15505
|
+
const n = parseInt(text128, 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 timestamp119 = 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
|
+
timestamp119 = 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 - timestamp119;
|
|
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 index111 = this._listeners.indexOf(listener);
|
|
18246
|
+
if (index111 !== -1) {
|
|
18247
|
+
this._listeners.splice(index111, 1);
|
|
18248
18248
|
}
|
|
18249
18249
|
}
|
|
18250
18250
|
toAbortSignal() {
|
|
@@ -22014,6 +22014,7 @@ __export(index_exports, {
|
|
|
22014
22014
|
contentEntries: () => contentEntries,
|
|
22015
22015
|
contentEntriesRelations: () => contentEntriesRelations,
|
|
22016
22016
|
contentLocks: () => contentLocks,
|
|
22017
|
+
contentModelVersions: () => contentModelVersions,
|
|
22017
22018
|
contentModels: () => contentModels,
|
|
22018
22019
|
contentModelsRelations: () => contentModelsRelations,
|
|
22019
22020
|
contentNavigation: () => contentNavigation,
|
|
@@ -22795,6 +22796,13 @@ var contentModels = pgTable4(
|
|
|
22795
22796
|
// without a concurrency token two editors silently delete each other's fields.
|
|
22796
22797
|
// Mirrors pages.optimistic_version; enforced via If-Match / ETag on PATCH.
|
|
22797
22798
|
optimisticVersion: integer4("optimistic_version").notNull().default(0),
|
|
22799
|
+
// V2 schema-editor settings (migration 0458). Authoring-only, never delivered. NULL = unset.
|
|
22800
|
+
/** A dock icon name for the collection, validated on write against the dock vocabulary. */
|
|
22801
|
+
icon: varchar4("icon", { length: 64 }),
|
|
22802
|
+
/** How an entry row reads in the list: each slot names a top-level field key. */
|
|
22803
|
+
listPreview: jsonb5("list_preview").$type(),
|
|
22804
|
+
/** The entries list order when the request sends no `sort`. */
|
|
22805
|
+
defaultSort: jsonb5("default_sort").$type(),
|
|
22798
22806
|
branchId: text5("branch_id"),
|
|
22799
22807
|
originId: text5("origin_id"),
|
|
22800
22808
|
createdAt: timestamp5("created_at").notNull().defaultNow(),
|
|
@@ -22972,6 +22980,9 @@ var mediaAssets = pgTable6(
|
|
|
22972
22980
|
// Non-destructive — unlike /crop, setting this never rewrites the original bytes.
|
|
22973
22981
|
focalX: real("focal_x"),
|
|
22974
22982
|
focalY: real("focal_y"),
|
|
22983
|
+
// When somebody set (or reset) the point above. NULL = never: the point, if any, is the one adoption
|
|
22984
|
+
// computed, which an in-place publish must not draw on a page nobody edited (migration 0461).
|
|
22985
|
+
focalEditedAt: timestamp7("focal_edited_at"),
|
|
22975
22986
|
// Image optimization pipeline (sharp on the VPS, src/lib/thumbnail.ts):
|
|
22976
22987
|
// 'pending' → queued or in-flight; cron retries after 5 min
|
|
22977
22988
|
// 'ready' → 200px WebP at <workspaceId>/<projectId>/<assetId>/thumbs/200.webp; thumbHash set
|
|
@@ -26872,6 +26883,16 @@ var components = pgTable83(
|
|
|
26872
26883
|
// Authoring chrome, DRAFT-only: outside the publish snapshot, so it never makes a component
|
|
26873
26884
|
// "changed". Null keeps the dashboard's global controls. Validated at the API layer.
|
|
26874
26885
|
design: jsonb44("design").$type(),
|
|
26886
|
+
// The component's BLOCK icon (migration 0460): a dock icon name for the root crumb, slot rows
|
|
26887
|
+
// and slot child frames. Draft-only authoring chrome like `design`. Null = unset. Validated at the API layer.
|
|
26888
|
+
icon: text84("icon"),
|
|
26889
|
+
// The V2 tabs NO top-level prop sits in (migration 0462): [{ id, label, icon?, order? }], declared
|
|
26890
|
+
// so a /kit schema round-trips. Draft-only authoring chrome like `design`. Null = none. Validated at the API layer.
|
|
26891
|
+
tabs: jsonb44("tabs").$type(),
|
|
26892
|
+
// How an instance reads as a ROW in a parent's slot list (migration 0459): { title?, subtitle?,
|
|
26893
|
+
// media?, fallback?, icon? }, title/subtitle/media naming top-level prop keys. Draft-only
|
|
26894
|
+
// authoring chrome like `design`. Null = unset. Validated at the API layer.
|
|
26895
|
+
preview: jsonb44("preview").$type(),
|
|
26875
26896
|
// Draft/live split (migration 0186_component_draft_live_split.sql). `blockJson`/`props`
|
|
26876
26897
|
// above are the DRAFT; these two are the LIVE snapshot that get_components_by_handle()
|
|
26877
26898
|
// serves. Nullable: a never-published component has no live copy. A DB trigger fills them
|
|
@@ -27025,30 +27046,50 @@ var savedBlocks = pgTable86(
|
|
|
27025
27046
|
(t) => [index73("saved_blocks_project_idx").on(t.workspaceId, t.projectId, t.createdAt)]
|
|
27026
27047
|
);
|
|
27027
27048
|
|
|
27049
|
+
// src/schema/content_model_versions.ts
|
|
27050
|
+
import { index as index74, integer as integer41, jsonb as jsonb47, pgTable as pgTable87, text as text88, timestamp as timestamp80 } from "drizzle-orm/pg-core";
|
|
27051
|
+
var contentModelVersions = pgTable87(
|
|
27052
|
+
"content_model_versions",
|
|
27053
|
+
{
|
|
27054
|
+
id: text88("id").primaryKey(),
|
|
27055
|
+
workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27056
|
+
modelId: text88("model_id").notNull().references(() => contentModels.id, { onDelete: "cascade" }),
|
|
27057
|
+
version: integer41("version").notNull(),
|
|
27058
|
+
/** The model as written. @see ContentModelSnapshot */
|
|
27059
|
+
snapshot: jsonb47("snapshot").$type().notNull(),
|
|
27060
|
+
/** What changed against the state this write replaced. @see ContentModelChangeSummary */
|
|
27061
|
+
summary: jsonb47("summary").$type().notNull().default({}),
|
|
27062
|
+
origin: text88("origin").$type().notNull(),
|
|
27063
|
+
createdBy: text88("created_by").references(() => users.id, { onDelete: "set null" }),
|
|
27064
|
+
createdAt: timestamp80("created_at").notNull().defaultNow()
|
|
27065
|
+
},
|
|
27066
|
+
(t) => [index74("content_model_versions_model_version_idx").on(t.modelId, t.version.desc())]
|
|
27067
|
+
);
|
|
27068
|
+
|
|
27028
27069
|
// src/schema/component_variants.ts
|
|
27029
27070
|
import {
|
|
27030
|
-
pgTable as
|
|
27031
|
-
text as
|
|
27071
|
+
pgTable as pgTable88,
|
|
27072
|
+
text as text89,
|
|
27032
27073
|
varchar as varchar64,
|
|
27033
|
-
timestamp as
|
|
27034
|
-
jsonb as
|
|
27035
|
-
integer as
|
|
27036
|
-
index as
|
|
27074
|
+
timestamp as timestamp81,
|
|
27075
|
+
jsonb as jsonb48,
|
|
27076
|
+
integer as integer42,
|
|
27077
|
+
index as index75,
|
|
27037
27078
|
unique as unique4,
|
|
27038
27079
|
uniqueIndex as uniqueIndex37
|
|
27039
27080
|
} from "drizzle-orm/pg-core";
|
|
27040
27081
|
import { relations as relations15 } from "drizzle-orm/relations";
|
|
27041
27082
|
import { sql as sql20 } from "drizzle-orm";
|
|
27042
|
-
var componentVariants =
|
|
27083
|
+
var componentVariants = pgTable88(
|
|
27043
27084
|
"component_variants",
|
|
27044
27085
|
{
|
|
27045
|
-
id:
|
|
27046
|
-
workspaceId:
|
|
27047
|
-
componentId:
|
|
27086
|
+
id: text89("id").primaryKey(),
|
|
27087
|
+
workspaceId: text89("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27088
|
+
componentId: text89("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27048
27089
|
name: varchar64("name", { length: 255 }).notNull(),
|
|
27049
27090
|
// `<component-root>-<variant-name>`, e.g. `footer-compact`.
|
|
27050
27091
|
key: varchar64("key", { length: 356 }).notNull(),
|
|
27051
|
-
delta:
|
|
27092
|
+
delta: jsonb48("delta").$type().notNull().default({
|
|
27052
27093
|
fieldOverrides: [],
|
|
27053
27094
|
addedProps: [],
|
|
27054
27095
|
removedFieldKeys: [],
|
|
@@ -27056,13 +27097,13 @@ var componentVariants = pgTable87(
|
|
|
27056
27097
|
valueOverrides: {},
|
|
27057
27098
|
addedBlocks: []
|
|
27058
27099
|
}),
|
|
27059
|
-
publishedDelta:
|
|
27100
|
+
publishedDelta: jsonb48("published_delta").$type(),
|
|
27060
27101
|
status: varchar64("status", { length: 20 }).$type().notNull().default("draft"),
|
|
27061
|
-
publishedAt:
|
|
27062
|
-
optimisticVersion:
|
|
27063
|
-
createdAt:
|
|
27064
|
-
updatedAt:
|
|
27065
|
-
deletedAt:
|
|
27102
|
+
publishedAt: timestamp81("published_at"),
|
|
27103
|
+
optimisticVersion: integer42("optimistic_version").notNull().default(0),
|
|
27104
|
+
createdAt: timestamp81("created_at").notNull().defaultNow(),
|
|
27105
|
+
updatedAt: timestamp81("updated_at").notNull().defaultNow(),
|
|
27106
|
+
deletedAt: timestamp81("deleted_at")
|
|
27066
27107
|
},
|
|
27067
27108
|
(table) => [
|
|
27068
27109
|
unique4("component_variants_id_workspace_component_unique").on(
|
|
@@ -27070,8 +27111,8 @@ var componentVariants = pgTable87(
|
|
|
27070
27111
|
table.workspaceId,
|
|
27071
27112
|
table.componentId
|
|
27072
27113
|
),
|
|
27073
|
-
|
|
27074
|
-
|
|
27114
|
+
index75("component_variants_workspace_idx").on(table.workspaceId),
|
|
27115
|
+
index75("component_variants_component_idx").on(table.componentId),
|
|
27075
27116
|
uniqueIndex37("component_variants_component_key_unique").on(table.componentId, table.key).where(sql20`${table.deletedAt} IS NULL`)
|
|
27076
27117
|
]
|
|
27077
27118
|
);
|
|
@@ -27090,37 +27131,37 @@ var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
|
|
|
27090
27131
|
import {
|
|
27091
27132
|
bigint as bigint4,
|
|
27092
27133
|
foreignKey as foreignKey6,
|
|
27093
|
-
index as
|
|
27094
|
-
integer as
|
|
27095
|
-
jsonb as
|
|
27096
|
-
pgTable as
|
|
27097
|
-
text as
|
|
27098
|
-
timestamp as
|
|
27134
|
+
index as index76,
|
|
27135
|
+
integer as integer43,
|
|
27136
|
+
jsonb as jsonb49,
|
|
27137
|
+
pgTable as pgTable89,
|
|
27138
|
+
text as text90,
|
|
27139
|
+
timestamp as timestamp82,
|
|
27099
27140
|
unique as unique5,
|
|
27100
27141
|
uniqueIndex as uniqueIndex38,
|
|
27101
27142
|
uuid as uuid2,
|
|
27102
27143
|
varchar as varchar65
|
|
27103
27144
|
} from "drizzle-orm/pg-core";
|
|
27104
27145
|
import { sql as sql21 } from "drizzle-orm";
|
|
27105
|
-
var componentImplementationCandidates =
|
|
27146
|
+
var componentImplementationCandidates = pgTable89(
|
|
27106
27147
|
"component_implementation_candidates",
|
|
27107
27148
|
{
|
|
27108
|
-
id:
|
|
27109
|
-
workspaceId:
|
|
27110
|
-
projectId:
|
|
27111
|
-
componentId:
|
|
27112
|
-
variantGroupId:
|
|
27113
|
-
familyKey:
|
|
27149
|
+
id: text90("id").primaryKey(),
|
|
27150
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27151
|
+
projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27152
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27153
|
+
variantGroupId: text90("variant_group_id"),
|
|
27154
|
+
familyKey: text90("family_key").notNull(),
|
|
27114
27155
|
familyContractHash: varchar65("family_contract_hash", { length: 64 }).notNull(),
|
|
27115
27156
|
// Exact value-bearing family contract. Unlike `contract.canonicalInputs` (the
|
|
27116
27157
|
// renderer/schema projection), this snapshot deliberately retains defaults because it
|
|
27117
27158
|
// becomes the immutable public-input source pinned by each published variant.
|
|
27118
|
-
familyContract:
|
|
27159
|
+
familyContract: jsonb49("family_contract").$type(),
|
|
27119
27160
|
schemaHash: varchar65("schema_hash", { length: 64 }).notNull(),
|
|
27120
27161
|
brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
|
|
27121
|
-
contract:
|
|
27122
|
-
createdBy:
|
|
27123
|
-
createdAt:
|
|
27162
|
+
contract: jsonb49("contract").$type().notNull(),
|
|
27163
|
+
createdBy: text90("created_by"),
|
|
27164
|
+
createdAt: timestamp82("created_at").notNull().defaultNow()
|
|
27124
27165
|
},
|
|
27125
27166
|
(table) => [
|
|
27126
27167
|
foreignKey6({
|
|
@@ -27139,26 +27180,26 @@ var componentImplementationCandidates = pgTable88(
|
|
|
27139
27180
|
table.familyContractHash
|
|
27140
27181
|
).where(sql21`${table.familyContract} IS NOT NULL`),
|
|
27141
27182
|
unique5("component_implementation_candidate_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27142
|
-
|
|
27183
|
+
index76("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
|
|
27143
27184
|
]
|
|
27144
27185
|
);
|
|
27145
|
-
var componentFamilyManifests =
|
|
27186
|
+
var componentFamilyManifests = pgTable89(
|
|
27146
27187
|
"component_family_manifests",
|
|
27147
27188
|
{
|
|
27148
|
-
id:
|
|
27149
|
-
workspaceId:
|
|
27150
|
-
projectId:
|
|
27151
|
-
familyKey:
|
|
27189
|
+
id: text90("id").primaryKey(),
|
|
27190
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27191
|
+
projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27192
|
+
familyKey: text90("family_key").notNull(),
|
|
27152
27193
|
familyContractHash: varchar65("family_contract_hash", { length: 64 }).notNull(),
|
|
27153
|
-
familyContract:
|
|
27194
|
+
familyContract: jsonb49("family_contract").$type(),
|
|
27154
27195
|
commitSha: varchar65("commit_sha", { length: 64 }).notNull(),
|
|
27155
27196
|
adapterHash: varchar65("adapter_hash", { length: 64 }).notNull(),
|
|
27156
27197
|
manifestHash: varchar65("manifest_hash", { length: 64 }).notNull(),
|
|
27157
|
-
previewOrigin:
|
|
27158
|
-
nativeViewports:
|
|
27159
|
-
adapter:
|
|
27160
|
-
createdBy:
|
|
27161
|
-
createdAt:
|
|
27198
|
+
previewOrigin: text90("preview_origin").notNull(),
|
|
27199
|
+
nativeViewports: jsonb49("native_viewports").$type().notNull(),
|
|
27200
|
+
adapter: jsonb49("adapter").$type().notNull(),
|
|
27201
|
+
createdBy: text90("created_by"),
|
|
27202
|
+
createdAt: timestamp82("created_at").notNull().defaultNow()
|
|
27162
27203
|
},
|
|
27163
27204
|
(table) => [
|
|
27164
27205
|
foreignKey6({
|
|
@@ -27170,21 +27211,21 @@ var componentFamilyManifests = pgTable88(
|
|
|
27170
27211
|
unique5("component_family_manifests_id_project_unique").on(table.id, table.projectId),
|
|
27171
27212
|
unique5("component_family_manifests_evidence_unique").on(table.id, table.projectId, table.manifestHash),
|
|
27172
27213
|
uniqueIndex38("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
|
|
27173
|
-
|
|
27214
|
+
index76("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
|
|
27174
27215
|
]
|
|
27175
27216
|
);
|
|
27176
|
-
var componentImplementationRequests =
|
|
27217
|
+
var componentImplementationRequests = pgTable89(
|
|
27177
27218
|
"component_implementation_requests",
|
|
27178
27219
|
{
|
|
27179
|
-
id:
|
|
27180
|
-
workspaceId:
|
|
27181
|
-
projectId:
|
|
27182
|
-
componentId:
|
|
27183
|
-
candidateId:
|
|
27184
|
-
componentVersion:
|
|
27220
|
+
id: text90("id").primaryKey(),
|
|
27221
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27222
|
+
projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27223
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27224
|
+
candidateId: text90("candidate_id").notNull(),
|
|
27225
|
+
componentVersion: integer43("component_version").notNull(),
|
|
27185
27226
|
provider: varchar65("provider", { length: 20 }).$type().notNull(),
|
|
27186
27227
|
status: varchar65("status", { length: 20 }).$type().notNull(),
|
|
27187
|
-
familyKey:
|
|
27228
|
+
familyKey: text90("family_key").notNull(),
|
|
27188
27229
|
familyContractHash: varchar65("family_contract_hash", { length: 64 }).notNull(),
|
|
27189
27230
|
schemaHash: varchar65("schema_hash", { length: 64 }).notNull(),
|
|
27190
27231
|
brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
|
|
@@ -27192,25 +27233,25 @@ var componentImplementationRequests = pgTable88(
|
|
|
27192
27233
|
commitSha: varchar65("commit_sha", { length: 64 }),
|
|
27193
27234
|
adapterHash: varchar65("adapter_hash", { length: 64 }),
|
|
27194
27235
|
familyManifestHash: varchar65("family_manifest_hash", { length: 64 }),
|
|
27195
|
-
previewOrigin:
|
|
27196
|
-
nativeViewports:
|
|
27197
|
-
adapter:
|
|
27198
|
-
providerProvenance:
|
|
27199
|
-
claimedByApiKeyId:
|
|
27236
|
+
previewOrigin: text90("preview_origin"),
|
|
27237
|
+
nativeViewports: jsonb49("native_viewports").$type(),
|
|
27238
|
+
adapter: jsonb49("adapter").$type(),
|
|
27239
|
+
providerProvenance: jsonb49("provider_provenance").$type(),
|
|
27240
|
+
claimedByApiKeyId: text90("claimed_by_api_key_id"),
|
|
27200
27241
|
claimCredentialHash: varchar65("claim_credential_hash", { length: 64 }),
|
|
27201
|
-
claimCredentialExpiresAt:
|
|
27202
|
-
claimCredentialConsumedAt:
|
|
27242
|
+
claimCredentialExpiresAt: timestamp82("claim_credential_expires_at", { withTimezone: true }),
|
|
27243
|
+
claimCredentialConsumedAt: timestamp82("claim_credential_consumed_at", { withTimezone: true }),
|
|
27203
27244
|
completionHash: varchar65("completion_hash", { length: 64 }),
|
|
27204
|
-
evidenceId:
|
|
27205
|
-
errorCode:
|
|
27206
|
-
errorMessage:
|
|
27207
|
-
requestedBy:
|
|
27208
|
-
createdAt:
|
|
27209
|
-
expiresAt:
|
|
27210
|
-
claimedAt:
|
|
27211
|
-
completedAt:
|
|
27212
|
-
failedAt:
|
|
27213
|
-
updatedAt:
|
|
27245
|
+
evidenceId: text90("evidence_id"),
|
|
27246
|
+
errorCode: text90("error_code"),
|
|
27247
|
+
errorMessage: text90("error_message"),
|
|
27248
|
+
requestedBy: text90("requested_by"),
|
|
27249
|
+
createdAt: timestamp82("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27250
|
+
expiresAt: timestamp82("expires_at", { withTimezone: true }).notNull(),
|
|
27251
|
+
claimedAt: timestamp82("claimed_at", { withTimezone: true }),
|
|
27252
|
+
completedAt: timestamp82("completed_at", { withTimezone: true }),
|
|
27253
|
+
failedAt: timestamp82("failed_at", { withTimezone: true }),
|
|
27254
|
+
updatedAt: timestamp82("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27214
27255
|
},
|
|
27215
27256
|
(table) => [
|
|
27216
27257
|
foreignKey6({
|
|
@@ -27225,35 +27266,35 @@ var componentImplementationRequests = pgTable88(
|
|
|
27225
27266
|
}).onDelete("cascade"),
|
|
27226
27267
|
unique5("component_implementation_requests_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27227
27268
|
uniqueIndex38("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql21`${table.status} IN ('pending', 'claimed')`),
|
|
27228
|
-
|
|
27269
|
+
index76("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
|
|
27229
27270
|
]
|
|
27230
27271
|
);
|
|
27231
|
-
var componentImplementationEvidence =
|
|
27272
|
+
var componentImplementationEvidence = pgTable89(
|
|
27232
27273
|
"component_implementation_evidence",
|
|
27233
27274
|
{
|
|
27234
|
-
id:
|
|
27235
|
-
workspaceId:
|
|
27236
|
-
projectId:
|
|
27237
|
-
componentId:
|
|
27238
|
-
candidateId:
|
|
27239
|
-
familyManifestId:
|
|
27275
|
+
id: text90("id").primaryKey(),
|
|
27276
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27277
|
+
projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27278
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27279
|
+
candidateId: text90("candidate_id").notNull(),
|
|
27280
|
+
familyManifestId: text90("family_manifest_id").notNull(),
|
|
27240
27281
|
familyManifestHash: varchar65("family_manifest_hash", { length: 64 }).notNull(),
|
|
27241
27282
|
variantBindingHash: varchar65("variant_binding_hash", { length: 64 }).notNull(),
|
|
27242
|
-
variantBinding:
|
|
27243
|
-
requestId:
|
|
27283
|
+
variantBinding: jsonb49("variant_binding").$type().notNull(),
|
|
27284
|
+
requestId: text90("request_id"),
|
|
27244
27285
|
schemaHash: varchar65("schema_hash", { length: 64 }).notNull(),
|
|
27245
27286
|
brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
|
|
27246
27287
|
commitSha: varchar65("commit_sha", { length: 64 }).notNull(),
|
|
27247
27288
|
adapterHash: varchar65("adapter_hash", { length: 64 }).notNull(),
|
|
27248
|
-
previewOrigin:
|
|
27249
|
-
nativeViewports:
|
|
27250
|
-
adapter:
|
|
27289
|
+
previewOrigin: text90("preview_origin").notNull(),
|
|
27290
|
+
nativeViewports: jsonb49("native_viewports").$type().notNull(),
|
|
27291
|
+
adapter: jsonb49("adapter").$type().notNull(),
|
|
27251
27292
|
status: varchar65("status", { length: 20 }).$type().notNull(),
|
|
27252
|
-
checks:
|
|
27293
|
+
checks: jsonb49("checks").$type().notNull(),
|
|
27253
27294
|
evidenceDigest: varchar65("evidence_digest", { length: 128 }).notNull(),
|
|
27254
27295
|
evidenceTupleHash: varchar65("evidence_tuple_hash", { length: 64 }).notNull(),
|
|
27255
|
-
createdBy:
|
|
27256
|
-
createdAt:
|
|
27296
|
+
createdBy: text90("created_by"),
|
|
27297
|
+
createdAt: timestamp82("created_at").notNull().defaultNow()
|
|
27257
27298
|
},
|
|
27258
27299
|
(table) => [
|
|
27259
27300
|
foreignKey6({
|
|
@@ -27279,20 +27320,20 @@ var componentImplementationEvidence = pgTable88(
|
|
|
27279
27320
|
uniqueIndex38("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
|
|
27280
27321
|
uniqueIndex38("component_implementation_evidence_request_unique").on(table.requestId).where(sql21`${table.requestId} IS NOT NULL`),
|
|
27281
27322
|
unique5("component_implementation_evidence_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27282
|
-
|
|
27323
|
+
index76("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
|
|
27283
27324
|
]
|
|
27284
27325
|
);
|
|
27285
|
-
var componentImplementationApprovals =
|
|
27326
|
+
var componentImplementationApprovals = pgTable89(
|
|
27286
27327
|
"component_implementation_approvals",
|
|
27287
27328
|
{
|
|
27288
|
-
id:
|
|
27289
|
-
workspaceId:
|
|
27290
|
-
projectId:
|
|
27291
|
-
componentId:
|
|
27292
|
-
candidateId:
|
|
27293
|
-
evidenceId:
|
|
27294
|
-
approvedBy:
|
|
27295
|
-
approvedAt:
|
|
27329
|
+
id: text90("id").primaryKey(),
|
|
27330
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27331
|
+
projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27332
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27333
|
+
candidateId: text90("candidate_id").notNull(),
|
|
27334
|
+
evidenceId: text90("evidence_id").notNull(),
|
|
27335
|
+
approvedBy: text90("approved_by").notNull(),
|
|
27336
|
+
approvedAt: timestamp82("approved_at").notNull().defaultNow()
|
|
27296
27337
|
},
|
|
27297
27338
|
(table) => [
|
|
27298
27339
|
foreignKey6({
|
|
@@ -27312,10 +27353,10 @@ var componentImplementationApprovals = pgTable88(
|
|
|
27312
27353
|
}).onDelete("cascade"),
|
|
27313
27354
|
uniqueIndex38("component_implementation_approval_evidence_unique").on(table.evidenceId),
|
|
27314
27355
|
unique5("component_implementation_approval_scope_unique").on(table.id, table.projectId, table.componentId),
|
|
27315
|
-
|
|
27356
|
+
index76("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
|
|
27316
27357
|
]
|
|
27317
27358
|
);
|
|
27318
|
-
var componentImplementationAdapters =
|
|
27359
|
+
var componentImplementationAdapters = pgTable89(
|
|
27319
27360
|
"component_implementation_adapters",
|
|
27320
27361
|
{
|
|
27321
27362
|
// uuid generated BY THE DATABASE, unlike this file's older `text` ids with app-side prefixes.
|
|
@@ -27323,15 +27364,15 @@ var componentImplementationAdapters = pgTable88(
|
|
|
27323
27364
|
// (project_id, component_id), which is unique — so there is nothing for a readable prefix to
|
|
27324
27365
|
// help with, and one fewer identifier for a writer to have to mint correctly.
|
|
27325
27366
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
27326
|
-
workspaceId:
|
|
27327
|
-
projectId:
|
|
27328
|
-
componentId:
|
|
27329
|
-
adapter:
|
|
27367
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27368
|
+
projectId: text90("project_id").notNull(),
|
|
27369
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27370
|
+
adapter: jsonb49("adapter").$type().notNull(),
|
|
27330
27371
|
adapterHash: varchar65("adapter_hash", { length: 64 }).notNull(),
|
|
27331
27372
|
source: varchar65("source", { length: 24 }).$type().notNull(),
|
|
27332
|
-
declaredBy:
|
|
27333
|
-
declaredAt:
|
|
27334
|
-
updatedAt:
|
|
27373
|
+
declaredBy: text90("declared_by"),
|
|
27374
|
+
declaredAt: timestamp82("declared_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27375
|
+
updatedAt: timestamp82("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27335
27376
|
},
|
|
27336
27377
|
(table) => [
|
|
27337
27378
|
foreignKey6({
|
|
@@ -27340,30 +27381,30 @@ var componentImplementationAdapters = pgTable88(
|
|
|
27340
27381
|
name: "component_implementation_adapters_scope_fkey"
|
|
27341
27382
|
}).onDelete("cascade"),
|
|
27342
27383
|
unique5("component_implementation_adapters_component_unique").on(table.projectId, table.componentId),
|
|
27343
|
-
|
|
27384
|
+
index76("component_implementation_adapters_project_idx").on(table.projectId, table.componentId)
|
|
27344
27385
|
]
|
|
27345
27386
|
);
|
|
27346
|
-
var componentImplementationStates =
|
|
27387
|
+
var componentImplementationStates = pgTable89(
|
|
27347
27388
|
"component_implementation_states",
|
|
27348
27389
|
{
|
|
27349
|
-
id:
|
|
27350
|
-
workspaceId:
|
|
27351
|
-
projectId:
|
|
27352
|
-
componentId:
|
|
27353
|
-
selectedCandidateId:
|
|
27354
|
-
selectedEvidenceId:
|
|
27355
|
-
selectedApprovalId:
|
|
27356
|
-
publishedCandidateId:
|
|
27357
|
-
publishedEvidenceId:
|
|
27358
|
-
publishedApprovalId:
|
|
27359
|
-
requestId:
|
|
27390
|
+
id: text90("id").primaryKey(),
|
|
27391
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27392
|
+
projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27393
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27394
|
+
selectedCandidateId: text90("selected_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
|
|
27395
|
+
selectedEvidenceId: text90("selected_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
|
|
27396
|
+
selectedApprovalId: text90("selected_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
|
|
27397
|
+
publishedCandidateId: text90("published_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
|
|
27398
|
+
publishedEvidenceId: text90("published_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
|
|
27399
|
+
publishedApprovalId: text90("published_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
|
|
27400
|
+
requestId: text90("request_id"),
|
|
27360
27401
|
requestProvider: varchar65("request_provider", { length: 20 }).$type(),
|
|
27361
27402
|
requestStatus: varchar65("request_status", { length: 20 }).$type().notNull().default("not-requested"),
|
|
27362
|
-
requestErrorCode:
|
|
27363
|
-
requestErrorMessage:
|
|
27364
|
-
requestedBy:
|
|
27365
|
-
requestedAt:
|
|
27366
|
-
updatedAt:
|
|
27403
|
+
requestErrorCode: text90("request_error_code"),
|
|
27404
|
+
requestErrorMessage: text90("request_error_message"),
|
|
27405
|
+
requestedBy: text90("requested_by"),
|
|
27406
|
+
requestedAt: timestamp82("requested_at"),
|
|
27407
|
+
updatedAt: timestamp82("updated_at").notNull().defaultNow()
|
|
27367
27408
|
},
|
|
27368
27409
|
(table) => [
|
|
27369
27410
|
foreignKey6({
|
|
@@ -27372,24 +27413,24 @@ var componentImplementationStates = pgTable88(
|
|
|
27372
27413
|
name: "component_implementation_states_project_workspace_fkey"
|
|
27373
27414
|
}).onDelete("cascade"),
|
|
27374
27415
|
uniqueIndex38("component_implementation_states_component_unique").on(table.projectId, table.componentId),
|
|
27375
|
-
|
|
27416
|
+
index76("component_implementation_states_workspace_idx").on(table.workspaceId)
|
|
27376
27417
|
]
|
|
27377
27418
|
);
|
|
27378
|
-
var componentPreviewSources =
|
|
27419
|
+
var componentPreviewSources = pgTable89(
|
|
27379
27420
|
"component_preview_sources",
|
|
27380
27421
|
{
|
|
27381
27422
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
27382
|
-
workspaceId:
|
|
27383
|
-
projectId:
|
|
27384
|
-
componentId:
|
|
27385
|
-
sourcePath:
|
|
27423
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27424
|
+
projectId: text90("project_id").notNull(),
|
|
27425
|
+
componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
27426
|
+
sourcePath: text90("source_path").notNull(),
|
|
27386
27427
|
sourceExport: varchar65("source_export", { length: 128 }).notNull().default("default"),
|
|
27387
27428
|
/** `file`: props are the component's fields. `section`: codemod-extracted, props `{ blockId, bind, overrides, page }` (0321). */
|
|
27388
27429
|
sourceKind: varchar65("source_kind", { length: 16 }).$type().notNull().default("file"),
|
|
27389
27430
|
recordedBy: varchar65("recorded_by", { length: 24 }).$type().notNull().default("agent"),
|
|
27390
|
-
updatedBy:
|
|
27391
|
-
createdAt:
|
|
27392
|
-
updatedAt:
|
|
27431
|
+
updatedBy: text90("updated_by"),
|
|
27432
|
+
createdAt: timestamp82("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27433
|
+
updatedAt: timestamp82("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27393
27434
|
},
|
|
27394
27435
|
(table) => [
|
|
27395
27436
|
foreignKey6({
|
|
@@ -27398,28 +27439,28 @@ var componentPreviewSources = pgTable88(
|
|
|
27398
27439
|
name: "component_preview_sources_scope_fkey"
|
|
27399
27440
|
}).onDelete("cascade"),
|
|
27400
27441
|
unique5("component_preview_sources_component_unique").on(table.projectId, table.componentId),
|
|
27401
|
-
|
|
27442
|
+
index76("component_preview_sources_project_idx").on(table.projectId)
|
|
27402
27443
|
]
|
|
27403
27444
|
);
|
|
27404
|
-
var componentPreviewBundles =
|
|
27445
|
+
var componentPreviewBundles = pgTable89(
|
|
27405
27446
|
"component_preview_bundles",
|
|
27406
27447
|
{
|
|
27407
27448
|
id: uuid2("id").primaryKey().defaultRandom(),
|
|
27408
|
-
workspaceId:
|
|
27409
|
-
projectId:
|
|
27449
|
+
workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27450
|
+
projectId: text90("project_id").notNull(),
|
|
27410
27451
|
commitSha: varchar65("commit_sha", { length: 64 }).notNull(),
|
|
27411
|
-
artifactKey:
|
|
27452
|
+
artifactKey: text90("artifact_key").notNull(),
|
|
27412
27453
|
checksum: varchar65("checksum", { length: 80 }).notNull(),
|
|
27413
27454
|
sizeBytes: bigint4("size_bytes", { mode: "number" }).notNull(),
|
|
27414
|
-
createdAt:
|
|
27455
|
+
createdAt: timestamp82("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27415
27456
|
/** The preview-runtime version that built this bundle (0330); null from a runner before 0.5.0. */
|
|
27416
|
-
runtimeVersion:
|
|
27457
|
+
runtimeVersion: text90("runtime_version"),
|
|
27417
27458
|
/** The latest runtime refresh of this commit: rebuilt with a newer runner without re-validating (0330). */
|
|
27418
27459
|
refreshId: uuid2("refresh_id"),
|
|
27419
|
-
refreshStatus:
|
|
27420
|
-
refreshErrorCode:
|
|
27421
|
-
refreshErrorMessage:
|
|
27422
|
-
refreshDispatchedAt:
|
|
27460
|
+
refreshStatus: text90("refresh_status"),
|
|
27461
|
+
refreshErrorCode: text90("refresh_error_code"),
|
|
27462
|
+
refreshErrorMessage: text90("refresh_error_message"),
|
|
27463
|
+
refreshDispatchedAt: timestamp82("refresh_dispatched_at", { withTimezone: true })
|
|
27423
27464
|
},
|
|
27424
27465
|
(table) => [
|
|
27425
27466
|
foreignKey6({
|
|
@@ -27428,7 +27469,7 @@ var componentPreviewBundles = pgTable88(
|
|
|
27428
27469
|
name: "component_preview_bundles_scope_fkey"
|
|
27429
27470
|
}).onDelete("cascade"),
|
|
27430
27471
|
unique5("component_preview_bundles_commit_unique").on(table.projectId, table.commitSha),
|
|
27431
|
-
|
|
27472
|
+
index76("component_preview_bundles_project_idx").on(table.projectId, table.createdAt)
|
|
27432
27473
|
]
|
|
27433
27474
|
);
|
|
27434
27475
|
|
|
@@ -27437,13 +27478,13 @@ import { sql as sql22 } from "drizzle-orm";
|
|
|
27437
27478
|
import {
|
|
27438
27479
|
check as check5,
|
|
27439
27480
|
foreignKey as foreignKey7,
|
|
27440
|
-
index as
|
|
27441
|
-
integer as
|
|
27442
|
-
jsonb as
|
|
27443
|
-
pgTable as
|
|
27481
|
+
index as index77,
|
|
27482
|
+
integer as integer44,
|
|
27483
|
+
jsonb as jsonb50,
|
|
27484
|
+
pgTable as pgTable90,
|
|
27444
27485
|
primaryKey as primaryKey8,
|
|
27445
|
-
text as
|
|
27446
|
-
timestamp as
|
|
27486
|
+
text as text91,
|
|
27487
|
+
timestamp as timestamp83,
|
|
27447
27488
|
unique as unique6,
|
|
27448
27489
|
uniqueIndex as uniqueIndex39,
|
|
27449
27490
|
uuid as uuid3,
|
|
@@ -27457,15 +27498,15 @@ var ORCHESTRATION_RUN_STATUSES = [
|
|
|
27457
27498
|
"completed",
|
|
27458
27499
|
"abandoned"
|
|
27459
27500
|
];
|
|
27460
|
-
var projectOrchestrationStates =
|
|
27501
|
+
var projectOrchestrationStates = pgTable90(
|
|
27461
27502
|
"project_orchestration_states",
|
|
27462
27503
|
{
|
|
27463
|
-
projectId:
|
|
27464
|
-
workspaceId:
|
|
27465
|
-
generation:
|
|
27466
|
-
enabledBy:
|
|
27467
|
-
enabledAt:
|
|
27468
|
-
updatedAt:
|
|
27504
|
+
projectId: text91("project_id").primaryKey().references(() => projects.id, { onDelete: "cascade" }),
|
|
27505
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27506
|
+
generation: integer44("generation").notNull().default(2),
|
|
27507
|
+
enabledBy: text91("enabled_by").notNull(),
|
|
27508
|
+
enabledAt: timestamp83("enabled_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27509
|
+
updatedAt: timestamp83("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27469
27510
|
},
|
|
27470
27511
|
(table) => [
|
|
27471
27512
|
foreignKey7({
|
|
@@ -27475,31 +27516,31 @@ var projectOrchestrationStates = pgTable89(
|
|
|
27475
27516
|
}).onDelete("cascade"),
|
|
27476
27517
|
unique6("project_orchestration_states_scope_unique").on(table.projectId, table.workspaceId),
|
|
27477
27518
|
check5("project_orchestration_states_generation_check", sql22`${table.generation} >= 2`),
|
|
27478
|
-
|
|
27519
|
+
index77("project_orchestration_states_workspace_idx").on(table.workspaceId)
|
|
27479
27520
|
]
|
|
27480
27521
|
);
|
|
27481
|
-
var orchestrationRuns =
|
|
27522
|
+
var orchestrationRuns = pgTable90(
|
|
27482
27523
|
"orchestration_runs",
|
|
27483
27524
|
{
|
|
27484
27525
|
id: uuid3("id").primaryKey().defaultRandom(),
|
|
27485
|
-
workspaceId:
|
|
27486
|
-
projectId:
|
|
27487
|
-
projectGeneration:
|
|
27488
|
-
startIdempotencyKey:
|
|
27526
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27527
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27528
|
+
projectGeneration: integer44("project_generation").notNull(),
|
|
27529
|
+
startIdempotencyKey: text91("start_idempotency_key").notNull(),
|
|
27489
27530
|
targetKind: varchar66("target_kind", { length: 32 }).$type().notNull().default("component-variant"),
|
|
27490
|
-
targetId:
|
|
27491
|
-
targetVariantId:
|
|
27492
|
-
targetMetadata:
|
|
27531
|
+
targetId: text91("target_id").notNull().references(() => components.id, { onDelete: "no action" }),
|
|
27532
|
+
targetVariantId: text91("target_variant_id"),
|
|
27533
|
+
targetMetadata: jsonb50("target_metadata").$type().notNull(),
|
|
27493
27534
|
status: varchar66("status", { length: 20 }).$type().notNull().default("open"),
|
|
27494
27535
|
activeStage: varchar66("active_stage", { length: 64 }).notNull().default("awaiting-executor"),
|
|
27495
|
-
version:
|
|
27496
|
-
preferredExecutorId:
|
|
27497
|
-
cancellationRequestedAt:
|
|
27498
|
-
cancellationRequestedBy:
|
|
27499
|
-
createdBy:
|
|
27536
|
+
version: integer44("version").notNull().default(1),
|
|
27537
|
+
preferredExecutorId: text91("preferred_executor_id"),
|
|
27538
|
+
cancellationRequestedAt: timestamp83("cancellation_requested_at", { withTimezone: true }),
|
|
27539
|
+
cancellationRequestedBy: text91("cancellation_requested_by"),
|
|
27540
|
+
createdBy: text91("created_by").notNull(),
|
|
27500
27541
|
policyVersion: varchar66("policy_version", { length: 64 }).notNull().default("orchestration-v2"),
|
|
27501
|
-
createdAt:
|
|
27502
|
-
updatedAt:
|
|
27542
|
+
createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27543
|
+
updatedAt: timestamp83("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27503
27544
|
},
|
|
27504
27545
|
(table) => [
|
|
27505
27546
|
foreignKey7({
|
|
@@ -27523,14 +27564,14 @@ var orchestrationRuns = pgTable89(
|
|
|
27523
27564
|
table.startIdempotencyKey
|
|
27524
27565
|
),
|
|
27525
27566
|
uniqueIndex39("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql22`${table.status} IN ('open', 'paused', 'cancelling')`),
|
|
27526
|
-
|
|
27567
|
+
index77("orchestration_runs_project_target_idx").on(
|
|
27527
27568
|
table.projectId,
|
|
27528
27569
|
table.targetKind,
|
|
27529
27570
|
table.targetId,
|
|
27530
27571
|
table.targetVariantId,
|
|
27531
27572
|
table.createdAt
|
|
27532
27573
|
),
|
|
27533
|
-
|
|
27574
|
+
index77("orchestration_runs_workspace_status_idx").on(
|
|
27534
27575
|
table.workspaceId,
|
|
27535
27576
|
table.status,
|
|
27536
27577
|
table.updatedAt
|
|
@@ -27617,14 +27658,14 @@ var orchestrationRuns = pgTable89(
|
|
|
27617
27658
|
check5("orchestration_runs_timestamps_check", sql22`${table.updatedAt} >= ${table.createdAt}`)
|
|
27618
27659
|
]
|
|
27619
27660
|
);
|
|
27620
|
-
var orchestrationRunStartKeys =
|
|
27661
|
+
var orchestrationRunStartKeys = pgTable90(
|
|
27621
27662
|
"orchestration_run_start_keys",
|
|
27622
27663
|
{
|
|
27623
|
-
workspaceId:
|
|
27624
|
-
projectId:
|
|
27625
|
-
idempotencyKey:
|
|
27664
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27665
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27666
|
+
idempotencyKey: text91("idempotency_key").notNull(),
|
|
27626
27667
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
27627
|
-
createdAt:
|
|
27668
|
+
createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
27628
27669
|
},
|
|
27629
27670
|
(table) => [
|
|
27630
27671
|
primaryKey8({ columns: [table.projectId, table.idempotencyKey] }),
|
|
@@ -27633,33 +27674,33 @@ var orchestrationRunStartKeys = pgTable89(
|
|
|
27633
27674
|
foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
|
|
27634
27675
|
name: "orchestration_run_start_keys_run_scope_fkey"
|
|
27635
27676
|
}).onDelete("cascade"),
|
|
27636
|
-
|
|
27677
|
+
index77("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
|
|
27637
27678
|
check5(
|
|
27638
27679
|
"orchestration_run_start_keys_idempotency_key_check",
|
|
27639
27680
|
sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
|
|
27640
27681
|
)
|
|
27641
27682
|
]
|
|
27642
27683
|
);
|
|
27643
|
-
var orchestrationRunEvents =
|
|
27684
|
+
var orchestrationRunEvents = pgTable90(
|
|
27644
27685
|
"orchestration_run_events",
|
|
27645
27686
|
{
|
|
27646
27687
|
id: uuid3("id").primaryKey().defaultRandom(),
|
|
27647
27688
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
27648
|
-
workspaceId:
|
|
27649
|
-
projectId:
|
|
27650
|
-
sequence:
|
|
27651
|
-
schemaVersion:
|
|
27652
|
-
idempotencyKey:
|
|
27689
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27690
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27691
|
+
sequence: integer44("sequence").notNull(),
|
|
27692
|
+
schemaVersion: integer44("schema_version").notNull().default(1),
|
|
27693
|
+
idempotencyKey: text91("idempotency_key").notNull(),
|
|
27653
27694
|
type: varchar66("type", { length: 100 }).notNull(),
|
|
27654
27695
|
actorType: varchar66("actor_type", { length: 32 }).notNull(),
|
|
27655
|
-
actorId:
|
|
27656
|
-
causationId:
|
|
27657
|
-
correlationId:
|
|
27658
|
-
payload:
|
|
27696
|
+
actorId: text91("actor_id").notNull(),
|
|
27697
|
+
causationId: text91("causation_id"),
|
|
27698
|
+
correlationId: text91("correlation_id"),
|
|
27699
|
+
payload: jsonb50("payload").$type().notNull().default({}),
|
|
27659
27700
|
payloadDigest: varchar66("payload_digest", { length: 71 }).generatedAlwaysAs(
|
|
27660
27701
|
sql22`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
|
|
27661
27702
|
),
|
|
27662
|
-
createdAt:
|
|
27703
|
+
createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
27663
27704
|
},
|
|
27664
27705
|
(table) => [
|
|
27665
27706
|
foreignKey7({
|
|
@@ -27669,7 +27710,7 @@ var orchestrationRunEvents = pgTable89(
|
|
|
27669
27710
|
}).onDelete("cascade"),
|
|
27670
27711
|
unique6("orchestration_run_events_sequence_unique").on(table.runId, table.sequence),
|
|
27671
27712
|
unique6("orchestration_run_events_idempotency_unique").on(table.runId, table.idempotencyKey),
|
|
27672
|
-
|
|
27713
|
+
index77("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
|
|
27673
27714
|
check5("orchestration_run_events_sequence_check", sql22`${table.sequence} >= 1`),
|
|
27674
27715
|
check5("orchestration_run_events_schema_version_check", sql22`${table.schemaVersion} >= 1`),
|
|
27675
27716
|
check5(
|
|
@@ -27685,20 +27726,20 @@ var orchestrationRunEvents = pgTable89(
|
|
|
27685
27726
|
)
|
|
27686
27727
|
]
|
|
27687
27728
|
);
|
|
27688
|
-
var orchestrationRunCommandResults =
|
|
27729
|
+
var orchestrationRunCommandResults = pgTable90(
|
|
27689
27730
|
"orchestration_run_command_results",
|
|
27690
27731
|
{
|
|
27691
27732
|
commandId: uuid3("command_id").primaryKey(),
|
|
27692
|
-
workspaceId:
|
|
27693
|
-
projectId:
|
|
27733
|
+
workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27734
|
+
projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27694
27735
|
runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
27695
27736
|
command: varchar66("command", { length: 20 }).$type().notNull(),
|
|
27696
|
-
expectedVersion:
|
|
27697
|
-
resultingVersion:
|
|
27698
|
-
actorId:
|
|
27737
|
+
expectedVersion: integer44("expected_version").notNull(),
|
|
27738
|
+
resultingVersion: integer44("resulting_version").notNull(),
|
|
27739
|
+
actorId: text91("actor_id").notNull(),
|
|
27699
27740
|
eventId: uuid3("event_id").notNull().references(() => orchestrationRunEvents.id, { onDelete: "cascade" }),
|
|
27700
|
-
resultPayload:
|
|
27701
|
-
createdAt:
|
|
27741
|
+
resultPayload: jsonb50("result_payload").$type().notNull(),
|
|
27742
|
+
createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
27702
27743
|
},
|
|
27703
27744
|
(table) => [
|
|
27704
27745
|
foreignKey7({
|
|
@@ -27706,8 +27747,8 @@ var orchestrationRunCommandResults = pgTable89(
|
|
|
27706
27747
|
foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
|
|
27707
27748
|
name: "orchestration_run_command_results_run_scope_fkey"
|
|
27708
27749
|
}).onDelete("cascade"),
|
|
27709
|
-
|
|
27710
|
-
|
|
27750
|
+
index77("orchestration_run_command_results_run_created_idx").on(table.runId, table.createdAt),
|
|
27751
|
+
index77("orchestration_run_command_results_project_created_idx").on(
|
|
27711
27752
|
table.projectId,
|
|
27712
27753
|
table.createdAt
|
|
27713
27754
|
),
|
|
@@ -27741,12 +27782,12 @@ import {
|
|
|
27741
27782
|
boolean as boolean30,
|
|
27742
27783
|
check as check6,
|
|
27743
27784
|
foreignKey as foreignKey8,
|
|
27744
|
-
index as
|
|
27745
|
-
integer as
|
|
27746
|
-
jsonb as
|
|
27747
|
-
pgTable as
|
|
27748
|
-
text as
|
|
27749
|
-
timestamp as
|
|
27785
|
+
index as index78,
|
|
27786
|
+
integer as integer45,
|
|
27787
|
+
jsonb as jsonb51,
|
|
27788
|
+
pgTable as pgTable91,
|
|
27789
|
+
text as text92,
|
|
27790
|
+
timestamp as timestamp84,
|
|
27750
27791
|
unique as unique7,
|
|
27751
27792
|
uniqueIndex as uniqueIndex40,
|
|
27752
27793
|
uuid as uuid4,
|
|
@@ -27791,20 +27832,20 @@ var EXECUTOR_COMMAND_KINDS = [
|
|
|
27791
27832
|
"cancel",
|
|
27792
27833
|
"handoff"
|
|
27793
27834
|
];
|
|
27794
|
-
var orchestrationExecutorInstallations =
|
|
27835
|
+
var orchestrationExecutorInstallations = pgTable91(
|
|
27795
27836
|
"orchestration_executor_installations",
|
|
27796
27837
|
{
|
|
27797
27838
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
27798
|
-
workspaceId:
|
|
27799
|
-
projectId:
|
|
27839
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27840
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27800
27841
|
kind: varchar67("kind", { length: 24 }).$type().notNull(),
|
|
27801
|
-
grantId:
|
|
27842
|
+
grantId: text92("grant_id").references(() => deviceAuthorizations.id, { onDelete: "cascade" }),
|
|
27802
27843
|
protocolVersion: varchar67("protocol_version", { length: 16 }).notNull(),
|
|
27803
|
-
capabilityDigest:
|
|
27804
|
-
repositoryClaim:
|
|
27844
|
+
capabilityDigest: text92("capability_digest").notNull(),
|
|
27845
|
+
repositoryClaim: jsonb51("repository_claim").$type().notNull().default({}),
|
|
27805
27846
|
status: varchar67("status", { length: 20 }).$type().notNull().default("active"),
|
|
27806
|
-
createdAt:
|
|
27807
|
-
updatedAt:
|
|
27847
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27848
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27808
27849
|
},
|
|
27809
27850
|
(table) => [
|
|
27810
27851
|
foreignKey8({
|
|
@@ -27817,7 +27858,7 @@ var orchestrationExecutorInstallations = pgTable90(
|
|
|
27817
27858
|
table.workspaceId,
|
|
27818
27859
|
table.projectId
|
|
27819
27860
|
),
|
|
27820
|
-
|
|
27861
|
+
index78("orchestration_executor_installations_project_status_idx").on(
|
|
27821
27862
|
table.projectId,
|
|
27822
27863
|
table.status
|
|
27823
27864
|
),
|
|
@@ -27854,24 +27895,24 @@ var orchestrationExecutorInstallations = pgTable90(
|
|
|
27854
27895
|
)
|
|
27855
27896
|
]
|
|
27856
27897
|
);
|
|
27857
|
-
var orchestrationExecutorSessions =
|
|
27898
|
+
var orchestrationExecutorSessions = pgTable91(
|
|
27858
27899
|
"orchestration_executor_sessions",
|
|
27859
27900
|
{
|
|
27860
27901
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
27861
|
-
workspaceId:
|
|
27862
|
-
projectId:
|
|
27902
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27903
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27863
27904
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
27864
|
-
sessionEpoch:
|
|
27905
|
+
sessionEpoch: integer45("session_epoch").notNull().default(1),
|
|
27865
27906
|
credentialAudience: varchar67("credential_audience", { length: 64 }).notNull(),
|
|
27866
27907
|
state: varchar67("state", { length: 20 }).$type().notNull().default("open"),
|
|
27867
27908
|
clientCursor: bigint5("client_cursor", { mode: "number" }).notNull().default(0),
|
|
27868
27909
|
serverCursor: bigint5("server_cursor", { mode: "number" }).notNull().default(0),
|
|
27869
|
-
connectedAt:
|
|
27870
|
-
lastHeartbeatAt:
|
|
27871
|
-
serverReceivedAt:
|
|
27872
|
-
closedAt:
|
|
27873
|
-
createdAt:
|
|
27874
|
-
updatedAt:
|
|
27910
|
+
connectedAt: timestamp84("connected_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27911
|
+
lastHeartbeatAt: timestamp84("last_heartbeat_at", { withTimezone: true }),
|
|
27912
|
+
serverReceivedAt: timestamp84("server_received_at", { withTimezone: true }),
|
|
27913
|
+
closedAt: timestamp84("closed_at", { withTimezone: true }),
|
|
27914
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27915
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27875
27916
|
},
|
|
27876
27917
|
(table) => [
|
|
27877
27918
|
foreignKey8({
|
|
@@ -27892,11 +27933,11 @@ var orchestrationExecutorSessions = pgTable90(
|
|
|
27892
27933
|
table.installationId,
|
|
27893
27934
|
table.sessionEpoch
|
|
27894
27935
|
),
|
|
27895
|
-
|
|
27936
|
+
index78("orchestration_executor_sessions_installation_state_idx").on(
|
|
27896
27937
|
table.installationId,
|
|
27897
27938
|
table.state
|
|
27898
27939
|
),
|
|
27899
|
-
|
|
27940
|
+
index78("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql23`${table.state} = 'open'`),
|
|
27900
27941
|
check6("orchestration_executor_sessions_epoch_check", sql23`${table.sessionEpoch} >= 1`),
|
|
27901
27942
|
check6(
|
|
27902
27943
|
"orchestration_executor_sessions_state_check",
|
|
@@ -27920,18 +27961,18 @@ var orchestrationExecutorSessions = pgTable90(
|
|
|
27920
27961
|
)
|
|
27921
27962
|
]
|
|
27922
27963
|
);
|
|
27923
|
-
var orchestrationImplementationAttempts =
|
|
27964
|
+
var orchestrationImplementationAttempts = pgTable91(
|
|
27924
27965
|
"orchestration_implementation_attempts",
|
|
27925
27966
|
{
|
|
27926
27967
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
27927
|
-
workspaceId:
|
|
27928
|
-
projectId:
|
|
27968
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
27969
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
27929
27970
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
27930
27971
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
27931
|
-
attemptNumber:
|
|
27972
|
+
attemptNumber: integer45("attempt_number").notNull(),
|
|
27932
27973
|
targetKind: varchar67("target_kind", { length: 32 }).notNull().default("component-variant"),
|
|
27933
|
-
targetId:
|
|
27934
|
-
targetBindingDigest:
|
|
27974
|
+
targetId: text92("target_id").notNull(),
|
|
27975
|
+
targetBindingDigest: text92("target_binding_digest").notNull(),
|
|
27935
27976
|
repositoryId: bigint5("repository_id", { mode: "number" }),
|
|
27936
27977
|
baseBranch: varchar67("base_branch", { length: 255 }),
|
|
27937
27978
|
baseSha: varchar67("base_sha", { length: 64 }),
|
|
@@ -27940,7 +27981,7 @@ var orchestrationImplementationAttempts = pgTable90(
|
|
|
27940
27981
|
* crash-safety line: if the process dies holding a branch, cancellation and reconciliation can
|
|
27941
27982
|
* still find it. Null until the branch exists. Shape-checked to run branches only (0278).
|
|
27942
27983
|
*/
|
|
27943
|
-
createdRef:
|
|
27984
|
+
createdRef: text92("created_ref"),
|
|
27944
27985
|
status: varchar67("status", { length: 24 }).$type().notNull().default("preflight"),
|
|
27945
27986
|
supersededBy: uuid4("superseded_by"),
|
|
27946
27987
|
/**
|
|
@@ -27948,11 +27989,11 @@ var orchestrationImplementationAttempts = pgTable90(
|
|
|
27948
27989
|
* withdrawn attempt's pull request is kept BY URL, so a reader of the run never has to
|
|
27949
27990
|
* discover from GitHub that one used to exist here.
|
|
27950
27991
|
*/
|
|
27951
|
-
withdrawnAt:
|
|
27952
|
-
withdrawnBy:
|
|
27953
|
-
withdrawnPullRequestUrl:
|
|
27954
|
-
createdAt:
|
|
27955
|
-
updatedAt:
|
|
27992
|
+
withdrawnAt: timestamp84("withdrawn_at", { withTimezone: true }),
|
|
27993
|
+
withdrawnBy: text92("withdrawn_by"),
|
|
27994
|
+
withdrawnPullRequestUrl: text92("withdrawn_pull_request_url"),
|
|
27995
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
27996
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
27956
27997
|
},
|
|
27957
27998
|
(table) => [
|
|
27958
27999
|
foreignKey8({
|
|
@@ -27987,7 +28028,7 @@ var orchestrationImplementationAttempts = pgTable90(
|
|
|
27987
28028
|
table.runId,
|
|
27988
28029
|
table.attemptNumber
|
|
27989
28030
|
),
|
|
27990
|
-
|
|
28031
|
+
index78("orchestration_implementation_attempts_run_created_idx").on(
|
|
27991
28032
|
table.runId,
|
|
27992
28033
|
table.createdAt
|
|
27993
28034
|
),
|
|
@@ -28018,49 +28059,49 @@ var orchestrationImplementationAttempts = pgTable90(
|
|
|
28018
28059
|
)
|
|
28019
28060
|
]
|
|
28020
28061
|
);
|
|
28021
|
-
var orchestrationPlanSnapshots =
|
|
28062
|
+
var orchestrationPlanSnapshots = pgTable91(
|
|
28022
28063
|
"orchestration_plan_snapshots",
|
|
28023
28064
|
{
|
|
28024
|
-
planDigest:
|
|
28025
|
-
workspaceId:
|
|
28026
|
-
projectId:
|
|
28065
|
+
planDigest: text92("plan_digest").primaryKey(),
|
|
28066
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28067
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28027
28068
|
baseHeadOid: varchar67("base_head_oid", { length: 64 }).notNull(),
|
|
28028
|
-
budget:
|
|
28029
|
-
files:
|
|
28030
|
-
fileCount:
|
|
28069
|
+
budget: jsonb51("budget").notNull(),
|
|
28070
|
+
files: jsonb51("files").notNull(),
|
|
28071
|
+
fileCount: integer45("file_count").notNull(),
|
|
28031
28072
|
byteCount: bigint5("byte_count", { mode: "number" }).notNull(),
|
|
28032
|
-
createdAt:
|
|
28073
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28033
28074
|
},
|
|
28034
|
-
(table) => [
|
|
28075
|
+
(table) => [index78("orchestration_plan_snapshots_project_idx").on(table.workspaceId, table.projectId, table.createdAt)]
|
|
28035
28076
|
);
|
|
28036
|
-
var orchestrationVisualApprovals =
|
|
28077
|
+
var orchestrationVisualApprovals = pgTable91(
|
|
28037
28078
|
"orchestration_visual_approvals",
|
|
28038
28079
|
{
|
|
28039
28080
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28040
|
-
workspaceId:
|
|
28041
|
-
projectId:
|
|
28081
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28082
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28042
28083
|
runId: uuid4("run_id").notNull(),
|
|
28043
28084
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28044
28085
|
headSha: varchar67("head_sha", { length: 64 }).notNull(),
|
|
28045
28086
|
evidenceId: uuid4("evidence_id").notNull(),
|
|
28046
|
-
authorizedBy:
|
|
28047
|
-
idempotencyKey:
|
|
28048
|
-
expiresAt:
|
|
28049
|
-
consumedAt:
|
|
28050
|
-
consumedByRef:
|
|
28051
|
-
createdAt:
|
|
28052
|
-
updatedAt:
|
|
28087
|
+
authorizedBy: text92("authorized_by").notNull(),
|
|
28088
|
+
idempotencyKey: text92("idempotency_key").notNull(),
|
|
28089
|
+
expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
|
|
28090
|
+
consumedAt: timestamp84("consumed_at", { withTimezone: true }),
|
|
28091
|
+
consumedByRef: text92("consumed_by_ref"),
|
|
28092
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28093
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28053
28094
|
}
|
|
28054
28095
|
);
|
|
28055
|
-
var orchestrationMergeAuthorizations =
|
|
28096
|
+
var orchestrationMergeAuthorizations = pgTable91(
|
|
28056
28097
|
"orchestration_merge_authorizations",
|
|
28057
28098
|
{
|
|
28058
28099
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28059
|
-
workspaceId:
|
|
28060
|
-
projectId:
|
|
28100
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28101
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28061
28102
|
runId: uuid4("run_id").notNull(),
|
|
28062
28103
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28063
|
-
pullRequestNumber:
|
|
28104
|
+
pullRequestNumber: integer45("pull_request_number").notNull(),
|
|
28064
28105
|
expectedHeadSha: varchar67("expected_head_sha", { length: 64 }).notNull(),
|
|
28065
28106
|
visualApprovalId: uuid4("visual_approval_id").notNull(),
|
|
28066
28107
|
/**
|
|
@@ -28068,85 +28109,85 @@ var orchestrationMergeAuthorizations = pgTable90(
|
|
|
28068
28109
|
* what an authorization BOUGHT, and a void bought nothing. A CHECK keeps the three together and
|
|
28069
28110
|
* forbids a row that is both spent and voided.
|
|
28070
28111
|
*/
|
|
28071
|
-
voidedAt:
|
|
28072
|
-
voidedBy:
|
|
28073
|
-
voidReason:
|
|
28074
|
-
authorizedBy:
|
|
28075
|
-
idempotencyKey:
|
|
28076
|
-
expiresAt:
|
|
28077
|
-
consumedAt:
|
|
28078
|
-
consumedByRef:
|
|
28079
|
-
createdAt:
|
|
28080
|
-
updatedAt:
|
|
28112
|
+
voidedAt: timestamp84("voided_at", { withTimezone: true }),
|
|
28113
|
+
voidedBy: text92("voided_by"),
|
|
28114
|
+
voidReason: text92("void_reason"),
|
|
28115
|
+
authorizedBy: text92("authorized_by").notNull(),
|
|
28116
|
+
idempotencyKey: text92("idempotency_key").notNull(),
|
|
28117
|
+
expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
|
|
28118
|
+
consumedAt: timestamp84("consumed_at", { withTimezone: true }),
|
|
28119
|
+
consumedByRef: text92("consumed_by_ref"),
|
|
28120
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28121
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28081
28122
|
}
|
|
28082
28123
|
);
|
|
28083
|
-
var orchestrationDeploymentAuthorizations =
|
|
28124
|
+
var orchestrationDeploymentAuthorizations = pgTable91(
|
|
28084
28125
|
"orchestration_deployment_authorizations",
|
|
28085
28126
|
{
|
|
28086
28127
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28087
|
-
workspaceId:
|
|
28088
|
-
projectId:
|
|
28128
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28129
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28089
28130
|
runId: uuid4("run_id").notNull(),
|
|
28090
28131
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28091
28132
|
mergeSha: varchar67("merge_sha", { length: 64 }).notNull(),
|
|
28092
28133
|
artifactChecksum: varchar67("artifact_checksum", { length: 80 }).notNull(),
|
|
28093
28134
|
mergeAuthorizationId: uuid4("merge_authorization_id").notNull(),
|
|
28094
|
-
authorizedBy:
|
|
28095
|
-
idempotencyKey:
|
|
28096
|
-
expiresAt:
|
|
28097
|
-
consumedAt:
|
|
28098
|
-
consumedByRef:
|
|
28099
|
-
createdAt:
|
|
28100
|
-
updatedAt:
|
|
28135
|
+
authorizedBy: text92("authorized_by").notNull(),
|
|
28136
|
+
idempotencyKey: text92("idempotency_key").notNull(),
|
|
28137
|
+
expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
|
|
28138
|
+
consumedAt: timestamp84("consumed_at", { withTimezone: true }),
|
|
28139
|
+
consumedByRef: text92("consumed_by_ref"),
|
|
28140
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28141
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28101
28142
|
}
|
|
28102
28143
|
);
|
|
28103
|
-
var orchestrationDeploymentRequests =
|
|
28144
|
+
var orchestrationDeploymentRequests = pgTable91(
|
|
28104
28145
|
"orchestration_deployment_requests",
|
|
28105
28146
|
{
|
|
28106
28147
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28107
|
-
workspaceId:
|
|
28108
|
-
projectId:
|
|
28148
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28149
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28109
28150
|
runId: uuid4("run_id").notNull(),
|
|
28110
28151
|
attemptId: uuid4("attempt_id").notNull(),
|
|
28111
28152
|
authorizationId: uuid4("authorization_id").notNull(),
|
|
28112
28153
|
expectedMergeSha: varchar67("expected_merge_sha", { length: 64 }).notNull(),
|
|
28113
28154
|
artifactChecksum: varchar67("artifact_checksum", { length: 80 }).notNull(),
|
|
28114
28155
|
state: varchar67("state", { length: 12 }).$type().notNull().default("live"),
|
|
28115
|
-
voidReason:
|
|
28116
|
-
releaseId:
|
|
28117
|
-
createdAt:
|
|
28118
|
-
updatedAt:
|
|
28156
|
+
voidReason: text92("void_reason"),
|
|
28157
|
+
releaseId: text92("release_id"),
|
|
28158
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28159
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28119
28160
|
}
|
|
28120
28161
|
);
|
|
28121
|
-
var orchestrationExecutionApprovals =
|
|
28162
|
+
var orchestrationExecutionApprovals = pgTable91(
|
|
28122
28163
|
"orchestration_execution_approvals",
|
|
28123
28164
|
{
|
|
28124
28165
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28125
|
-
workspaceId:
|
|
28126
|
-
projectId:
|
|
28166
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28167
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28127
28168
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28128
28169
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28129
28170
|
installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
28130
|
-
idempotencyKey:
|
|
28131
|
-
approvedBy:
|
|
28171
|
+
idempotencyKey: text92("idempotency_key").notNull(),
|
|
28172
|
+
approvedBy: text92("approved_by").notNull(),
|
|
28132
28173
|
targetKind: varchar67("target_kind", { length: 32 }).notNull().default("component-variant"),
|
|
28133
|
-
targetId:
|
|
28134
|
-
targetBindingDigest:
|
|
28174
|
+
targetId: text92("target_id").notNull(),
|
|
28175
|
+
targetBindingDigest: text92("target_binding_digest").notNull(),
|
|
28135
28176
|
repositoryId: bigint5("repository_id", { mode: "number" }),
|
|
28136
28177
|
baseBranch: varchar67("base_branch", { length: 255 }),
|
|
28137
28178
|
baseSha: varchar67("base_sha", { length: 64 }),
|
|
28138
28179
|
/** Set when the approval is spent. 0274 grants UPDATE on THESE TWO COLUMNS ONLY, so every
|
|
28139
28180
|
* other field on a row a human signed stays as unwritable as it was before. */
|
|
28140
|
-
consumedAt:
|
|
28181
|
+
consumedAt: timestamp84("consumed_at", { withTimezone: true }),
|
|
28141
28182
|
consumedByAttemptId: uuid4("consumed_by_attempt_id"),
|
|
28142
|
-
pathPolicy:
|
|
28143
|
-
operationClasses:
|
|
28144
|
-
mutationBudget:
|
|
28145
|
-
planDigest:
|
|
28146
|
-
capabilityDigest:
|
|
28147
|
-
validationDigest:
|
|
28148
|
-
expiresAt:
|
|
28149
|
-
createdAt:
|
|
28183
|
+
pathPolicy: jsonb51("path_policy").$type().notNull().default({}),
|
|
28184
|
+
operationClasses: jsonb51("operation_classes").$type().notNull().default([]),
|
|
28185
|
+
mutationBudget: jsonb51("mutation_budget").$type().notNull().default({}),
|
|
28186
|
+
planDigest: text92("plan_digest").notNull(),
|
|
28187
|
+
capabilityDigest: text92("capability_digest").notNull(),
|
|
28188
|
+
validationDigest: text92("validation_digest").notNull(),
|
|
28189
|
+
expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
|
|
28190
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28150
28191
|
},
|
|
28151
28192
|
(table) => [
|
|
28152
28193
|
foreignKey8({
|
|
@@ -28183,7 +28224,7 @@ var orchestrationExecutionApprovals = pgTable90(
|
|
|
28183
28224
|
// One approval per attempt. A running implementation never introduces a second approval; a
|
|
28184
28225
|
// changed binding requires a NEW attempt, which is what makes the authority auditable.
|
|
28185
28226
|
unique7("orchestration_execution_approvals_attempt_unique").on(table.attemptId),
|
|
28186
|
-
|
|
28227
|
+
index78("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
|
|
28187
28228
|
check6(
|
|
28188
28229
|
"orchestration_execution_approvals_idempotency_key_check",
|
|
28189
28230
|
sql23`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
|
|
@@ -28230,23 +28271,23 @@ var orchestrationExecutionApprovals = pgTable90(
|
|
|
28230
28271
|
)
|
|
28231
28272
|
]
|
|
28232
28273
|
);
|
|
28233
|
-
var orchestrationExecutorLeases =
|
|
28274
|
+
var orchestrationExecutorLeases = pgTable91(
|
|
28234
28275
|
"orchestration_executor_leases",
|
|
28235
28276
|
{
|
|
28236
28277
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28237
|
-
workspaceId:
|
|
28238
|
-
projectId:
|
|
28278
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28279
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28239
28280
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28240
28281
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28241
28282
|
sessionId: uuid4("session_id").notNull().references(() => orchestrationExecutorSessions.id, { onDelete: "cascade" }),
|
|
28242
|
-
leaseEpoch:
|
|
28283
|
+
leaseEpoch: integer45("lease_epoch").notNull().default(1),
|
|
28243
28284
|
state: varchar67("state", { length: 20 }).$type().notNull().default("active"),
|
|
28244
|
-
heartbeatDeadline:
|
|
28245
|
-
acquiredAt:
|
|
28246
|
-
releasedAt:
|
|
28285
|
+
heartbeatDeadline: timestamp84("heartbeat_deadline", { withTimezone: true }).notNull(),
|
|
28286
|
+
acquiredAt: timestamp84("acquired_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28287
|
+
releasedAt: timestamp84("released_at", { withTimezone: true }),
|
|
28247
28288
|
releaseReason: varchar67("release_reason", { length: 32 }).$type(),
|
|
28248
|
-
createdAt:
|
|
28249
|
-
updatedAt:
|
|
28289
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28290
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28250
28291
|
},
|
|
28251
28292
|
(table) => [
|
|
28252
28293
|
foreignKey8({
|
|
@@ -28284,7 +28325,7 @@ var orchestrationExecutorLeases = pgTable90(
|
|
|
28284
28325
|
unique7("orchestration_executor_leases_epoch_unique").on(table.attemptId, table.leaseEpoch),
|
|
28285
28326
|
// Plan invariant 6, enforced in the database: a run has at most one active executor lease.
|
|
28286
28327
|
uniqueIndex40("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql23`${table.state} = 'active'`),
|
|
28287
|
-
|
|
28328
|
+
index78("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql23`${table.state} = 'active'`),
|
|
28288
28329
|
check6("orchestration_executor_leases_epoch_check", sql23`${table.leaseEpoch} >= 1`),
|
|
28289
28330
|
check6(
|
|
28290
28331
|
"orchestration_executor_leases_state_check",
|
|
@@ -28304,32 +28345,32 @@ var orchestrationExecutorLeases = pgTable90(
|
|
|
28304
28345
|
)
|
|
28305
28346
|
]
|
|
28306
28347
|
);
|
|
28307
|
-
var orchestrationExecutorCommands =
|
|
28348
|
+
var orchestrationExecutorCommands = pgTable91(
|
|
28308
28349
|
"orchestration_executor_commands",
|
|
28309
28350
|
{
|
|
28310
28351
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28311
|
-
workspaceId:
|
|
28312
|
-
projectId:
|
|
28352
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28353
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28313
28354
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28314
28355
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28315
28356
|
leaseId: uuid4("lease_id").references(() => orchestrationExecutorLeases.id, {
|
|
28316
28357
|
onDelete: "set null"
|
|
28317
28358
|
}),
|
|
28318
|
-
leaseEpoch:
|
|
28359
|
+
leaseEpoch: integer45("lease_epoch"),
|
|
28319
28360
|
approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
|
|
28320
28361
|
onDelete: "set null"
|
|
28321
28362
|
}),
|
|
28322
28363
|
sequence: bigint5("sequence", { mode: "number" }).notNull(),
|
|
28323
28364
|
kind: varchar67("kind", { length: 32 }).$type().notNull(),
|
|
28324
|
-
idempotencyKey:
|
|
28325
|
-
expectedRunVersion:
|
|
28326
|
-
payload:
|
|
28365
|
+
idempotencyKey: text92("idempotency_key").notNull(),
|
|
28366
|
+
expectedRunVersion: integer45("expected_run_version").notNull(),
|
|
28367
|
+
payload: jsonb51("payload").$type().notNull().default({}),
|
|
28327
28368
|
payloadDigest: varchar67("payload_digest", { length: 71 }).generatedAlwaysAs(
|
|
28328
28369
|
sql23`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
|
|
28329
28370
|
),
|
|
28330
|
-
deliveredAt:
|
|
28331
|
-
acknowledgedAt:
|
|
28332
|
-
createdAt:
|
|
28371
|
+
deliveredAt: timestamp84("delivered_at", { withTimezone: true }),
|
|
28372
|
+
acknowledgedAt: timestamp84("acknowledged_at", { withTimezone: true }),
|
|
28373
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28333
28374
|
},
|
|
28334
28375
|
(table) => [
|
|
28335
28376
|
foreignKey8({
|
|
@@ -28355,9 +28396,9 @@ var orchestrationExecutorCommands = pgTable90(
|
|
|
28355
28396
|
table.runId,
|
|
28356
28397
|
table.idempotencyKey
|
|
28357
28398
|
),
|
|
28358
|
-
|
|
28399
|
+
index78("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
|
|
28359
28400
|
// The long-poll cursor read: unacknowledged commands for a run, in order.
|
|
28360
|
-
|
|
28401
|
+
index78("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql23`${table.acknowledgedAt} IS NULL`),
|
|
28361
28402
|
check6("orchestration_executor_commands_sequence_check", sql23`${table.sequence} >= 1`),
|
|
28362
28403
|
check6(
|
|
28363
28404
|
"orchestration_executor_commands_kind_check",
|
|
@@ -28387,25 +28428,25 @@ var orchestrationExecutorCommands = pgTable90(
|
|
|
28387
28428
|
]
|
|
28388
28429
|
);
|
|
28389
28430
|
var PATCH_OPERATIONS = ["create", "update", "delete"];
|
|
28390
|
-
var orchestrationPatchManifests =
|
|
28431
|
+
var orchestrationPatchManifests = pgTable91(
|
|
28391
28432
|
"orchestration_patch_manifests",
|
|
28392
28433
|
{
|
|
28393
28434
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28394
|
-
workspaceId:
|
|
28395
|
-
projectId:
|
|
28435
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28436
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28396
28437
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28397
28438
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28398
28439
|
approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
|
|
28399
28440
|
onDelete: "set null"
|
|
28400
28441
|
}),
|
|
28401
|
-
sequence:
|
|
28402
|
-
path:
|
|
28442
|
+
sequence: integer45("sequence").notNull(),
|
|
28443
|
+
path: text92("path").notNull(),
|
|
28403
28444
|
operation: varchar67("operation", { length: 16 }).$type().notNull(),
|
|
28404
28445
|
fileMode: varchar67("file_mode", { length: 6 }).notNull().default("100644"),
|
|
28405
28446
|
expectedBefore: varchar67("expected_before", { length: 64 }),
|
|
28406
28447
|
resultingBlobSha: varchar67("resulting_blob_sha", { length: 64 }),
|
|
28407
28448
|
byteCount: bigint5("byte_count", { mode: "number" }).notNull().default(0),
|
|
28408
|
-
createdAt:
|
|
28449
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28409
28450
|
},
|
|
28410
28451
|
(table) => [
|
|
28411
28452
|
foreignKey8({
|
|
@@ -28428,7 +28469,7 @@ var orchestrationPatchManifests = pgTable90(
|
|
|
28428
28469
|
}).onDelete("cascade"),
|
|
28429
28470
|
unique7("orchestration_patch_manifests_sequence_unique").on(table.attemptId, table.sequence),
|
|
28430
28471
|
unique7("orchestration_patch_manifests_path_unique").on(table.attemptId, table.path),
|
|
28431
|
-
|
|
28472
|
+
index78("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
|
|
28432
28473
|
check6("orchestration_patch_manifests_sequence_check", sql23`${table.sequence} >= 1`),
|
|
28433
28474
|
check6(
|
|
28434
28475
|
"orchestration_patch_manifests_operation_check",
|
|
@@ -28454,19 +28495,19 @@ var orchestrationPatchManifests = pgTable90(
|
|
|
28454
28495
|
check6("orchestration_patch_manifests_byte_count_check", sql23`${table.byteCount} >= 0`)
|
|
28455
28496
|
]
|
|
28456
28497
|
);
|
|
28457
|
-
var orchestrationPullRequestReceipts =
|
|
28498
|
+
var orchestrationPullRequestReceipts = pgTable91(
|
|
28458
28499
|
"orchestration_pull_request_receipts",
|
|
28459
28500
|
{
|
|
28460
28501
|
id: uuid4("id").primaryKey().defaultRandom(),
|
|
28461
|
-
workspaceId:
|
|
28462
|
-
projectId:
|
|
28502
|
+
workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28503
|
+
projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28463
28504
|
runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28464
28505
|
attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28465
28506
|
repositoryId: bigint5("repository_id", { mode: "number" }).notNull(),
|
|
28466
28507
|
installationId: bigint5("installation_id", { mode: "number" }),
|
|
28467
28508
|
pullRequestId: bigint5("pull_request_id", { mode: "number" }).notNull(),
|
|
28468
|
-
pullRequestNumber:
|
|
28469
|
-
pullRequestUrl:
|
|
28509
|
+
pullRequestNumber: integer45("pull_request_number").notNull(),
|
|
28510
|
+
pullRequestUrl: text92("pull_request_url").notNull(),
|
|
28470
28511
|
baseRef: varchar67("base_ref", { length: 255 }).notNull(),
|
|
28471
28512
|
baseSha: varchar67("base_sha", { length: 64 }).notNull(),
|
|
28472
28513
|
headRef: varchar67("head_ref", { length: 255 }).notNull(),
|
|
@@ -28474,10 +28515,10 @@ var orchestrationPullRequestReceipts = pgTable90(
|
|
|
28474
28515
|
/** True when BetterCMS created and owns the head branch. A head we do not own is observable
|
|
28475
28516
|
* but never advanceable by the adapter. */
|
|
28476
28517
|
branchOwned: boolean30("branch_owned").notNull().default(true),
|
|
28477
|
-
generation:
|
|
28518
|
+
generation: integer45("generation").notNull().default(1),
|
|
28478
28519
|
isDraft: boolean30("is_draft").notNull().default(true),
|
|
28479
|
-
createdAt:
|
|
28480
|
-
updatedAt:
|
|
28520
|
+
createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28521
|
+
updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28481
28522
|
},
|
|
28482
28523
|
(table) => [
|
|
28483
28524
|
foreignKey8({
|
|
@@ -28502,11 +28543,11 @@ var orchestrationPullRequestReceipts = pgTable90(
|
|
|
28502
28543
|
table.attemptId,
|
|
28503
28544
|
table.generation
|
|
28504
28545
|
),
|
|
28505
|
-
|
|
28546
|
+
index78("orchestration_pull_request_receipts_attempt_generation_idx").on(
|
|
28506
28547
|
table.attemptId,
|
|
28507
28548
|
table.generation
|
|
28508
28549
|
),
|
|
28509
|
-
|
|
28550
|
+
index78("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
|
|
28510
28551
|
check6("orchestration_pull_request_receipts_generation_check", sql23`${table.generation} >= 1`),
|
|
28511
28552
|
check6("orchestration_pull_request_receipts_number_check", sql23`${table.pullRequestNumber} >= 1`),
|
|
28512
28553
|
check6(
|
|
@@ -28535,24 +28576,24 @@ var orchestrationPullRequestReceipts = pgTable90(
|
|
|
28535
28576
|
|
|
28536
28577
|
// src/schema/conversion_proposals.ts
|
|
28537
28578
|
import { sql as sql24 } from "drizzle-orm";
|
|
28538
|
-
import { check as check7, foreignKey as foreignKey9, index as
|
|
28579
|
+
import { check as check7, foreignKey as foreignKey9, index as index79, integer as integer46, jsonb as jsonb52, pgTable as pgTable92, text as text93, timestamp as timestamp85, unique as unique8, uuid as uuid5, varchar as varchar68 } from "drizzle-orm/pg-core";
|
|
28539
28580
|
var CONVERSION_PROPOSAL_STATUSES = ["draft", "approved", "superseded"];
|
|
28540
|
-
var conversionProposals =
|
|
28581
|
+
var conversionProposals = pgTable92(
|
|
28541
28582
|
"conversion_proposals",
|
|
28542
28583
|
{
|
|
28543
28584
|
id: uuid5("id").primaryKey().defaultRandom(),
|
|
28544
|
-
workspaceId:
|
|
28545
|
-
projectId:
|
|
28585
|
+
workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28586
|
+
projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28546
28587
|
/** The plan snapshot holding the proposed file contents. */
|
|
28547
|
-
planDigest:
|
|
28588
|
+
planDigest: text93("plan_digest").notNull().references(() => orchestrationPlanSnapshots.planDigest),
|
|
28548
28589
|
/** sha256 of the canonical brief — what the CMS held when this was proposed. */
|
|
28549
|
-
briefDigest:
|
|
28590
|
+
briefDigest: text93("brief_digest").notNull(),
|
|
28550
28591
|
baseHeadOid: varchar68("base_head_oid", { length: 64 }).notNull(),
|
|
28551
|
-
baseBranch:
|
|
28592
|
+
baseBranch: text93("base_branch").notNull(),
|
|
28552
28593
|
/** Brief paths whose `original` was not found in any source file. */
|
|
28553
|
-
unlocated:
|
|
28594
|
+
unlocated: jsonb52("unlocated").notNull().default(sql24`'[]'::jsonb`),
|
|
28554
28595
|
/** Files that matched a brief original but fell outside the acquisition caps. */
|
|
28555
|
-
omittedByCap:
|
|
28596
|
+
omittedByCap: jsonb52("omitted_by_cap").notNull().default(sql24`'[]'::jsonb`),
|
|
28556
28597
|
/**
|
|
28557
28598
|
* The codemod's receipt (migration 0296) — every path it bound, and every one it could not.
|
|
28558
28599
|
*
|
|
@@ -28560,25 +28601,25 @@ var conversionProposals = pgTable91(
|
|
|
28560
28601
|
* pending list for those, which is exactly the silent "nothing left to do" this lane refuses.
|
|
28561
28602
|
* Informative: `proposeConversion` re-derives every claim it acts on from the proposed files.
|
|
28562
28603
|
*/
|
|
28563
|
-
receipt:
|
|
28564
|
-
status:
|
|
28565
|
-
version:
|
|
28566
|
-
idempotencyKey:
|
|
28604
|
+
receipt: jsonb52("receipt"),
|
|
28605
|
+
status: text93("status").notNull().default("draft"),
|
|
28606
|
+
version: integer46("version").notNull().default(1),
|
|
28607
|
+
idempotencyKey: text93("idempotency_key").notNull(),
|
|
28567
28608
|
/**
|
|
28568
28609
|
* The key of the transition that put this row in its CURRENT terminal state — the approve, or
|
|
28569
28610
|
* the manual supersede. Separate from `idempotencyKey`, which belongs to the create: a client
|
|
28570
28611
|
* retrying one act must never be answered with the result of another.
|
|
28571
28612
|
*/
|
|
28572
|
-
transitionIdempotencyKey:
|
|
28573
|
-
createdBy:
|
|
28574
|
-
createdAt:
|
|
28575
|
-
approvedBy:
|
|
28576
|
-
approvedAt:
|
|
28577
|
-
supersededAt:
|
|
28578
|
-
supersededReason:
|
|
28613
|
+
transitionIdempotencyKey: text93("transition_idempotency_key"),
|
|
28614
|
+
createdBy: text93("created_by").notNull(),
|
|
28615
|
+
createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28616
|
+
approvedBy: text93("approved_by"),
|
|
28617
|
+
approvedAt: timestamp85("approved_at", { withTimezone: true }),
|
|
28618
|
+
supersededAt: timestamp85("superseded_at", { withTimezone: true }),
|
|
28619
|
+
supersededReason: text93("superseded_reason")
|
|
28579
28620
|
},
|
|
28580
28621
|
(table) => [
|
|
28581
|
-
|
|
28622
|
+
index79("conversion_proposals_project_idx").on(table.workspaceId, table.projectId, table.createdAt),
|
|
28582
28623
|
unique8("conversion_proposals_idempotency_unique").on(table.projectId, table.idempotencyKey),
|
|
28583
28624
|
foreignKey9({
|
|
28584
28625
|
columns: [table.projectId, table.workspaceId],
|
|
@@ -28596,28 +28637,28 @@ var conversionProposals = pgTable91(
|
|
|
28596
28637
|
|
|
28597
28638
|
// src/schema/conversion_briefs_issued.ts
|
|
28598
28639
|
import { sql as sql25 } from "drizzle-orm";
|
|
28599
|
-
import { check as check8, foreignKey as foreignKey10, index as
|
|
28600
|
-
var conversionBriefsIssued =
|
|
28640
|
+
import { check as check8, foreignKey as foreignKey10, index as index80, jsonb as jsonb53, pgTable as pgTable93, text as text94, timestamp as timestamp86, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
|
|
28641
|
+
var conversionBriefsIssued = pgTable93(
|
|
28601
28642
|
"conversion_briefs_issued",
|
|
28602
28643
|
{
|
|
28603
28644
|
id: uuid6("id").primaryKey().defaultRandom(),
|
|
28604
|
-
workspaceId:
|
|
28605
|
-
projectId:
|
|
28645
|
+
workspaceId: text94("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28646
|
+
projectId: text94("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28606
28647
|
/** sha256 of the canonical brief — `briefDigest`, computed identically by the codemod. */
|
|
28607
|
-
briefDigest:
|
|
28648
|
+
briefDigest: text94("brief_digest").notNull(),
|
|
28608
28649
|
/** `[{ route, scope, path, kind, locator? }]` — every bindable path the brief listed. */
|
|
28609
|
-
paths:
|
|
28650
|
+
paths: jsonb53("paths").notNull().default(sql25`'[]'::jsonb`),
|
|
28610
28651
|
/**
|
|
28611
28652
|
* The codemod's account of the run against THIS digest (`submit_conversion_receipt`): which
|
|
28612
28653
|
* paths it rewrote, which it could not, and why. Null until one is submitted — a hand
|
|
28613
28654
|
* conversion never submits one and still counts toward coverage.
|
|
28614
28655
|
*/
|
|
28615
|
-
receipt:
|
|
28656
|
+
receipt: jsonb53("receipt"),
|
|
28616
28657
|
/** The LAST time this pin was issued. What a retention sweep keys on. */
|
|
28617
|
-
issuedAt:
|
|
28658
|
+
issuedAt: timestamp86("issued_at", { withTimezone: true }).notNull().defaultNow()
|
|
28618
28659
|
},
|
|
28619
28660
|
(table) => [
|
|
28620
|
-
|
|
28661
|
+
index80("conversion_briefs_issued_project_issued_idx").on(table.projectId, table.issuedAt),
|
|
28621
28662
|
unique9("conversion_briefs_issued_digest_unique").on(table.projectId, table.briefDigest),
|
|
28622
28663
|
foreignKey10({
|
|
28623
28664
|
columns: [table.projectId, table.workspaceId],
|
|
@@ -28635,12 +28676,12 @@ import {
|
|
|
28635
28676
|
bigint as bigint6,
|
|
28636
28677
|
check as check9,
|
|
28637
28678
|
foreignKey as foreignKey11,
|
|
28638
|
-
index as
|
|
28639
|
-
integer as
|
|
28640
|
-
jsonb as
|
|
28641
|
-
pgTable as
|
|
28642
|
-
text as
|
|
28643
|
-
timestamp as
|
|
28679
|
+
index as index81,
|
|
28680
|
+
integer as integer47,
|
|
28681
|
+
jsonb as jsonb54,
|
|
28682
|
+
pgTable as pgTable94,
|
|
28683
|
+
text as text95,
|
|
28684
|
+
timestamp as timestamp87,
|
|
28644
28685
|
unique as unique10,
|
|
28645
28686
|
uniqueIndex as uniqueIndex41,
|
|
28646
28687
|
uuid as uuid7,
|
|
@@ -28657,24 +28698,24 @@ var VALIDATION_ENVELOPE_STATUSES = [
|
|
|
28657
28698
|
"cancelled"
|
|
28658
28699
|
];
|
|
28659
28700
|
var VALIDATION_LIVE_STATUSES = ["queued", "dispatched", "action_required"];
|
|
28660
|
-
var orchestrationValidationEnvelopes =
|
|
28701
|
+
var orchestrationValidationEnvelopes = pgTable94(
|
|
28661
28702
|
"orchestration_validation_envelopes",
|
|
28662
28703
|
{
|
|
28663
28704
|
id: uuid7("id").primaryKey().defaultRandom(),
|
|
28664
|
-
workspaceId:
|
|
28665
|
-
projectId:
|
|
28705
|
+
workspaceId: text95("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28706
|
+
projectId: text95("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28666
28707
|
runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28667
28708
|
attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28668
28709
|
/** Null until a receipt writer exists (Phase 6). The head below is pinned regardless. */
|
|
28669
28710
|
receiptId: uuid7("receipt_id").references(() => orchestrationPullRequestReceipts.id, {
|
|
28670
28711
|
onDelete: "set null"
|
|
28671
28712
|
}),
|
|
28672
|
-
receiptGeneration:
|
|
28713
|
+
receiptGeneration: integer47("receipt_generation").notNull().default(1),
|
|
28673
28714
|
// The pinned tuple. Every field here is compared against returned evidence, and each mismatch
|
|
28674
28715
|
// has its own error code — "wrong repository" and "wrong head" are different recoveries.
|
|
28675
28716
|
repositoryId: bigint6("repository_id", { mode: "number" }).notNull(),
|
|
28676
28717
|
pullRequestId: bigint6("pull_request_id", { mode: "number" }).notNull(),
|
|
28677
|
-
pullRequestNumber:
|
|
28718
|
+
pullRequestNumber: integer47("pull_request_number").notNull(),
|
|
28678
28719
|
/** The exact commit this validation is about. A validation proves nothing about any other. */
|
|
28679
28720
|
headSha: varchar69("head_sha", { length: 64 }).notNull(),
|
|
28680
28721
|
baseSha: varchar69("base_sha", { length: 64 }).notNull(),
|
|
@@ -28683,25 +28724,25 @@ var orchestrationValidationEnvelopes = pgTable93(
|
|
|
28683
28724
|
brandContractHash: varchar69("brand_contract_hash", { length: 64 }).notNull(),
|
|
28684
28725
|
baselineDigest: varchar69("baseline_digest", { length: 71 }).notNull(),
|
|
28685
28726
|
toolchainHash: varchar69("toolchain_hash", { length: 64 }).notNull(),
|
|
28686
|
-
validatorVersion:
|
|
28727
|
+
validatorVersion: text95("validator_version").notNull(),
|
|
28687
28728
|
workflowSha256: varchar69("workflow_sha256", { length: 64 }).notNull(),
|
|
28688
28729
|
/** Digest only. The single-use credential itself is handed to the validator and never stored. */
|
|
28689
28730
|
nonceHash: varchar69("nonce_hash", { length: 64 }).notNull(),
|
|
28690
|
-
nonceExpiresAt:
|
|
28691
|
-
nonceConsumedAt:
|
|
28731
|
+
nonceExpiresAt: timestamp87("nonce_expires_at", { withTimezone: true }).notNull(),
|
|
28732
|
+
nonceConsumedAt: timestamp87("nonce_consumed_at", { withTimezone: true }),
|
|
28692
28733
|
status: varchar69("status", { length: 20 }).notNull().default("queued"),
|
|
28693
|
-
errorCode:
|
|
28694
|
-
errorMessage:
|
|
28734
|
+
errorCode: text95("error_code"),
|
|
28735
|
+
errorMessage: text95("error_message"),
|
|
28695
28736
|
/** Composite-FK'd to (evidence.id, evidence.envelope_id) in 0273, so an envelope cannot be
|
|
28696
28737
|
* marked passed while pointing at a DIFFERENT envelope's evidence. */
|
|
28697
28738
|
evidenceId: uuid7("evidence_id"),
|
|
28698
28739
|
/** Written on pass, read by nothing. The unlock that consumes it is a later phase. */
|
|
28699
28740
|
attestationDigest: varchar69("attestation_digest", { length: 71 }),
|
|
28700
|
-
dispatchedAt:
|
|
28741
|
+
dispatchedAt: timestamp87("dispatched_at", { withTimezone: true }),
|
|
28701
28742
|
/** A retry is a NEW row with a NEW nonce, linked back — never a status reset on this one. */
|
|
28702
28743
|
retryOf: uuid7("retry_of"),
|
|
28703
|
-
createdAt:
|
|
28704
|
-
updatedAt:
|
|
28744
|
+
createdAt: timestamp87("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28745
|
+
updatedAt: timestamp87("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28705
28746
|
},
|
|
28706
28747
|
(table) => [
|
|
28707
28748
|
unique10("orchestration_validation_envelopes_scope_unique").on(
|
|
@@ -28726,11 +28767,11 @@ var orchestrationValidationEnvelopes = pgTable93(
|
|
|
28726
28767
|
// One live envelope per (attempt, head): two validators can never both be authoritative for
|
|
28727
28768
|
// the same commit. The index arbitrates, so no read-then-write can lose the race.
|
|
28728
28769
|
uniqueIndex41("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql26`status IN ('queued', 'dispatched', 'action_required')`),
|
|
28729
|
-
|
|
28770
|
+
index81("orchestration_validation_envelopes_attempt_idx").on(
|
|
28730
28771
|
table.attemptId,
|
|
28731
28772
|
table.createdAt.desc()
|
|
28732
28773
|
),
|
|
28733
|
-
|
|
28774
|
+
index81("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql26`status IN ('queued', 'dispatched')`),
|
|
28734
28775
|
check9(
|
|
28735
28776
|
"orchestration_validation_envelopes_status_check",
|
|
28736
28777
|
sql26`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
|
|
@@ -28746,28 +28787,28 @@ var orchestrationValidationEnvelopes = pgTable93(
|
|
|
28746
28787
|
)
|
|
28747
28788
|
]
|
|
28748
28789
|
);
|
|
28749
|
-
var orchestrationValidationEvidence =
|
|
28790
|
+
var orchestrationValidationEvidence = pgTable94(
|
|
28750
28791
|
"orchestration_validation_evidence",
|
|
28751
28792
|
{
|
|
28752
28793
|
id: uuid7("id").primaryKey().defaultRandom(),
|
|
28753
|
-
workspaceId:
|
|
28754
|
-
projectId:
|
|
28794
|
+
workspaceId: text95("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28795
|
+
projectId: text95("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28755
28796
|
runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
|
|
28756
28797
|
attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
|
|
28757
28798
|
envelopeId: uuid7("envelope_id").notNull().references(() => orchestrationValidationEnvelopes.id, { onDelete: "cascade" }),
|
|
28758
28799
|
headSha: varchar69("head_sha", { length: 64 }).notNull(),
|
|
28759
28800
|
evidenceDigest: varchar69("evidence_digest", { length: 71 }).notNull(),
|
|
28760
28801
|
artifactDigest: varchar69("artifact_digest", { length: 71 }).notNull(),
|
|
28761
|
-
validatorVersion:
|
|
28802
|
+
validatorVersion: text95("validator_version").notNull(),
|
|
28762
28803
|
/** The BrandKit contract this evidence is filed under. 0273 ties it to
|
|
28763
28804
|
* `checks->brandKit->contractHash`, so a payload cannot claim a different one. Comparing it
|
|
28764
28805
|
* against the ENVELOPE's hash is an ingest check — a CHECK cannot reach another table. */
|
|
28765
28806
|
brandContractHash: varchar69("brand_contract_hash", { length: 64 }).notNull(),
|
|
28766
28807
|
status: varchar69("status", { length: 10 }).notNull(),
|
|
28767
28808
|
/** brandKit / runtime / visual. The shape is enforced by CHECK in 0273, not by the writer. */
|
|
28768
|
-
checks:
|
|
28769
|
-
createdBy:
|
|
28770
|
-
createdAt:
|
|
28809
|
+
checks: jsonb54("checks").notNull(),
|
|
28810
|
+
createdBy: text95("created_by"),
|
|
28811
|
+
createdAt: timestamp87("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
28771
28812
|
},
|
|
28772
28813
|
(table) => [
|
|
28773
28814
|
unique10("orchestration_validation_evidence_scope_unique").on(
|
|
@@ -28794,7 +28835,7 @@ var orchestrationValidationEvidence = pgTable93(
|
|
|
28794
28835
|
table.attemptId,
|
|
28795
28836
|
table.evidenceDigest
|
|
28796
28837
|
),
|
|
28797
|
-
|
|
28838
|
+
index81("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
|
|
28798
28839
|
check9(
|
|
28799
28840
|
"orchestration_validation_evidence_status_check",
|
|
28800
28841
|
sql26`${table.status} IN ('passed', 'failed')`
|
|
@@ -28804,27 +28845,27 @@ var orchestrationValidationEvidence = pgTable93(
|
|
|
28804
28845
|
|
|
28805
28846
|
// src/schema/orchestration_executor_grants.ts
|
|
28806
28847
|
import { sql as sql27 } from "drizzle-orm";
|
|
28807
|
-
import { check as check10, foreignKey as foreignKey12, index as
|
|
28848
|
+
import { check as check10, foreignKey as foreignKey12, index as index82, integer as integer48, pgTable as pgTable95, text as text96, timestamp as timestamp88, unique as unique11, uniqueIndex as uniqueIndex42, uuid as uuid8, varchar as varchar70 } from "drizzle-orm/pg-core";
|
|
28808
28849
|
var EXECUTOR_GRANT_STATUSES = ["active", "revoked", "expired"];
|
|
28809
|
-
var orchestrationExecutorGrants =
|
|
28850
|
+
var orchestrationExecutorGrants = pgTable95(
|
|
28810
28851
|
"orchestration_executor_grants",
|
|
28811
28852
|
{
|
|
28812
|
-
id:
|
|
28813
|
-
workspaceId:
|
|
28814
|
-
projectId:
|
|
28853
|
+
id: text96("id").primaryKey().default(sql27`gen_random_uuid()`),
|
|
28854
|
+
workspaceId: text96("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28855
|
+
projectId: text96("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28815
28856
|
installationId: uuid8("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
|
|
28816
28857
|
/** Digest only. The credential is returned once at mint and never stored. */
|
|
28817
28858
|
credentialHash: varchar70("credential_hash", { length: 64 }).notNull(),
|
|
28818
|
-
credentialAudience:
|
|
28819
|
-
credentialExpiresAt:
|
|
28859
|
+
credentialAudience: text96("credential_audience").notNull(),
|
|
28860
|
+
credentialExpiresAt: timestamp88("credential_expires_at", { withTimezone: true }).notNull(),
|
|
28820
28861
|
/** The epoch this credential is valid for. A fenced session's credential dies before it expires. */
|
|
28821
|
-
sessionEpoch:
|
|
28862
|
+
sessionEpoch: integer48("session_epoch").notNull(),
|
|
28822
28863
|
status: varchar70("status", { length: 16 }).notNull().default("active"),
|
|
28823
|
-
revokedAt:
|
|
28824
|
-
revokedBy:
|
|
28825
|
-
createdBy:
|
|
28826
|
-
createdAt:
|
|
28827
|
-
updatedAt:
|
|
28864
|
+
revokedAt: timestamp88("revoked_at", { withTimezone: true }),
|
|
28865
|
+
revokedBy: text96("revoked_by"),
|
|
28866
|
+
createdBy: text96("created_by"),
|
|
28867
|
+
createdAt: timestamp88("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
28868
|
+
updatedAt: timestamp88("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
28828
28869
|
},
|
|
28829
28870
|
(table) => [
|
|
28830
28871
|
unique11("orchestration_executor_grants_scope_unique").on(
|
|
@@ -28844,7 +28885,7 @@ var orchestrationExecutorGrants = pgTable94(
|
|
|
28844
28885
|
// One live credential per installation. Two would mean two processes can each present a valid
|
|
28845
28886
|
// one, and the exclusion argument collapses before the lease layer is reached.
|
|
28846
28887
|
uniqueIndex42("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql27`status = 'active'`),
|
|
28847
|
-
|
|
28888
|
+
index82("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql27`status = 'active'`),
|
|
28848
28889
|
check10(
|
|
28849
28890
|
"orchestration_executor_grants_status_check",
|
|
28850
28891
|
sql27`${table.status} IN ('active', 'revoked', 'expired')`
|
|
@@ -28857,27 +28898,27 @@ var orchestrationExecutorGrants = pgTable94(
|
|
|
28857
28898
|
);
|
|
28858
28899
|
|
|
28859
28900
|
// src/schema/component_presets.ts
|
|
28860
|
-
import { pgTable as
|
|
28901
|
+
import { pgTable as pgTable96, text as text97, varchar as varchar71, timestamp as timestamp89, jsonb as jsonb55, integer as integer49, index as index83, uniqueIndex as uniqueIndex43 } from "drizzle-orm/pg-core";
|
|
28861
28902
|
import { relations as relations16 } from "drizzle-orm";
|
|
28862
|
-
var componentPresets =
|
|
28903
|
+
var componentPresets = pgTable96(
|
|
28863
28904
|
"component_presets",
|
|
28864
28905
|
{
|
|
28865
|
-
id:
|
|
28866
|
-
workspaceId:
|
|
28867
|
-
componentId:
|
|
28906
|
+
id: text97("id").primaryKey(),
|
|
28907
|
+
workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28908
|
+
componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
|
|
28868
28909
|
name: varchar71("name", { length: 255 }).notNull(),
|
|
28869
28910
|
/** ^[a-z0-9-]+$, unique per component — stable across renames. */
|
|
28870
28911
|
slug: varchar71("slug", { length: 255 }).notNull(),
|
|
28871
28912
|
/** Prop key → value. Validated against the component's `props` on every write. */
|
|
28872
|
-
values:
|
|
28873
|
-
position:
|
|
28874
|
-
createdAt:
|
|
28875
|
-
updatedAt:
|
|
28876
|
-
createdBy:
|
|
28877
|
-
updatedBy:
|
|
28913
|
+
values: jsonb55("values").$type().notNull().default({}),
|
|
28914
|
+
position: integer49("position").notNull().default(0),
|
|
28915
|
+
createdAt: timestamp89("created_at").notNull().defaultNow(),
|
|
28916
|
+
updatedAt: timestamp89("updated_at").notNull().defaultNow(),
|
|
28917
|
+
createdBy: text97("created_by"),
|
|
28918
|
+
updatedBy: text97("updated_by")
|
|
28878
28919
|
},
|
|
28879
28920
|
(t) => [
|
|
28880
|
-
|
|
28921
|
+
index83("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
|
|
28881
28922
|
uniqueIndex43("component_presets_component_slug_key").on(t.componentId, t.slug)
|
|
28882
28923
|
]
|
|
28883
28924
|
);
|
|
@@ -28891,12 +28932,12 @@ var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
|
|
|
28891
28932
|
// src/schema/section_zones.ts
|
|
28892
28933
|
import {
|
|
28893
28934
|
foreignKey as foreignKey13,
|
|
28894
|
-
index as
|
|
28895
|
-
integer as
|
|
28896
|
-
jsonb as
|
|
28897
|
-
pgTable as
|
|
28898
|
-
text as
|
|
28899
|
-
timestamp as
|
|
28935
|
+
index as index84,
|
|
28936
|
+
integer as integer50,
|
|
28937
|
+
jsonb as jsonb56,
|
|
28938
|
+
pgTable as pgTable97,
|
|
28939
|
+
text as text98,
|
|
28940
|
+
timestamp as timestamp90,
|
|
28900
28941
|
unique as unique12,
|
|
28901
28942
|
uniqueIndex as uniqueIndex44,
|
|
28902
28943
|
varchar as varchar72
|
|
@@ -28910,15 +28951,15 @@ var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
|
|
|
28910
28951
|
"passed",
|
|
28911
28952
|
"failed"
|
|
28912
28953
|
];
|
|
28913
|
-
var sectionDefinitions =
|
|
28954
|
+
var sectionDefinitions = pgTable97(
|
|
28914
28955
|
"section_definitions",
|
|
28915
28956
|
{
|
|
28916
|
-
id:
|
|
28917
|
-
workspaceId:
|
|
28918
|
-
projectId:
|
|
28957
|
+
id: text98("id").primaryKey(),
|
|
28958
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28959
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28919
28960
|
apiId: varchar72("api_id", { length: 100 }).notNull(),
|
|
28920
|
-
firstPublishedAt:
|
|
28921
|
-
archivedAt:
|
|
28961
|
+
firstPublishedAt: timestamp90("first_published_at"),
|
|
28962
|
+
archivedAt: timestamp90("archived_at"),
|
|
28922
28963
|
...auditColumns
|
|
28923
28964
|
},
|
|
28924
28965
|
(table) => [
|
|
@@ -28929,23 +28970,23 @@ var sectionDefinitions = pgTable96(
|
|
|
28929
28970
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
28930
28971
|
unique12("section_definitions_id_project_unique").on(table.id, table.projectId),
|
|
28931
28972
|
uniqueIndex44("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
|
|
28932
|
-
|
|
28933
|
-
|
|
28973
|
+
index84("section_definitions_workspace_idx").on(table.workspaceId),
|
|
28974
|
+
index84("section_definitions_project_idx").on(table.projectId)
|
|
28934
28975
|
]
|
|
28935
28976
|
);
|
|
28936
|
-
var sectionDefinitionVersions =
|
|
28977
|
+
var sectionDefinitionVersions = pgTable97(
|
|
28937
28978
|
"section_definition_versions",
|
|
28938
28979
|
{
|
|
28939
|
-
id:
|
|
28940
|
-
workspaceId:
|
|
28941
|
-
projectId:
|
|
28942
|
-
sectionDefinitionId:
|
|
28943
|
-
version:
|
|
28980
|
+
id: text98("id").primaryKey(),
|
|
28981
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
28982
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28983
|
+
sectionDefinitionId: text98("section_definition_id").notNull(),
|
|
28984
|
+
version: integer50("version").notNull(),
|
|
28944
28985
|
label: varchar72("label", { length: 255 }).notNull(),
|
|
28945
|
-
fields:
|
|
28986
|
+
fields: jsonb56("fields").$type().notNull().default([]),
|
|
28946
28987
|
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
28947
|
-
createdBy:
|
|
28948
|
-
createdAt:
|
|
28988
|
+
createdBy: text98("created_by"),
|
|
28989
|
+
createdAt: timestamp90("created_at").notNull().defaultNow()
|
|
28949
28990
|
},
|
|
28950
28991
|
(table) => [
|
|
28951
28992
|
foreignKey13({
|
|
@@ -28964,20 +29005,20 @@ var sectionDefinitionVersions = pgTable96(
|
|
|
28964
29005
|
table.version,
|
|
28965
29006
|
table.projectId
|
|
28966
29007
|
),
|
|
28967
|
-
|
|
29008
|
+
index84("section_definition_versions_project_idx").on(table.projectId)
|
|
28968
29009
|
]
|
|
28969
29010
|
);
|
|
28970
|
-
var sectionZones =
|
|
29011
|
+
var sectionZones = pgTable97(
|
|
28971
29012
|
"section_zones",
|
|
28972
29013
|
{
|
|
28973
|
-
id:
|
|
28974
|
-
workspaceId:
|
|
28975
|
-
projectId:
|
|
29014
|
+
id: text98("id").primaryKey(),
|
|
29015
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29016
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
28976
29017
|
schemaKind: varchar72("schema_kind", { length: 20 }).$type().notNull(),
|
|
28977
|
-
schemaId:
|
|
29018
|
+
schemaId: text98("schema_id").notNull(),
|
|
28978
29019
|
fieldKey: varchar72("field_key", { length: 255 }).notNull(),
|
|
28979
|
-
draftRevision:
|
|
28980
|
-
publishedRevision:
|
|
29020
|
+
draftRevision: integer50("draft_revision").notNull().default(1),
|
|
29021
|
+
publishedRevision: integer50("published_revision"),
|
|
28981
29022
|
...auditColumns
|
|
28982
29023
|
},
|
|
28983
29024
|
(table) => [
|
|
@@ -28988,20 +29029,20 @@ var sectionZones = pgTable96(
|
|
|
28988
29029
|
}).onDelete("cascade").onUpdate("cascade"),
|
|
28989
29030
|
unique12("section_zones_id_project_unique").on(table.id, table.projectId),
|
|
28990
29031
|
uniqueIndex44("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
|
|
28991
|
-
|
|
29032
|
+
index84("section_zones_workspace_idx").on(table.workspaceId)
|
|
28992
29033
|
]
|
|
28993
29034
|
);
|
|
28994
|
-
var sectionZoneAttachments =
|
|
29035
|
+
var sectionZoneAttachments = pgTable97(
|
|
28995
29036
|
"section_zone_attachments",
|
|
28996
29037
|
{
|
|
28997
|
-
id:
|
|
28998
|
-
workspaceId:
|
|
28999
|
-
projectId:
|
|
29000
|
-
zoneId:
|
|
29001
|
-
sectionDefinitionId:
|
|
29002
|
-
draftVersion:
|
|
29003
|
-
publishedVersion:
|
|
29004
|
-
position:
|
|
29038
|
+
id: text98("id").primaryKey(),
|
|
29039
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29040
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29041
|
+
zoneId: text98("zone_id").notNull(),
|
|
29042
|
+
sectionDefinitionId: text98("section_definition_id").notNull(),
|
|
29043
|
+
draftVersion: integer50("draft_version").notNull(),
|
|
29044
|
+
publishedVersion: integer50("published_version"),
|
|
29045
|
+
position: integer50("position").notNull().default(0),
|
|
29005
29046
|
...auditColumns
|
|
29006
29047
|
},
|
|
29007
29048
|
(table) => [
|
|
@@ -29039,23 +29080,23 @@ var sectionZoneAttachments = pgTable96(
|
|
|
29039
29080
|
name: "section_zone_attachments_published_version_fkey"
|
|
29040
29081
|
}).onDelete("restrict"),
|
|
29041
29082
|
uniqueIndex44("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
|
|
29042
|
-
|
|
29083
|
+
index84("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
|
|
29043
29084
|
]
|
|
29044
29085
|
);
|
|
29045
|
-
var sectionManifests =
|
|
29086
|
+
var sectionManifests = pgTable97(
|
|
29046
29087
|
"section_manifests",
|
|
29047
29088
|
{
|
|
29048
|
-
id:
|
|
29049
|
-
workspaceId:
|
|
29050
|
-
projectId:
|
|
29051
|
-
sectionDefinitionId:
|
|
29052
|
-
sectionVersion:
|
|
29089
|
+
id: text98("id").primaryKey(),
|
|
29090
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29091
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29092
|
+
sectionDefinitionId: text98("section_definition_id").notNull(),
|
|
29093
|
+
sectionVersion: integer50("section_version").notNull(),
|
|
29053
29094
|
apiId: varchar72("api_id", { length: 100 }).notNull(),
|
|
29054
29095
|
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
29055
29096
|
commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
|
|
29056
|
-
manifest:
|
|
29057
|
-
createdBy:
|
|
29058
|
-
createdAt:
|
|
29097
|
+
manifest: jsonb56("manifest").$type().notNull(),
|
|
29098
|
+
createdBy: text98("created_by"),
|
|
29099
|
+
createdAt: timestamp90("created_at").notNull().defaultNow()
|
|
29059
29100
|
},
|
|
29060
29101
|
(table) => [
|
|
29061
29102
|
foreignKey13({
|
|
@@ -29073,26 +29114,26 @@ var sectionManifests = pgTable96(
|
|
|
29073
29114
|
name: "section_manifests_definition_version_project_fkey"
|
|
29074
29115
|
}).onDelete("cascade"),
|
|
29075
29116
|
unique12("section_manifests_id_project_unique").on(table.id, table.projectId),
|
|
29076
|
-
|
|
29117
|
+
index84("section_manifests_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
29077
29118
|
]
|
|
29078
29119
|
);
|
|
29079
|
-
var sectionValidationRuns =
|
|
29120
|
+
var sectionValidationRuns = pgTable97(
|
|
29080
29121
|
"section_validation_runs",
|
|
29081
29122
|
{
|
|
29082
|
-
id:
|
|
29083
|
-
workspaceId:
|
|
29084
|
-
projectId:
|
|
29085
|
-
sectionDefinitionId:
|
|
29086
|
-
sectionVersion:
|
|
29087
|
-
manifestId:
|
|
29123
|
+
id: text98("id").primaryKey(),
|
|
29124
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29125
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29126
|
+
sectionDefinitionId: text98("section_definition_id").notNull(),
|
|
29127
|
+
sectionVersion: integer50("section_version").notNull(),
|
|
29128
|
+
manifestId: text98("manifest_id").notNull(),
|
|
29088
29129
|
status: varchar72("status", { length: 20 }).$type().notNull(),
|
|
29089
29130
|
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
29090
29131
|
commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
|
|
29091
29132
|
fixtureHash: varchar72("fixture_hash", { length: 64 }).notNull(),
|
|
29092
29133
|
evidenceDigest: varchar72("evidence_digest", { length: 128 }).notNull(),
|
|
29093
|
-
results:
|
|
29094
|
-
createdBy:
|
|
29095
|
-
createdAt:
|
|
29134
|
+
results: jsonb56("results").$type().notNull(),
|
|
29135
|
+
createdBy: text98("created_by"),
|
|
29136
|
+
createdAt: timestamp90("created_at").notNull().defaultNow()
|
|
29096
29137
|
},
|
|
29097
29138
|
(table) => [
|
|
29098
29139
|
foreignKey13({
|
|
@@ -29115,25 +29156,25 @@ var sectionValidationRuns = pgTable96(
|
|
|
29115
29156
|
name: "section_validation_runs_manifest_project_fkey"
|
|
29116
29157
|
}).onDelete("restrict"),
|
|
29117
29158
|
unique12("section_validation_runs_id_project_unique").on(table.id, table.projectId),
|
|
29118
|
-
|
|
29159
|
+
index84("section_validation_runs_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
29119
29160
|
]
|
|
29120
29161
|
);
|
|
29121
|
-
var sectionVisualApprovals =
|
|
29162
|
+
var sectionVisualApprovals = pgTable97(
|
|
29122
29163
|
"section_visual_approvals",
|
|
29123
29164
|
{
|
|
29124
|
-
id:
|
|
29125
|
-
workspaceId:
|
|
29126
|
-
projectId:
|
|
29127
|
-
sectionDefinitionId:
|
|
29128
|
-
sectionVersion:
|
|
29129
|
-
manifestId:
|
|
29130
|
-
validationRunId:
|
|
29165
|
+
id: text98("id").primaryKey(),
|
|
29166
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29167
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29168
|
+
sectionDefinitionId: text98("section_definition_id").notNull(),
|
|
29169
|
+
sectionVersion: integer50("section_version").notNull(),
|
|
29170
|
+
manifestId: text98("manifest_id").notNull(),
|
|
29171
|
+
validationRunId: text98("validation_run_id").notNull(),
|
|
29131
29172
|
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
29132
29173
|
commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
|
|
29133
29174
|
fixtureHash: varchar72("fixture_hash", { length: 64 }).notNull(),
|
|
29134
29175
|
evidenceDigest: varchar72("evidence_digest", { length: 128 }).notNull(),
|
|
29135
|
-
approvedBy:
|
|
29136
|
-
createdAt:
|
|
29176
|
+
approvedBy: text98("approved_by").notNull(),
|
|
29177
|
+
createdAt: timestamp90("created_at").notNull().defaultNow()
|
|
29137
29178
|
},
|
|
29138
29179
|
(table) => [
|
|
29139
29180
|
foreignKey13({
|
|
@@ -29160,36 +29201,36 @@ var sectionVisualApprovals = pgTable96(
|
|
|
29160
29201
|
foreignColumns: [sectionValidationRuns.id, sectionValidationRuns.projectId],
|
|
29161
29202
|
name: "section_visual_approvals_validation_project_fkey"
|
|
29162
29203
|
}).onDelete("restrict"),
|
|
29163
|
-
|
|
29204
|
+
index84("section_visual_approvals_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
|
|
29164
29205
|
]
|
|
29165
29206
|
);
|
|
29166
|
-
var sectionImplementationRequests =
|
|
29207
|
+
var sectionImplementationRequests = pgTable97(
|
|
29167
29208
|
"section_implementation_requests",
|
|
29168
29209
|
{
|
|
29169
|
-
id:
|
|
29170
|
-
workspaceId:
|
|
29171
|
-
projectId:
|
|
29172
|
-
sectionDefinitionId:
|
|
29173
|
-
sectionVersion:
|
|
29210
|
+
id: text98("id").primaryKey(),
|
|
29211
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29212
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29213
|
+
sectionDefinitionId: text98("section_definition_id").notNull(),
|
|
29214
|
+
sectionVersion: integer50("section_version").notNull(),
|
|
29174
29215
|
provider: varchar72("provider", { length: 20 }).$type().notNull(),
|
|
29175
29216
|
status: varchar72("status", { length: 20 }).$type().notNull().default("queued"),
|
|
29176
29217
|
schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
|
|
29177
29218
|
targetCommitSha: varchar72("target_commit_sha", { length: 64 }),
|
|
29178
29219
|
providerRunId: varchar72("provider_run_id", { length: 255 }),
|
|
29179
|
-
providerRunUrl:
|
|
29180
|
-
manifestId:
|
|
29181
|
-
validationRunId:
|
|
29220
|
+
providerRunUrl: text98("provider_run_url"),
|
|
29221
|
+
manifestId: text98("manifest_id"),
|
|
29222
|
+
validationRunId: text98("validation_run_id"),
|
|
29182
29223
|
/** SHA-256 of the request-scoped GitHub callback bearer. The plaintext is never persisted. */
|
|
29183
29224
|
callbackTokenHash: varchar72("callback_token_hash", { length: 64 }),
|
|
29184
|
-
requestedBy:
|
|
29185
|
-
claimedBy:
|
|
29225
|
+
requestedBy: text98("requested_by").notNull(),
|
|
29226
|
+
claimedBy: text98("claimed_by"),
|
|
29186
29227
|
errorCode: varchar72("error_code", { length: 100 }),
|
|
29187
|
-
errorMessage:
|
|
29188
|
-
dispatchedAt:
|
|
29189
|
-
startedAt:
|
|
29190
|
-
completedAt:
|
|
29191
|
-
createdAt:
|
|
29192
|
-
updatedAt:
|
|
29228
|
+
errorMessage: text98("error_message"),
|
|
29229
|
+
dispatchedAt: timestamp90("dispatched_at"),
|
|
29230
|
+
startedAt: timestamp90("started_at"),
|
|
29231
|
+
completedAt: timestamp90("completed_at"),
|
|
29232
|
+
createdAt: timestamp90("created_at").notNull().defaultNow(),
|
|
29233
|
+
updatedAt: timestamp90("updated_at").notNull().defaultNow()
|
|
29193
29234
|
},
|
|
29194
29235
|
(table) => [
|
|
29195
29236
|
foreignKey13({
|
|
@@ -29218,20 +29259,20 @@ var sectionImplementationRequests = pgTable96(
|
|
|
29218
29259
|
}).onDelete("restrict"),
|
|
29219
29260
|
unique12("section_implementation_requests_id_project_unique").on(table.id, table.projectId),
|
|
29220
29261
|
uniqueIndex44("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql28`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
|
|
29221
|
-
|
|
29262
|
+
index84("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
|
|
29222
29263
|
]
|
|
29223
29264
|
);
|
|
29224
|
-
var sectionZoneReleases =
|
|
29265
|
+
var sectionZoneReleases = pgTable97(
|
|
29225
29266
|
"section_zone_releases",
|
|
29226
29267
|
{
|
|
29227
|
-
id:
|
|
29228
|
-
workspaceId:
|
|
29229
|
-
projectId:
|
|
29230
|
-
zoneId:
|
|
29231
|
-
revision:
|
|
29232
|
-
snapshot:
|
|
29233
|
-
publishedBy:
|
|
29234
|
-
publishedAt:
|
|
29268
|
+
id: text98("id").primaryKey(),
|
|
29269
|
+
workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
29270
|
+
projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
29271
|
+
zoneId: text98("zone_id").notNull(),
|
|
29272
|
+
revision: integer50("revision").notNull(),
|
|
29273
|
+
snapshot: jsonb56("snapshot").$type().notNull(),
|
|
29274
|
+
publishedBy: text98("published_by").notNull(),
|
|
29275
|
+
publishedAt: timestamp90("published_at").notNull().defaultNow()
|
|
29235
29276
|
},
|
|
29236
29277
|
(table) => [
|
|
29237
29278
|
foreignKey13({
|
|
@@ -29245,12 +29286,12 @@ var sectionZoneReleases = pgTable96(
|
|
|
29245
29286
|
name: "section_zone_releases_zone_project_fkey"
|
|
29246
29287
|
}).onDelete("cascade"),
|
|
29247
29288
|
unique12("section_zone_releases_zone_revision_unique").on(table.zoneId, table.revision),
|
|
29248
|
-
|
|
29289
|
+
index84("section_zone_releases_project_published_idx").on(table.projectId, table.publishedAt)
|
|
29249
29290
|
]
|
|
29250
29291
|
);
|
|
29251
29292
|
|
|
29252
29293
|
// src/schema/content_locks.ts
|
|
29253
|
-
import { check as check11, index as
|
|
29294
|
+
import { check as check11, index as index85, jsonb as jsonb57, pgTable as pgTable98, text as text99, timestamp as timestamp91 } from "drizzle-orm/pg-core";
|
|
29254
29295
|
import { sql as sql29 } from "drizzle-orm";
|
|
29255
29296
|
var CONTENT_LOCK_TARGET_KINDS = [
|
|
29256
29297
|
"page",
|
|
@@ -29259,30 +29300,30 @@ var CONTENT_LOCK_TARGET_KINDS = [
|
|
|
29259
29300
|
"component_definition"
|
|
29260
29301
|
];
|
|
29261
29302
|
var CONTENT_LOCK_MODES = ["all", "agents"];
|
|
29262
|
-
var contentLocks =
|
|
29303
|
+
var contentLocks = pgTable98(
|
|
29263
29304
|
"content_locks",
|
|
29264
29305
|
{
|
|
29265
|
-
id:
|
|
29266
|
-
workspaceId:
|
|
29267
|
-
projectId:
|
|
29268
|
-
targetKind:
|
|
29269
|
-
targetId:
|
|
29270
|
-
blockId:
|
|
29306
|
+
id: text99("id").primaryKey(),
|
|
29307
|
+
workspaceId: text99("workspace_id").notNull(),
|
|
29308
|
+
projectId: text99("project_id").notNull(),
|
|
29309
|
+
targetKind: text99("target_kind").$type().notNull(),
|
|
29310
|
+
targetId: text99("target_id").notNull(),
|
|
29311
|
+
blockId: text99("block_id"),
|
|
29271
29312
|
// Deterministic structural path plus block ancestry captured when the lock is created.
|
|
29272
29313
|
// Nullable so Wave 5 remains compatible with locks created before this fingerprint existed.
|
|
29273
|
-
blockFingerprint:
|
|
29274
|
-
fieldPath:
|
|
29275
|
-
mode:
|
|
29276
|
-
reason:
|
|
29277
|
-
createdBy:
|
|
29278
|
-
createdAt:
|
|
29279
|
-
releasedBy:
|
|
29280
|
-
releasedAt:
|
|
29314
|
+
blockFingerprint: jsonb57("block_fingerprint").$type(),
|
|
29315
|
+
fieldPath: text99("field_path").array(),
|
|
29316
|
+
mode: text99("mode").$type().notNull().default("all"),
|
|
29317
|
+
reason: text99("reason"),
|
|
29318
|
+
createdBy: text99("created_by").notNull(),
|
|
29319
|
+
createdAt: timestamp91("created_at").notNull().defaultNow(),
|
|
29320
|
+
releasedBy: text99("released_by"),
|
|
29321
|
+
releasedAt: timestamp91("released_at")
|
|
29281
29322
|
},
|
|
29282
29323
|
(table) => [
|
|
29283
|
-
|
|
29284
|
-
|
|
29285
|
-
|
|
29324
|
+
index85("content_locks_workspace_idx").on(table.workspaceId),
|
|
29325
|
+
index85("content_locks_project_idx").on(table.projectId),
|
|
29326
|
+
index85("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql29`${table.releasedAt} IS NULL`),
|
|
29286
29327
|
check11("content_locks_target_kind_check", sql29`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
|
|
29287
29328
|
check11("content_locks_mode_check", sql29`${table.mode} IN ('all','agents')`)
|
|
29288
29329
|
// `content_locks_shape_check` lives in migration 0192 ONLY: it calls
|
|
@@ -29298,75 +29339,75 @@ var contentLocks = pgTable97(
|
|
|
29298
29339
|
|
|
29299
29340
|
// src/schema/project_transfers.ts
|
|
29300
29341
|
import {
|
|
29301
|
-
pgTable as
|
|
29302
|
-
text as
|
|
29342
|
+
pgTable as pgTable99,
|
|
29343
|
+
text as text100,
|
|
29303
29344
|
varchar as varchar73,
|
|
29304
|
-
timestamp as
|
|
29305
|
-
index as
|
|
29345
|
+
timestamp as timestamp92,
|
|
29346
|
+
index as index86,
|
|
29306
29347
|
uniqueIndex as uniqueIndex45
|
|
29307
29348
|
} from "drizzle-orm/pg-core";
|
|
29308
29349
|
import { sql as sql30 } from "drizzle-orm";
|
|
29309
|
-
var projectTransfers =
|
|
29350
|
+
var projectTransfers = pgTable99(
|
|
29310
29351
|
"project_transfers",
|
|
29311
29352
|
{
|
|
29312
|
-
id:
|
|
29353
|
+
id: text100("id").primaryKey(),
|
|
29313
29354
|
// nanoid
|
|
29314
|
-
token:
|
|
29355
|
+
token: text100("token").notNull(),
|
|
29315
29356
|
// nanoid(32) — recipient handshake / magic link
|
|
29316
29357
|
status: varchar73("status", { length: 20 }).notNull().default("pending"),
|
|
29317
29358
|
// pending | accepted (transient) | completed | declined | cancelled | expired | failed
|
|
29318
|
-
projectId:
|
|
29359
|
+
projectId: text100("project_id").notNull(),
|
|
29319
29360
|
// FK → projects.id (ON DELETE CASCADE, via migration)
|
|
29320
|
-
fromWorkspaceId:
|
|
29361
|
+
fromWorkspaceId: text100("from_workspace_id").notNull(),
|
|
29321
29362
|
// FK → workspaces.id (source)
|
|
29322
|
-
toWorkspaceId:
|
|
29363
|
+
toWorkspaceId: text100("to_workspace_id"),
|
|
29323
29364
|
// FK → workspaces.id — resolved at accept (null while pending)
|
|
29324
|
-
initiatedBy:
|
|
29365
|
+
initiatedBy: text100("initiated_by").notNull(),
|
|
29325
29366
|
// FK → users.id (source owner)
|
|
29326
29367
|
recipientEmail: varchar73("recipient_email", { length: 255 }).notNull(),
|
|
29327
29368
|
// lowercased
|
|
29328
|
-
note:
|
|
29369
|
+
note: text100("note"),
|
|
29329
29370
|
// optional message to the recipient
|
|
29330
|
-
resolvedAt:
|
|
29371
|
+
resolvedAt: timestamp92("resolved_at"),
|
|
29331
29372
|
// set on accept/decline/cancel/expire
|
|
29332
|
-
resolvedBy:
|
|
29373
|
+
resolvedBy: text100("resolved_by"),
|
|
29333
29374
|
// FK → users.id (accepter/decliner/canceller)
|
|
29334
|
-
error:
|
|
29375
|
+
error: text100("error"),
|
|
29335
29376
|
// failure detail when status='failed'
|
|
29336
|
-
expiresAt:
|
|
29377
|
+
expiresAt: timestamp92("expires_at").notNull(),
|
|
29337
29378
|
// createdAt + 7d
|
|
29338
|
-
createdAt:
|
|
29339
|
-
updatedAt:
|
|
29379
|
+
createdAt: timestamp92("created_at").notNull().defaultNow(),
|
|
29380
|
+
updatedAt: timestamp92("updated_at").notNull().defaultNow()
|
|
29340
29381
|
},
|
|
29341
29382
|
(table) => [
|
|
29342
29383
|
// At most one OPEN transfer per project. Partial-unique so completed/declined/
|
|
29343
29384
|
// cancelled/expired/failed rows never wedge a re-initiation.
|
|
29344
29385
|
uniqueIndex45("project_transfers_one_pending_idx").on(table.projectId).where(sql30`${table.status} = 'pending'`),
|
|
29345
29386
|
// Recipient inbox lookup (GET /me/transfers by email + status).
|
|
29346
|
-
|
|
29387
|
+
index86("project_transfers_recipient_idx").on(
|
|
29347
29388
|
table.recipientEmail,
|
|
29348
29389
|
table.status
|
|
29349
29390
|
),
|
|
29350
29391
|
// Source-side list (GET /projects/:id/transfers) + cancel.
|
|
29351
|
-
|
|
29352
|
-
|
|
29392
|
+
index86("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
|
|
29393
|
+
index86("project_transfers_project_idx").on(table.projectId),
|
|
29353
29394
|
// Magic-link resolution.
|
|
29354
29395
|
uniqueIndex45("project_transfers_token_idx").on(table.token),
|
|
29355
29396
|
// Expiry sweep — only pending rows are ever candidates.
|
|
29356
|
-
|
|
29397
|
+
index86("project_transfers_expires_idx").on(table.expiresAt).where(sql30`${table.status} = 'pending'`)
|
|
29357
29398
|
]
|
|
29358
29399
|
);
|
|
29359
29400
|
|
|
29360
29401
|
// src/schema/backups.ts
|
|
29361
29402
|
import {
|
|
29362
|
-
pgTable as
|
|
29363
|
-
text as
|
|
29403
|
+
pgTable as pgTable100,
|
|
29404
|
+
text as text101,
|
|
29364
29405
|
varchar as varchar74,
|
|
29365
|
-
integer as
|
|
29406
|
+
integer as integer51,
|
|
29366
29407
|
bigint as bigint7,
|
|
29367
|
-
jsonb as
|
|
29368
|
-
timestamp as
|
|
29369
|
-
index as
|
|
29408
|
+
jsonb as jsonb58,
|
|
29409
|
+
timestamp as timestamp93,
|
|
29410
|
+
index as index87
|
|
29370
29411
|
} from "drizzle-orm/pg-core";
|
|
29371
29412
|
var FULL_BACKUP_SCOPE = {
|
|
29372
29413
|
content: true,
|
|
@@ -29375,142 +29416,142 @@ var FULL_BACKUP_SCOPE = {
|
|
|
29375
29416
|
submissions: true,
|
|
29376
29417
|
analytics: true
|
|
29377
29418
|
};
|
|
29378
|
-
var backups =
|
|
29419
|
+
var backups = pgTable100(
|
|
29379
29420
|
"backups",
|
|
29380
29421
|
{
|
|
29381
|
-
id:
|
|
29422
|
+
id: text101("id").primaryKey(),
|
|
29382
29423
|
// nanoid
|
|
29383
|
-
workspaceId:
|
|
29424
|
+
workspaceId: text101("workspace_id").notNull(),
|
|
29384
29425
|
// FK → workspaces.id (RLS scope)
|
|
29385
|
-
projectId:
|
|
29426
|
+
projectId: text101("project_id").notNull(),
|
|
29386
29427
|
// FK → projects.id
|
|
29387
29428
|
name: varchar74("name", { length: 255 }).notNull(),
|
|
29388
29429
|
source: varchar74("source", { length: 20 }).notNull().default("manual"),
|
|
29389
29430
|
status: varchar74("status", { length: 20 }).notNull().default("pending"),
|
|
29390
|
-
manifestKey:
|
|
29431
|
+
manifestKey: text101("manifest_key"),
|
|
29391
29432
|
// R2 key of the gzipped manifest; NULL until ready
|
|
29392
|
-
manifestVersion:
|
|
29433
|
+
manifestVersion: integer51("manifest_version").notNull().default(1),
|
|
29393
29434
|
// forward-compat
|
|
29394
29435
|
sizeBytes: bigint7("size_bytes", { mode: "number" }),
|
|
29395
|
-
counts:
|
|
29436
|
+
counts: jsonb58("counts").$type().notNull().default({}),
|
|
29396
29437
|
// R2 object keys this snapshot references. Powers the media-GC hold:
|
|
29397
29438
|
// `list_backup_referenced_media_keys()` keeps these keys alive while the
|
|
29398
29439
|
// backup is live, so a restore never finds a garbage-collected object.
|
|
29399
|
-
mediaKeys:
|
|
29400
|
-
scope:
|
|
29401
|
-
error:
|
|
29402
|
-
createdBy:
|
|
29440
|
+
mediaKeys: jsonb58("media_keys").$type().notNull().default([]),
|
|
29441
|
+
scope: jsonb58("scope").$type().notNull().default(FULL_BACKUP_SCOPE),
|
|
29442
|
+
error: text101("error"),
|
|
29443
|
+
createdBy: text101("created_by"),
|
|
29403
29444
|
// FK → users(id); NULL = system-initiated
|
|
29404
|
-
createdAt:
|
|
29405
|
-
readyAt:
|
|
29406
|
-
expiresAt:
|
|
29445
|
+
createdAt: timestamp93("created_at").notNull().defaultNow(),
|
|
29446
|
+
readyAt: timestamp93("ready_at"),
|
|
29447
|
+
expiresAt: timestamp93("expires_at"),
|
|
29407
29448
|
// retention horizon; NULL = keep until count-pruned
|
|
29408
|
-
deletedAt:
|
|
29449
|
+
deletedAt: timestamp93("deleted_at")
|
|
29409
29450
|
},
|
|
29410
29451
|
(t) => [
|
|
29411
|
-
|
|
29412
|
-
|
|
29452
|
+
index87("backups_project_idx").on(t.projectId, t.createdAt),
|
|
29453
|
+
index87("backups_workspace_idx").on(t.workspaceId)
|
|
29413
29454
|
]
|
|
29414
29455
|
);
|
|
29415
29456
|
|
|
29416
29457
|
// src/schema/backup_jobs.ts
|
|
29417
29458
|
import {
|
|
29418
|
-
pgTable as
|
|
29419
|
-
text as
|
|
29459
|
+
pgTable as pgTable101,
|
|
29460
|
+
text as text102,
|
|
29420
29461
|
varchar as varchar75,
|
|
29421
|
-
integer as
|
|
29422
|
-
jsonb as
|
|
29423
|
-
timestamp as
|
|
29424
|
-
index as
|
|
29462
|
+
integer as integer52,
|
|
29463
|
+
jsonb as jsonb59,
|
|
29464
|
+
timestamp as timestamp94,
|
|
29465
|
+
index as index88
|
|
29425
29466
|
} from "drizzle-orm/pg-core";
|
|
29426
|
-
var backupJobs =
|
|
29467
|
+
var backupJobs = pgTable101(
|
|
29427
29468
|
"backup_jobs",
|
|
29428
29469
|
{
|
|
29429
|
-
id:
|
|
29470
|
+
id: text102("id").primaryKey(),
|
|
29430
29471
|
// nanoid
|
|
29431
|
-
workspaceId:
|
|
29432
|
-
projectId:
|
|
29472
|
+
workspaceId: text102("workspace_id").notNull(),
|
|
29473
|
+
projectId: text102("project_id").notNull(),
|
|
29433
29474
|
// create → the pending backups.id this job fills; restore → the source backup.
|
|
29434
|
-
backupId:
|
|
29475
|
+
backupId: text102("backup_id"),
|
|
29435
29476
|
operation: varchar75("operation", { length: 16 }).notNull(),
|
|
29436
29477
|
status: varchar75("status", { length: 16 }).notNull().default("pending"),
|
|
29437
|
-
progress:
|
|
29478
|
+
progress: integer52("progress").notNull().default(0),
|
|
29438
29479
|
// 0–100
|
|
29439
|
-
workingSince:
|
|
29440
|
-
attempts:
|
|
29441
|
-
error:
|
|
29442
|
-
payload:
|
|
29443
|
-
createdAt:
|
|
29444
|
-
updatedAt:
|
|
29480
|
+
workingSince: timestamp94("working_since", { withTimezone: true }),
|
|
29481
|
+
attempts: integer52("attempts").notNull().default(0),
|
|
29482
|
+
error: text102("error"),
|
|
29483
|
+
payload: jsonb59("payload").$type().notNull().default({}),
|
|
29484
|
+
createdAt: timestamp94("created_at").notNull().defaultNow(),
|
|
29485
|
+
updatedAt: timestamp94("updated_at").notNull().defaultNow()
|
|
29445
29486
|
},
|
|
29446
29487
|
(t) => [
|
|
29447
|
-
|
|
29448
|
-
|
|
29488
|
+
index88("backup_jobs_drain_idx").on(t.status, t.createdAt),
|
|
29489
|
+
index88("backup_jobs_project_idx").on(t.projectId)
|
|
29449
29490
|
]
|
|
29450
29491
|
);
|
|
29451
29492
|
|
|
29452
29493
|
// src/schema/clone_links.ts
|
|
29453
|
-
import { pgTable as
|
|
29454
|
-
var cloneLinks =
|
|
29494
|
+
import { pgTable as pgTable102, text as text103, boolean as boolean31, jsonb as jsonb60, timestamp as timestamp95, index as index89 } from "drizzle-orm/pg-core";
|
|
29495
|
+
var cloneLinks = pgTable102(
|
|
29455
29496
|
"clone_links",
|
|
29456
29497
|
{
|
|
29457
|
-
id:
|
|
29498
|
+
id: text103("id").primaryKey(),
|
|
29458
29499
|
// nanoid
|
|
29459
|
-
workspaceId:
|
|
29500
|
+
workspaceId: text103("workspace_id").notNull(),
|
|
29460
29501
|
// FK → workspaces.id (RLS scope)
|
|
29461
|
-
projectId:
|
|
29502
|
+
projectId: text103("project_id").notNull(),
|
|
29462
29503
|
// FK → projects.id
|
|
29463
|
-
token:
|
|
29504
|
+
token: text103("token").notNull(),
|
|
29464
29505
|
// public share token (nanoid); unique among active links
|
|
29465
29506
|
enabled: boolean31("enabled").notNull().default(true),
|
|
29466
|
-
scope:
|
|
29467
|
-
createdBy:
|
|
29507
|
+
scope: jsonb60("scope").$type().notNull(),
|
|
29508
|
+
createdBy: text103("created_by"),
|
|
29468
29509
|
// FK → users(id); NULL = system-initiated
|
|
29469
|
-
createdAt:
|
|
29470
|
-
updatedAt:
|
|
29471
|
-
revokedAt:
|
|
29510
|
+
createdAt: timestamp95("created_at").notNull().defaultNow(),
|
|
29511
|
+
updatedAt: timestamp95("updated_at").notNull().defaultNow(),
|
|
29512
|
+
revokedAt: timestamp95("revoked_at")
|
|
29472
29513
|
// set when the link is rotated/disabled
|
|
29473
29514
|
},
|
|
29474
29515
|
(t) => [
|
|
29475
|
-
|
|
29476
|
-
|
|
29516
|
+
index89("clone_links_project_idx").on(t.projectId),
|
|
29517
|
+
index89("clone_links_workspace_idx").on(t.workspaceId)
|
|
29477
29518
|
]
|
|
29478
29519
|
);
|
|
29479
29520
|
|
|
29480
29521
|
// src/schema/clone_jobs.ts
|
|
29481
|
-
import { pgTable as
|
|
29522
|
+
import { pgTable as pgTable103, text as text104, varchar as varchar76, integer as integer53, jsonb as jsonb61, timestamp as timestamp96, index as index90, uniqueIndex as uniqueIndex46 } from "drizzle-orm/pg-core";
|
|
29482
29523
|
import { sql as sql31 } from "drizzle-orm";
|
|
29483
|
-
var cloneJobs =
|
|
29524
|
+
var cloneJobs = pgTable103(
|
|
29484
29525
|
"clone_jobs",
|
|
29485
29526
|
{
|
|
29486
|
-
id:
|
|
29527
|
+
id: text104("id").primaryKey(),
|
|
29487
29528
|
// nanoid
|
|
29488
|
-
workspaceId:
|
|
29529
|
+
workspaceId: text104("workspace_id").notNull(),
|
|
29489
29530
|
// = targetWorkspaceId (RLS scope)
|
|
29490
|
-
sourceProjectId:
|
|
29491
|
-
sourceWorkspaceId:
|
|
29492
|
-
targetProjectId:
|
|
29531
|
+
sourceProjectId: text104("source_project_id").notNull(),
|
|
29532
|
+
sourceWorkspaceId: text104("source_workspace_id").notNull(),
|
|
29533
|
+
targetProjectId: text104("target_project_id"),
|
|
29493
29534
|
// stamped on success
|
|
29494
29535
|
requestedName: varchar76("requested_name", { length: 255 }),
|
|
29495
29536
|
requestedSlug: varchar76("requested_slug", { length: 255 }),
|
|
29496
29537
|
status: varchar76("status", { length: 16 }).notNull().default("pending"),
|
|
29497
|
-
progress:
|
|
29538
|
+
progress: integer53("progress").notNull().default(0),
|
|
29498
29539
|
// 0–100
|
|
29499
|
-
workingSince:
|
|
29500
|
-
attempts:
|
|
29501
|
-
error:
|
|
29502
|
-
payload:
|
|
29540
|
+
workingSince: timestamp96("working_since", { withTimezone: true }),
|
|
29541
|
+
attempts: integer53("attempts").notNull().default(0),
|
|
29542
|
+
error: text104("error"),
|
|
29543
|
+
payload: jsonb61("payload").$type().notNull().default({}),
|
|
29503
29544
|
// Which post-clone work the drain owes a finished job. 'clone' = none, today's behaviour.
|
|
29504
29545
|
// Migration 0343.
|
|
29505
29546
|
purpose: varchar76("purpose", { length: 32 }).notNull().default("clone"),
|
|
29506
|
-
initiatedBy:
|
|
29547
|
+
initiatedBy: text104("initiated_by"),
|
|
29507
29548
|
// FK → users(id); NULL = system/agent
|
|
29508
|
-
createdAt:
|
|
29509
|
-
updatedAt:
|
|
29549
|
+
createdAt: timestamp96("created_at").notNull().defaultNow(),
|
|
29550
|
+
updatedAt: timestamp96("updated_at").notNull().defaultNow()
|
|
29510
29551
|
},
|
|
29511
29552
|
(t) => [
|
|
29512
|
-
|
|
29513
|
-
|
|
29553
|
+
index90("clone_jobs_drain_idx").on(t.status, t.createdAt),
|
|
29554
|
+
index90("clone_jobs_workspace_idx").on(t.workspaceId),
|
|
29514
29555
|
// One unfinished hybrid→headless switch per source (0343). The route maps its 23505 to
|
|
29515
29556
|
// SWITCH_ALREADY_PENDING.
|
|
29516
29557
|
uniqueIndex46("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql31`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
|
|
@@ -29520,141 +29561,141 @@ var cloneJobs = pgTable102(
|
|
|
29520
29561
|
// src/schema/project_branches.ts
|
|
29521
29562
|
import {
|
|
29522
29563
|
primaryKey as primaryKey9,
|
|
29523
|
-
pgTable as
|
|
29524
|
-
text as
|
|
29564
|
+
pgTable as pgTable104,
|
|
29565
|
+
text as text105,
|
|
29525
29566
|
varchar as varchar77,
|
|
29526
|
-
timestamp as
|
|
29527
|
-
index as
|
|
29567
|
+
timestamp as timestamp97,
|
|
29568
|
+
index as index91,
|
|
29528
29569
|
uniqueIndex as uniqueIndex47
|
|
29529
29570
|
} from "drizzle-orm/pg-core";
|
|
29530
29571
|
import { sql as sql32 } from "drizzle-orm";
|
|
29531
|
-
var projectBranches =
|
|
29572
|
+
var projectBranches = pgTable104(
|
|
29532
29573
|
"project_branches",
|
|
29533
29574
|
{
|
|
29534
|
-
id:
|
|
29535
|
-
workspaceId:
|
|
29536
|
-
projectId:
|
|
29575
|
+
id: text105("id").primaryKey(),
|
|
29576
|
+
workspaceId: text105("workspace_id").notNull(),
|
|
29577
|
+
projectId: text105("project_id").notNull(),
|
|
29537
29578
|
name: varchar77("name", { length: 80 }).notNull(),
|
|
29538
29579
|
slug: varchar77("slug", { length: 80 }).notNull(),
|
|
29539
|
-
parentBranchId:
|
|
29580
|
+
parentBranchId: text105("parent_branch_id"),
|
|
29540
29581
|
status: varchar77("status", { length: 16 }).$type().notNull().default("open"),
|
|
29541
|
-
appliedAt:
|
|
29542
|
-
abandonedAt:
|
|
29582
|
+
appliedAt: timestamp97("applied_at"),
|
|
29583
|
+
abandonedAt: timestamp97("abandoned_at"),
|
|
29543
29584
|
/** Set while an Apply/Pull runs (0374); a second one is refused. Stale after five minutes. */
|
|
29544
|
-
applyingAt:
|
|
29585
|
+
applyingAt: timestamp97("applying_at"),
|
|
29545
29586
|
...auditColumns
|
|
29546
29587
|
},
|
|
29547
29588
|
(t) => [
|
|
29548
|
-
|
|
29589
|
+
index91("project_branches_project_idx").on(t.projectId),
|
|
29549
29590
|
uniqueIndex47("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql32`${t.status} = 'open'`)
|
|
29550
29591
|
]
|
|
29551
29592
|
);
|
|
29552
|
-
var branchRowSyncs =
|
|
29593
|
+
var branchRowSyncs = pgTable104(
|
|
29553
29594
|
"branch_row_syncs",
|
|
29554
29595
|
{
|
|
29555
|
-
workspaceId:
|
|
29556
|
-
projectId:
|
|
29557
|
-
branchId:
|
|
29558
|
-
kind:
|
|
29559
|
-
parentRowId:
|
|
29560
|
-
syncedAt:
|
|
29596
|
+
workspaceId: text105("workspace_id").notNull(),
|
|
29597
|
+
projectId: text105("project_id").notNull(),
|
|
29598
|
+
branchId: text105("branch_id").notNull(),
|
|
29599
|
+
kind: text105("kind").notNull(),
|
|
29600
|
+
parentRowId: text105("parent_row_id").notNull(),
|
|
29601
|
+
syncedAt: timestamp97("synced_at").notNull().defaultNow()
|
|
29561
29602
|
},
|
|
29562
29603
|
(t) => [
|
|
29563
29604
|
primaryKey9({ columns: [t.branchId, t.kind, t.parentRowId] }),
|
|
29564
|
-
|
|
29605
|
+
index91("branch_row_syncs_project_idx").on(t.projectId)
|
|
29565
29606
|
]
|
|
29566
29607
|
);
|
|
29567
29608
|
|
|
29568
29609
|
// src/schema/branch_preview_share.ts
|
|
29569
|
-
import { pgTable as
|
|
29570
|
-
var branchPreviewShares =
|
|
29610
|
+
import { pgTable as pgTable105, text as text106, boolean as boolean32, timestamp as timestamp98, index as index92, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
|
|
29611
|
+
var branchPreviewShares = pgTable105(
|
|
29571
29612
|
"branch_preview_shares",
|
|
29572
29613
|
{
|
|
29573
|
-
id:
|
|
29574
|
-
workspaceId:
|
|
29575
|
-
projectId:
|
|
29576
|
-
branchId:
|
|
29614
|
+
id: text106("id").primaryKey(),
|
|
29615
|
+
workspaceId: text106("workspace_id").notNull(),
|
|
29616
|
+
projectId: text106("project_id").notNull(),
|
|
29617
|
+
branchId: text106("branch_id").notNull(),
|
|
29577
29618
|
publicEnabled: boolean32("public_enabled").notNull().default(false),
|
|
29578
|
-
publicToken:
|
|
29579
|
-
createdBy:
|
|
29580
|
-
createdAt:
|
|
29581
|
-
updatedAt:
|
|
29619
|
+
publicToken: text106("public_token"),
|
|
29620
|
+
createdBy: text106("created_by"),
|
|
29621
|
+
createdAt: timestamp98("created_at").notNull().defaultNow(),
|
|
29622
|
+
updatedAt: timestamp98("updated_at").notNull().defaultNow()
|
|
29582
29623
|
},
|
|
29583
29624
|
(t) => [
|
|
29584
29625
|
uniqueIndex48("branch_preview_shares_branch_idx").on(t.branchId),
|
|
29585
29626
|
uniqueIndex48("branch_preview_shares_active_token_idx").on(t.publicToken),
|
|
29586
|
-
|
|
29587
|
-
|
|
29627
|
+
index92("branch_preview_shares_project_idx").on(t.projectId),
|
|
29628
|
+
index92("branch_preview_shares_workspace_idx").on(t.workspaceId)
|
|
29588
29629
|
]
|
|
29589
29630
|
);
|
|
29590
|
-
var branchPreviewGrants =
|
|
29631
|
+
var branchPreviewGrants = pgTable105(
|
|
29591
29632
|
"branch_preview_grants",
|
|
29592
29633
|
{
|
|
29593
|
-
id:
|
|
29594
|
-
workspaceId:
|
|
29595
|
-
projectId:
|
|
29596
|
-
branchId:
|
|
29597
|
-
email:
|
|
29598
|
-
invitedBy:
|
|
29599
|
-
createdAt:
|
|
29634
|
+
id: text106("id").primaryKey(),
|
|
29635
|
+
workspaceId: text106("workspace_id").notNull(),
|
|
29636
|
+
projectId: text106("project_id").notNull(),
|
|
29637
|
+
branchId: text106("branch_id").notNull(),
|
|
29638
|
+
email: text106("email").notNull(),
|
|
29639
|
+
invitedBy: text106("invited_by"),
|
|
29640
|
+
createdAt: timestamp98("created_at").notNull().defaultNow()
|
|
29600
29641
|
},
|
|
29601
29642
|
(t) => [
|
|
29602
29643
|
uniqueIndex48("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
|
|
29603
|
-
|
|
29644
|
+
index92("branch_preview_grants_project_idx").on(t.projectId)
|
|
29604
29645
|
]
|
|
29605
29646
|
);
|
|
29606
29647
|
|
|
29607
29648
|
// src/schema/share_links.ts
|
|
29608
|
-
import { pgTable as
|
|
29609
|
-
var shareLinks =
|
|
29649
|
+
import { pgTable as pgTable106, text as text107, boolean as boolean33, timestamp as timestamp99, index as index93 } from "drizzle-orm/pg-core";
|
|
29650
|
+
var shareLinks = pgTable106(
|
|
29610
29651
|
"share_links",
|
|
29611
29652
|
{
|
|
29612
|
-
id:
|
|
29653
|
+
id: text107("id").primaryKey(),
|
|
29613
29654
|
// nanoid
|
|
29614
|
-
workspaceId:
|
|
29655
|
+
workspaceId: text107("workspace_id").notNull(),
|
|
29615
29656
|
// FK → workspaces.id (RLS scope)
|
|
29616
|
-
projectId:
|
|
29657
|
+
projectId: text107("project_id").notNull(),
|
|
29617
29658
|
// FK → projects.id
|
|
29618
|
-
token:
|
|
29659
|
+
token: text107("token").notNull(),
|
|
29619
29660
|
// public share token (nanoid); unique among active links
|
|
29620
29661
|
enabled: boolean33("enabled").notNull().default(true),
|
|
29621
|
-
createdBy:
|
|
29662
|
+
createdBy: text107("created_by"),
|
|
29622
29663
|
// FK → users(id); NULL = system-initiated
|
|
29623
|
-
createdAt:
|
|
29624
|
-
updatedAt:
|
|
29625
|
-
revokedAt:
|
|
29664
|
+
createdAt: timestamp99("created_at").notNull().defaultNow(),
|
|
29665
|
+
updatedAt: timestamp99("updated_at").notNull().defaultNow(),
|
|
29666
|
+
revokedAt: timestamp99("revoked_at")
|
|
29626
29667
|
// set when the link is disabled
|
|
29627
29668
|
},
|
|
29628
29669
|
(t) => [
|
|
29629
|
-
|
|
29630
|
-
|
|
29670
|
+
index93("share_links_project_idx").on(t.projectId),
|
|
29671
|
+
index93("share_links_workspace_idx").on(t.workspaceId)
|
|
29631
29672
|
]
|
|
29632
29673
|
);
|
|
29633
29674
|
|
|
29634
29675
|
// src/schema/templates.ts
|
|
29635
29676
|
import {
|
|
29636
|
-
pgTable as
|
|
29637
|
-
text as
|
|
29677
|
+
pgTable as pgTable107,
|
|
29678
|
+
text as text108,
|
|
29638
29679
|
varchar as varchar78,
|
|
29639
|
-
timestamp as
|
|
29640
|
-
jsonb as
|
|
29641
|
-
integer as
|
|
29642
|
-
index as
|
|
29680
|
+
timestamp as timestamp100,
|
|
29681
|
+
jsonb as jsonb62,
|
|
29682
|
+
integer as integer54,
|
|
29683
|
+
index as index94,
|
|
29643
29684
|
uniqueIndex as uniqueIndex49
|
|
29644
29685
|
} from "drizzle-orm/pg-core";
|
|
29645
29686
|
import { relations as relations17 } from "drizzle-orm/relations";
|
|
29646
29687
|
import { sql as sql33 } from "drizzle-orm";
|
|
29647
|
-
var templates =
|
|
29688
|
+
var templates = pgTable107(
|
|
29648
29689
|
"templates",
|
|
29649
29690
|
{
|
|
29650
|
-
id:
|
|
29691
|
+
id: text108("id").primaryKey(),
|
|
29651
29692
|
// nanoid
|
|
29652
|
-
workspaceId:
|
|
29693
|
+
workspaceId: text108("workspace_id").notNull(),
|
|
29653
29694
|
// FK to workspaces.id (RLS scope / owner)
|
|
29654
29695
|
slug: varchar78("slug", { length: 255 }).notNull(),
|
|
29655
29696
|
// ^[a-z0-9-]+$, unique per workspace
|
|
29656
29697
|
name: varchar78("name", { length: 255 }).notNull(),
|
|
29657
|
-
description:
|
|
29698
|
+
description: text108("description"),
|
|
29658
29699
|
scope: varchar78("scope", { length: 10 }).$type().notNull().default("project"),
|
|
29659
29700
|
// 'demo' ships seed content; 'starter-kit' is the same schema with the content blanked.
|
|
29660
29701
|
// Defaults to 'demo' because a user template is a frozen snapshot of a real project,
|
|
@@ -29665,25 +29706,25 @@ var templates = pgTable106(
|
|
|
29665
29706
|
thumbnail: varchar78("thumbnail", { length: 2048 }),
|
|
29666
29707
|
// Frozen snapshot manifest (stripped snapshot_project output). Never returned in
|
|
29667
29708
|
// list/gallery responses — only read server-side to instantiate.
|
|
29668
|
-
manifest:
|
|
29709
|
+
manifest: jsonb62("manifest").$type().notNull(),
|
|
29669
29710
|
visibility: varchar78("visibility", { length: 10 }).$type().notNull().default("private"),
|
|
29670
|
-
sourceProjectId:
|
|
29711
|
+
sourceProjectId: text108("source_project_id"),
|
|
29671
29712
|
// provenance (nullable — source may be deleted later)
|
|
29672
|
-
createdBy:
|
|
29713
|
+
createdBy: text108("created_by"),
|
|
29673
29714
|
// user id, or null for a management-key create
|
|
29674
|
-
optimisticVersion:
|
|
29675
|
-
createdAt:
|
|
29676
|
-
updatedAt:
|
|
29677
|
-
deletedAt:
|
|
29715
|
+
optimisticVersion: integer54("optimistic_version").notNull().default(0),
|
|
29716
|
+
createdAt: timestamp100("created_at").notNull().defaultNow(),
|
|
29717
|
+
updatedAt: timestamp100("updated_at").notNull().defaultNow(),
|
|
29718
|
+
deletedAt: timestamp100("deleted_at")
|
|
29678
29719
|
// soft-delete
|
|
29679
29720
|
},
|
|
29680
29721
|
(table) => [
|
|
29681
|
-
|
|
29722
|
+
index94("templates_workspace_idx").on(table.workspaceId),
|
|
29682
29723
|
// Partial: only live rows. A soft-deleted template frees its slug (mirrors
|
|
29683
29724
|
// components_ws_proj_slug_idx / migration 0114).
|
|
29684
29725
|
uniqueIndex49("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql33`${table.deletedAt} IS NULL`),
|
|
29685
29726
|
// Public gallery scan (created_at DESC over live public rows).
|
|
29686
|
-
|
|
29727
|
+
index94("templates_public_idx").on(table.visibility).where(sql33`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
|
|
29687
29728
|
]
|
|
29688
29729
|
);
|
|
29689
29730
|
var templatesRelations = relations17(templates, ({ one }) => ({
|
|
@@ -29695,99 +29736,99 @@ var templatesRelations = relations17(templates, ({ one }) => ({
|
|
|
29695
29736
|
|
|
29696
29737
|
// src/schema/payment_records.ts
|
|
29697
29738
|
import {
|
|
29698
|
-
pgTable as
|
|
29699
|
-
text as
|
|
29739
|
+
pgTable as pgTable108,
|
|
29740
|
+
text as text109,
|
|
29700
29741
|
varchar as varchar79,
|
|
29701
|
-
integer as
|
|
29702
|
-
timestamp as
|
|
29703
|
-
index as
|
|
29742
|
+
integer as integer55,
|
|
29743
|
+
timestamp as timestamp101,
|
|
29744
|
+
index as index95
|
|
29704
29745
|
} from "drizzle-orm/pg-core";
|
|
29705
|
-
var paymentRecords =
|
|
29746
|
+
var paymentRecords = pgTable108(
|
|
29706
29747
|
"payment_records",
|
|
29707
29748
|
{
|
|
29708
|
-
id:
|
|
29749
|
+
id: text109("id").primaryKey(),
|
|
29709
29750
|
// nanoid
|
|
29710
|
-
workspaceId:
|
|
29751
|
+
workspaceId: text109("workspace_id").notNull(),
|
|
29711
29752
|
// FK → workspaces.id
|
|
29712
|
-
amountCents:
|
|
29753
|
+
amountCents: integer55("amount_cents").notNull(),
|
|
29713
29754
|
// store money as integer cents
|
|
29714
29755
|
currency: varchar79("currency", { length: 3 }).notNull().default("usd"),
|
|
29715
29756
|
method: varchar79("method", { length: 50 }).notNull().default("manual"),
|
|
29716
29757
|
// manual | stripe | wire | ...
|
|
29717
|
-
note:
|
|
29718
|
-
recordedBy:
|
|
29758
|
+
note: text109("note"),
|
|
29759
|
+
recordedBy: text109("recorded_by"),
|
|
29719
29760
|
// FK → users.id (the admin who entered it)
|
|
29720
|
-
createdAt:
|
|
29761
|
+
createdAt: timestamp101("created_at").notNull().defaultNow()
|
|
29721
29762
|
},
|
|
29722
29763
|
(table) => [
|
|
29723
|
-
|
|
29764
|
+
index95("payment_records_workspace_idx").on(table.workspaceId, table.createdAt)
|
|
29724
29765
|
]
|
|
29725
29766
|
);
|
|
29726
29767
|
|
|
29727
29768
|
// src/schema/plan_changes.ts
|
|
29728
29769
|
import {
|
|
29729
|
-
pgTable as
|
|
29730
|
-
text as
|
|
29731
|
-
timestamp as
|
|
29732
|
-
index as
|
|
29770
|
+
pgTable as pgTable109,
|
|
29771
|
+
text as text110,
|
|
29772
|
+
timestamp as timestamp102,
|
|
29773
|
+
index as index96
|
|
29733
29774
|
} from "drizzle-orm/pg-core";
|
|
29734
|
-
var planChanges =
|
|
29775
|
+
var planChanges = pgTable109(
|
|
29735
29776
|
"plan_changes",
|
|
29736
29777
|
{
|
|
29737
|
-
id:
|
|
29778
|
+
id: text110("id").primaryKey(),
|
|
29738
29779
|
// nanoid
|
|
29739
|
-
workspaceId:
|
|
29780
|
+
workspaceId: text110("workspace_id").notNull(),
|
|
29740
29781
|
// FK → workspaces.id
|
|
29741
|
-
fromPlan:
|
|
29782
|
+
fromPlan: text110("from_plan"),
|
|
29742
29783
|
// plan_limits.id before the change (null if unknown)
|
|
29743
|
-
toPlan:
|
|
29784
|
+
toPlan: text110("to_plan").notNull(),
|
|
29744
29785
|
// plan_limits.id after the change
|
|
29745
|
-
reason:
|
|
29746
|
-
changedBy:
|
|
29786
|
+
reason: text110("reason"),
|
|
29787
|
+
changedBy: text110("changed_by"),
|
|
29747
29788
|
// FK → users.id (the admin)
|
|
29748
|
-
createdAt:
|
|
29789
|
+
createdAt: timestamp102("created_at").notNull().defaultNow()
|
|
29749
29790
|
},
|
|
29750
29791
|
(table) => [
|
|
29751
|
-
|
|
29792
|
+
index96("plan_changes_workspace_idx").on(table.workspaceId, table.createdAt)
|
|
29752
29793
|
]
|
|
29753
29794
|
);
|
|
29754
29795
|
|
|
29755
29796
|
// src/schema/billing_addons.ts
|
|
29756
|
-
import { pgTable as
|
|
29757
|
-
var billingAddons =
|
|
29797
|
+
import { pgTable as pgTable110, text as text111, varchar as varchar80, integer as integer56, boolean as boolean34, jsonb as jsonb63, index as index97 } from "drizzle-orm/pg-core";
|
|
29798
|
+
var billingAddons = pgTable110(
|
|
29758
29799
|
"billing_addons",
|
|
29759
29800
|
{
|
|
29760
|
-
id:
|
|
29801
|
+
id: text111("id").primaryKey(),
|
|
29761
29802
|
// stable slug, e.g. "developer", "ai-1000", "localization"
|
|
29762
29803
|
kind: varchar80("kind", { length: 20 }).notNull(),
|
|
29763
29804
|
// seat_role | ai_credits | localization | ab_testing
|
|
29764
29805
|
name: varchar80("name", { length: 100 }).notNull(),
|
|
29765
|
-
dodoProductId:
|
|
29806
|
+
dodoProductId: text111("dodo_product_id"),
|
|
29766
29807
|
// NULL until the Dodo product is created
|
|
29767
|
-
unitPriceCents:
|
|
29808
|
+
unitPriceCents: integer56("unit_price_cents").notNull(),
|
|
29768
29809
|
currency: varchar80("currency", { length: 8 }).notNull().default("usd"),
|
|
29769
|
-
credits:
|
|
29810
|
+
credits: integer56("credits"),
|
|
29770
29811
|
// ai_credits packs only: credits granted per unit
|
|
29771
29812
|
recurring: boolean34("recurring").notNull().default(false),
|
|
29772
29813
|
// seats/localization/AB = true; credit packs = false
|
|
29773
|
-
metadata:
|
|
29814
|
+
metadata: jsonb63("metadata").$type().default({})
|
|
29774
29815
|
},
|
|
29775
|
-
(t) => [
|
|
29816
|
+
(t) => [index97("billing_addons_kind_idx").on(t.kind)]
|
|
29776
29817
|
);
|
|
29777
29818
|
|
|
29778
29819
|
// src/schema/billing_customers.ts
|
|
29779
|
-
import { pgTable as
|
|
29780
|
-
var billingCustomers =
|
|
29820
|
+
import { pgTable as pgTable111, text as text112, varchar as varchar81, timestamp as timestamp103, uniqueIndex as uniqueIndex50 } from "drizzle-orm/pg-core";
|
|
29821
|
+
var billingCustomers = pgTable111(
|
|
29781
29822
|
"billing_customers",
|
|
29782
29823
|
{
|
|
29783
|
-
id:
|
|
29824
|
+
id: text112("id").primaryKey(),
|
|
29784
29825
|
// nanoid
|
|
29785
|
-
workspaceId:
|
|
29826
|
+
workspaceId: text112("workspace_id").notNull(),
|
|
29786
29827
|
// FK → workspaces.id (RLS scope)
|
|
29787
|
-
dodoCustomerId:
|
|
29828
|
+
dodoCustomerId: text112("dodo_customer_id").notNull(),
|
|
29788
29829
|
email: varchar81("email", { length: 255 }),
|
|
29789
|
-
createdAt:
|
|
29790
|
-
updatedAt:
|
|
29830
|
+
createdAt: timestamp103("created_at").notNull().defaultNow(),
|
|
29831
|
+
updatedAt: timestamp103("updated_at").notNull().defaultNow()
|
|
29791
29832
|
},
|
|
29792
29833
|
(t) => [
|
|
29793
29834
|
uniqueIndex50("billing_customers_workspace_idx").on(t.workspaceId),
|
|
@@ -29796,34 +29837,34 @@ var billingCustomers = pgTable110(
|
|
|
29796
29837
|
);
|
|
29797
29838
|
|
|
29798
29839
|
// src/schema/subscriptions.ts
|
|
29799
|
-
import { pgTable as
|
|
29840
|
+
import { pgTable as pgTable112, text as text113, varchar as varchar82, boolean as boolean35, timestamp as timestamp104, index as index98, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
|
|
29800
29841
|
import { sql as sql34 } from "drizzle-orm";
|
|
29801
|
-
var subscriptions =
|
|
29842
|
+
var subscriptions = pgTable112(
|
|
29802
29843
|
"subscriptions",
|
|
29803
29844
|
{
|
|
29804
|
-
id:
|
|
29845
|
+
id: text113("id").primaryKey(),
|
|
29805
29846
|
// nanoid
|
|
29806
|
-
workspaceId:
|
|
29847
|
+
workspaceId: text113("workspace_id").notNull(),
|
|
29807
29848
|
// FK → workspaces.id (RLS scope)
|
|
29808
|
-
projectId:
|
|
29849
|
+
projectId: text113("project_id"),
|
|
29809
29850
|
// NULL = workspace plan; set = site plan (FK → projects.id)
|
|
29810
|
-
planId:
|
|
29851
|
+
planId: text113("plan_id").notNull(),
|
|
29811
29852
|
// FK → plan_limits.id
|
|
29812
|
-
dodoSubscriptionId:
|
|
29813
|
-
dodoCustomerId:
|
|
29853
|
+
dodoSubscriptionId: text113("dodo_subscription_id"),
|
|
29854
|
+
dodoCustomerId: text113("dodo_customer_id"),
|
|
29814
29855
|
status: varchar82("status", { length: 20 }).notNull().default("active"),
|
|
29815
29856
|
// active | on_hold | cancelled | expired | pending
|
|
29816
29857
|
// Which of plan_limits' two prices this row is billed at. Without it the bill cannot tell
|
|
29817
29858
|
// whether the owner pays price_cents or price_cents_yearly (0147).
|
|
29818
29859
|
interval: varchar82("interval", { length: 10 }).notNull().default("month"),
|
|
29819
29860
|
// month | year
|
|
29820
|
-
currentPeriodEnd:
|
|
29861
|
+
currentPeriodEnd: timestamp104("current_period_end"),
|
|
29821
29862
|
cancelAtPeriodEnd: boolean35("cancel_at_period_end").notNull().default(false),
|
|
29822
|
-
createdAt:
|
|
29823
|
-
updatedAt:
|
|
29863
|
+
createdAt: timestamp104("created_at").notNull().defaultNow(),
|
|
29864
|
+
updatedAt: timestamp104("updated_at").notNull().defaultNow()
|
|
29824
29865
|
},
|
|
29825
29866
|
(t) => [
|
|
29826
|
-
|
|
29867
|
+
index98("subscriptions_workspace_idx").on(t.workspaceId),
|
|
29827
29868
|
uniqueIndex51("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql34`${t.dodoSubscriptionId} IS NOT NULL`),
|
|
29828
29869
|
// At most one workspace-level subscription per workspace.
|
|
29829
29870
|
uniqueIndex51("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql34`${t.projectId} IS NULL`),
|
|
@@ -29833,39 +29874,39 @@ var subscriptions = pgTable111(
|
|
|
29833
29874
|
);
|
|
29834
29875
|
|
|
29835
29876
|
// src/schema/subscription_addons.ts
|
|
29836
|
-
import { pgTable as
|
|
29877
|
+
import { pgTable as pgTable113, text as text114, varchar as varchar83, integer as integer57, timestamp as timestamp105, index as index99, uniqueIndex as uniqueIndex52 } from "drizzle-orm/pg-core";
|
|
29837
29878
|
import { sql as sql35 } from "drizzle-orm";
|
|
29838
|
-
var subscriptionAddons =
|
|
29879
|
+
var subscriptionAddons = pgTable113(
|
|
29839
29880
|
"subscription_addons",
|
|
29840
29881
|
{
|
|
29841
|
-
id:
|
|
29882
|
+
id: text114("id").primaryKey(),
|
|
29842
29883
|
// nanoid
|
|
29843
|
-
workspaceId:
|
|
29884
|
+
workspaceId: text114("workspace_id").notNull(),
|
|
29844
29885
|
// FK → workspaces.id (RLS scope)
|
|
29845
|
-
addonId:
|
|
29886
|
+
addonId: text114("addon_id").notNull(),
|
|
29846
29887
|
// FK → billing_addons.id
|
|
29847
|
-
quantity:
|
|
29848
|
-
dodoSubscriptionId:
|
|
29888
|
+
quantity: integer57("quantity").notNull().default(1),
|
|
29889
|
+
dodoSubscriptionId: text114("dodo_subscription_id"),
|
|
29849
29890
|
// NULL for a manual/admin grant
|
|
29850
29891
|
status: varchar83("status", { length: 20 }).notNull().default("active"),
|
|
29851
29892
|
// active | cancelled | expired
|
|
29852
|
-
createdAt:
|
|
29853
|
-
updatedAt:
|
|
29893
|
+
createdAt: timestamp105("created_at").notNull().defaultNow(),
|
|
29894
|
+
updatedAt: timestamp105("updated_at").notNull().defaultNow()
|
|
29854
29895
|
},
|
|
29855
29896
|
(t) => [
|
|
29856
|
-
|
|
29897
|
+
index99("subscription_addons_workspace_idx").on(t.workspaceId),
|
|
29857
29898
|
uniqueIndex52("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql35`${t.dodoSubscriptionId} IS NOT NULL`)
|
|
29858
29899
|
]
|
|
29859
29900
|
);
|
|
29860
29901
|
|
|
29861
29902
|
// src/schema/billing_alerts.ts
|
|
29862
|
-
import { pgTable as
|
|
29863
|
-
var billingAlerts =
|
|
29903
|
+
import { pgTable as pgTable114, text as text115, varchar as varchar84, timestamp as timestamp106, index as index100, uniqueIndex as uniqueIndex53 } from "drizzle-orm/pg-core";
|
|
29904
|
+
var billingAlerts = pgTable114(
|
|
29864
29905
|
"billing_alerts",
|
|
29865
29906
|
{
|
|
29866
|
-
id:
|
|
29907
|
+
id: text115("id").primaryKey(),
|
|
29867
29908
|
// nanoid
|
|
29868
|
-
workspaceId:
|
|
29909
|
+
workspaceId: text115("workspace_id").notNull(),
|
|
29869
29910
|
// FK → workspaces.id (internal table, no RLS)
|
|
29870
29911
|
kind: varchar84("kind", { length: 32 }).notNull(),
|
|
29871
29912
|
// renewal_due | bandwidth_80 | bandwidth_100
|
|
@@ -29875,104 +29916,104 @@ var billingAlerts = pgTable113(
|
|
|
29875
29916
|
* period-end change. Bandwidth keys on the threshold + calendar month, matching the window
|
|
29876
29917
|
* getUsage() measures — so the counter resetting on the 1st re-arms the alert.
|
|
29877
29918
|
*/
|
|
29878
|
-
dedupeKey:
|
|
29879
|
-
sentAt:
|
|
29919
|
+
dedupeKey: text115("dedupe_key").notNull(),
|
|
29920
|
+
sentAt: timestamp106("sent_at", { withTimezone: true }).notNull().defaultNow()
|
|
29880
29921
|
},
|
|
29881
29922
|
(t) => [
|
|
29882
29923
|
uniqueIndex53("billing_alerts_dedupe_idx").on(t.dedupeKey),
|
|
29883
|
-
|
|
29924
|
+
index100("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
|
|
29884
29925
|
]
|
|
29885
29926
|
);
|
|
29886
29927
|
|
|
29887
29928
|
// src/schema/ai_credit_ledger.ts
|
|
29888
|
-
import { pgTable as
|
|
29929
|
+
import { pgTable as pgTable115, text as text116, varchar as varchar85, integer as integer58, timestamp as timestamp107, index as index101, uniqueIndex as uniqueIndex54 } from "drizzle-orm/pg-core";
|
|
29889
29930
|
import { sql as sql36 } from "drizzle-orm";
|
|
29890
|
-
var aiCreditLedger =
|
|
29931
|
+
var aiCreditLedger = pgTable115(
|
|
29891
29932
|
"ai_credit_ledger",
|
|
29892
29933
|
{
|
|
29893
|
-
id:
|
|
29934
|
+
id: text116("id").primaryKey(),
|
|
29894
29935
|
// nanoid
|
|
29895
|
-
workspaceId:
|
|
29936
|
+
workspaceId: text116("workspace_id").notNull(),
|
|
29896
29937
|
// FK → workspaces.id (RLS scope)
|
|
29897
|
-
delta:
|
|
29938
|
+
delta: integer58("delta").notNull(),
|
|
29898
29939
|
// signed: +purchase/grant, -consume/expire
|
|
29899
29940
|
reason: varchar85("reason", { length: 20 }).notNull(),
|
|
29900
29941
|
// purchase | consume | grant | expire
|
|
29901
|
-
dodoPaymentId:
|
|
29942
|
+
dodoPaymentId: text116("dodo_payment_id"),
|
|
29902
29943
|
// set for purchases
|
|
29903
|
-
note:
|
|
29904
|
-
createdAt:
|
|
29944
|
+
note: text116("note"),
|
|
29945
|
+
createdAt: timestamp107("created_at").notNull().defaultNow()
|
|
29905
29946
|
},
|
|
29906
29947
|
(t) => [
|
|
29907
|
-
|
|
29948
|
+
index101("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt),
|
|
29908
29949
|
uniqueIndex54("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql36`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
|
|
29909
29950
|
]
|
|
29910
29951
|
);
|
|
29911
29952
|
|
|
29912
29953
|
// src/schema/support_tickets.ts
|
|
29913
29954
|
import {
|
|
29914
|
-
pgTable as
|
|
29915
|
-
text as
|
|
29955
|
+
pgTable as pgTable116,
|
|
29956
|
+
text as text117,
|
|
29916
29957
|
varchar as varchar86,
|
|
29917
|
-
timestamp as
|
|
29958
|
+
timestamp as timestamp108,
|
|
29918
29959
|
boolean as boolean36,
|
|
29919
|
-
jsonb as
|
|
29920
|
-
index as
|
|
29960
|
+
jsonb as jsonb64,
|
|
29961
|
+
index as index102
|
|
29921
29962
|
} from "drizzle-orm/pg-core";
|
|
29922
|
-
var supportTickets =
|
|
29963
|
+
var supportTickets = pgTable116(
|
|
29923
29964
|
"support_tickets",
|
|
29924
29965
|
{
|
|
29925
|
-
id:
|
|
29966
|
+
id: text117("id").primaryKey(),
|
|
29926
29967
|
// nanoid
|
|
29927
|
-
workspaceId:
|
|
29968
|
+
workspaceId: text117("workspace_id"),
|
|
29928
29969
|
// FK → workspaces.id (nullable: account-level tickets)
|
|
29929
29970
|
// FK → users.id (the customer). NULL for a ticket Plain created: an email or Slack
|
|
29930
29971
|
// sender has no BetterCMS account. visibleTicketWhere() compares this to the session
|
|
29931
29972
|
// user, and NULL never matches, so those tickets stay invisible to every customer —
|
|
29932
29973
|
// which is correct, since there is no dashboard reply transport for them.
|
|
29933
|
-
userId:
|
|
29974
|
+
userId: text117("user_id"),
|
|
29934
29975
|
// The only identity a Plain-origin ticket has. The staff list coalesces it with
|
|
29935
29976
|
// users.email; NULL whenever userId is set.
|
|
29936
|
-
customerEmail:
|
|
29937
|
-
customerName:
|
|
29977
|
+
customerEmail: text117("customer_email"),
|
|
29978
|
+
customerName: text117("customer_name"),
|
|
29938
29979
|
subject: varchar86("subject", { length: 255 }).notNull(),
|
|
29939
|
-
body:
|
|
29980
|
+
body: text117("body").notNull(),
|
|
29940
29981
|
status: varchar86("status", { length: 20 }).notNull().default("open"),
|
|
29941
29982
|
// open | pending | closed
|
|
29942
29983
|
priority: varchar86("priority", { length: 20 }).notNull().default("normal"),
|
|
29943
29984
|
// low | normal | high | urgent
|
|
29944
|
-
assigneeId:
|
|
29985
|
+
assigneeId: text117("assignee_id"),
|
|
29945
29986
|
// FK → users.id (staff member handling it)
|
|
29946
29987
|
// Plain's ThreadChannel, lowercased. 'api' is a ticket opened in the dashboard; the
|
|
29947
29988
|
// rest arrive from Plain. The staff reply path branches on this: 'api' threads deliver
|
|
29948
29989
|
// nothing to the customer so we send the email ourselves, every other channel is
|
|
29949
29990
|
// delivered by Plain.
|
|
29950
|
-
channel:
|
|
29991
|
+
channel: text117("channel").notNull().default("api"),
|
|
29951
29992
|
// The Plain thread this ticket mirrors. NULL until the first outbound sync succeeds,
|
|
29952
29993
|
// hence the partial unique index rather than a unique column.
|
|
29953
|
-
plainThreadId:
|
|
29994
|
+
plainThreadId: text117("plain_thread_id"),
|
|
29954
29995
|
// Files attached when the case was opened, before any message row exists.
|
|
29955
|
-
attachments:
|
|
29956
|
-
createdAt:
|
|
29957
|
-
updatedAt:
|
|
29996
|
+
attachments: jsonb64("attachments").$type().notNull().default([]),
|
|
29997
|
+
createdAt: timestamp108("created_at").notNull().defaultNow(),
|
|
29998
|
+
updatedAt: timestamp108("updated_at").notNull().defaultNow()
|
|
29958
29999
|
},
|
|
29959
30000
|
(table) => [
|
|
29960
|
-
|
|
29961
|
-
|
|
29962
|
-
|
|
29963
|
-
|
|
30001
|
+
index102("support_tickets_status_idx").on(table.status, table.updatedAt),
|
|
30002
|
+
index102("support_tickets_workspace_idx").on(table.workspaceId),
|
|
30003
|
+
index102("support_tickets_user_idx").on(table.userId),
|
|
30004
|
+
index102("support_tickets_channel_idx").on(table.channel, table.updatedAt)
|
|
29964
30005
|
]
|
|
29965
30006
|
);
|
|
29966
|
-
var supportTicketMessages =
|
|
30007
|
+
var supportTicketMessages = pgTable116(
|
|
29967
30008
|
"support_ticket_messages",
|
|
29968
30009
|
{
|
|
29969
|
-
id:
|
|
30010
|
+
id: text117("id").primaryKey(),
|
|
29970
30011
|
// nanoid
|
|
29971
|
-
ticketId:
|
|
30012
|
+
ticketId: text117("ticket_id").notNull(),
|
|
29972
30013
|
// FK → support_tickets.id
|
|
29973
|
-
authorId:
|
|
30014
|
+
authorId: text117("author_id"),
|
|
29974
30015
|
// FK → users.id (staff or customer)
|
|
29975
|
-
body:
|
|
30016
|
+
body: text117("body").notNull(),
|
|
29976
30017
|
isStaff: boolean36("is_staff").notNull().default(false),
|
|
29977
30018
|
// true = team reply
|
|
29978
30019
|
// Staff-only triage note. NEVER leaves the platform-admin lane: the customer read
|
|
@@ -29982,30 +30023,30 @@ var supportTicketMessages = pgTable115(
|
|
|
29982
30023
|
// at-least-once webhook. NULL for anything Plain never saw, and for our own replies on
|
|
29983
30024
|
// channels whose mutation returns no entry id — replyToThread returns only an error
|
|
29984
30025
|
// slot, which is why the echo check keys on the actor and this is the backstop.
|
|
29985
|
-
plainMessageId:
|
|
29986
|
-
attachments:
|
|
29987
|
-
createdAt:
|
|
30026
|
+
plainMessageId: text117("plain_message_id"),
|
|
30027
|
+
attachments: jsonb64("attachments").$type().notNull().default([]),
|
|
30028
|
+
createdAt: timestamp108("created_at").notNull().defaultNow()
|
|
29988
30029
|
},
|
|
29989
30030
|
(table) => [
|
|
29990
|
-
|
|
30031
|
+
index102("support_ticket_messages_ticket_idx").on(table.ticketId, table.createdAt)
|
|
29991
30032
|
]
|
|
29992
30033
|
);
|
|
29993
30034
|
|
|
29994
30035
|
// src/schema/admin_action_logs.ts
|
|
29995
30036
|
import {
|
|
29996
|
-
pgTable as
|
|
29997
|
-
text as
|
|
30037
|
+
pgTable as pgTable117,
|
|
30038
|
+
text as text118,
|
|
29998
30039
|
varchar as varchar87,
|
|
29999
|
-
jsonb as
|
|
30000
|
-
timestamp as
|
|
30001
|
-
index as
|
|
30040
|
+
jsonb as jsonb65,
|
|
30041
|
+
timestamp as timestamp109,
|
|
30042
|
+
index as index103
|
|
30002
30043
|
} from "drizzle-orm/pg-core";
|
|
30003
|
-
var adminActionLogs =
|
|
30044
|
+
var adminActionLogs = pgTable117(
|
|
30004
30045
|
"admin_action_logs",
|
|
30005
30046
|
{
|
|
30006
|
-
id:
|
|
30047
|
+
id: text118("id").primaryKey(),
|
|
30007
30048
|
// nanoid
|
|
30008
|
-
actorId:
|
|
30049
|
+
actorId: text118("actor_id"),
|
|
30009
30050
|
// FK → users.id (the staff member)
|
|
30010
30051
|
actorEmail: varchar87("actor_email", { length: 320 }),
|
|
30011
30052
|
// denormalized for display
|
|
@@ -30015,66 +30056,66 @@ var adminActionLogs = pgTable116(
|
|
|
30015
30056
|
// e.g. workspace.plan_change
|
|
30016
30057
|
targetType: varchar87("target_type", { length: 40 }),
|
|
30017
30058
|
// workspace | user | plan | ticket
|
|
30018
|
-
targetId:
|
|
30019
|
-
reason:
|
|
30020
|
-
metadata:
|
|
30021
|
-
ipAddress:
|
|
30022
|
-
createdAt:
|
|
30059
|
+
targetId: text118("target_id"),
|
|
30060
|
+
reason: text118("reason"),
|
|
30061
|
+
metadata: jsonb65("metadata").$type().notNull().default({}),
|
|
30062
|
+
ipAddress: text118("ip_address"),
|
|
30063
|
+
createdAt: timestamp109("created_at").notNull().defaultNow()
|
|
30023
30064
|
},
|
|
30024
30065
|
(table) => [
|
|
30025
|
-
|
|
30026
|
-
|
|
30066
|
+
index103("admin_action_logs_created_idx").on(table.createdAt),
|
|
30067
|
+
index103("admin_action_logs_action_idx").on(table.action, table.createdAt)
|
|
30027
30068
|
]
|
|
30028
30069
|
);
|
|
30029
30070
|
|
|
30030
30071
|
// src/schema/admin_notes.ts
|
|
30031
|
-
import { pgTable as
|
|
30032
|
-
var adminNotes =
|
|
30072
|
+
import { pgTable as pgTable118, text as text119, varchar as varchar88, boolean as boolean37, timestamp as timestamp110, index as index104 } from "drizzle-orm/pg-core";
|
|
30073
|
+
var adminNotes = pgTable118(
|
|
30033
30074
|
"admin_notes",
|
|
30034
30075
|
{
|
|
30035
|
-
id:
|
|
30076
|
+
id: text119("id").primaryKey(),
|
|
30036
30077
|
// nanoid
|
|
30037
30078
|
targetType: varchar88("target_type", { length: 20 }).notNull(),
|
|
30038
30079
|
// user | workspace | project
|
|
30039
|
-
targetId:
|
|
30040
|
-
body:
|
|
30041
|
-
authorId:
|
|
30080
|
+
targetId: text119("target_id").notNull(),
|
|
30081
|
+
body: text119("body").notNull(),
|
|
30082
|
+
authorId: text119("author_id"),
|
|
30042
30083
|
// FK → users.id (the staff member)
|
|
30043
30084
|
authorEmail: varchar88("author_email", { length: 320 }),
|
|
30044
30085
|
// denormalized for display
|
|
30045
30086
|
pinned: boolean37("pinned").notNull().default(false),
|
|
30046
|
-
createdAt:
|
|
30047
|
-
updatedAt:
|
|
30087
|
+
createdAt: timestamp110("created_at").notNull().defaultNow(),
|
|
30088
|
+
updatedAt: timestamp110("updated_at").notNull().defaultNow()
|
|
30048
30089
|
},
|
|
30049
30090
|
(t) => [
|
|
30050
30091
|
// Pinned first, then newest — the exact order the tab renders.
|
|
30051
|
-
|
|
30092
|
+
index104("admin_notes_target_idx").on(t.targetType, t.targetId, t.pinned, t.createdAt)
|
|
30052
30093
|
]
|
|
30053
30094
|
);
|
|
30054
30095
|
|
|
30055
30096
|
// src/schema/admin_agent_sessions.ts
|
|
30056
|
-
import { pgTable as
|
|
30057
|
-
var adminAgentSessions =
|
|
30097
|
+
import { pgTable as pgTable119, text as text120, varchar as varchar89, doublePrecision as doublePrecision2, timestamp as timestamp111, index as index105 } from "drizzle-orm/pg-core";
|
|
30098
|
+
var adminAgentSessions = pgTable119(
|
|
30058
30099
|
"admin_agent_sessions",
|
|
30059
30100
|
{
|
|
30060
|
-
id:
|
|
30101
|
+
id: text120("id").primaryKey(),
|
|
30061
30102
|
// nanoid
|
|
30062
|
-
actorId:
|
|
30103
|
+
actorId: text120("actor_id").notNull(),
|
|
30063
30104
|
// FK → users.id (the staff member)
|
|
30064
30105
|
actorEmail: varchar89("actor_email", { length: 320 }),
|
|
30065
30106
|
title: varchar89("title", { length: 200 }),
|
|
30066
30107
|
status: varchar89("status", { length: 20 }).notNull().default("active"),
|
|
30067
30108
|
// active | error
|
|
30068
30109
|
costUsd: doublePrecision2("cost_usd").notNull().default(0),
|
|
30069
|
-
createdAt:
|
|
30070
|
-
updatedAt:
|
|
30071
|
-
lastActiveAt:
|
|
30110
|
+
createdAt: timestamp111("created_at").notNull().defaultNow(),
|
|
30111
|
+
updatedAt: timestamp111("updated_at").notNull().defaultNow(),
|
|
30112
|
+
lastActiveAt: timestamp111("last_active_at").notNull().defaultNow()
|
|
30072
30113
|
},
|
|
30073
|
-
(t) => [
|
|
30114
|
+
(t) => [index105("admin_agent_sessions_actor_idx").on(t.actorId, t.lastActiveAt)]
|
|
30074
30115
|
);
|
|
30075
30116
|
|
|
30076
30117
|
// src/schema/crm_deals.ts
|
|
30077
|
-
import { pgTable as
|
|
30118
|
+
import { pgTable as pgTable120, text as text121, varchar as varchar90, integer as integer59, timestamp as timestamp112, index as index106, unique as unique13 } from "drizzle-orm/pg-core";
|
|
30078
30119
|
var CRM_STAGES = [
|
|
30079
30120
|
"qualified",
|
|
30080
30121
|
"conversation",
|
|
@@ -30082,58 +30123,58 @@ var CRM_STAGES = [
|
|
|
30082
30123
|
"customer",
|
|
30083
30124
|
"at_risk"
|
|
30084
30125
|
];
|
|
30085
|
-
var crmDeals =
|
|
30126
|
+
var crmDeals = pgTable120(
|
|
30086
30127
|
"crm_deals",
|
|
30087
30128
|
{
|
|
30088
|
-
id:
|
|
30129
|
+
id: text121("id").primaryKey(),
|
|
30089
30130
|
// nanoid
|
|
30090
|
-
workspaceId:
|
|
30131
|
+
workspaceId: text121("workspace_id").notNull(),
|
|
30091
30132
|
// FK → workspaces.id
|
|
30092
30133
|
stage: varchar90("stage", { length: 20 }).notNull().default("qualified").$type(),
|
|
30093
|
-
valueCents:
|
|
30134
|
+
valueCents: integer59("value_cents"),
|
|
30094
30135
|
// annual contract value the rep is working toward
|
|
30095
|
-
ownerId:
|
|
30136
|
+
ownerId: text121("owner_id"),
|
|
30096
30137
|
// FK → users.id (the staff member on the account)
|
|
30097
|
-
nextStep:
|
|
30098
|
-
notes:
|
|
30099
|
-
lastTouchAt:
|
|
30100
|
-
createdAt:
|
|
30101
|
-
updatedAt:
|
|
30138
|
+
nextStep: text121("next_step"),
|
|
30139
|
+
notes: text121("notes"),
|
|
30140
|
+
lastTouchAt: timestamp112("last_touch_at"),
|
|
30141
|
+
createdAt: timestamp112("created_at").notNull().defaultNow(),
|
|
30142
|
+
updatedAt: timestamp112("updated_at").notNull().defaultNow()
|
|
30102
30143
|
},
|
|
30103
30144
|
(t) => [
|
|
30104
30145
|
unique13("crm_deals_workspace_id_key").on(t.workspaceId),
|
|
30105
|
-
|
|
30106
|
-
|
|
30146
|
+
index106("crm_deals_stage_idx").on(t.stage, t.lastTouchAt),
|
|
30147
|
+
index106("crm_deals_owner_idx").on(t.ownerId)
|
|
30107
30148
|
]
|
|
30108
30149
|
);
|
|
30109
30150
|
|
|
30110
30151
|
// src/schema/project_env_vars.ts
|
|
30111
30152
|
import {
|
|
30112
|
-
pgTable as
|
|
30113
|
-
text as
|
|
30153
|
+
pgTable as pgTable121,
|
|
30154
|
+
text as text122,
|
|
30114
30155
|
varchar as varchar91,
|
|
30115
|
-
timestamp as
|
|
30116
|
-
index as
|
|
30156
|
+
timestamp as timestamp113,
|
|
30157
|
+
index as index107,
|
|
30117
30158
|
uniqueIndex as uniqueIndex55
|
|
30118
30159
|
} from "drizzle-orm/pg-core";
|
|
30119
30160
|
var ENV_VAR_SCOPES = ["production", "preview", "development"];
|
|
30120
|
-
var projectEnvVars =
|
|
30161
|
+
var projectEnvVars = pgTable121(
|
|
30121
30162
|
"project_env_vars",
|
|
30122
30163
|
{
|
|
30123
|
-
id:
|
|
30164
|
+
id: text122("id").primaryKey(),
|
|
30124
30165
|
// nanoid
|
|
30125
|
-
projectId:
|
|
30166
|
+
projectId: text122("project_id").notNull(),
|
|
30126
30167
|
// FK to projects.id
|
|
30127
|
-
workspaceId:
|
|
30168
|
+
workspaceId: text122("workspace_id").notNull(),
|
|
30128
30169
|
// FK to workspaces.id — RLS scope
|
|
30129
30170
|
key: varchar91("key", { length: 128 }).notNull(),
|
|
30130
|
-
valueEnc:
|
|
30171
|
+
valueEnc: text122("value_enc").notNull(),
|
|
30131
30172
|
// AES-256-GCM, `iv:tag:ciphertext` hex
|
|
30132
30173
|
scope: varchar91("scope", { length: 16 }).$type().notNull(),
|
|
30133
|
-
updatedBy:
|
|
30174
|
+
updatedBy: text122("updated_by"),
|
|
30134
30175
|
// FK to users.id, nullable
|
|
30135
|
-
updatedAt:
|
|
30136
|
-
createdAt:
|
|
30176
|
+
updatedAt: timestamp113("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30177
|
+
createdAt: timestamp113("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
30137
30178
|
},
|
|
30138
30179
|
(table) => [
|
|
30139
30180
|
// One value per key per scope — the same key MAY exist in production and preview.
|
|
@@ -30142,21 +30183,21 @@ var projectEnvVars = pgTable120(
|
|
|
30142
30183
|
table.key,
|
|
30143
30184
|
table.scope
|
|
30144
30185
|
),
|
|
30145
|
-
|
|
30186
|
+
index107("project_env_vars_project_idx").on(table.projectId)
|
|
30146
30187
|
]
|
|
30147
30188
|
);
|
|
30148
30189
|
|
|
30149
30190
|
// src/schema/mcp_connections.ts
|
|
30150
|
-
import { pgTable as
|
|
30191
|
+
import { pgTable as pgTable122, text as text123, varchar as varchar92, jsonb as jsonb66, timestamp as timestamp114, index as index108, uniqueIndex as uniqueIndex56 } from "drizzle-orm/pg-core";
|
|
30151
30192
|
import { sql as sql37 } from "drizzle-orm";
|
|
30152
|
-
var mcpConnections =
|
|
30193
|
+
var mcpConnections = pgTable122(
|
|
30153
30194
|
"mcp_connections",
|
|
30154
30195
|
{
|
|
30155
|
-
id:
|
|
30196
|
+
id: text123("id").primaryKey(),
|
|
30156
30197
|
// nanoid
|
|
30157
|
-
workspaceId:
|
|
30198
|
+
workspaceId: text123("workspace_id").notNull(),
|
|
30158
30199
|
// FK → workspaces.id (RLS scope)
|
|
30159
|
-
projectId:
|
|
30200
|
+
projectId: text123("project_id").notNull(),
|
|
30160
30201
|
// FK → projects.id (application-enforced)
|
|
30161
30202
|
/** Catalog slug (`notion` | `linear` | `hubspot` | `figma`) or `custom` for a user-added server. */
|
|
30162
30203
|
providerSlug: varchar92("provider_slug", { length: 32 }).notNull(),
|
|
@@ -30167,30 +30208,30 @@ var mcpConnections = pgTable121(
|
|
|
30167
30208
|
/** Display name. The catalog's name for a known provider; user-supplied for a custom one. */
|
|
30168
30209
|
name: varchar92("name", { length: 120 }).notNull(),
|
|
30169
30210
|
/** Remote Streamable-HTTP endpoint. NULL for `kind: 'rest'`, which has no MCP server. */
|
|
30170
|
-
serverUrl:
|
|
30211
|
+
serverUrl: text123("server_url"),
|
|
30171
30212
|
/** Display only — the connected Notion workspace / Linear org / Figma account. */
|
|
30172
30213
|
accountLabel: varchar92("account_label", { length: 255 }),
|
|
30173
|
-
accessTokenEnc:
|
|
30174
|
-
refreshTokenEnc:
|
|
30175
|
-
expiresAt:
|
|
30214
|
+
accessTokenEnc: text123("access_token_enc"),
|
|
30215
|
+
refreshTokenEnc: text123("refresh_token_enc"),
|
|
30216
|
+
expiresAt: timestamp114("expires_at", { withTimezone: true }),
|
|
30176
30217
|
/** `custom_headers` mode only: the encrypted header map a gateway requires on every call. */
|
|
30177
|
-
headersEnc:
|
|
30218
|
+
headersEnc: text123("headers_enc"),
|
|
30178
30219
|
/** DCR-issued or statically configured — the same two columns serve both, deliberately. */
|
|
30179
30220
|
oauthClientId: varchar92("oauth_client_id", { length: 255 }),
|
|
30180
|
-
oauthClientSecretEnc:
|
|
30221
|
+
oauthClientSecretEnc: text123("oauth_client_secret_enc"),
|
|
30181
30222
|
/** Both cleared on a successful exchange; see the header note on why they must exist at all. */
|
|
30182
|
-
oauthState:
|
|
30183
|
-
pkceVerifierEnc:
|
|
30223
|
+
oauthState: text123("oauth_state"),
|
|
30224
|
+
pkceVerifierEnc: text123("pkce_verifier_enc"),
|
|
30184
30225
|
/** Discovery output: authorization server metadata, token endpoint, RFC 8707 resource. */
|
|
30185
|
-
authMetadata:
|
|
30186
|
-
scopes:
|
|
30226
|
+
authMetadata: jsonb66("auth_metadata").$type(),
|
|
30227
|
+
scopes: text123("scopes").array().$type(),
|
|
30187
30228
|
/**
|
|
30188
30229
|
* Full descriptors (name, description, inputSchema, annotations) — NOT just names. The
|
|
30189
30230
|
* read-only boundary is decided from `annotations.readOnlyHint`, so the names alone would
|
|
30190
30231
|
* force a live listTools on the turn path to answer a governance question.
|
|
30191
30232
|
*/
|
|
30192
|
-
toolsCache:
|
|
30193
|
-
toolsCachedAt:
|
|
30233
|
+
toolsCache: jsonb66("tools_cache").$type().notNull().default([]),
|
|
30234
|
+
toolsCachedAt: timestamp114("tools_cached_at", { withTimezone: true }),
|
|
30194
30235
|
/**
|
|
30195
30236
|
* pending | ok | invalid | revoked. `pending` is the pre-consent row; `invalid` is set on a
|
|
30196
30237
|
* provider 401 or a decrypt failure so the UI can say "reconnect" instead of replaying the
|
|
@@ -30199,16 +30240,16 @@ var mcpConnections = pgTable121(
|
|
|
30199
30240
|
status: varchar92("status", { length: 16 }).notNull().default("pending").$type(),
|
|
30200
30241
|
/** Machine-readable companion to `status`, e.g. `decrypt_failed`, `provider_401`. */
|
|
30201
30242
|
statusReason: varchar92("status_reason", { length: 64 }),
|
|
30202
|
-
lastError:
|
|
30203
|
-
lastUsedAt:
|
|
30204
|
-
connectedBy:
|
|
30243
|
+
lastError: text123("last_error"),
|
|
30244
|
+
lastUsedAt: timestamp114("last_used_at", { withTimezone: true }),
|
|
30245
|
+
connectedBy: text123("connected_by"),
|
|
30205
30246
|
// FK → users(id), added in migration
|
|
30206
30247
|
...auditColumns,
|
|
30207
30248
|
...softDeleteColumn
|
|
30208
30249
|
},
|
|
30209
30250
|
(t) => [
|
|
30210
|
-
|
|
30211
|
-
|
|
30251
|
+
index108("mcp_connections_workspace_idx").on(t.workspaceId),
|
|
30252
|
+
index108("mcp_connections_project_idx").on(t.projectId),
|
|
30212
30253
|
// Reconnecting a catalog provider UPDATEs rather than accumulating a second live credential.
|
|
30213
30254
|
// Custom connectors are excluded: a project may legitimately add many distinct MCP servers.
|
|
30214
30255
|
uniqueIndex56("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql37`deleted_at IS NULL AND provider_slug <> 'custom'`)
|
|
@@ -30217,30 +30258,30 @@ var mcpConnections = pgTable121(
|
|
|
30217
30258
|
|
|
30218
30259
|
// src/schema/crm_connections.ts
|
|
30219
30260
|
import {
|
|
30220
|
-
pgTable as
|
|
30221
|
-
text as
|
|
30222
|
-
timestamp as
|
|
30261
|
+
pgTable as pgTable123,
|
|
30262
|
+
text as text124,
|
|
30263
|
+
timestamp as timestamp115,
|
|
30223
30264
|
boolean as boolean38,
|
|
30224
|
-
jsonb as
|
|
30225
|
-
integer as
|
|
30265
|
+
jsonb as jsonb67,
|
|
30266
|
+
integer as integer60,
|
|
30226
30267
|
uniqueIndex as uniqueIndex57
|
|
30227
30268
|
} from "drizzle-orm/pg-core";
|
|
30228
|
-
var crmConnections =
|
|
30269
|
+
var crmConnections = pgTable123(
|
|
30229
30270
|
"crm_connections",
|
|
30230
30271
|
{
|
|
30231
|
-
id:
|
|
30232
|
-
workspaceId:
|
|
30233
|
-
provider:
|
|
30234
|
-
accountId:
|
|
30235
|
-
accountName:
|
|
30236
|
-
instanceUrl:
|
|
30272
|
+
id: text124("id").primaryKey(),
|
|
30273
|
+
workspaceId: text124("workspace_id").notNull(),
|
|
30274
|
+
provider: text124("provider").$type().notNull(),
|
|
30275
|
+
accountId: text124("account_id").notNull(),
|
|
30276
|
+
accountName: text124("account_name").notNull(),
|
|
30277
|
+
instanceUrl: text124("instance_url").notNull(),
|
|
30237
30278
|
sandbox: boolean38("sandbox").notNull().default(false),
|
|
30238
|
-
status:
|
|
30239
|
-
accessToken:
|
|
30240
|
-
refreshToken:
|
|
30241
|
-
expiresAt:
|
|
30242
|
-
createdAt:
|
|
30243
|
-
updatedAt:
|
|
30279
|
+
status: text124("status").notNull().default("connected"),
|
|
30280
|
+
accessToken: text124("access_token").notNull(),
|
|
30281
|
+
refreshToken: text124("refresh_token").notNull(),
|
|
30282
|
+
expiresAt: timestamp115("expires_at").notNull(),
|
|
30283
|
+
createdAt: timestamp115("created_at").notNull().defaultNow(),
|
|
30284
|
+
updatedAt: timestamp115("updated_at").notNull().defaultNow()
|
|
30244
30285
|
},
|
|
30245
30286
|
(t) => [
|
|
30246
30287
|
uniqueIndex57("crm_connection_account_uq").on(
|
|
@@ -30250,35 +30291,35 @@ var crmConnections = pgTable122(
|
|
|
30250
30291
|
)
|
|
30251
30292
|
]
|
|
30252
30293
|
);
|
|
30253
|
-
var crmOauthStates =
|
|
30254
|
-
id:
|
|
30255
|
-
workspaceId:
|
|
30256
|
-
userId:
|
|
30257
|
-
provider:
|
|
30258
|
-
verifier:
|
|
30259
|
-
returnPath:
|
|
30294
|
+
var crmOauthStates = pgTable123("crm_oauth_states", {
|
|
30295
|
+
id: text124("id").primaryKey(),
|
|
30296
|
+
workspaceId: text124("workspace_id").notNull(),
|
|
30297
|
+
userId: text124("user_id").notNull(),
|
|
30298
|
+
provider: text124("provider").notNull(),
|
|
30299
|
+
verifier: text124("verifier").notNull(),
|
|
30300
|
+
returnPath: text124("return_path").notNull(),
|
|
30260
30301
|
sandbox: boolean38("sandbox").notNull(),
|
|
30261
|
-
expiresAt:
|
|
30302
|
+
expiresAt: timestamp115("expires_at").notNull()
|
|
30262
30303
|
});
|
|
30263
|
-
var formIntegrationDeliveries =
|
|
30304
|
+
var formIntegrationDeliveries = pgTable123(
|
|
30264
30305
|
"form_integration_deliveries",
|
|
30265
30306
|
{
|
|
30266
|
-
id:
|
|
30267
|
-
workspaceId:
|
|
30268
|
-
formId:
|
|
30269
|
-
integrationId:
|
|
30270
|
-
eventId:
|
|
30271
|
-
submissionId:
|
|
30272
|
-
snapshot:
|
|
30273
|
-
data:
|
|
30274
|
-
status:
|
|
30275
|
-
attempts:
|
|
30276
|
-
lastError:
|
|
30277
|
-
remoteRecordId:
|
|
30278
|
-
nextAttemptAt:
|
|
30279
|
-
leaseUntil:
|
|
30280
|
-
createdAt:
|
|
30281
|
-
updatedAt:
|
|
30307
|
+
id: text124("id").primaryKey(),
|
|
30308
|
+
workspaceId: text124("workspace_id").notNull(),
|
|
30309
|
+
formId: text124("form_id").notNull(),
|
|
30310
|
+
integrationId: text124("integration_id").notNull(),
|
|
30311
|
+
eventId: text124("event_id").notNull(),
|
|
30312
|
+
submissionId: text124("submission_id").notNull(),
|
|
30313
|
+
snapshot: jsonb67("snapshot").$type().notNull(),
|
|
30314
|
+
data: jsonb67("data").$type().notNull(),
|
|
30315
|
+
status: text124("status").notNull().default("queued"),
|
|
30316
|
+
attempts: integer60("attempts").notNull().default(0),
|
|
30317
|
+
lastError: text124("last_error"),
|
|
30318
|
+
remoteRecordId: text124("remote_record_id"),
|
|
30319
|
+
nextAttemptAt: timestamp115("next_attempt_at").notNull().defaultNow(),
|
|
30320
|
+
leaseUntil: timestamp115("lease_until"),
|
|
30321
|
+
createdAt: timestamp115("created_at").notNull().defaultNow(),
|
|
30322
|
+
updatedAt: timestamp115("updated_at").notNull().defaultNow()
|
|
30282
30323
|
},
|
|
30283
30324
|
(t) => [
|
|
30284
30325
|
uniqueIndex57("crm_delivery_event_uq").on(
|
|
@@ -30290,101 +30331,101 @@ var formIntegrationDeliveries = pgTable122(
|
|
|
30290
30331
|
);
|
|
30291
30332
|
|
|
30292
30333
|
// src/schema/platform_incidents.ts
|
|
30293
|
-
import { check as check12, integer as
|
|
30334
|
+
import { check as check12, integer as integer61, pgTable as pgTable124, smallint as smallint2, text as text125, timestamp as timestamp116, index as index109 } from "drizzle-orm/pg-core";
|
|
30294
30335
|
import { sql as sql38 } from "drizzle-orm";
|
|
30295
30336
|
var STATUS_IN = sql38.raw("('investigating', 'identified', 'monitoring', 'resolved')");
|
|
30296
|
-
var platformIncidents =
|
|
30337
|
+
var platformIncidents = pgTable124(
|
|
30297
30338
|
"platform_incidents",
|
|
30298
30339
|
{
|
|
30299
|
-
id:
|
|
30300
|
-
number:
|
|
30301
|
-
title:
|
|
30340
|
+
id: text125("id").primaryKey(),
|
|
30341
|
+
number: integer61("number").generatedAlwaysAsIdentity().notNull().unique("platform_incidents_number_key"),
|
|
30342
|
+
title: text125("title").notNull(),
|
|
30302
30343
|
severity: smallint2("severity").notNull(),
|
|
30303
30344
|
// 1 (worst) … 4
|
|
30304
|
-
status:
|
|
30345
|
+
status: text125("status").notNull().default("investigating"),
|
|
30305
30346
|
// investigating | identified | monitoring | resolved
|
|
30306
|
-
services:
|
|
30307
|
-
commanderId:
|
|
30308
|
-
startedAt:
|
|
30309
|
-
resolvedAt:
|
|
30310
|
-
createdBy:
|
|
30311
|
-
createdAt:
|
|
30312
|
-
updatedAt:
|
|
30347
|
+
services: text125("services").array().notNull().default([]),
|
|
30348
|
+
commanderId: text125("commander_id"),
|
|
30349
|
+
startedAt: timestamp116("started_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30350
|
+
resolvedAt: timestamp116("resolved_at", { withTimezone: true }),
|
|
30351
|
+
createdBy: text125("created_by"),
|
|
30352
|
+
createdAt: timestamp116("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30353
|
+
updatedAt: timestamp116("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
30313
30354
|
},
|
|
30314
30355
|
// Mirrors 0375 exactly: drizzle-kit push builds fresh DBs before the migration runs.
|
|
30315
30356
|
(t) => [
|
|
30316
|
-
|
|
30357
|
+
index109("platform_incidents_started_idx").on(t.startedAt.desc()),
|
|
30317
30358
|
check12("platform_incidents_severity_check", sql38`${t.severity} BETWEEN 1 AND 4`),
|
|
30318
30359
|
check12("platform_incidents_status_check", sql38`${t.status} IN ${STATUS_IN}`)
|
|
30319
30360
|
]
|
|
30320
30361
|
);
|
|
30321
|
-
var platformIncidentUpdates =
|
|
30362
|
+
var platformIncidentUpdates = pgTable124(
|
|
30322
30363
|
"platform_incident_updates",
|
|
30323
30364
|
{
|
|
30324
|
-
id:
|
|
30325
|
-
incidentId:
|
|
30326
|
-
status:
|
|
30327
|
-
note:
|
|
30328
|
-
createdBy:
|
|
30329
|
-
createdAt:
|
|
30365
|
+
id: text125("id").primaryKey(),
|
|
30366
|
+
incidentId: text125("incident_id").notNull().references(() => platformIncidents.id, { onDelete: "cascade" }),
|
|
30367
|
+
status: text125("status").notNull(),
|
|
30368
|
+
note: text125("note").notNull(),
|
|
30369
|
+
createdBy: text125("created_by"),
|
|
30370
|
+
createdAt: timestamp116("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
30330
30371
|
},
|
|
30331
30372
|
(t) => [
|
|
30332
|
-
|
|
30373
|
+
index109("platform_incident_updates_incident_idx").on(t.incidentId, t.createdAt),
|
|
30333
30374
|
check12("platform_incident_updates_status_check", sql38`${t.status} IN ${STATUS_IN}`)
|
|
30334
30375
|
]
|
|
30335
30376
|
);
|
|
30336
30377
|
|
|
30337
30378
|
// src/schema/platform_vendors.ts
|
|
30338
|
-
import { date as date3, integer as
|
|
30339
|
-
var platformVendors =
|
|
30340
|
-
id:
|
|
30341
|
-
name:
|
|
30342
|
-
category:
|
|
30343
|
-
billingCycle:
|
|
30379
|
+
import { date as date3, integer as integer62, pgTable as pgTable125, text as text126, timestamp as timestamp117, varchar as varchar93 } from "drizzle-orm/pg-core";
|
|
30380
|
+
var platformVendors = pgTable125("platform_vendors", {
|
|
30381
|
+
id: text126("id").primaryKey(),
|
|
30382
|
+
name: text126("name").notNull(),
|
|
30383
|
+
category: text126("category").notNull(),
|
|
30384
|
+
billingCycle: text126("billing_cycle").notNull().default("monthly"),
|
|
30344
30385
|
// monthly | yearly | usage
|
|
30345
|
-
monthlyCents:
|
|
30386
|
+
monthlyCents: integer62("monthly_cents").notNull().default(0),
|
|
30346
30387
|
// normalised monthly cost
|
|
30347
30388
|
currency: varchar93("currency", { length: 3 }).notNull().default("usd"),
|
|
30348
30389
|
renewsOn: date3("renews_on"),
|
|
30349
30390
|
// YYYY-MM-DD
|
|
30350
|
-
status:
|
|
30391
|
+
status: text126("status").notNull().default("active"),
|
|
30351
30392
|
// active | trial | cancelling | unused
|
|
30352
|
-
ownerEmail:
|
|
30353
|
-
notes:
|
|
30354
|
-
createdBy:
|
|
30355
|
-
createdAt:
|
|
30356
|
-
updatedAt:
|
|
30393
|
+
ownerEmail: text126("owner_email"),
|
|
30394
|
+
notes: text126("notes"),
|
|
30395
|
+
createdBy: text126("created_by"),
|
|
30396
|
+
createdAt: timestamp117("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30397
|
+
updatedAt: timestamp117("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
30357
30398
|
});
|
|
30358
30399
|
|
|
30359
30400
|
// src/schema/platform_tasks.ts
|
|
30360
|
-
import { check as check13, date as date4, pgTable as
|
|
30401
|
+
import { check as check13, date as date4, pgTable as pgTable126, text as text127, timestamp as timestamp118, index as index110 } from "drizzle-orm/pg-core";
|
|
30361
30402
|
import { sql as sql39 } from "drizzle-orm";
|
|
30362
|
-
var platformTasks =
|
|
30403
|
+
var platformTasks = pgTable126(
|
|
30363
30404
|
"platform_tasks",
|
|
30364
30405
|
{
|
|
30365
|
-
id:
|
|
30366
|
-
title:
|
|
30367
|
-
description:
|
|
30368
|
-
status:
|
|
30406
|
+
id: text127("id").primaryKey(),
|
|
30407
|
+
title: text127("title").notNull(),
|
|
30408
|
+
description: text127("description"),
|
|
30409
|
+
status: text127("status").notNull().default("open"),
|
|
30369
30410
|
// open | in_progress | done
|
|
30370
|
-
priority:
|
|
30411
|
+
priority: text127("priority").notNull().default("medium"),
|
|
30371
30412
|
// low | medium | high | urgent
|
|
30372
|
-
assigneeId:
|
|
30413
|
+
assigneeId: text127("assignee_id"),
|
|
30373
30414
|
dueOn: date4("due_on"),
|
|
30374
30415
|
// YYYY-MM-DD
|
|
30375
|
-
entityType:
|
|
30416
|
+
entityType: text127("entity_type"),
|
|
30376
30417
|
// user | workspace | incident | deal
|
|
30377
|
-
entityId:
|
|
30378
|
-
entityLabel:
|
|
30379
|
-
completedAt:
|
|
30380
|
-
createdBy:
|
|
30381
|
-
createdAt:
|
|
30382
|
-
updatedAt:
|
|
30418
|
+
entityId: text127("entity_id"),
|
|
30419
|
+
entityLabel: text127("entity_label"),
|
|
30420
|
+
completedAt: timestamp118("completed_at", { withTimezone: true }),
|
|
30421
|
+
createdBy: text127("created_by"),
|
|
30422
|
+
createdAt: timestamp118("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
30423
|
+
updatedAt: timestamp118("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
30383
30424
|
},
|
|
30384
30425
|
// Mirrors 0377 exactly: drizzle-kit push builds fresh DBs before the migration runs.
|
|
30385
30426
|
(t) => [
|
|
30386
|
-
|
|
30387
|
-
|
|
30427
|
+
index110("platform_tasks_open_idx").on(t.status, t.dueOn),
|
|
30428
|
+
index110("platform_tasks_entity_idx").on(t.entityType, t.entityId),
|
|
30388
30429
|
check13("platform_tasks_status_check", sql39`${t.status} IN ('open', 'in_progress', 'done')`),
|
|
30389
30430
|
check13("platform_tasks_priority_check", sql39`${t.priority} IN ('low', 'medium', 'high', 'urgent')`),
|
|
30390
30431
|
check13("platform_tasks_entity_type_check", sql39`${t.entityType} IN ('user', 'workspace', 'incident', 'deal')`),
|
|
@@ -31018,6 +31059,7 @@ export {
|
|
|
31018
31059
|
contentEntries,
|
|
31019
31060
|
contentEntriesRelations,
|
|
31020
31061
|
contentLocks,
|
|
31062
|
+
contentModelVersions,
|
|
31021
31063
|
contentModels,
|
|
31022
31064
|
contentModelsRelations,
|
|
31023
31065
|
contentNavigation,
|