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